diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 000000000..5aae8fff1 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,14 @@ +root = true + +[*.{kt,kts}] +ktlint_code_style = intellij_idea +ktlint_ignore_back_ticked_identifier = true + +ktlint_standard = enabled +ktlint_standard_no-wildcard-imports = disabled +ktlint_standard_filename = disabled +ktlint_standard_import-ordering = disabled +ktlint_standard_function-naming = disabled + +ktlint_experimental = disabled + diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index e6ab58abe..d73a0c00c 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -97,6 +97,8 @@ jobs: key: cocoapods-cache-v2 - name: Setup test environment uses: ./.github/actions/setup_test_action + - name: ktLint + run: ./gradlew lintKotlin - name: Run iOS Tests run: ./gradlew cleanTest iosSimulatorArm64Test - name: Upload iOS test artifact @@ -118,6 +120,8 @@ jobs: - name: Setup test environment uses: ./.github/actions/setup_test_action timeout-minutes: 10 + - name: run apiCheck + run: ./gradlew apiCheck - name: Run JVM Tests run: ./gradlew cleanTest jvmTest - name: Upload JVM test artifact diff --git a/README.md b/README.md index acfe8d1b4..cd08cbbe4 100644 --- a/README.md +++ b/README.md @@ -293,10 +293,12 @@ To run the tests you can use the following gradle tasks: `./gradlew connectedAndroidTest` (an emulator needs to be running) -`./gradlew iosSimulatorArm64Test` +`./gradlew iosSimulatorArm64Test` (On Apple Chip) `./gradlew iosX64Test` (On Intel Chip) `./gradlew jsNodeTest` +`./gradlew jvmTest` + For some tests you need to have the firebase emulator suite running. After installing them you can run the following command inside the `test` directory: `firebase emulators:start` @@ -305,6 +307,17 @@ For some tests you need to have the firebase emulator suite running. After insta For every publicly available class or function there needs to be documentation written in the [KDoc syntax](https://kotlinlang.org/docs/kotlin-doc.html). We publish a new version of the documentation after every release and can be found [here](https://gitliveapp.github.io/firebase-kotlin-sdk/) +### Validation +To ensure changes to the public API are well documented, this library validates its binary API. If you make changes to the API, make sure to run + +`./gradlew apiDump` + +### Code style +This library uses the [Intellij Kotlin code style](https://www.jetbrains.com/help/idea/code-style-kotlin.html). Run the linter to make sure you follow these styles. + +`./gradlew formatKotlin` to format to the proper style +`./gradlew lintKotlin` to validate the correct style is used + ### Compatibility with the official [Firebase Android SDK](https://github.com/firebase/firebase-android-sdk) When this project began, the official Firebase Android SDK was a pure java library and the separate Kotlin extensions (KTX) module consisted of only a few extensions providing some syntactic sugar, for example `Firebase.firestore` instead of `Firebase.getInstance(),` which we naturally copied for the Firebase Kotlin SDK. diff --git a/build.gradle.kts b/build.gradle.kts index 089af9d48..e1a50f727 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -16,6 +16,8 @@ plugins { alias(libs.plugins.native.cocoapods) apply false alias(libs.plugins.test.logger.plugin) apply false alias(libs.plugins.ben.manes.versions) apply false + alias(libs.plugins.kotlinter) apply false + alias(libs.plugins.kotlinx.binarycompatibilityvalidator) alias(libs.plugins.dokka) id("base") id("testOptionsConvention") @@ -104,6 +106,7 @@ subprojects { } apply(plugin = "com.adarshr.test-logger") + apply(plugin = "org.jmailen.kotlinter") repositories { mavenLocal() diff --git a/firebase-analytics/api/android/firebase-analytics.api b/firebase-analytics/api/android/firebase-analytics.api new file mode 100644 index 000000000..4dc99834b --- /dev/null +++ b/firebase-analytics/api/android/firebase-analytics.api @@ -0,0 +1,210 @@ +public final class dev/gitlive/firebase/analytics/AnalyticEventConstantsKt { + public static final fun getEvent (Ldev/gitlive/firebase/analytics/FirebaseAnalytics;)Ldev/gitlive/firebase/analytics/FirebaseAnalyticsEvents; + public static final fun getParam (Ldev/gitlive/firebase/analytics/FirebaseAnalytics;)Ldev/gitlive/firebase/analytics/FirebaseAnalyticsParam; + public static final fun getUserProperty (Ldev/gitlive/firebase/analytics/FirebaseAnalytics;)Ldev/gitlive/firebase/analytics/FirebaseAnalyticsUserProperty; +} + +public final class dev/gitlive/firebase/analytics/AnalyticsKt { + public static final fun logEvent (Ldev/gitlive/firebase/analytics/FirebaseAnalytics;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)V + public static final fun setConsent (Ldev/gitlive/firebase/analytics/FirebaseAnalytics;Lkotlin/jvm/functions/Function1;)V +} + +public final class dev/gitlive/firebase/analytics/FirebaseAnalytics { + public fun (Lcom/google/firebase/analytics/FirebaseAnalytics;)V + public final fun getAndroid ()Lcom/google/firebase/analytics/FirebaseAnalytics; + public final fun getSessionId (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun logEvent (Ljava/lang/String;Ljava/util/Map;)V + public static synthetic fun logEvent$default (Ldev/gitlive/firebase/analytics/FirebaseAnalytics;Ljava/lang/String;Ljava/util/Map;ILjava/lang/Object;)V + public final fun resetAnalyticsData ()V + public final fun setAnalyticsCollectionEnabled (Z)V + public final fun setConsent (Ljava/util/Map;)V + public final fun setDefaultEventParameters (Ljava/util/Map;)V + public final fun setSessionTimeoutInterval (J)V + public final fun setUserId (Ljava/lang/String;)V + public final fun setUserProperty (Ljava/lang/String;Ljava/lang/String;)V +} + +public final class dev/gitlive/firebase/analytics/FirebaseAnalytics$ConsentStatus : java/lang/Enum { + public static final field DENIED Ldev/gitlive/firebase/analytics/FirebaseAnalytics$ConsentStatus; + public static final field GRANTED Ldev/gitlive/firebase/analytics/FirebaseAnalytics$ConsentStatus; + public static fun getEntries ()Lkotlin/enums/EnumEntries; + public static fun valueOf (Ljava/lang/String;)Ldev/gitlive/firebase/analytics/FirebaseAnalytics$ConsentStatus; + public static fun values ()[Ldev/gitlive/firebase/analytics/FirebaseAnalytics$ConsentStatus; +} + +public final class dev/gitlive/firebase/analytics/FirebaseAnalytics$ConsentType : java/lang/Enum { + public static final field AD_PERSONALIZATION Ldev/gitlive/firebase/analytics/FirebaseAnalytics$ConsentType; + public static final field AD_STORAGE Ldev/gitlive/firebase/analytics/FirebaseAnalytics$ConsentType; + public static final field AD_USER_DATA Ldev/gitlive/firebase/analytics/FirebaseAnalytics$ConsentType; + public static final field ANALYTICS_STORAGE Ldev/gitlive/firebase/analytics/FirebaseAnalytics$ConsentType; + public static fun getEntries ()Lkotlin/enums/EnumEntries; + public static fun valueOf (Ljava/lang/String;)Ldev/gitlive/firebase/analytics/FirebaseAnalytics$ConsentType; + public static fun values ()[Ldev/gitlive/firebase/analytics/FirebaseAnalytics$ConsentType; +} + +public final class dev/gitlive/firebase/analytics/FirebaseAnalyticsConsentBuilder { + public fun ()V + public fun (Ljava/util/Map;)V + public synthetic fun (Ljava/util/Map;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun component1 ()Ljava/util/Map; + public final fun copy (Ljava/util/Map;)Ldev/gitlive/firebase/analytics/FirebaseAnalyticsConsentBuilder; + public static synthetic fun copy$default (Ldev/gitlive/firebase/analytics/FirebaseAnalyticsConsentBuilder;Ljava/util/Map;ILjava/lang/Object;)Ldev/gitlive/firebase/analytics/FirebaseAnalyticsConsentBuilder; + public fun equals (Ljava/lang/Object;)Z + public final fun getAdPersonalization ()Ldev/gitlive/firebase/analytics/FirebaseAnalytics$ConsentStatus; + public final fun getAdStorage ()Ldev/gitlive/firebase/analytics/FirebaseAnalytics$ConsentStatus; + public final fun getAdUserData ()Ldev/gitlive/firebase/analytics/FirebaseAnalytics$ConsentStatus; + public final fun getAnalyticsStorage ()Ldev/gitlive/firebase/analytics/FirebaseAnalytics$ConsentStatus; + public final fun getConsentSettings ()Ljava/util/Map; + public fun hashCode ()I + public final fun setAdPersonalization (Ldev/gitlive/firebase/analytics/FirebaseAnalytics$ConsentStatus;)V + public final fun setAdStorage (Ldev/gitlive/firebase/analytics/FirebaseAnalytics$ConsentStatus;)V + public final fun setAdUserData (Ldev/gitlive/firebase/analytics/FirebaseAnalytics$ConsentStatus;)V + public final fun setAnalyticsStorage (Ldev/gitlive/firebase/analytics/FirebaseAnalytics$ConsentStatus;)V + public fun toString ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/analytics/FirebaseAnalyticsEvents { + public static final field ADD_PAYMENT_INFO Ljava/lang/String; + public static final field ADD_SHIPPING_INFO Ljava/lang/String; + public static final field ADD_TO_CART Ljava/lang/String; + public static final field ADD_TO_WISHLIST Ljava/lang/String; + public static final field AD_IMPRESSION Ljava/lang/String; + public static final field APP_OPEN Ljava/lang/String; + public static final field BEGIN_CHECKOUT Ljava/lang/String; + public static final field CAMPAIGN_DETAILS Ljava/lang/String; + public static final field EARN_VIRTUAL_CURRENCY Ljava/lang/String; + public static final field GENERATE_LEAD Ljava/lang/String; + public static final field INSTANCE Ldev/gitlive/firebase/analytics/FirebaseAnalyticsEvents; + public static final field JOIN_GROUP Ljava/lang/String; + public static final field LEVEL_END Ljava/lang/String; + public static final field LEVEL_START Ljava/lang/String; + public static final field LEVEL_UP Ljava/lang/String; + public static final field LOGIN Ljava/lang/String; + public static final field POST_SCORE Ljava/lang/String; + public static final field PURCHASE Ljava/lang/String; + public static final field REFUND Ljava/lang/String; + public static final field REMOVE_FROM_CART Ljava/lang/String; + public static final field SCREEN_VIEW Ljava/lang/String; + public static final field SEARCH Ljava/lang/String; + public static final field SELECT_CONTENT Ljava/lang/String; + public static final field SELECT_ITEM Ljava/lang/String; + public static final field SELECT_PROMOTION Ljava/lang/String; + public static final field SHARE Ljava/lang/String; + public static final field SIGN_UP Ljava/lang/String; + public static final field SPEND_VIRTUAL_CURRENCY Ljava/lang/String; + public static final field TUTORIAL_BEGIN Ljava/lang/String; + public static final field TUTORIAL_COMPLETE Ljava/lang/String; + public static final field UNLOCK_ACHIEVEMENT Ljava/lang/String; + public static final field VIEW_CART Ljava/lang/String; + public static final field VIEW_ITEM Ljava/lang/String; + public static final field VIEW_ITEM_LIST Ljava/lang/String; + public static final field VIEW_PROMOTION Ljava/lang/String; + public static final field VIEW_SEARCH_RESULTS Ljava/lang/String; +} + +public final class dev/gitlive/firebase/analytics/FirebaseAnalyticsException : java/lang/Exception { + public fun (Ljava/lang/String;)V +} + +public final class dev/gitlive/firebase/analytics/FirebaseAnalyticsParam { + public static final field ACHIEVEMENT_ID Ljava/lang/String; + public static final field ACLID Ljava/lang/String; + public static final field AD_FORMAT Ljava/lang/String; + public static final field AD_PLATFORM Ljava/lang/String; + public static final field AD_SOURCE Ljava/lang/String; + public static final field AD_UNIT_NAME Ljava/lang/String; + public static final field AFFILIATION Ljava/lang/String; + public static final field CAMPAIGN Ljava/lang/String; + public static final field CAMPAIGN_ID Ljava/lang/String; + public static final field CHARACTER Ljava/lang/String; + public static final field CONTENT Ljava/lang/String; + public static final field CONTENT_TYPE Ljava/lang/String; + public static final field COUPON Ljava/lang/String; + public static final field CP1 Ljava/lang/String; + public static final field CREATIVE_FORMAT Ljava/lang/String; + public static final field CREATIVE_NAME Ljava/lang/String; + public static final field CREATIVE_SLOT Ljava/lang/String; + public static final field CURRENCY Ljava/lang/String; + public static final field DESTINATION Ljava/lang/String; + public static final field DISCOUNT Ljava/lang/String; + public static final field END_DATE Ljava/lang/String; + public static final field EXTEND_SESSION Ljava/lang/String; + public static final field FLIGHT_NUMBER Ljava/lang/String; + public static final field GROUP_ID Ljava/lang/String; + public static final field INDEX Ljava/lang/String; + public static final field INSTANCE Ldev/gitlive/firebase/analytics/FirebaseAnalyticsParam; + public static final field ITEMS Ljava/lang/String; + public static final field ITEM_BRAND Ljava/lang/String; + public static final field ITEM_CATEGORY Ljava/lang/String; + public static final field ITEM_CATEGORY2 Ljava/lang/String; + public static final field ITEM_CATEGORY3 Ljava/lang/String; + public static final field ITEM_CATEGORY4 Ljava/lang/String; + public static final field ITEM_CATEGORY5 Ljava/lang/String; + public static final field ITEM_ID Ljava/lang/String; + public static final field ITEM_LIST_ID Ljava/lang/String; + public static final field ITEM_LIST_NAME Ljava/lang/String; + public static final field ITEM_NAME Ljava/lang/String; + public static final field ITEM_VARIANT Ljava/lang/String; + public static final field LEVEL Ljava/lang/String; + public static final field LEVEL_NAME Ljava/lang/String; + public static final field LOCATION Ljava/lang/String; + public static final field LOCATION_ID Ljava/lang/String; + public static final field MARKETING_TACTIC Ljava/lang/String; + public static final field MEDIUM Ljava/lang/String; + public static final field METHOD Ljava/lang/String; + public static final field NUMBER_OF_NIGHTS Ljava/lang/String; + public static final field NUMBER_OF_PASSENGERS Ljava/lang/String; + public static final field NUMBER_OF_ROOMS Ljava/lang/String; + public static final field ORIGIN Ljava/lang/String; + public static final field PAYMENT_TYPE Ljava/lang/String; + public static final field PRICE Ljava/lang/String; + public static final field PROMOTION_ID Ljava/lang/String; + public static final field PROMOTION_NAME Ljava/lang/String; + public static final field QUANTITY Ljava/lang/String; + public static final field SCORE Ljava/lang/String; + public static final field SCREEN_CLASS Ljava/lang/String; + public static final field SCREEN_NAME Ljava/lang/String; + public static final field SEARCH_TERM Ljava/lang/String; + public static final field SHIPPING Ljava/lang/String; + public static final field SHIPPING_TIER Ljava/lang/String; + public static final field SOURCE Ljava/lang/String; + public static final field SOURCE_PLATFORM Ljava/lang/String; + public static final field START_DATE Ljava/lang/String; + public static final field SUCCESS Ljava/lang/String; + public static final field TAX Ljava/lang/String; + public static final field TERM Ljava/lang/String; + public static final field TRANSACTION_ID Ljava/lang/String; + public static final field TRAVEL_CLASS Ljava/lang/String; + public static final field VALUE Ljava/lang/String; + public static final field VIRTUAL_CURRENCY_NAME Ljava/lang/String; +} + +public final class dev/gitlive/firebase/analytics/FirebaseAnalyticsParameters { + public fun ()V + public fun (Ljava/util/Map;)V + public synthetic fun (Ljava/util/Map;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun component1 ()Ljava/util/Map; + public final fun copy (Ljava/util/Map;)Ldev/gitlive/firebase/analytics/FirebaseAnalyticsParameters; + public static synthetic fun copy$default (Ldev/gitlive/firebase/analytics/FirebaseAnalyticsParameters;Ljava/util/Map;ILjava/lang/Object;)Ldev/gitlive/firebase/analytics/FirebaseAnalyticsParameters; + public fun equals (Ljava/lang/Object;)Z + public final fun getParameters ()Ljava/util/Map; + public fun hashCode ()I + public final fun param (Ljava/lang/String;D)V + public final fun param (Ljava/lang/String;I)V + public final fun param (Ljava/lang/String;J)V + public final fun param (Ljava/lang/String;Ljava/lang/String;)V + public final fun param (Ljava/lang/String;Z)V + public fun toString ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/analytics/FirebaseAnalyticsUserProperty { + public static final field ALLOW_AD_PERSONALIZATION_SIGNALS Ljava/lang/String; + public static final field INSTANCE Ldev/gitlive/firebase/analytics/FirebaseAnalyticsUserProperty; + public static final field SIGN_UP_METHOD Ljava/lang/String; +} + +public final class dev/gitlive/firebase/analytics/analyticsAndroid { + public static final fun analytics (Ldev/gitlive/firebase/Firebase;Ldev/gitlive/firebase/FirebaseApp;)Ldev/gitlive/firebase/analytics/FirebaseAnalytics; + public static final fun getAnalytics (Ldev/gitlive/firebase/Firebase;)Ldev/gitlive/firebase/analytics/FirebaseAnalytics; +} + diff --git a/firebase-analytics/api/jvm/firebase-analytics.api b/firebase-analytics/api/jvm/firebase-analytics.api new file mode 100644 index 000000000..94af482ef --- /dev/null +++ b/firebase-analytics/api/jvm/firebase-analytics.api @@ -0,0 +1,208 @@ +public final class dev/gitlive/firebase/analytics/AnalyticEventConstantsKt { + public static final fun getEvent (Ldev/gitlive/firebase/analytics/FirebaseAnalytics;)Ldev/gitlive/firebase/analytics/FirebaseAnalyticsEvents; + public static final fun getParam (Ldev/gitlive/firebase/analytics/FirebaseAnalytics;)Ldev/gitlive/firebase/analytics/FirebaseAnalyticsParam; + public static final fun getUserProperty (Ldev/gitlive/firebase/analytics/FirebaseAnalytics;)Ldev/gitlive/firebase/analytics/FirebaseAnalyticsUserProperty; +} + +public final class dev/gitlive/firebase/analytics/AnalyticsKt { + public static final fun logEvent (Ldev/gitlive/firebase/analytics/FirebaseAnalytics;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)V + public static final fun setConsent (Ldev/gitlive/firebase/analytics/FirebaseAnalytics;Lkotlin/jvm/functions/Function1;)V +} + +public final class dev/gitlive/firebase/analytics/Analytics_jvmKt { + public static final fun analytics (Ldev/gitlive/firebase/Firebase;Ldev/gitlive/firebase/FirebaseApp;)Ldev/gitlive/firebase/analytics/FirebaseAnalytics; + public static final fun getAnalytics (Ldev/gitlive/firebase/Firebase;)Ldev/gitlive/firebase/analytics/FirebaseAnalytics; +} + +public final class dev/gitlive/firebase/analytics/FirebaseAnalytics { + public fun ()V + public final fun getSessionId (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun logEvent (Ljava/lang/String;Ljava/util/Map;)V + public static synthetic fun logEvent$default (Ldev/gitlive/firebase/analytics/FirebaseAnalytics;Ljava/lang/String;Ljava/util/Map;ILjava/lang/Object;)V + public final fun resetAnalyticsData ()V + public final fun setAnalyticsCollectionEnabled (Z)V + public final fun setConsent (Ljava/util/Map;)V + public final fun setDefaultEventParameters (Ljava/util/Map;)V + public final fun setSessionTimeoutInterval (J)V + public final fun setUserId (Ljava/lang/String;)V + public final fun setUserProperty (Ljava/lang/String;Ljava/lang/String;)V +} + +public final class dev/gitlive/firebase/analytics/FirebaseAnalytics$ConsentStatus : java/lang/Enum { + public static final field DENIED Ldev/gitlive/firebase/analytics/FirebaseAnalytics$ConsentStatus; + public static final field GRANTED Ldev/gitlive/firebase/analytics/FirebaseAnalytics$ConsentStatus; + public static fun getEntries ()Lkotlin/enums/EnumEntries; + public static fun valueOf (Ljava/lang/String;)Ldev/gitlive/firebase/analytics/FirebaseAnalytics$ConsentStatus; + public static fun values ()[Ldev/gitlive/firebase/analytics/FirebaseAnalytics$ConsentStatus; +} + +public final class dev/gitlive/firebase/analytics/FirebaseAnalytics$ConsentType : java/lang/Enum { + public static final field AD_PERSONALIZATION Ldev/gitlive/firebase/analytics/FirebaseAnalytics$ConsentType; + public static final field AD_STORAGE Ldev/gitlive/firebase/analytics/FirebaseAnalytics$ConsentType; + public static final field AD_USER_DATA Ldev/gitlive/firebase/analytics/FirebaseAnalytics$ConsentType; + public static final field ANALYTICS_STORAGE Ldev/gitlive/firebase/analytics/FirebaseAnalytics$ConsentType; + public static fun getEntries ()Lkotlin/enums/EnumEntries; + public static fun valueOf (Ljava/lang/String;)Ldev/gitlive/firebase/analytics/FirebaseAnalytics$ConsentType; + public static fun values ()[Ldev/gitlive/firebase/analytics/FirebaseAnalytics$ConsentType; +} + +public final class dev/gitlive/firebase/analytics/FirebaseAnalyticsConsentBuilder { + public fun ()V + public fun (Ljava/util/Map;)V + public synthetic fun (Ljava/util/Map;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun component1 ()Ljava/util/Map; + public final fun copy (Ljava/util/Map;)Ldev/gitlive/firebase/analytics/FirebaseAnalyticsConsentBuilder; + public static synthetic fun copy$default (Ldev/gitlive/firebase/analytics/FirebaseAnalyticsConsentBuilder;Ljava/util/Map;ILjava/lang/Object;)Ldev/gitlive/firebase/analytics/FirebaseAnalyticsConsentBuilder; + public fun equals (Ljava/lang/Object;)Z + public final fun getAdPersonalization ()Ldev/gitlive/firebase/analytics/FirebaseAnalytics$ConsentStatus; + public final fun getAdStorage ()Ldev/gitlive/firebase/analytics/FirebaseAnalytics$ConsentStatus; + public final fun getAdUserData ()Ldev/gitlive/firebase/analytics/FirebaseAnalytics$ConsentStatus; + public final fun getAnalyticsStorage ()Ldev/gitlive/firebase/analytics/FirebaseAnalytics$ConsentStatus; + public final fun getConsentSettings ()Ljava/util/Map; + public fun hashCode ()I + public final fun setAdPersonalization (Ldev/gitlive/firebase/analytics/FirebaseAnalytics$ConsentStatus;)V + public final fun setAdStorage (Ldev/gitlive/firebase/analytics/FirebaseAnalytics$ConsentStatus;)V + public final fun setAdUserData (Ldev/gitlive/firebase/analytics/FirebaseAnalytics$ConsentStatus;)V + public final fun setAnalyticsStorage (Ldev/gitlive/firebase/analytics/FirebaseAnalytics$ConsentStatus;)V + public fun toString ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/analytics/FirebaseAnalyticsEvents { + public static final field ADD_PAYMENT_INFO Ljava/lang/String; + public static final field ADD_SHIPPING_INFO Ljava/lang/String; + public static final field ADD_TO_CART Ljava/lang/String; + public static final field ADD_TO_WISHLIST Ljava/lang/String; + public static final field AD_IMPRESSION Ljava/lang/String; + public static final field APP_OPEN Ljava/lang/String; + public static final field BEGIN_CHECKOUT Ljava/lang/String; + public static final field CAMPAIGN_DETAILS Ljava/lang/String; + public static final field EARN_VIRTUAL_CURRENCY Ljava/lang/String; + public static final field GENERATE_LEAD Ljava/lang/String; + public static final field INSTANCE Ldev/gitlive/firebase/analytics/FirebaseAnalyticsEvents; + public static final field JOIN_GROUP Ljava/lang/String; + public static final field LEVEL_END Ljava/lang/String; + public static final field LEVEL_START Ljava/lang/String; + public static final field LEVEL_UP Ljava/lang/String; + public static final field LOGIN Ljava/lang/String; + public static final field POST_SCORE Ljava/lang/String; + public static final field PURCHASE Ljava/lang/String; + public static final field REFUND Ljava/lang/String; + public static final field REMOVE_FROM_CART Ljava/lang/String; + public static final field SCREEN_VIEW Ljava/lang/String; + public static final field SEARCH Ljava/lang/String; + public static final field SELECT_CONTENT Ljava/lang/String; + public static final field SELECT_ITEM Ljava/lang/String; + public static final field SELECT_PROMOTION Ljava/lang/String; + public static final field SHARE Ljava/lang/String; + public static final field SIGN_UP Ljava/lang/String; + public static final field SPEND_VIRTUAL_CURRENCY Ljava/lang/String; + public static final field TUTORIAL_BEGIN Ljava/lang/String; + public static final field TUTORIAL_COMPLETE Ljava/lang/String; + public static final field UNLOCK_ACHIEVEMENT Ljava/lang/String; + public static final field VIEW_CART Ljava/lang/String; + public static final field VIEW_ITEM Ljava/lang/String; + public static final field VIEW_ITEM_LIST Ljava/lang/String; + public static final field VIEW_PROMOTION Ljava/lang/String; + public static final field VIEW_SEARCH_RESULTS Ljava/lang/String; +} + +public final class dev/gitlive/firebase/analytics/FirebaseAnalyticsException : com/google/firebase/FirebaseException { +} + +public final class dev/gitlive/firebase/analytics/FirebaseAnalyticsParam { + public static final field ACHIEVEMENT_ID Ljava/lang/String; + public static final field ACLID Ljava/lang/String; + public static final field AD_FORMAT Ljava/lang/String; + public static final field AD_PLATFORM Ljava/lang/String; + public static final field AD_SOURCE Ljava/lang/String; + public static final field AD_UNIT_NAME Ljava/lang/String; + public static final field AFFILIATION Ljava/lang/String; + public static final field CAMPAIGN Ljava/lang/String; + public static final field CAMPAIGN_ID Ljava/lang/String; + public static final field CHARACTER Ljava/lang/String; + public static final field CONTENT Ljava/lang/String; + public static final field CONTENT_TYPE Ljava/lang/String; + public static final field COUPON Ljava/lang/String; + public static final field CP1 Ljava/lang/String; + public static final field CREATIVE_FORMAT Ljava/lang/String; + public static final field CREATIVE_NAME Ljava/lang/String; + public static final field CREATIVE_SLOT Ljava/lang/String; + public static final field CURRENCY Ljava/lang/String; + public static final field DESTINATION Ljava/lang/String; + public static final field DISCOUNT Ljava/lang/String; + public static final field END_DATE Ljava/lang/String; + public static final field EXTEND_SESSION Ljava/lang/String; + public static final field FLIGHT_NUMBER Ljava/lang/String; + public static final field GROUP_ID Ljava/lang/String; + public static final field INDEX Ljava/lang/String; + public static final field INSTANCE Ldev/gitlive/firebase/analytics/FirebaseAnalyticsParam; + public static final field ITEMS Ljava/lang/String; + public static final field ITEM_BRAND Ljava/lang/String; + public static final field ITEM_CATEGORY Ljava/lang/String; + public static final field ITEM_CATEGORY2 Ljava/lang/String; + public static final field ITEM_CATEGORY3 Ljava/lang/String; + public static final field ITEM_CATEGORY4 Ljava/lang/String; + public static final field ITEM_CATEGORY5 Ljava/lang/String; + public static final field ITEM_ID Ljava/lang/String; + public static final field ITEM_LIST_ID Ljava/lang/String; + public static final field ITEM_LIST_NAME Ljava/lang/String; + public static final field ITEM_NAME Ljava/lang/String; + public static final field ITEM_VARIANT Ljava/lang/String; + public static final field LEVEL Ljava/lang/String; + public static final field LEVEL_NAME Ljava/lang/String; + public static final field LOCATION Ljava/lang/String; + public static final field LOCATION_ID Ljava/lang/String; + public static final field MARKETING_TACTIC Ljava/lang/String; + public static final field MEDIUM Ljava/lang/String; + public static final field METHOD Ljava/lang/String; + public static final field NUMBER_OF_NIGHTS Ljava/lang/String; + public static final field NUMBER_OF_PASSENGERS Ljava/lang/String; + public static final field NUMBER_OF_ROOMS Ljava/lang/String; + public static final field ORIGIN Ljava/lang/String; + public static final field PAYMENT_TYPE Ljava/lang/String; + public static final field PRICE Ljava/lang/String; + public static final field PROMOTION_ID Ljava/lang/String; + public static final field PROMOTION_NAME Ljava/lang/String; + public static final field QUANTITY Ljava/lang/String; + public static final field SCORE Ljava/lang/String; + public static final field SCREEN_CLASS Ljava/lang/String; + public static final field SCREEN_NAME Ljava/lang/String; + public static final field SEARCH_TERM Ljava/lang/String; + public static final field SHIPPING Ljava/lang/String; + public static final field SHIPPING_TIER Ljava/lang/String; + public static final field SOURCE Ljava/lang/String; + public static final field SOURCE_PLATFORM Ljava/lang/String; + public static final field START_DATE Ljava/lang/String; + public static final field SUCCESS Ljava/lang/String; + public static final field TAX Ljava/lang/String; + public static final field TERM Ljava/lang/String; + public static final field TRANSACTION_ID Ljava/lang/String; + public static final field TRAVEL_CLASS Ljava/lang/String; + public static final field VALUE Ljava/lang/String; + public static final field VIRTUAL_CURRENCY_NAME Ljava/lang/String; +} + +public final class dev/gitlive/firebase/analytics/FirebaseAnalyticsParameters { + public fun ()V + public fun (Ljava/util/Map;)V + public synthetic fun (Ljava/util/Map;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun component1 ()Ljava/util/Map; + public final fun copy (Ljava/util/Map;)Ldev/gitlive/firebase/analytics/FirebaseAnalyticsParameters; + public static synthetic fun copy$default (Ldev/gitlive/firebase/analytics/FirebaseAnalyticsParameters;Ljava/util/Map;ILjava/lang/Object;)Ldev/gitlive/firebase/analytics/FirebaseAnalyticsParameters; + public fun equals (Ljava/lang/Object;)Z + public final fun getParameters ()Ljava/util/Map; + public fun hashCode ()I + public final fun param (Ljava/lang/String;D)V + public final fun param (Ljava/lang/String;I)V + public final fun param (Ljava/lang/String;J)V + public final fun param (Ljava/lang/String;Ljava/lang/String;)V + public final fun param (Ljava/lang/String;Z)V + public fun toString ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/analytics/FirebaseAnalyticsUserProperty { + public static final field ALLOW_AD_PERSONALIZATION_SIGNALS Ljava/lang/String; + public static final field INSTANCE Ldev/gitlive/firebase/analytics/FirebaseAnalyticsUserProperty; + public static final field SIGN_UP_METHOD Ljava/lang/String; +} + diff --git a/firebase-analytics/build.gradle.kts b/firebase-analytics/build.gradle.kts index 9d8711cbf..e496277d9 100644 --- a/firebase-analytics/build.gradle.kts +++ b/firebase-analytics/build.gradle.kts @@ -47,6 +47,8 @@ android { val supportIosTarget = project.property("skipIosTarget") != "true" kotlin { + explicitApi() + @OptIn(ExperimentalKotlinGradlePluginApi::class) compilerOptions { freeCompilerArgs.add("-Xexpect-actual-classes") diff --git a/firebase-analytics/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/analytics/analytics.kt b/firebase-analytics/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/analytics/analytics.kt index 9b6ae269a..2f6d67096 100644 --- a/firebase-analytics/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/analytics/analytics.kt +++ b/firebase-analytics/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/analytics/analytics.kt @@ -3,12 +3,11 @@ */ @file:JvmName("tests") + package dev.gitlive.firebase.analytics import androidx.test.platform.app.InstrumentationRegistry -actual val emulatorHost: String = "10.0.2.2" - actual val context: Any = InstrumentationRegistry.getInstrumentation().targetContext @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) diff --git a/firebase-analytics/src/androidMain/kotlin/dev/gitlive/firebase/analytics/analytics.kt b/firebase-analytics/src/androidMain/kotlin/dev/gitlive/firebase/analytics/analytics.kt index 31795e294..f5aa12238 100644 --- a/firebase-analytics/src/androidMain/kotlin/dev/gitlive/firebase/analytics/analytics.kt +++ b/firebase-analytics/src/androidMain/kotlin/dev/gitlive/firebase/analytics/analytics.kt @@ -1,52 +1,48 @@ @file:JvmName("analyticsAndroid") + package dev.gitlive.firebase.analytics import android.os.Bundle -import android.os.IBinder -import android.os.Parcelable -import android.util.Size -import android.util.SizeF import com.google.firebase.analytics.analytics import com.google.firebase.analytics.setConsent import dev.gitlive.firebase.Firebase import dev.gitlive.firebase.FirebaseApp import kotlinx.coroutines.tasks.await -import java.io.Serializable -actual val Firebase.analytics: FirebaseAnalytics +public actual val Firebase.analytics: FirebaseAnalytics get() = FirebaseAnalytics(com.google.firebase.Firebase.analytics) -actual fun Firebase.analytics(app: FirebaseApp) = +public actual fun Firebase.analytics(app: FirebaseApp): FirebaseAnalytics = FirebaseAnalytics(com.google.firebase.Firebase.analytics) -actual class FirebaseAnalytics(val android: com.google.firebase.analytics.FirebaseAnalytics) { - actual fun logEvent(name: String, parameters: Map?) { +public actual class FirebaseAnalytics(public val android: com.google.firebase.analytics.FirebaseAnalytics) { + public actual fun logEvent(name: String, parameters: Map?) { android.logEvent(name, parameters?.toBundle()) } - actual fun setUserProperty(name: String, value: String) { + public actual fun setUserProperty(name: String, value: String) { android.setUserProperty(name, value) } - actual fun setUserId(id: String) { + public actual fun setUserId(id: String) { android.setUserId(id) } - actual fun resetAnalyticsData() { + public actual fun resetAnalyticsData() { android.resetAnalyticsData() } - actual fun setDefaultEventParameters(parameters: Map) { + public actual fun setDefaultEventParameters(parameters: Map) { android.setDefaultEventParameters(parameters.toBundle()) } - actual fun setAnalyticsCollectionEnabled(enabled: Boolean) { + public actual fun setAnalyticsCollectionEnabled(enabled: Boolean) { android.setAnalyticsCollectionEnabled(enabled) } - actual fun setSessionTimeoutInterval(sessionTimeoutInterval: Long) { + public actual fun setSessionTimeoutInterval(sessionTimeoutInterval: Long) { android.setSessionTimeoutDuration(sessionTimeoutInterval) } - actual suspend fun getSessionId(): Long? = android.sessionId.await() + public actual suspend fun getSessionId(): Long? = android.sessionId.await() - actual fun setConsent(consentSettings: Map) { + public actual fun setConsent(consentSettings: Map) { consentSettings.entries.associate { it.key to when (it.value) { ConsentStatus.GRANTED -> com.google.firebase.analytics.FirebaseAnalytics.ConsentStatus.GRANTED @@ -69,35 +65,33 @@ actual class FirebaseAnalytics(val android: com.google.firebase.analytics.Fireba this.analyticsStorage = it.value } } - } } } - actual enum class ConsentType { + public actual enum class ConsentType { AD_PERSONALIZATION, AD_STORAGE, AD_USER_DATA, - ANALYTICS_STORAGE + ANALYTICS_STORAGE, } - actual enum class ConsentStatus { + public actual enum class ConsentStatus { GRANTED, - DENIED + DENIED, } } -actual class FirebaseAnalyticsException(message: String): Exception(message) +public actual class FirebaseAnalyticsException(message: String) : Exception(message) private fun Map.toBundle() = Bundle().apply { forEach { (key, value) -> - when(value::class) { + when (value::class) { String::class -> putString(key, value as String) Int::class -> putInt(key, value as Int) Long::class -> putLong(key, value as Long) Double::class -> putDouble(key, value as Double) Boolean::class -> putBoolean(key, value as Boolean) } - } -} \ No newline at end of file +} diff --git a/firebase-analytics/src/androidUnitTest/kotlin/dev/gitlive/firebase/analytics/analytics.kt b/firebase-analytics/src/androidUnitTest/kotlin/dev/gitlive/firebase/analytics/analytics.kt index aa0d883dd..53eee5cd5 100644 --- a/firebase-analytics/src/androidUnitTest/kotlin/dev/gitlive/firebase/analytics/analytics.kt +++ b/firebase-analytics/src/androidUnitTest/kotlin/dev/gitlive/firebase/analytics/analytics.kt @@ -2,8 +2,6 @@ package dev.gitlive.firebase.analytics import org.junit.Ignore -actual val emulatorHost: String = "10.0.2.2" - actual val context: Any = "" actual typealias IgnoreForAndroidUnitTest = Ignore diff --git a/firebase-analytics/src/commonMain/kotlin/dev/gitlive/firebase/analytics/AnalyticEventConstants.kt b/firebase-analytics/src/commonMain/kotlin/dev/gitlive/firebase/analytics/AnalyticEventConstants.kt index 7b4e132db..240c8d4f1 100644 --- a/firebase-analytics/src/commonMain/kotlin/dev/gitlive/firebase/analytics/AnalyticEventConstants.kt +++ b/firebase-analytics/src/commonMain/kotlin/dev/gitlive/firebase/analytics/AnalyticEventConstants.kt @@ -1,125 +1,127 @@ +@file:Suppress("UnusedReceiverParameter") + package dev.gitlive.firebase.analytics -val FirebaseAnalytics.Event: FirebaseAnalyticsEvents +public val FirebaseAnalytics.Event: FirebaseAnalyticsEvents get() = FirebaseAnalyticsEvents -object FirebaseAnalyticsEvents { - const val ADD_PAYMENT_INFO: String = "add_payment_info" - const val ADD_SHIPPING_INFO: String = "add_shipping_info" - const val ADD_TO_CART: String = "add_to_cart" - const val ADD_TO_WISHLIST: String = "add_to_wishlist" - const val AD_IMPRESSION: String = "ad_impression" - const val APP_OPEN: String = "app_open" - const val BEGIN_CHECKOUT: String = "begin_checkout" - const val CAMPAIGN_DETAILS: String = "campaign_details" - const val EARN_VIRTUAL_CURRENCY: String = "earn_virtual_currency" - const val GENERATE_LEAD: String = "generate_lead" - const val JOIN_GROUP: String = "join_group" - const val LEVEL_END: String = "level_end" - const val LEVEL_START: String = "level_start" - const val LEVEL_UP: String = "level_up" - const val LOGIN: String = "login" - const val POST_SCORE: String = "post_score" - const val PURCHASE: String = "purchase" - const val REFUND: String = "refund" - const val REMOVE_FROM_CART: String = "remove_from_cart" - const val SCREEN_VIEW: String = "screen_view" - const val SEARCH: String = "search" - const val SELECT_CONTENT: String = "select_content" - const val SELECT_ITEM: String = "select_item" - const val SELECT_PROMOTION: String = "select_promotion" - const val SHARE: String = "share" - const val SIGN_UP: String = "sign_up" - const val SPEND_VIRTUAL_CURRENCY: String = "spend_virtual_currency" - const val TUTORIAL_BEGIN: String = "tutorial_begin" - const val TUTORIAL_COMPLETE: String = "tutorial_complete" - const val UNLOCK_ACHIEVEMENT: String = "unlock_achievement" - const val VIEW_CART: String = "view_cart" - const val VIEW_ITEM: String = "view_item" - const val VIEW_ITEM_LIST: String = "view_item_list" - const val VIEW_PROMOTION: String = "view_promotion" - const val VIEW_SEARCH_RESULTS: String = "view_search_results" +public object FirebaseAnalyticsEvents { + public const val ADD_PAYMENT_INFO: String = "add_payment_info" + public const val ADD_SHIPPING_INFO: String = "add_shipping_info" + public const val ADD_TO_CART: String = "add_to_cart" + public const val ADD_TO_WISHLIST: String = "add_to_wishlist" + public const val AD_IMPRESSION: String = "ad_impression" + public const val APP_OPEN: String = "app_open" + public const val BEGIN_CHECKOUT: String = "begin_checkout" + public const val CAMPAIGN_DETAILS: String = "campaign_details" + public const val EARN_VIRTUAL_CURRENCY: String = "earn_virtual_currency" + public const val GENERATE_LEAD: String = "generate_lead" + public const val JOIN_GROUP: String = "join_group" + public const val LEVEL_END: String = "level_end" + public const val LEVEL_START: String = "level_start" + public const val LEVEL_UP: String = "level_up" + public const val LOGIN: String = "login" + public const val POST_SCORE: String = "post_score" + public const val PURCHASE: String = "purchase" + public const val REFUND: String = "refund" + public const val REMOVE_FROM_CART: String = "remove_from_cart" + public const val SCREEN_VIEW: String = "screen_view" + public const val SEARCH: String = "search" + public const val SELECT_CONTENT: String = "select_content" + public const val SELECT_ITEM: String = "select_item" + public const val SELECT_PROMOTION: String = "select_promotion" + public const val SHARE: String = "share" + public const val SIGN_UP: String = "sign_up" + public const val SPEND_VIRTUAL_CURRENCY: String = "spend_virtual_currency" + public const val TUTORIAL_BEGIN: String = "tutorial_begin" + public const val TUTORIAL_COMPLETE: String = "tutorial_complete" + public const val UNLOCK_ACHIEVEMENT: String = "unlock_achievement" + public const val VIEW_CART: String = "view_cart" + public const val VIEW_ITEM: String = "view_item" + public const val VIEW_ITEM_LIST: String = "view_item_list" + public const val VIEW_PROMOTION: String = "view_promotion" + public const val VIEW_SEARCH_RESULTS: String = "view_search_results" } -val FirebaseAnalytics.Param: FirebaseAnalyticsParam +public val FirebaseAnalytics.Param: FirebaseAnalyticsParam get() = FirebaseAnalyticsParam -object FirebaseAnalyticsParam { - const val ACHIEVEMENT_ID: String = "achievement_id" - const val ACLID: String = "aclid" - const val AD_FORMAT: String = "ad_format" - const val AD_PLATFORM: String = "ad_platform" - const val AD_SOURCE: String = "ad_source" - const val AD_UNIT_NAME: String = "ad_unit_name" - const val AFFILIATION: String = "affiliation" - const val CAMPAIGN: String = "campaign" - const val CAMPAIGN_ID: String = "campaign_id" - const val CHARACTER: String = "character" - const val CONTENT: String = "content" - const val CONTENT_TYPE: String = "content_type" - const val COUPON: String = "coupon" - const val CP1: String = "cp1" - const val CREATIVE_FORMAT: String = "creative_format" - const val CREATIVE_NAME: String = "creative_name" - const val CREATIVE_SLOT: String = "creative_slot" - const val CURRENCY: String = "currency" - const val DESTINATION: String = "destination" - const val DISCOUNT: String = "discount" - const val END_DATE: String = "end_date" - const val EXTEND_SESSION: String = "extend_session" - const val FLIGHT_NUMBER: String = "flight_number" - const val GROUP_ID: String = "group_id" - const val INDEX: String = "index" - const val ITEMS: String = "items" - const val ITEM_BRAND: String = "item_brand" - const val ITEM_CATEGORY: String = "item_category" - const val ITEM_CATEGORY2: String = "item_category2" - const val ITEM_CATEGORY3: String = "item_category3" - const val ITEM_CATEGORY4: String = "item_category4" - const val ITEM_CATEGORY5: String = "item_category5" - const val ITEM_ID: String = "item_id" - const val ITEM_LIST_ID: String = "item_list_id" - const val ITEM_LIST_NAME: String = "item_list_name" - const val ITEM_NAME: String = "item_name" - const val ITEM_VARIANT: String = "item_variant" - const val LEVEL: String = "level" - const val LEVEL_NAME: String = "level_name" - const val LOCATION: String = "location" - const val LOCATION_ID: String = "location_id" - const val MARKETING_TACTIC: String = "marketing_tactic" - const val MEDIUM: String = "medium" - const val METHOD: String = "method" - const val NUMBER_OF_NIGHTS: String = "number_of_nights" - const val NUMBER_OF_PASSENGERS: String = "number_of_passengers" - const val NUMBER_OF_ROOMS: String = "number_of_rooms" - const val ORIGIN: String = "origin" - const val PAYMENT_TYPE: String = "payment_type" - const val PRICE: String = "price" - const val PROMOTION_ID: String = "promotion_id" - const val PROMOTION_NAME: String = "promotion_name" - const val QUANTITY: String = "quantity" - const val SCORE: String = "score" - const val SCREEN_CLASS: String = "screen_class" - const val SCREEN_NAME: String = "screen_name" - const val SEARCH_TERM: String = "search_term" - const val SHIPPING: String = "shipping" - const val SHIPPING_TIER: String = "shipping_tier" - const val SOURCE: String = "source" - const val SOURCE_PLATFORM: String = "source_platform" - const val START_DATE: String = "start_date" - const val SUCCESS: String = "success" - const val TAX: String = "tax" - const val TERM: String = "term" - const val TRANSACTION_ID: String = "transaction_id" - const val TRAVEL_CLASS: String = "travel_class" - const val VALUE: String = "value" - const val VIRTUAL_CURRENCY_NAME: String = "virtual_currency_name" +public object FirebaseAnalyticsParam { + public const val ACHIEVEMENT_ID: String = "achievement_id" + public const val ACLID: String = "aclid" + public const val AD_FORMAT: String = "ad_format" + public const val AD_PLATFORM: String = "ad_platform" + public const val AD_SOURCE: String = "ad_source" + public const val AD_UNIT_NAME: String = "ad_unit_name" + public const val AFFILIATION: String = "affiliation" + public const val CAMPAIGN: String = "campaign" + public const val CAMPAIGN_ID: String = "campaign_id" + public const val CHARACTER: String = "character" + public const val CONTENT: String = "content" + public const val CONTENT_TYPE: String = "content_type" + public const val COUPON: String = "coupon" + public const val CP1: String = "cp1" + public const val CREATIVE_FORMAT: String = "creative_format" + public const val CREATIVE_NAME: String = "creative_name" + public const val CREATIVE_SLOT: String = "creative_slot" + public const val CURRENCY: String = "currency" + public const val DESTINATION: String = "destination" + public const val DISCOUNT: String = "discount" + public const val END_DATE: String = "end_date" + public const val EXTEND_SESSION: String = "extend_session" + public const val FLIGHT_NUMBER: String = "flight_number" + public const val GROUP_ID: String = "group_id" + public const val INDEX: String = "index" + public const val ITEMS: String = "items" + public const val ITEM_BRAND: String = "item_brand" + public const val ITEM_CATEGORY: String = "item_category" + public const val ITEM_CATEGORY2: String = "item_category2" + public const val ITEM_CATEGORY3: String = "item_category3" + public const val ITEM_CATEGORY4: String = "item_category4" + public const val ITEM_CATEGORY5: String = "item_category5" + public const val ITEM_ID: String = "item_id" + public const val ITEM_LIST_ID: String = "item_list_id" + public const val ITEM_LIST_NAME: String = "item_list_name" + public const val ITEM_NAME: String = "item_name" + public const val ITEM_VARIANT: String = "item_variant" + public const val LEVEL: String = "level" + public const val LEVEL_NAME: String = "level_name" + public const val LOCATION: String = "location" + public const val LOCATION_ID: String = "location_id" + public const val MARKETING_TACTIC: String = "marketing_tactic" + public const val MEDIUM: String = "medium" + public const val METHOD: String = "method" + public const val NUMBER_OF_NIGHTS: String = "number_of_nights" + public const val NUMBER_OF_PASSENGERS: String = "number_of_passengers" + public const val NUMBER_OF_ROOMS: String = "number_of_rooms" + public const val ORIGIN: String = "origin" + public const val PAYMENT_TYPE: String = "payment_type" + public const val PRICE: String = "price" + public const val PROMOTION_ID: String = "promotion_id" + public const val PROMOTION_NAME: String = "promotion_name" + public const val QUANTITY: String = "quantity" + public const val SCORE: String = "score" + public const val SCREEN_CLASS: String = "screen_class" + public const val SCREEN_NAME: String = "screen_name" + public const val SEARCH_TERM: String = "search_term" + public const val SHIPPING: String = "shipping" + public const val SHIPPING_TIER: String = "shipping_tier" + public const val SOURCE: String = "source" + public const val SOURCE_PLATFORM: String = "source_platform" + public const val START_DATE: String = "start_date" + public const val SUCCESS: String = "success" + public const val TAX: String = "tax" + public const val TERM: String = "term" + public const val TRANSACTION_ID: String = "transaction_id" + public const val TRAVEL_CLASS: String = "travel_class" + public const val VALUE: String = "value" + public const val VIRTUAL_CURRENCY_NAME: String = "virtual_currency_name" } -val FirebaseAnalytics.UserProperty: FirebaseAnalyticsUserProperty +public val FirebaseAnalytics.UserProperty: FirebaseAnalyticsUserProperty get() = FirebaseAnalyticsUserProperty -object FirebaseAnalyticsUserProperty { - const val ALLOW_AD_PERSONALIZATION_SIGNALS: String = "allow_personalized_ads" - const val SIGN_UP_METHOD: String = "sign_up_method" +public object FirebaseAnalyticsUserProperty { + public const val ALLOW_AD_PERSONALIZATION_SIGNALS: String = "allow_personalized_ads" + public const val SIGN_UP_METHOD: String = "sign_up_method" } diff --git a/firebase-analytics/src/commonMain/kotlin/dev/gitlive/firebase/analytics/analytics.kt b/firebase-analytics/src/commonMain/kotlin/dev/gitlive/firebase/analytics/analytics.kt index a46f1688c..a3bc10d6b 100644 --- a/firebase-analytics/src/commonMain/kotlin/dev/gitlive/firebase/analytics/analytics.kt +++ b/firebase-analytics/src/commonMain/kotlin/dev/gitlive/firebase/analytics/analytics.kt @@ -3,75 +3,75 @@ package dev.gitlive.firebase.analytics import dev.gitlive.firebase.Firebase import dev.gitlive.firebase.FirebaseApp -expect val Firebase.analytics: FirebaseAnalytics +public expect val Firebase.analytics: FirebaseAnalytics /** Returns the [FirebaseStorage] instance of a given [FirebaseApp]. */ -expect fun Firebase.analytics(app: FirebaseApp): FirebaseAnalytics - -expect class FirebaseAnalytics { - fun logEvent(name: String, parameters: Map? = null) - fun setUserProperty(name: String, value: String) - fun setUserId(id: String) - fun setAnalyticsCollectionEnabled(enabled: Boolean) - fun setSessionTimeoutInterval(sessionTimeoutInterval: Long) - suspend fun getSessionId(): Long? - fun resetAnalyticsData() - fun setDefaultEventParameters(parameters: Map) - fun setConsent(consentSettings: Map) - - enum class ConsentType { +public expect fun Firebase.analytics(app: FirebaseApp): FirebaseAnalytics + +public expect class FirebaseAnalytics { + public fun logEvent(name: String, parameters: Map? = null) + public fun setUserProperty(name: String, value: String) + public fun setUserId(id: String) + public fun setAnalyticsCollectionEnabled(enabled: Boolean) + public fun setSessionTimeoutInterval(sessionTimeoutInterval: Long) + public suspend fun getSessionId(): Long? + public fun resetAnalyticsData() + public fun setDefaultEventParameters(parameters: Map) + public fun setConsent(consentSettings: Map) + + public enum class ConsentType { AD_PERSONALIZATION, AD_STORAGE, AD_USER_DATA, - ANALYTICS_STORAGE + ANALYTICS_STORAGE, } - enum class ConsentStatus { + public enum class ConsentStatus { GRANTED, - DENIED + DENIED, } } -fun FirebaseAnalytics.setConsent(builder: FirebaseAnalyticsConsentBuilder.() -> Unit) { +public fun FirebaseAnalytics.setConsent(builder: FirebaseAnalyticsConsentBuilder.() -> Unit) { val consentBuilder = FirebaseAnalyticsConsentBuilder() consentBuilder.builder() setConsent(consentBuilder.consentSettings) } -fun FirebaseAnalytics.logEvent(name: String, builder: FirebaseAnalyticsParameters.() -> Unit) { +public fun FirebaseAnalytics.logEvent(name: String, builder: FirebaseAnalyticsParameters.() -> Unit) { val params = FirebaseAnalyticsParameters() params.builder() logEvent(name, params.parameters) } -expect class FirebaseAnalyticsException +public expect class FirebaseAnalyticsException -data class FirebaseAnalyticsParameters( - val parameters: MutableMap = mutableMapOf() +public data class FirebaseAnalyticsParameters( + val parameters: MutableMap = mutableMapOf(), ) { - fun param(key: String, value: String) { + public fun param(key: String, value: String) { parameters[key] = value } - fun param(key: String, value: Double) { + public fun param(key: String, value: Double) { parameters[key] = value } - fun param(key: String, value: Long) { + public fun param(key: String, value: Long) { parameters[key] = value } - fun param(key: String, value: Int) { + public fun param(key: String, value: Int) { parameters[key] = value } - fun param(key: String, value: Boolean) { + public fun param(key: String, value: Boolean) { parameters[key] = value } } -data class FirebaseAnalyticsConsentBuilder( - val consentSettings: MutableMap = mutableMapOf() +public data class FirebaseAnalyticsConsentBuilder( + val consentSettings: MutableMap = mutableMapOf(), ) { var adPersonalization: FirebaseAnalytics.ConsentStatus? get() = consentSettings[FirebaseAnalytics.ConsentType.AD_PERSONALIZATION] @@ -104,4 +104,4 @@ data class FirebaseAnalyticsConsentBuilder( consentSettings[FirebaseAnalytics.ConsentType.ANALYTICS_STORAGE] = it } } -} \ No newline at end of file +} diff --git a/firebase-analytics/src/commonTest/kotlin/dev/gitlive/firebase/analytics/analytics.kt b/firebase-analytics/src/commonTest/kotlin/dev/gitlive/firebase/analytics/analytics.kt index 0cd25e326..9f1f5c529 100644 --- a/firebase-analytics/src/commonTest/kotlin/dev/gitlive/firebase/analytics/analytics.kt +++ b/firebase-analytics/src/commonTest/kotlin/dev/gitlive/firebase/analytics/analytics.kt @@ -14,7 +14,6 @@ import kotlin.test.BeforeTest import kotlin.test.Test import kotlin.test.assertNotNull -expect val emulatorHost: String expect val context: Any expect annotation class IgnoreForAndroidUnitTest() @@ -33,8 +32,8 @@ class FirebaseAnalyticsTest { databaseUrl = "https://fir-kotlin-sdk.firebaseio.com", storageBucket = "fir-kotlin-sdk.appspot.com", projectId = "fir-kotlin-sdk", - gcmSenderId = "846484016111" - ) + gcmSenderId = "846484016111", + ), ) analytics = Firebase.analytics(app) @@ -56,4 +55,4 @@ class FirebaseAnalyticsTest { param("key", "value") } } -} \ No newline at end of file +} diff --git a/firebase-analytics/src/iosMain/kotlin/dev/gitlive/firebase/analytics/analytics.kt b/firebase-analytics/src/iosMain/kotlin/dev/gitlive/firebase/analytics/analytics.kt index db369fb5e..b2e94176f 100644 --- a/firebase-analytics/src/iosMain/kotlin/dev/gitlive/firebase/analytics/analytics.kt +++ b/firebase-analytics/src/iosMain/kotlin/dev/gitlive/firebase/analytics/analytics.kt @@ -7,67 +7,66 @@ import dev.gitlive.firebase.FirebaseApp import dev.gitlive.firebase.FirebaseException import kotlinx.coroutines.CompletableDeferred import platform.Foundation.NSError -import platform.Foundation.NSTimeInterval -actual val Firebase.analytics: FirebaseAnalytics +public actual val Firebase.analytics: FirebaseAnalytics get() = FirebaseAnalytics(FIRAnalytics) -actual fun Firebase.analytics(app: FirebaseApp): FirebaseAnalytics = FirebaseAnalytics(FIRAnalytics) +public actual fun Firebase.analytics(app: FirebaseApp): FirebaseAnalytics = FirebaseAnalytics(FIRAnalytics) -actual class FirebaseAnalytics(val ios: FIRAnalytics.Companion) { - actual fun logEvent(name: String, parameters: Map?) { +public actual class FirebaseAnalytics(public val ios: FIRAnalytics.Companion) { + public actual fun logEvent(name: String, parameters: Map?) { val mappedParameters: Map? = parameters?.map { it.key to it.value }?.toMap() ios.logEventWithName(name, mappedParameters) } - actual fun setUserProperty(name: String, value: String) { + public actual fun setUserProperty(name: String, value: String) { ios.setUserPropertyString(value, name) } - actual fun setUserId(id: String) { + public actual fun setUserId(id: String) { ios.setUserID(id) } - actual fun resetAnalyticsData() { + public actual fun resetAnalyticsData() { ios.resetAnalyticsData() } - actual fun setAnalyticsCollectionEnabled(enabled: Boolean) { + public actual fun setAnalyticsCollectionEnabled(enabled: Boolean) { ios.setAnalyticsCollectionEnabled(enabled) } - actual fun setSessionTimeoutInterval(sessionTimeoutInterval: Long) { + public actual fun setSessionTimeoutInterval(sessionTimeoutInterval: Long) { ios.setSessionTimeoutInterval(sessionTimeoutInterval.toDouble()) } - actual suspend fun getSessionId(): Long? = ios.awaitResult { sessionIDWithCompletion(it) } + public actual suspend fun getSessionId(): Long? = ios.awaitResult { sessionIDWithCompletion(it) } - actual fun setDefaultEventParameters(parameters: Map) { + public actual fun setDefaultEventParameters(parameters: Map) { val mappedParameters: Map = parameters.map { it.key to it.value }.toMap() ios.setDefaultEventParameters(mappedParameters) } - actual fun setConsent(consentSettings: Map) { + public actual fun setConsent(consentSettings: Map) { val mappedConsentSettings: Map = consentSettings.map { it.key.name to it.value.name }.toMap() ios.setConsent(mappedConsentSettings) } - actual enum class ConsentType { + public actual enum class ConsentType { AD_PERSONALIZATION, AD_STORAGE, AD_USER_DATA, - ANALYTICS_STORAGE + ANALYTICS_STORAGE, } - actual enum class ConsentStatus { + public actual enum class ConsentStatus { GRANTED, - DENIED + DENIED, } } -actual class FirebaseAnalyticsException(message: String): FirebaseException(message) +public actual class FirebaseAnalyticsException(message: String) : FirebaseException(message) internal suspend inline fun T.await(function: T.(callback: (NSError?) -> Unit) -> Unit) { val job = CompletableDeferred() function { error -> - if(error == null) { + if (error == null) { job.complete(Unit) } else { job.completeExceptionally(FirebaseAnalyticsException(error.toString())) @@ -79,11 +78,11 @@ internal suspend inline fun T.await(function: T.(callback: (NSError?) -> Uni internal suspend inline fun T.awaitResult(function: T.(callback: (R?, NSError?) -> Unit) -> Unit): R { val job = CompletableDeferred() function { result, error -> - if(error == null) { + if (error == null) { job.complete(result) } else { job.completeExceptionally(FirebaseAnalyticsException(error.toString())) } } return job.await() as R -} \ No newline at end of file +} diff --git a/firebase-analytics/src/iosTest/kotlin/dev/gitlive/firebase/analytics/analytics.kt b/firebase-analytics/src/iosTest/kotlin/dev/gitlive/firebase/analytics/analytics.kt index 722724e53..8fbb53329 100644 --- a/firebase-analytics/src/iosTest/kotlin/dev/gitlive/firebase/analytics/analytics.kt +++ b/firebase-analytics/src/iosTest/kotlin/dev/gitlive/firebase/analytics/analytics.kt @@ -4,8 +4,6 @@ package dev.gitlive.firebase.analytics -actual val emulatorHost: String = "127.0.0.1" - actual val context: Any = Unit @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) diff --git a/firebase-analytics/src/jsMain/kotlin/dev/gitlive/firebase/analytics/analytics.kt b/firebase-analytics/src/jsMain/kotlin/dev/gitlive/firebase/analytics/analytics.kt index 413203706..6c4b2a644 100644 --- a/firebase-analytics/src/jsMain/kotlin/dev/gitlive/firebase/analytics/analytics.kt +++ b/firebase-analytics/src/jsMain/kotlin/dev/gitlive/firebase/analytics/analytics.kt @@ -6,47 +6,47 @@ import dev.gitlive.firebase.FirebaseException import dev.gitlive.firebase.analytics.externals.getAnalytics import kotlinx.coroutines.await -actual val Firebase.analytics: FirebaseAnalytics +public actual val Firebase.analytics: FirebaseAnalytics get() = FirebaseAnalytics(getAnalytics()) -actual fun Firebase.analytics(app: FirebaseApp) = +public actual fun Firebase.analytics(app: FirebaseApp): FirebaseAnalytics = FirebaseAnalytics(getAnalytics(app.js)) -actual class FirebaseAnalytics(val js: dev.gitlive.firebase.analytics.externals.FirebaseAnalytics) { - actual fun logEvent( +public actual class FirebaseAnalytics(public val js: dev.gitlive.firebase.analytics.externals.FirebaseAnalytics) { + public actual fun logEvent( name: String, - parameters: Map? + parameters: Map?, ) { dev.gitlive.firebase.analytics.externals.logEvent(js, name, parameters) } - actual fun setUserProperty(name: String, value: String) { + public actual fun setUserProperty(name: String, value: String) { dev.gitlive.firebase.analytics.externals.setUserProperty(js, name, value) } - actual fun setUserId(id: String) { + public actual fun setUserId(id: String) { dev.gitlive.firebase.analytics.externals.setUserId(js, id) } - actual fun setAnalyticsCollectionEnabled(enabled: Boolean) { + public actual fun setAnalyticsCollectionEnabled(enabled: Boolean) { dev.gitlive.firebase.analytics.externals.setAnalyticsCollectionEnabled(js, enabled) } - actual fun setSessionTimeoutInterval(sessionTimeoutInterval: Long) { + public actual fun setSessionTimeoutInterval(sessionTimeoutInterval: Long) { dev.gitlive.firebase.analytics.externals.setSessionTimeoutInterval(js, sessionTimeoutInterval) } - actual suspend fun getSessionId(): Long? = rethrow { dev.gitlive.firebase.analytics.externals.getSessionId(js).await() } + public actual suspend fun getSessionId(): Long? = rethrow { dev.gitlive.firebase.analytics.externals.getSessionId(js).await() } - actual fun resetAnalyticsData() { + public actual fun resetAnalyticsData() { dev.gitlive.firebase.analytics.externals.resetAnalyticsData(js) } - actual fun setDefaultEventParameters(parameters: Map) { + public actual fun setDefaultEventParameters(parameters: Map) { dev.gitlive.firebase.analytics.externals.setDefaultEventParameters(js, parameters) } - actual fun setConsent(consentSettings: Map) { + public actual fun setConsent(consentSettings: Map) { val consent = dev.gitlive.firebase.analytics.externals.ConsentSettings() consentSettings.forEach { when (it.key) { @@ -59,20 +59,20 @@ actual class FirebaseAnalytics(val js: dev.gitlive.firebase.analytics.externals. dev.gitlive.firebase.analytics.externals.setConsent(js, consent) } - actual enum class ConsentType { + public actual enum class ConsentType { AD_PERSONALIZATION, AD_STORAGE, AD_USER_DATA, - ANALYTICS_STORAGE + ANALYTICS_STORAGE, } - actual enum class ConsentStatus { + public actual enum class ConsentStatus { GRANTED, - DENIED + DENIED, } } -actual open class FirebaseAnalyticsException(code: String, cause: Throwable): FirebaseException(code, cause) +public actual open class FirebaseAnalyticsException(code: String, cause: Throwable) : FirebaseException(code, cause) internal inline fun rethrow(function: () -> R): R { try { @@ -91,7 +91,7 @@ internal fun errorToException(error: dynamic) = (error?.code ?: error?.message ? when { else -> { println("Unknown error code in ${JSON.stringify(error)}") - FirebaseAnalyticsException(code, error) + FirebaseAnalyticsException(code, error.unsafeCast()) } } - } \ No newline at end of file + } diff --git a/firebase-analytics/src/jsMain/kotlin/dev/gitlive/firebase/analytics/externals/analytics.kt b/firebase-analytics/src/jsMain/kotlin/dev/gitlive/firebase/analytics/externals/analytics.kt index ceded59d4..e9e9c109d 100644 --- a/firebase-analytics/src/jsMain/kotlin/dev/gitlive/firebase/analytics/externals/analytics.kt +++ b/firebase-analytics/src/jsMain/kotlin/dev/gitlive/firebase/analytics/externals/analytics.kt @@ -1,3 +1,4 @@ +@file:Suppress("ktlint:standard:property-naming", "PropertyName") @file:JsModule("firebase/analytics") @file:JsNonModule @@ -6,27 +7,26 @@ package dev.gitlive.firebase.analytics.externals import dev.gitlive.firebase.externals.FirebaseApp import kotlin.js.Promise +public external fun getAnalytics(app: FirebaseApp? = definedExternally): FirebaseAnalytics -external fun getAnalytics(app: FirebaseApp? = definedExternally): FirebaseAnalytics +public external fun logEvent(app: FirebaseAnalytics, name: String, parameters: Map?) +public external fun setUserProperty(app: FirebaseAnalytics, name: String, value: String) +public external fun setUserId(app: FirebaseAnalytics, id: String) +public external fun resetAnalyticsData(app: FirebaseAnalytics) +public external fun setDefaultEventParameters(app: FirebaseAnalytics, parameters: Map) +public external fun setAnalyticsCollectionEnabled(app: FirebaseAnalytics, enabled: Boolean) +public external fun setSessionTimeoutInterval(app: FirebaseAnalytics, sessionTimeoutInterval: Long) +public external fun getSessionId(app: FirebaseAnalytics): Promise +public external fun setConsent(app: FirebaseAnalytics, consentSettings: ConsentSettings) -external fun logEvent(app: FirebaseAnalytics, name: String, parameters: Map?) -external fun setUserProperty(app: FirebaseAnalytics, name: String, value: String) -external fun setUserId(app: FirebaseAnalytics, id: String) -external fun resetAnalyticsData(app: FirebaseAnalytics) -external fun setDefaultEventParameters(app: FirebaseAnalytics, parameters: Map) -external fun setAnalyticsCollectionEnabled(app: FirebaseAnalytics, enabled: Boolean) -external fun setSessionTimeoutInterval(app: FirebaseAnalytics, sessionTimeoutInterval: Long) -external fun getSessionId(app: FirebaseAnalytics): Promise -external fun setConsent(app: FirebaseAnalytics, consentSettings: ConsentSettings) +public external interface FirebaseAnalytics -external interface FirebaseAnalytics - -external class ConsentSettings() { - var ad_personalization: String? - var ad_storage: String? - var ad_user_data: String? - var analytics_storage: String? - var functionality_storage: String? - var personalization_storage: String? - var security_storage: String? +public external class ConsentSettings { + public var ad_personalization: String? + public var ad_storage: String? + public var ad_user_data: String? + public var analytics_storage: String? + public var functionality_storage: String? + public var personalization_storage: String? + public var security_storage: String? } diff --git a/firebase-analytics/src/jsTest/kotlin/dev/gitlive/firebase/analytics/analytics.kt b/firebase-analytics/src/jsTest/kotlin/dev/gitlive/firebase/analytics/analytics.kt index 117266228..e9532b753 100644 --- a/firebase-analytics/src/jsTest/kotlin/dev/gitlive/firebase/analytics/analytics.kt +++ b/firebase-analytics/src/jsTest/kotlin/dev/gitlive/firebase/analytics/analytics.kt @@ -1,8 +1,6 @@ package dev.gitlive.firebase.analytics -actual val emulatorHost: String = "10.0.2.2" - actual val context: Any = Unit @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) -actual annotation class IgnoreForAndroidUnitTest \ No newline at end of file +actual annotation class IgnoreForAndroidUnitTest diff --git a/firebase-analytics/src/jvmMain/kotlin/dev/gitlive/firebase/analytics/analytics.jvm.kt b/firebase-analytics/src/jvmMain/kotlin/dev/gitlive/firebase/analytics/analytics.jvm.kt index ce0bae02a..96112d0bb 100644 --- a/firebase-analytics/src/jvmMain/kotlin/dev/gitlive/firebase/analytics/analytics.jvm.kt +++ b/firebase-analytics/src/jvmMain/kotlin/dev/gitlive/firebase/analytics/analytics.jvm.kt @@ -4,32 +4,36 @@ import dev.gitlive.firebase.Firebase import dev.gitlive.firebase.FirebaseApp import dev.gitlive.firebase.FirebaseException -actual val Firebase.analytics: FirebaseAnalytics +public actual val Firebase.analytics: FirebaseAnalytics get() = TODO("Not yet implemented") -actual fun Firebase.analytics(app: FirebaseApp): FirebaseAnalytics { +public actual fun Firebase.analytics(app: FirebaseApp): FirebaseAnalytics { TODO("Not yet implemented") } -actual class FirebaseAnalytics { - actual fun setUserProperty(name: String, value: String) {} - actual fun setUserId(id: String) {} - actual fun resetAnalyticsData() {} - actual fun setAnalyticsCollectionEnabled(enabled: Boolean) {} - actual fun setSessionTimeoutInterval(sessionTimeoutInterval: Long) {} - actual suspend fun getSessionId(): Long? = TODO("Not yet implemented") - actual fun setDefaultEventParameters(parameters: Map) {} - actual fun logEvent(name: String, parameters: Map?) {} - - actual fun setConsent(consentSettings: Map) {} - - actual enum class ConsentType { - AD_PERSONALIZATION, AD_STORAGE, AD_USER_DATA, ANALYTICS_STORAGE +public actual class FirebaseAnalytics { + public actual fun setUserProperty(name: String, value: String) {} + public actual fun setUserId(id: String) {} + public actual fun resetAnalyticsData() {} + public actual fun setAnalyticsCollectionEnabled(enabled: Boolean) {} + public actual fun setSessionTimeoutInterval(sessionTimeoutInterval: Long) {} + public actual suspend fun getSessionId(): Long? = TODO("Not yet implemented") + public actual fun setDefaultEventParameters(parameters: Map) {} + public actual fun logEvent(name: String, parameters: Map?) {} + + public actual fun setConsent(consentSettings: Map) {} + + public actual enum class ConsentType { + AD_PERSONALIZATION, + AD_STORAGE, + AD_USER_DATA, + ANALYTICS_STORAGE, } - actual enum class ConsentStatus { - GRANTED, DENIED + public actual enum class ConsentStatus { + GRANTED, + DENIED, } } -actual class FirebaseAnalyticsException internal constructor(message: String) : FirebaseException(message) \ No newline at end of file +public actual class FirebaseAnalyticsException internal constructor(message: String) : FirebaseException(message) diff --git a/firebase-analytics/src/jvmTest/kotlin/dev/gitlive/firebase/analytics/analytics.kt b/firebase-analytics/src/jvmTest/kotlin/dev/gitlive/firebase/analytics/analytics.kt index 10eb69e38..d0efecbd4 100644 --- a/firebase-analytics/src/jvmTest/kotlin/dev/gitlive/firebase/analytics/analytics.kt +++ b/firebase-analytics/src/jvmTest/kotlin/dev/gitlive/firebase/analytics/analytics.kt @@ -7,8 +7,6 @@ package dev.gitlive.firebase.analytics import dev.gitlive.firebase.testContext -actual val emulatorHost: String = "10.0.2.2" - actual val context: Any = testContext @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) diff --git a/firebase-app/api/android/firebase-app.api b/firebase-app/api/android/firebase-app.api new file mode 100644 index 000000000..3aa3adbc2 --- /dev/null +++ b/firebase-app/api/android/firebase-app.api @@ -0,0 +1,60 @@ +public final class dev/gitlive/firebase/CommonKt { + public static final fun getOptions (Ldev/gitlive/firebase/Firebase;)Ldev/gitlive/firebase/FirebaseOptions; +} + +public final class dev/gitlive/firebase/Firebase { + public static final field INSTANCE Ldev/gitlive/firebase/Firebase; +} + +public final class dev/gitlive/firebase/FirebaseApp { + public final fun component1 ()Lcom/google/firebase/FirebaseApp; + public final fun copy (Lcom/google/firebase/FirebaseApp;)Ldev/gitlive/firebase/FirebaseApp; + public static synthetic fun copy$default (Ldev/gitlive/firebase/FirebaseApp;Lcom/google/firebase/FirebaseApp;ILjava/lang/Object;)Ldev/gitlive/firebase/FirebaseApp; + public final fun delete (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public fun equals (Ljava/lang/Object;)Z + public final fun getAndroid ()Lcom/google/firebase/FirebaseApp; + public final fun getName ()Ljava/lang/String; + public final fun getOptions ()Ldev/gitlive/firebase/FirebaseOptions; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/FirebaseKt { + public static final fun app (Ldev/gitlive/firebase/Firebase;Ljava/lang/String;)Ldev/gitlive/firebase/FirebaseApp; + public static final fun apps (Ldev/gitlive/firebase/Firebase;Ljava/lang/Object;)Ljava/util/List; + public static synthetic fun apps$default (Ldev/gitlive/firebase/Firebase;Ljava/lang/Object;ILjava/lang/Object;)Ljava/util/List; + public static final fun getApp (Ldev/gitlive/firebase/Firebase;)Ldev/gitlive/firebase/FirebaseApp; + public static final fun initialize (Ldev/gitlive/firebase/Firebase;Ljava/lang/Object;)Ldev/gitlive/firebase/FirebaseApp; + public static final fun initialize (Ldev/gitlive/firebase/Firebase;Ljava/lang/Object;Ldev/gitlive/firebase/FirebaseOptions;)Ldev/gitlive/firebase/FirebaseApp; + public static final fun initialize (Ldev/gitlive/firebase/Firebase;Ljava/lang/Object;Ldev/gitlive/firebase/FirebaseOptions;Ljava/lang/String;)Ldev/gitlive/firebase/FirebaseApp; + public static synthetic fun initialize$default (Ldev/gitlive/firebase/Firebase;Ljava/lang/Object;ILjava/lang/Object;)Ldev/gitlive/firebase/FirebaseApp; + public static synthetic fun initialize$default (Ldev/gitlive/firebase/Firebase;Ljava/lang/Object;Ldev/gitlive/firebase/FirebaseOptions;ILjava/lang/Object;)Ldev/gitlive/firebase/FirebaseApp; + public static synthetic fun initialize$default (Ldev/gitlive/firebase/Firebase;Ljava/lang/Object;Ldev/gitlive/firebase/FirebaseOptions;Ljava/lang/String;ILjava/lang/Object;)Ldev/gitlive/firebase/FirebaseApp; +} + +public final class dev/gitlive/firebase/FirebaseOptions { + public fun (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V + public synthetic fun (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun component1 ()Ljava/lang/String; + public final fun component2 ()Ljava/lang/String; + public final fun component3 ()Ljava/lang/String; + public final fun component4 ()Ljava/lang/String; + public final fun component5 ()Ljava/lang/String; + public final fun component6 ()Ljava/lang/String; + public final fun component7 ()Ljava/lang/String; + public final fun component8 ()Ljava/lang/String; + public final fun copy (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ldev/gitlive/firebase/FirebaseOptions; + public static synthetic fun copy$default (Ldev/gitlive/firebase/FirebaseOptions;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ldev/gitlive/firebase/FirebaseOptions; + public fun equals (Ljava/lang/Object;)Z + public final fun getApiKey ()Ljava/lang/String; + public final fun getApplicationId ()Ljava/lang/String; + public final fun getAuthDomain ()Ljava/lang/String; + public final fun getDatabaseUrl ()Ljava/lang/String; + public final fun getGaTrackingId ()Ljava/lang/String; + public final fun getGcmSenderId ()Ljava/lang/String; + public final fun getProjectId ()Ljava/lang/String; + public final fun getStorageBucket ()Ljava/lang/String; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + diff --git a/firebase-app/api/jvm/firebase-app.api b/firebase-app/api/jvm/firebase-app.api new file mode 100644 index 000000000..3aa3adbc2 --- /dev/null +++ b/firebase-app/api/jvm/firebase-app.api @@ -0,0 +1,60 @@ +public final class dev/gitlive/firebase/CommonKt { + public static final fun getOptions (Ldev/gitlive/firebase/Firebase;)Ldev/gitlive/firebase/FirebaseOptions; +} + +public final class dev/gitlive/firebase/Firebase { + public static final field INSTANCE Ldev/gitlive/firebase/Firebase; +} + +public final class dev/gitlive/firebase/FirebaseApp { + public final fun component1 ()Lcom/google/firebase/FirebaseApp; + public final fun copy (Lcom/google/firebase/FirebaseApp;)Ldev/gitlive/firebase/FirebaseApp; + public static synthetic fun copy$default (Ldev/gitlive/firebase/FirebaseApp;Lcom/google/firebase/FirebaseApp;ILjava/lang/Object;)Ldev/gitlive/firebase/FirebaseApp; + public final fun delete (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public fun equals (Ljava/lang/Object;)Z + public final fun getAndroid ()Lcom/google/firebase/FirebaseApp; + public final fun getName ()Ljava/lang/String; + public final fun getOptions ()Ldev/gitlive/firebase/FirebaseOptions; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/FirebaseKt { + public static final fun app (Ldev/gitlive/firebase/Firebase;Ljava/lang/String;)Ldev/gitlive/firebase/FirebaseApp; + public static final fun apps (Ldev/gitlive/firebase/Firebase;Ljava/lang/Object;)Ljava/util/List; + public static synthetic fun apps$default (Ldev/gitlive/firebase/Firebase;Ljava/lang/Object;ILjava/lang/Object;)Ljava/util/List; + public static final fun getApp (Ldev/gitlive/firebase/Firebase;)Ldev/gitlive/firebase/FirebaseApp; + public static final fun initialize (Ldev/gitlive/firebase/Firebase;Ljava/lang/Object;)Ldev/gitlive/firebase/FirebaseApp; + public static final fun initialize (Ldev/gitlive/firebase/Firebase;Ljava/lang/Object;Ldev/gitlive/firebase/FirebaseOptions;)Ldev/gitlive/firebase/FirebaseApp; + public static final fun initialize (Ldev/gitlive/firebase/Firebase;Ljava/lang/Object;Ldev/gitlive/firebase/FirebaseOptions;Ljava/lang/String;)Ldev/gitlive/firebase/FirebaseApp; + public static synthetic fun initialize$default (Ldev/gitlive/firebase/Firebase;Ljava/lang/Object;ILjava/lang/Object;)Ldev/gitlive/firebase/FirebaseApp; + public static synthetic fun initialize$default (Ldev/gitlive/firebase/Firebase;Ljava/lang/Object;Ldev/gitlive/firebase/FirebaseOptions;ILjava/lang/Object;)Ldev/gitlive/firebase/FirebaseApp; + public static synthetic fun initialize$default (Ldev/gitlive/firebase/Firebase;Ljava/lang/Object;Ldev/gitlive/firebase/FirebaseOptions;Ljava/lang/String;ILjava/lang/Object;)Ldev/gitlive/firebase/FirebaseApp; +} + +public final class dev/gitlive/firebase/FirebaseOptions { + public fun (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V + public synthetic fun (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun component1 ()Ljava/lang/String; + public final fun component2 ()Ljava/lang/String; + public final fun component3 ()Ljava/lang/String; + public final fun component4 ()Ljava/lang/String; + public final fun component5 ()Ljava/lang/String; + public final fun component6 ()Ljava/lang/String; + public final fun component7 ()Ljava/lang/String; + public final fun component8 ()Ljava/lang/String; + public final fun copy (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ldev/gitlive/firebase/FirebaseOptions; + public static synthetic fun copy$default (Ldev/gitlive/firebase/FirebaseOptions;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ldev/gitlive/firebase/FirebaseOptions; + public fun equals (Ljava/lang/Object;)Z + public final fun getApiKey ()Ljava/lang/String; + public final fun getApplicationId ()Ljava/lang/String; + public final fun getAuthDomain ()Ljava/lang/String; + public final fun getDatabaseUrl ()Ljava/lang/String; + public final fun getGaTrackingId ()Ljava/lang/String; + public final fun getGcmSenderId ()Ljava/lang/String; + public final fun getProjectId ()Ljava/lang/String; + public final fun getStorageBucket ()Ljava/lang/String; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + diff --git a/firebase-app/build.gradle.kts b/firebase-app/build.gradle.kts index d13e9341c..48ad17696 100644 --- a/firebase-app/build.gradle.kts +++ b/firebase-app/build.gradle.kts @@ -47,6 +47,8 @@ android { val supportIosTarget = project.property("skipIosTarget") != "true" kotlin { + explicitApi() + @OptIn(ExperimentalKotlinGradlePluginApi::class) compilerOptions { freeCompilerArgs.add("-Xexpect-actual-classes") diff --git a/firebase-app/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/firebase.kt b/firebase-app/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/firebase.kt index bdc3f7e6c..6a91ae72f 100644 --- a/firebase-app/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/firebase.kt +++ b/firebase-app/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/firebase.kt @@ -3,6 +3,7 @@ */ @file:JvmName("tests") + package dev.gitlive.firebase import androidx.test.platform.app.InstrumentationRegistry diff --git a/firebase-app/src/androidMain/kotlin/dev/gitlive/firebase/firebase.kt b/firebase-app/src/androidMain/kotlin/dev/gitlive/firebase/firebase.kt index 37c834ac3..7a51b210c 100644 --- a/firebase-app/src/androidMain/kotlin/dev/gitlive/firebase/firebase.kt +++ b/firebase-app/src/androidMain/kotlin/dev/gitlive/firebase/firebase.kt @@ -6,41 +6,41 @@ package dev.gitlive.firebase import android.content.Context -actual typealias FirebaseException = com.google.firebase.FirebaseException +public actual typealias FirebaseException = com.google.firebase.FirebaseException -actual typealias FirebaseNetworkException = com.google.firebase.FirebaseNetworkException +public actual typealias FirebaseNetworkException = com.google.firebase.FirebaseNetworkException -actual typealias FirebaseTooManyRequestsException = com.google.firebase.FirebaseTooManyRequestsException +public actual typealias FirebaseTooManyRequestsException = com.google.firebase.FirebaseTooManyRequestsException -actual typealias FirebaseApiNotAvailableException = com.google.firebase.FirebaseApiNotAvailableException +public actual typealias FirebaseApiNotAvailableException = com.google.firebase.FirebaseApiNotAvailableException -actual val Firebase.app: FirebaseApp +public actual val Firebase.app: FirebaseApp get() = FirebaseApp(com.google.firebase.FirebaseApp.getInstance()) -actual fun Firebase.app(name: String): FirebaseApp = +public actual fun Firebase.app(name: String): FirebaseApp = FirebaseApp(com.google.firebase.FirebaseApp.getInstance(name)) -actual fun Firebase.initialize(context: Any?): FirebaseApp? = +public actual fun Firebase.initialize(context: Any?): FirebaseApp? = com.google.firebase.FirebaseApp.initializeApp(context as Context)?.let { FirebaseApp(it) } -actual fun Firebase.initialize(context: Any?, options: FirebaseOptions, name: String): FirebaseApp = +public actual fun Firebase.initialize(context: Any?, options: FirebaseOptions, name: String): FirebaseApp = FirebaseApp(com.google.firebase.FirebaseApp.initializeApp(context as Context, options.toAndroid(), name)) -actual fun Firebase.initialize(context: Any?, options: FirebaseOptions) = +public actual fun Firebase.initialize(context: Any?, options: FirebaseOptions): FirebaseApp = FirebaseApp(com.google.firebase.FirebaseApp.initializeApp(context as Context, options.toAndroid())) -actual data class FirebaseApp internal constructor(val android: com.google.firebase.FirebaseApp) { +public actual data class FirebaseApp internal constructor(val android: com.google.firebase.FirebaseApp) { actual val name: String get() = android.name actual val options: FirebaseOptions get() = android.options.run { FirebaseOptions(applicationId, apiKey, databaseUrl, gaTrackingId, storageBucket, projectId, gcmSenderId) } - actual suspend fun delete() { + public actual suspend fun delete() { android.delete() } } -actual fun Firebase.apps(context: Any?) = com.google.firebase.FirebaseApp.getApps(context as Context) +public actual fun Firebase.apps(context: Any?): List = com.google.firebase.FirebaseApp.getApps(context as Context) .map { FirebaseApp(it) } private fun FirebaseOptions.toAndroid() = com.google.firebase.FirebaseOptions.Builder() diff --git a/firebase-app/src/androidUnitTest/kotlin/dev/gitlive/firebase/firebase.kt b/firebase-app/src/androidUnitTest/kotlin/dev/gitlive/firebase/firebase.kt index 9810ef6a8..1ba1b6865 100644 --- a/firebase-app/src/androidUnitTest/kotlin/dev/gitlive/firebase/firebase.kt +++ b/firebase-app/src/androidUnitTest/kotlin/dev/gitlive/firebase/firebase.kt @@ -3,6 +3,7 @@ */ @file:JvmName("tests") + package dev.gitlive.firebase import org.junit.Ignore diff --git a/firebase-app/src/commonMain/kotlin/dev/gitlive/firebase/firebase.kt b/firebase-app/src/commonMain/kotlin/dev/gitlive/firebase/firebase.kt index ac818128b..fe03f6c3e 100644 --- a/firebase-app/src/commonMain/kotlin/dev/gitlive/firebase/firebase.kt +++ b/firebase-app/src/commonMain/kotlin/dev/gitlive/firebase/firebase.kt @@ -4,6 +4,7 @@ @file:JvmMultifileClass @file:JvmName("CommonKt") + package dev.gitlive.firebase import kotlin.jvm.JvmMultifileClass @@ -14,7 +15,7 @@ import kotlin.jvm.JvmName * * Acts as a target for extension methods provided by sdks. */ -object Firebase +public object Firebase /** * The entry point of Firebase SDKs. It holds common configuration and state for Firebase APIs. Most @@ -31,12 +32,12 @@ object Firebase * Use of Firebase in processes other than the main process is not supported and will likely cause * problems related to resource contention. */ -expect class FirebaseApp { +public expect class FirebaseApp { /** Returns the unique name of this app. */ - val name: String + public val name: String /** Returns the specified [FirebaseOptions]. */ - val options: FirebaseOptions + public val options: FirebaseOptions /** * Deletes the [FirebaseApp] and all its data. All calls to this [FirebaseApp] @@ -44,33 +45,34 @@ expect class FirebaseApp { * * A no-op if delete was called before. */ - suspend fun delete() + public suspend fun delete() } /** Returns the default firebase app instance. */ -expect val Firebase.app: FirebaseApp +public expect val Firebase.app: FirebaseApp /** Returns a named firebase app instance. */ -expect fun Firebase.app(name: String): FirebaseApp +public expect fun Firebase.app(name: String): FirebaseApp /** Returns all firebase app instances. */ -expect fun Firebase.apps(context: Any? = null): List +public expect fun Firebase.apps(context: Any? = null): List /** Initializes and returns a FirebaseApp. */ -expect fun Firebase.initialize(context: Any? = null): FirebaseApp? +public expect fun Firebase.initialize(context: Any? = null): FirebaseApp? /** Initializes and returns a FirebaseApp. */ -expect fun Firebase.initialize(context: Any? = null, options: FirebaseOptions): FirebaseApp +public expect fun Firebase.initialize(context: Any? = null, options: FirebaseOptions): FirebaseApp /** Initializes and returns a FirebaseApp. */ -expect fun Firebase.initialize(context: Any? = null, options: FirebaseOptions, name: String): FirebaseApp +public expect fun Firebase.initialize(context: Any? = null, options: FirebaseOptions, name: String): FirebaseApp /** Returns options of default FirebaseApp */ -val Firebase.options: FirebaseOptions +@Suppress("UnusedReceiverParameter") +public val Firebase.options: FirebaseOptions get() = Firebase.app.options /** Configurable Firebase options. */ -data class FirebaseOptions( +public data class FirebaseOptions( /** The Google App ID that is used to uniquely identify an instance of an app. */ val applicationId: String, @@ -101,26 +103,25 @@ data class FirebaseOptions( val gcmSenderId: String? = null, /** The auth domain. */ - val authDomain: String? = null + val authDomain: String? = null, ) /** * Exception that gets thrown when an operation on Firebase fails. */ -expect open class FirebaseException : Exception +public expect open class FirebaseException : Exception /** * Exception that gets thrown when an operation on Firebase fails. */ -expect class FirebaseNetworkException : FirebaseException +public expect class FirebaseNetworkException : FirebaseException /** * Exception that gets thrown when an operation on Firebase fails. */ -expect open class FirebaseTooManyRequestsException : FirebaseException +public expect open class FirebaseTooManyRequestsException : FirebaseException /** * Exception that gets thrown when an operation on Firebase fails. */ -expect open class FirebaseApiNotAvailableException : FirebaseException - +public expect open class FirebaseApiNotAvailableException : FirebaseException diff --git a/firebase-app/src/commonTest/kotlin/dev/gitlive/firebase/firebase.kt b/firebase-app/src/commonTest/kotlin/dev/gitlive/firebase/firebase.kt index 9c49761f6..7fac32601 100644 --- a/firebase-app/src/commonTest/kotlin/dev/gitlive/firebase/firebase.kt +++ b/firebase-app/src/commonTest/kotlin/dev/gitlive/firebase/firebase.kt @@ -18,8 +18,8 @@ class FirebaseAppTest { databaseUrl = "https://fir-kotlin-sdk.firebaseio.com", storageBucket = "fir-kotlin-sdk.appspot.com", projectId = "fir-kotlin-sdk", - gcmSenderId = "846484016111" - ) + gcmSenderId = "846484016111", + ), ) assertEquals(1, Firebase.apps(context).size) @@ -28,5 +28,4 @@ class FirebaseAppTest { it.delete() } } - -} \ No newline at end of file +} diff --git a/firebase-app/src/iosMain/kotlin/dev/gitlive/firebase/firebase.kt b/firebase-app/src/iosMain/kotlin/dev/gitlive/firebase/firebase.kt index f28d6ddee..b770afdc8 100644 --- a/firebase-app/src/iosMain/kotlin/dev/gitlive/firebase/firebase.kt +++ b/firebase-app/src/iosMain/kotlin/dev/gitlive/firebase/firebase.kt @@ -7,48 +7,48 @@ package dev.gitlive.firebase import cocoapods.FirebaseCore.* import kotlinx.coroutines.CompletableDeferred -actual open class FirebaseException(message: String) : Exception(message) -actual open class FirebaseNetworkException(message: String) : FirebaseException(message) -actual open class FirebaseTooManyRequestsException(message: String) : FirebaseException(message) -actual open class FirebaseApiNotAvailableException(message: String) : FirebaseException(message) +public actual open class FirebaseException(message: String) : Exception(message) +public actual open class FirebaseNetworkException(message: String) : FirebaseException(message) +public actual open class FirebaseTooManyRequestsException(message: String) : FirebaseException(message) +public actual open class FirebaseApiNotAvailableException(message: String) : FirebaseException(message) -actual val Firebase.app: FirebaseApp +public actual val Firebase.app: FirebaseApp get() = FirebaseApp(FIRApp.defaultApp()!!) -actual fun Firebase.app(name: String): FirebaseApp = +public actual fun Firebase.app(name: String): FirebaseApp = FirebaseApp(FIRApp.appNamed(name)!!) -actual fun Firebase.initialize(context: Any?): FirebaseApp? = +public actual fun Firebase.initialize(context: Any?): FirebaseApp? = FIRApp.configure().let { app } -actual fun Firebase.initialize(context: Any?, options: FirebaseOptions, name: String): FirebaseApp = +public actual fun Firebase.initialize(context: Any?, options: FirebaseOptions, name: String): FirebaseApp = FIRApp.configureWithName(name, options.toIos()).let { app(name) } -actual fun Firebase.initialize(context: Any?, options: FirebaseOptions) = +public actual fun Firebase.initialize(context: Any?, options: FirebaseOptions): FirebaseApp = FIRApp.configureWithOptions(options.toIos()).let { app } -actual data class FirebaseApp internal constructor(val ios: FIRApp) { +public actual data class FirebaseApp internal constructor(val ios: FIRApp) { actual val name: String get() = ios.name actual val options: FirebaseOptions get() = ios.options.run { FirebaseOptions(bundleID, APIKey!!, databaseURL!!, trackingID, storageBucket, projectID, GCMSenderID) } - actual suspend fun delete() { + public actual suspend fun delete() { val deleted = CompletableDeferred() ios.deleteApp { deleted.complete(Unit) } deleted.await() } } -actual fun Firebase.apps(context: Any?) = FIRApp.allApps() +public actual fun Firebase.apps(context: Any?): List = FIRApp.allApps() .orEmpty() .values .map { FirebaseApp(it as FIRApp) } private fun FirebaseOptions.toIos() = FIROptions(this@toIos.applicationId, this@toIos.gcmSenderId ?: "").apply { - APIKey = this@toIos.apiKey - databaseURL = this@toIos.databaseUrl - trackingID = this@toIos.gaTrackingId - storageBucket = this@toIos.storageBucket - projectID = this@toIos.projectId - } + APIKey = this@toIos.apiKey + databaseURL = this@toIos.databaseUrl + trackingID = this@toIos.gaTrackingId + storageBucket = this@toIos.storageBucket + projectID = this@toIos.projectId +} diff --git a/firebase-app/src/jsMain/kotlin/dev/gitlive/firebase/externals/app.kt b/firebase-app/src/jsMain/kotlin/dev/gitlive/firebase/externals/app.kt index ab2066cf9..2563e0311 100644 --- a/firebase-app/src/jsMain/kotlin/dev/gitlive/firebase/externals/app.kt +++ b/firebase-app/src/jsMain/kotlin/dev/gitlive/firebase/externals/app.kt @@ -5,28 +5,28 @@ package dev.gitlive.firebase.externals import kotlin.js.Promise -external fun initializeApp(options: Any, name: String = definedExternally): FirebaseApp +public external fun initializeApp(options: Any, name: String = definedExternally): FirebaseApp -external fun getApp(name: String = definedExternally): FirebaseApp +public external fun getApp(name: String = definedExternally): FirebaseApp -external fun getApps(): Array +public external fun getApps(): Array -external fun deleteApp(app: FirebaseApp): Promise +public external fun deleteApp(app: FirebaseApp): Promise -external interface FirebaseApp { - val automaticDataCollectionEnabled: Boolean - val name: String - val options: FirebaseOptions +public external interface FirebaseApp { + public val automaticDataCollectionEnabled: Boolean + public val name: String + public val options: FirebaseOptions } -external interface FirebaseOptions { - val apiKey: String - val appId : String - val authDomain: String? - val databaseURL: String? - val measurementId: String? - val messagingSenderId: String? - val gaTrackingId: String? - val projectId: String? - val storageBucket: String? +public external interface FirebaseOptions { + public val apiKey: String + public val appId: String + public val authDomain: String? + public val databaseURL: String? + public val measurementId: String? + public val messagingSenderId: String? + public val gaTrackingId: String? + public val projectId: String? + public val storageBucket: String? } diff --git a/firebase-app/src/jsMain/kotlin/dev/gitlive/firebase/firebase.kt b/firebase-app/src/jsMain/kotlin/dev/gitlive/firebase/firebase.kt index ed7619ab9..1d9797bbd 100644 --- a/firebase-app/src/jsMain/kotlin/dev/gitlive/firebase/firebase.kt +++ b/firebase-app/src/jsMain/kotlin/dev/gitlive/firebase/firebase.kt @@ -11,35 +11,35 @@ import dev.gitlive.firebase.externals.initializeApp import kotlin.js.json import dev.gitlive.firebase.externals.FirebaseApp as JsFirebaseApp -actual val Firebase.app: FirebaseApp +public actual val Firebase.app: FirebaseApp get() = FirebaseApp(getApp()) -actual fun Firebase.app(name: String): FirebaseApp = +public actual fun Firebase.app(name: String): FirebaseApp = FirebaseApp(getApp(name)) -actual fun Firebase.initialize(context: Any?): FirebaseApp? = +public actual fun Firebase.initialize(context: Any?): FirebaseApp? = throw UnsupportedOperationException("Cannot initialize firebase without options in JS") -actual fun Firebase.initialize(context: Any?, options: FirebaseOptions, name: String): FirebaseApp = +public actual fun Firebase.initialize(context: Any?, options: FirebaseOptions, name: String): FirebaseApp = FirebaseApp(initializeApp(options.toJson(), name)) -actual fun Firebase.initialize(context: Any?, options: FirebaseOptions) = +public actual fun Firebase.initialize(context: Any?, options: FirebaseOptions): FirebaseApp = FirebaseApp(initializeApp(options.toJson())) -actual class FirebaseApp internal constructor(val js: JsFirebaseApp) { - actual val name: String +public actual class FirebaseApp internal constructor(public val js: JsFirebaseApp) { + public actual val name: String get() = js.name - actual val options: FirebaseOptions + public actual val options: FirebaseOptions get() = js.options.run { FirebaseOptions(appId, apiKey, databaseURL, gaTrackingId, storageBucket, projectId, messagingSenderId, authDomain) } - actual suspend fun delete() { + public actual suspend fun delete() { deleteApp(js) } } -actual fun Firebase.apps(context: Any?) = getApps().map { FirebaseApp(it) } +public actual fun Firebase.apps(context: Any?): List = getApps().map { FirebaseApp(it) } private fun FirebaseOptions.toJson() = json( "apiKey" to apiKey, @@ -49,10 +49,10 @@ private fun FirebaseOptions.toJson() = json( "projectId" to (projectId ?: undefined), "gaTrackingId" to (gaTrackingId ?: undefined), "messagingSenderId" to (gcmSenderId ?: undefined), - "authDomain" to (authDomain ?: undefined) + "authDomain" to (authDomain ?: undefined), ) -actual open class FirebaseException(code: String?, cause: Throwable) : Exception("$code: ${cause.message}", cause) -actual open class FirebaseNetworkException(code: String?, cause: Throwable) : FirebaseException(code, cause) -actual open class FirebaseTooManyRequestsException(code: String?, cause: Throwable) : FirebaseException(code, cause) -actual open class FirebaseApiNotAvailableException(code: String?, cause: Throwable) : FirebaseException(code, cause) +public actual open class FirebaseException(code: String?, cause: Throwable) : Exception("$code: ${cause.message}", cause) +public actual open class FirebaseNetworkException(code: String?, cause: Throwable) : FirebaseException(code, cause) +public actual open class FirebaseTooManyRequestsException(code: String?, cause: Throwable) : FirebaseException(code, cause) +public actual open class FirebaseApiNotAvailableException(code: String?, cause: Throwable) : FirebaseException(code, cause) diff --git a/firebase-app/src/jsTest/kotlin/dev/gitlive/firebase/firebase.kt b/firebase-app/src/jsTest/kotlin/dev/gitlive/firebase/firebase.kt index 699d3b292..c56fadc7d 100644 --- a/firebase-app/src/jsTest/kotlin/dev/gitlive/firebase/firebase.kt +++ b/firebase-app/src/jsTest/kotlin/dev/gitlive/firebase/firebase.kt @@ -7,4 +7,4 @@ package dev.gitlive.firebase actual val context: Any = Unit @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) -actual annotation class IgnoreForAndroidUnitTest \ No newline at end of file +actual annotation class IgnoreForAndroidUnitTest diff --git a/firebase-app/src/jvmTest/kotlin/dev/gitlive/firebase/firebase.kt b/firebase-app/src/jvmTest/kotlin/dev/gitlive/firebase/firebase.kt index 3ab2b6e7e..a5dd86da4 100644 --- a/firebase-app/src/jvmTest/kotlin/dev/gitlive/firebase/firebase.kt +++ b/firebase-app/src/jvmTest/kotlin/dev/gitlive/firebase/firebase.kt @@ -3,6 +3,7 @@ */ @file:JvmName("tests") + package dev.gitlive.firebase actual val context: Any = testContext diff --git a/firebase-auth/api/android/firebase-auth.api b/firebase-auth/api/android/firebase-auth.api new file mode 100644 index 000000000..cc211e626 --- /dev/null +++ b/firebase-auth/api/android/firebase-auth.api @@ -0,0 +1,277 @@ +public abstract class dev/gitlive/firebase/auth/ActionCodeResult { +} + +public final class dev/gitlive/firebase/auth/ActionCodeResult$PasswordReset : dev/gitlive/firebase/auth/ActionCodeResult { + public final fun getEmail ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/auth/ActionCodeResult$RecoverEmail : dev/gitlive/firebase/auth/ActionCodeResult { + public final fun getEmail ()Ljava/lang/String; + public final fun getPreviousEmail ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/auth/ActionCodeResult$RevertSecondFactorAddition : dev/gitlive/firebase/auth/ActionCodeResult { + public final fun getEmail ()Ljava/lang/String; + public final fun getMultiFactorInfo ()Ldev/gitlive/firebase/auth/MultiFactorInfo; +} + +public final class dev/gitlive/firebase/auth/ActionCodeResult$SignInWithEmailLink : dev/gitlive/firebase/auth/ActionCodeResult { + public static final field INSTANCE Ldev/gitlive/firebase/auth/ActionCodeResult$SignInWithEmailLink; + public fun equals (Ljava/lang/Object;)Z + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/auth/ActionCodeResult$VerifyBeforeChangeEmail : dev/gitlive/firebase/auth/ActionCodeResult { + public final fun getEmail ()Ljava/lang/String; + public final fun getPreviousEmail ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/auth/ActionCodeResult$VerifyEmail : dev/gitlive/firebase/auth/ActionCodeResult { + public final fun getEmail ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/auth/ActionCodeSettings { + public fun (Ljava/lang/String;Ldev/gitlive/firebase/auth/AndroidPackageName;Ljava/lang/String;ZLjava/lang/String;)V + public synthetic fun (Ljava/lang/String;Ldev/gitlive/firebase/auth/AndroidPackageName;Ljava/lang/String;ZLjava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun component1 ()Ljava/lang/String; + public final fun component2 ()Ldev/gitlive/firebase/auth/AndroidPackageName; + public final fun component3 ()Ljava/lang/String; + public final fun component4 ()Z + public final fun component5 ()Ljava/lang/String; + public final fun copy (Ljava/lang/String;Ldev/gitlive/firebase/auth/AndroidPackageName;Ljava/lang/String;ZLjava/lang/String;)Ldev/gitlive/firebase/auth/ActionCodeSettings; + public static synthetic fun copy$default (Ldev/gitlive/firebase/auth/ActionCodeSettings;Ljava/lang/String;Ldev/gitlive/firebase/auth/AndroidPackageName;Ljava/lang/String;ZLjava/lang/String;ILjava/lang/Object;)Ldev/gitlive/firebase/auth/ActionCodeSettings; + public fun equals (Ljava/lang/Object;)Z + public final fun getAndroidPackageName ()Ldev/gitlive/firebase/auth/AndroidPackageName; + public final fun getCanHandleCodeInApp ()Z + public final fun getDynamicLinkDomain ()Ljava/lang/String; + public final fun getIOSBundleId ()Ljava/lang/String; + public final fun getUrl ()Ljava/lang/String; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/auth/AndroidPackageName { + public fun (Ljava/lang/String;ZLjava/lang/String;)V + public synthetic fun (Ljava/lang/String;ZLjava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun component1 ()Ljava/lang/String; + public final fun component2 ()Z + public final fun component3 ()Ljava/lang/String; + public final fun copy (Ljava/lang/String;ZLjava/lang/String;)Ldev/gitlive/firebase/auth/AndroidPackageName; + public static synthetic fun copy$default (Ldev/gitlive/firebase/auth/AndroidPackageName;Ljava/lang/String;ZLjava/lang/String;ILjava/lang/Object;)Ldev/gitlive/firebase/auth/AndroidPackageName; + public fun equals (Ljava/lang/Object;)Z + public final fun getInstallIfNotAvailable ()Z + public final fun getMinimumVersion ()Ljava/lang/String; + public final fun getPackageName ()Ljava/lang/String; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public class dev/gitlive/firebase/auth/AuthCredential { + public fun (Lcom/google/firebase/auth/AuthCredential;)V + public fun getAndroid ()Lcom/google/firebase/auth/AuthCredential; + public final fun getProviderId ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/auth/AuthResult { + public final fun getAndroid ()Lcom/google/firebase/auth/AuthResult; + public final fun getUser ()Ldev/gitlive/firebase/auth/FirebaseUser; +} + +public final class dev/gitlive/firebase/auth/AuthTokenResult { + public fun (Lcom/google/firebase/auth/GetTokenResult;)V + public final fun getAndroid ()Lcom/google/firebase/auth/GetTokenResult; + public final fun getClaims ()Ljava/util/Map; + public final fun getSignInProvider ()Ljava/lang/String; + public final fun getToken ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/auth/EmailAuthProvider { + public static final field INSTANCE Ldev/gitlive/firebase/auth/EmailAuthProvider; + public final fun credential (Ljava/lang/String;Ljava/lang/String;)Ldev/gitlive/firebase/auth/AuthCredential; + public final fun credentialWithLink (Ljava/lang/String;Ljava/lang/String;)Ldev/gitlive/firebase/auth/AuthCredential; +} + +public final class dev/gitlive/firebase/auth/FacebookAuthProvider { + public static final field INSTANCE Ldev/gitlive/firebase/auth/FacebookAuthProvider; + public final fun credential (Ljava/lang/String;)Ldev/gitlive/firebase/auth/AuthCredential; +} + +public final class dev/gitlive/firebase/auth/FirebaseAuth { + public final fun applyActionCode (Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun checkActionCode (Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun confirmPasswordReset (Ljava/lang/String;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun createUserWithEmailAndPassword (Ljava/lang/String;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun fetchSignInMethodsForEmail (Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun getAndroid ()Lcom/google/firebase/auth/FirebaseAuth; + public final fun getAuthStateChanged ()Lkotlinx/coroutines/flow/Flow; + public final fun getCurrentUser ()Ldev/gitlive/firebase/auth/FirebaseUser; + public final fun getIdTokenChanged ()Lkotlinx/coroutines/flow/Flow; + public final fun getLanguageCode ()Ljava/lang/String; + public final fun isSignInWithEmailLink (Ljava/lang/String;)Z + public final fun sendPasswordResetEmail (Ljava/lang/String;Ldev/gitlive/firebase/auth/ActionCodeSettings;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static synthetic fun sendPasswordResetEmail$default (Ldev/gitlive/firebase/auth/FirebaseAuth;Ljava/lang/String;Ldev/gitlive/firebase/auth/ActionCodeSettings;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; + public final fun sendSignInLinkToEmail (Ljava/lang/String;Ldev/gitlive/firebase/auth/ActionCodeSettings;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun setLanguageCode (Ljava/lang/String;)V + public final fun signInAnonymously (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun signInWithCredential (Ldev/gitlive/firebase/auth/AuthCredential;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun signInWithCustomToken (Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun signInWithEmailAndPassword (Ljava/lang/String;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun signInWithEmailLink (Ljava/lang/String;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun signOut (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun updateCurrentUser (Ldev/gitlive/firebase/auth/FirebaseUser;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun useEmulator (Ljava/lang/String;I)V + public final fun verifyPasswordResetCode (Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; +} + +public final class dev/gitlive/firebase/auth/FirebaseUser { + public final fun delete (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun getAndroid ()Lcom/google/firebase/auth/FirebaseUser; + public final fun getDisplayName ()Ljava/lang/String; + public final fun getEmail ()Ljava/lang/String; + public final fun getIdToken (ZLkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun getIdTokenResult (ZLkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun getMetaData ()Ldev/gitlive/firebase/auth/UserMetaData; + public final fun getMultiFactor ()Ldev/gitlive/firebase/auth/MultiFactor; + public final fun getPhoneNumber ()Ljava/lang/String; + public final fun getPhotoURL ()Ljava/lang/String; + public final fun getProviderData ()Ljava/util/List; + public final fun getProviderId ()Ljava/lang/String; + public final fun getUid ()Ljava/lang/String; + public final fun isAnonymous ()Z + public final fun isEmailVerified ()Z + public final fun linkWithCredential (Ldev/gitlive/firebase/auth/AuthCredential;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun reauthenticate (Ldev/gitlive/firebase/auth/AuthCredential;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun reauthenticateAndRetrieveData (Ldev/gitlive/firebase/auth/AuthCredential;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun reload (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun sendEmailVerification (Ldev/gitlive/firebase/auth/ActionCodeSettings;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static synthetic fun sendEmailVerification$default (Ldev/gitlive/firebase/auth/FirebaseUser;Ldev/gitlive/firebase/auth/ActionCodeSettings;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; + public final fun unlink (Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun updateEmail (Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun updatePassword (Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun updatePhoneNumber (Ldev/gitlive/firebase/auth/PhoneAuthCredential;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun updateProfile (Ljava/lang/String;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static synthetic fun updateProfile$default (Ldev/gitlive/firebase/auth/FirebaseUser;Ljava/lang/String;Ljava/lang/String;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; + public final fun verifyBeforeUpdateEmail (Ljava/lang/String;Ldev/gitlive/firebase/auth/ActionCodeSettings;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static synthetic fun verifyBeforeUpdateEmail$default (Ldev/gitlive/firebase/auth/FirebaseUser;Ljava/lang/String;Ldev/gitlive/firebase/auth/ActionCodeSettings;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; +} + +public final class dev/gitlive/firebase/auth/GithubAuthProvider { + public static final field INSTANCE Ldev/gitlive/firebase/auth/GithubAuthProvider; + public final fun credential (Ljava/lang/String;)Ldev/gitlive/firebase/auth/AuthCredential; +} + +public final class dev/gitlive/firebase/auth/GoogleAuthProvider { + public static final field INSTANCE Ldev/gitlive/firebase/auth/GoogleAuthProvider; + public final fun credential (Ljava/lang/String;Ljava/lang/String;)Ldev/gitlive/firebase/auth/AuthCredential; +} + +public final class dev/gitlive/firebase/auth/MultiFactor { + public fun (Lcom/google/firebase/auth/MultiFactor;)V + public final fun enroll (Ldev/gitlive/firebase/auth/MultiFactorAssertion;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun getAndroid ()Lcom/google/firebase/auth/MultiFactor; + public final fun getEnrolledFactors ()Ljava/util/List; + public final fun getSession (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun unenroll (Ldev/gitlive/firebase/auth/MultiFactorInfo;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun unenroll (Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; +} + +public final class dev/gitlive/firebase/auth/MultiFactorAssertion { + public fun (Lcom/google/firebase/auth/MultiFactorAssertion;)V + public final fun getAndroid ()Lcom/google/firebase/auth/MultiFactorAssertion; + public final fun getFactorId ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/auth/MultiFactorInfo { + public fun (Lcom/google/firebase/auth/MultiFactorInfo;)V + public final fun getAndroid ()Lcom/google/firebase/auth/MultiFactorInfo; + public final fun getDisplayName ()Ljava/lang/String; + public final fun getEnrollmentTime ()D + public final fun getFactorId ()Ljava/lang/String; + public final fun getUid ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/auth/MultiFactorResolver { + public fun (Lcom/google/firebase/auth/MultiFactorResolver;)V + public final fun getAndroid ()Lcom/google/firebase/auth/MultiFactorResolver; + public final fun getAuth ()Ldev/gitlive/firebase/auth/FirebaseAuth; + public final fun getHints ()Ljava/util/List; + public final fun getSession ()Ldev/gitlive/firebase/auth/MultiFactorSession; + public final fun resolveSignIn (Ldev/gitlive/firebase/auth/MultiFactorAssertion;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; +} + +public final class dev/gitlive/firebase/auth/MultiFactorSession { + public fun (Lcom/google/firebase/auth/MultiFactorSession;)V + public final fun getAndroid ()Lcom/google/firebase/auth/MultiFactorSession; +} + +public final class dev/gitlive/firebase/auth/OAuthCredential : dev/gitlive/firebase/auth/AuthCredential { + public fun (Lcom/google/firebase/auth/OAuthCredential;)V + public synthetic fun getAndroid ()Lcom/google/firebase/auth/AuthCredential; + public fun getAndroid ()Lcom/google/firebase/auth/OAuthCredential; +} + +public final class dev/gitlive/firebase/auth/OAuthProvider { + public static final field Companion Ldev/gitlive/firebase/auth/OAuthProvider$Companion; + public fun (Lcom/google/firebase/auth/OAuthProvider;)V + public fun (Ljava/lang/String;Ljava/util/List;Ljava/util/Map;Ldev/gitlive/firebase/auth/FirebaseAuth;)V + public synthetic fun (Ljava/lang/String;Ljava/util/List;Ljava/util/Map;Ldev/gitlive/firebase/auth/FirebaseAuth;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun getAndroid ()Lcom/google/firebase/auth/OAuthProvider; +} + +public final class dev/gitlive/firebase/auth/OAuthProvider$Companion { + public final fun credential (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ldev/gitlive/firebase/auth/OAuthCredential; + public static synthetic fun credential$default (Ldev/gitlive/firebase/auth/OAuthProvider$Companion;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ldev/gitlive/firebase/auth/OAuthCredential; +} + +public final class dev/gitlive/firebase/auth/PhoneAuthCredential : dev/gitlive/firebase/auth/AuthCredential { + public fun (Lcom/google/firebase/auth/PhoneAuthCredential;)V + public synthetic fun getAndroid ()Lcom/google/firebase/auth/AuthCredential; + public fun getAndroid ()Lcom/google/firebase/auth/PhoneAuthCredential; +} + +public final class dev/gitlive/firebase/auth/PhoneAuthProvider { + public fun (Ldev/gitlive/firebase/auth/FirebaseAuth;)V + public synthetic fun (Ldev/gitlive/firebase/auth/FirebaseAuth;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public fun (Lkotlin/jvm/functions/Function0;)V + public final fun credential (Ljava/lang/String;Ljava/lang/String;)Ldev/gitlive/firebase/auth/PhoneAuthCredential; + public final fun getCreateOptionsBuilder ()Lkotlin/jvm/functions/Function0; + public final fun verifyPhoneNumber (Ljava/lang/String;Ldev/gitlive/firebase/auth/PhoneVerificationProvider;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; +} + +public abstract interface class dev/gitlive/firebase/auth/PhoneVerificationProvider { + public abstract fun codeSent (Lkotlin/jvm/functions/Function1;)V + public abstract fun getActivity ()Landroid/app/Activity; + public abstract fun getTimeout ()J + public abstract fun getUnit ()Ljava/util/concurrent/TimeUnit; + public abstract fun getVerificationCode (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; +} + +public final class dev/gitlive/firebase/auth/TwitterAuthProvider { + public static final field INSTANCE Ldev/gitlive/firebase/auth/TwitterAuthProvider; + public final fun credential (Ljava/lang/String;Ljava/lang/String;)Ldev/gitlive/firebase/auth/AuthCredential; +} + +public final class dev/gitlive/firebase/auth/UserInfo { + public fun (Lcom/google/firebase/auth/UserInfo;)V + public final fun getAndroid ()Lcom/google/firebase/auth/UserInfo; + public final fun getDisplayName ()Ljava/lang/String; + public final fun getEmail ()Ljava/lang/String; + public final fun getPhoneNumber ()Ljava/lang/String; + public final fun getPhotoURL ()Ljava/lang/String; + public final fun getProviderId ()Ljava/lang/String; + public final fun getUid ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/auth/UserMetaData { + public fun (Lcom/google/firebase/auth/FirebaseUserMetadata;)V + public final fun getAndroid ()Lcom/google/firebase/auth/FirebaseUserMetadata; + public final fun getCreationTime ()Ljava/lang/Double; + public final fun getLastSignInTime ()Ljava/lang/Double; +} + +public final class dev/gitlive/firebase/auth/android { + public static final fun auth (Ldev/gitlive/firebase/Firebase;Ldev/gitlive/firebase/FirebaseApp;)Ldev/gitlive/firebase/auth/FirebaseAuth; + public static final fun getAuth (Ldev/gitlive/firebase/Firebase;)Ldev/gitlive/firebase/auth/FirebaseAuth; +} + diff --git a/firebase-auth/api/jvm/firebase-auth.api b/firebase-auth/api/jvm/firebase-auth.api new file mode 100644 index 000000000..3afffeac4 --- /dev/null +++ b/firebase-auth/api/jvm/firebase-auth.api @@ -0,0 +1,277 @@ +public abstract class dev/gitlive/firebase/auth/ActionCodeResult { +} + +public final class dev/gitlive/firebase/auth/ActionCodeResult$PasswordReset : dev/gitlive/firebase/auth/ActionCodeResult { + public final fun getEmail ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/auth/ActionCodeResult$RecoverEmail : dev/gitlive/firebase/auth/ActionCodeResult { + public final fun getEmail ()Ljava/lang/String; + public final fun getPreviousEmail ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/auth/ActionCodeResult$RevertSecondFactorAddition : dev/gitlive/firebase/auth/ActionCodeResult { + public final fun getEmail ()Ljava/lang/String; + public final fun getMultiFactorInfo ()Ldev/gitlive/firebase/auth/MultiFactorInfo; +} + +public final class dev/gitlive/firebase/auth/ActionCodeResult$SignInWithEmailLink : dev/gitlive/firebase/auth/ActionCodeResult { + public static final field INSTANCE Ldev/gitlive/firebase/auth/ActionCodeResult$SignInWithEmailLink; + public fun equals (Ljava/lang/Object;)Z + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/auth/ActionCodeResult$VerifyBeforeChangeEmail : dev/gitlive/firebase/auth/ActionCodeResult { + public final fun getEmail ()Ljava/lang/String; + public final fun getPreviousEmail ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/auth/ActionCodeResult$VerifyEmail : dev/gitlive/firebase/auth/ActionCodeResult { + public final fun getEmail ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/auth/ActionCodeSettings { + public fun (Ljava/lang/String;Ldev/gitlive/firebase/auth/AndroidPackageName;Ljava/lang/String;ZLjava/lang/String;)V + public synthetic fun (Ljava/lang/String;Ldev/gitlive/firebase/auth/AndroidPackageName;Ljava/lang/String;ZLjava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun component1 ()Ljava/lang/String; + public final fun component2 ()Ldev/gitlive/firebase/auth/AndroidPackageName; + public final fun component3 ()Ljava/lang/String; + public final fun component4 ()Z + public final fun component5 ()Ljava/lang/String; + public final fun copy (Ljava/lang/String;Ldev/gitlive/firebase/auth/AndroidPackageName;Ljava/lang/String;ZLjava/lang/String;)Ldev/gitlive/firebase/auth/ActionCodeSettings; + public static synthetic fun copy$default (Ldev/gitlive/firebase/auth/ActionCodeSettings;Ljava/lang/String;Ldev/gitlive/firebase/auth/AndroidPackageName;Ljava/lang/String;ZLjava/lang/String;ILjava/lang/Object;)Ldev/gitlive/firebase/auth/ActionCodeSettings; + public fun equals (Ljava/lang/Object;)Z + public final fun getAndroidPackageName ()Ldev/gitlive/firebase/auth/AndroidPackageName; + public final fun getCanHandleCodeInApp ()Z + public final fun getDynamicLinkDomain ()Ljava/lang/String; + public final fun getIOSBundleId ()Ljava/lang/String; + public final fun getUrl ()Ljava/lang/String; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/auth/AndroidPackageName { + public fun (Ljava/lang/String;ZLjava/lang/String;)V + public synthetic fun (Ljava/lang/String;ZLjava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun component1 ()Ljava/lang/String; + public final fun component2 ()Z + public final fun component3 ()Ljava/lang/String; + public final fun copy (Ljava/lang/String;ZLjava/lang/String;)Ldev/gitlive/firebase/auth/AndroidPackageName; + public static synthetic fun copy$default (Ldev/gitlive/firebase/auth/AndroidPackageName;Ljava/lang/String;ZLjava/lang/String;ILjava/lang/Object;)Ldev/gitlive/firebase/auth/AndroidPackageName; + public fun equals (Ljava/lang/Object;)Z + public final fun getInstallIfNotAvailable ()Z + public final fun getMinimumVersion ()Ljava/lang/String; + public final fun getPackageName ()Ljava/lang/String; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public class dev/gitlive/firebase/auth/AuthCredential { + public fun (Lcom/google/firebase/auth/AuthCredential;)V + public fun getAndroid ()Lcom/google/firebase/auth/AuthCredential; + public final fun getProviderId ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/auth/AuthResult { + public final fun getAndroid ()Lcom/google/firebase/auth/AuthResult; + public final fun getUser ()Ldev/gitlive/firebase/auth/FirebaseUser; +} + +public final class dev/gitlive/firebase/auth/AuthTokenResult { + public fun (Lcom/google/firebase/auth/GetTokenResult;)V + public final fun getAndroid ()Lcom/google/firebase/auth/GetTokenResult; + public final fun getClaims ()Ljava/util/Map; + public final fun getSignInProvider ()Ljava/lang/String; + public final fun getToken ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/auth/EmailAuthProvider { + public static final field INSTANCE Ldev/gitlive/firebase/auth/EmailAuthProvider; + public final fun credential (Ljava/lang/String;Ljava/lang/String;)Ldev/gitlive/firebase/auth/AuthCredential; + public final fun credentialWithLink (Ljava/lang/String;Ljava/lang/String;)Ldev/gitlive/firebase/auth/AuthCredential; +} + +public final class dev/gitlive/firebase/auth/FacebookAuthProvider { + public static final field INSTANCE Ldev/gitlive/firebase/auth/FacebookAuthProvider; + public final fun credential (Ljava/lang/String;)Ldev/gitlive/firebase/auth/AuthCredential; +} + +public final class dev/gitlive/firebase/auth/FirebaseAuth { + public final fun applyActionCode (Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun checkActionCode (Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun confirmPasswordReset (Ljava/lang/String;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun createUserWithEmailAndPassword (Ljava/lang/String;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun fetchSignInMethodsForEmail (Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun getAndroid ()Lcom/google/firebase/auth/FirebaseAuth; + public final fun getAuthStateChanged ()Lkotlinx/coroutines/flow/Flow; + public final fun getCurrentUser ()Ldev/gitlive/firebase/auth/FirebaseUser; + public final fun getIdTokenChanged ()Lkotlinx/coroutines/flow/Flow; + public final fun getLanguageCode ()Ljava/lang/String; + public final fun isSignInWithEmailLink (Ljava/lang/String;)Z + public final fun sendPasswordResetEmail (Ljava/lang/String;Ldev/gitlive/firebase/auth/ActionCodeSettings;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static synthetic fun sendPasswordResetEmail$default (Ldev/gitlive/firebase/auth/FirebaseAuth;Ljava/lang/String;Ldev/gitlive/firebase/auth/ActionCodeSettings;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; + public final fun sendSignInLinkToEmail (Ljava/lang/String;Ldev/gitlive/firebase/auth/ActionCodeSettings;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun setLanguageCode (Ljava/lang/String;)V + public final fun signInAnonymously (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun signInWithCredential (Ldev/gitlive/firebase/auth/AuthCredential;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun signInWithCustomToken (Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun signInWithEmailAndPassword (Ljava/lang/String;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun signInWithEmailLink (Ljava/lang/String;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun signOut (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun updateCurrentUser (Ldev/gitlive/firebase/auth/FirebaseUser;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun useEmulator (Ljava/lang/String;I)V + public final fun verifyPasswordResetCode (Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; +} + +public final class dev/gitlive/firebase/auth/FirebaseUser { + public final fun delete (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun getAndroid ()Lcom/google/firebase/auth/FirebaseUser; + public final fun getDisplayName ()Ljava/lang/String; + public final fun getEmail ()Ljava/lang/String; + public final fun getIdToken (ZLkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun getIdTokenResult (ZLkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun getMetaData ()Ldev/gitlive/firebase/auth/UserMetaData; + public final fun getMultiFactor ()Ldev/gitlive/firebase/auth/MultiFactor; + public final fun getPhoneNumber ()Ljava/lang/String; + public final fun getPhotoURL ()Ljava/lang/String; + public final fun getProviderData ()Ljava/util/List; + public final fun getProviderId ()Ljava/lang/String; + public final fun getUid ()Ljava/lang/String; + public final fun isAnonymous ()Z + public final fun isEmailVerified ()Z + public final fun linkWithCredential (Ldev/gitlive/firebase/auth/AuthCredential;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun reauthenticate (Ldev/gitlive/firebase/auth/AuthCredential;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun reauthenticateAndRetrieveData (Ldev/gitlive/firebase/auth/AuthCredential;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun reload (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun sendEmailVerification (Ldev/gitlive/firebase/auth/ActionCodeSettings;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static synthetic fun sendEmailVerification$default (Ldev/gitlive/firebase/auth/FirebaseUser;Ldev/gitlive/firebase/auth/ActionCodeSettings;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; + public final fun unlink (Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun updateEmail (Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun updatePassword (Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun updatePhoneNumber (Ldev/gitlive/firebase/auth/PhoneAuthCredential;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun updateProfile (Ljava/lang/String;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static synthetic fun updateProfile$default (Ldev/gitlive/firebase/auth/FirebaseUser;Ljava/lang/String;Ljava/lang/String;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; + public final fun verifyBeforeUpdateEmail (Ljava/lang/String;Ldev/gitlive/firebase/auth/ActionCodeSettings;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static synthetic fun verifyBeforeUpdateEmail$default (Ldev/gitlive/firebase/auth/FirebaseUser;Ljava/lang/String;Ldev/gitlive/firebase/auth/ActionCodeSettings;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; +} + +public final class dev/gitlive/firebase/auth/GithubAuthProvider { + public static final field INSTANCE Ldev/gitlive/firebase/auth/GithubAuthProvider; + public final fun credential (Ljava/lang/String;)Ldev/gitlive/firebase/auth/AuthCredential; +} + +public final class dev/gitlive/firebase/auth/GoogleAuthProvider { + public static final field INSTANCE Ldev/gitlive/firebase/auth/GoogleAuthProvider; + public final fun credential (Ljava/lang/String;Ljava/lang/String;)Ldev/gitlive/firebase/auth/AuthCredential; +} + +public final class dev/gitlive/firebase/auth/MultiFactor { + public fun (Lcom/google/firebase/auth/MultiFactor;)V + public final fun enroll (Ldev/gitlive/firebase/auth/MultiFactorAssertion;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun getAndroid ()Lcom/google/firebase/auth/MultiFactor; + public final fun getEnrolledFactors ()Ljava/util/List; + public final fun getSession (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun unenroll (Ldev/gitlive/firebase/auth/MultiFactorInfo;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun unenroll (Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; +} + +public final class dev/gitlive/firebase/auth/MultiFactorAssertion { + public fun (Lcom/google/firebase/auth/MultiFactorAssertion;)V + public final fun getAndroid ()Lcom/google/firebase/auth/MultiFactorAssertion; + public final fun getFactorId ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/auth/MultiFactorInfo { + public fun (Lcom/google/firebase/auth/MultiFactorInfo;)V + public final fun getAndroid ()Lcom/google/firebase/auth/MultiFactorInfo; + public final fun getDisplayName ()Ljava/lang/String; + public final fun getEnrollmentTime ()D + public final fun getFactorId ()Ljava/lang/String; + public final fun getUid ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/auth/MultiFactorResolver { + public fun (Lcom/google/firebase/auth/MultiFactorResolver;)V + public final fun getAndroid ()Lcom/google/firebase/auth/MultiFactorResolver; + public final fun getAuth ()Ldev/gitlive/firebase/auth/FirebaseAuth; + public final fun getHints ()Ljava/util/List; + public final fun getSession ()Ldev/gitlive/firebase/auth/MultiFactorSession; + public final fun resolveSignIn (Ldev/gitlive/firebase/auth/MultiFactorAssertion;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; +} + +public final class dev/gitlive/firebase/auth/MultiFactorSession { + public fun (Lcom/google/firebase/auth/MultiFactorSession;)V + public final fun getAndroid ()Lcom/google/firebase/auth/MultiFactorSession; +} + +public final class dev/gitlive/firebase/auth/OAuthCredential : dev/gitlive/firebase/auth/AuthCredential { + public fun (Lcom/google/firebase/auth/OAuthCredential;)V + public synthetic fun getAndroid ()Lcom/google/firebase/auth/AuthCredential; + public fun getAndroid ()Lcom/google/firebase/auth/OAuthCredential; +} + +public final class dev/gitlive/firebase/auth/OAuthProvider { + public static final field Companion Ldev/gitlive/firebase/auth/OAuthProvider$Companion; + public fun (Lcom/google/firebase/auth/OAuthProvider;)V + public fun (Ljava/lang/String;Ljava/util/List;Ljava/util/Map;Ldev/gitlive/firebase/auth/FirebaseAuth;)V + public synthetic fun (Ljava/lang/String;Ljava/util/List;Ljava/util/Map;Ldev/gitlive/firebase/auth/FirebaseAuth;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun getAndroid ()Lcom/google/firebase/auth/OAuthProvider; +} + +public final class dev/gitlive/firebase/auth/OAuthProvider$Companion { + public final fun credential (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ldev/gitlive/firebase/auth/OAuthCredential; + public static synthetic fun credential$default (Ldev/gitlive/firebase/auth/OAuthProvider$Companion;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ldev/gitlive/firebase/auth/OAuthCredential; +} + +public final class dev/gitlive/firebase/auth/PhoneAuthCredential : dev/gitlive/firebase/auth/AuthCredential { + public fun (Lcom/google/firebase/auth/PhoneAuthCredential;)V + public synthetic fun getAndroid ()Lcom/google/firebase/auth/AuthCredential; + public fun getAndroid ()Lcom/google/firebase/auth/PhoneAuthCredential; +} + +public final class dev/gitlive/firebase/auth/PhoneAuthProvider { + public fun (Lcom/google/firebase/auth/PhoneAuthProvider;)V + public fun (Ldev/gitlive/firebase/auth/FirebaseAuth;)V + public synthetic fun (Ldev/gitlive/firebase/auth/FirebaseAuth;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun credential (Ljava/lang/String;Ljava/lang/String;)Ldev/gitlive/firebase/auth/PhoneAuthCredential; + public final fun getAndroid ()Lcom/google/firebase/auth/PhoneAuthProvider; + public final fun verifyPhoneNumber (Ljava/lang/String;Ldev/gitlive/firebase/auth/PhoneVerificationProvider;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; +} + +public abstract interface class dev/gitlive/firebase/auth/PhoneVerificationProvider { + public abstract fun codeSent (Lkotlin/jvm/functions/Function1;)V + public abstract fun getActivity ()Landroid/app/Activity; + public abstract fun getTimeout ()J + public abstract fun getUnit ()Ljava/util/concurrent/TimeUnit; + public abstract fun getVerificationCode (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; +} + +public final class dev/gitlive/firebase/auth/TwitterAuthProvider { + public static final field INSTANCE Ldev/gitlive/firebase/auth/TwitterAuthProvider; + public final fun credential (Ljava/lang/String;Ljava/lang/String;)Ldev/gitlive/firebase/auth/AuthCredential; +} + +public final class dev/gitlive/firebase/auth/UserInfo { + public fun (Lcom/google/firebase/auth/UserInfo;)V + public final fun getAndroid ()Lcom/google/firebase/auth/UserInfo; + public final fun getDisplayName ()Ljava/lang/String; + public final fun getEmail ()Ljava/lang/String; + public final fun getPhoneNumber ()Ljava/lang/String; + public final fun getPhotoURL ()Ljava/lang/String; + public final fun getProviderId ()Ljava/lang/String; + public final fun getUid ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/auth/UserMetaData { + public fun (Lcom/google/firebase/auth/FirebaseUserMetadata;)V + public final fun getAndroid ()Lcom/google/firebase/auth/FirebaseUserMetadata; + public final fun getCreationTime ()Ljava/lang/Double; + public final fun getLastSignInTime ()Ljava/lang/Double; +} + +public final class dev/gitlive/firebase/auth/android { + public static final fun auth (Ldev/gitlive/firebase/Firebase;Ldev/gitlive/firebase/FirebaseApp;)Ldev/gitlive/firebase/auth/FirebaseAuth; + public static final fun getAuth (Ldev/gitlive/firebase/Firebase;)Ldev/gitlive/firebase/auth/FirebaseAuth; +} + diff --git a/firebase-auth/build.gradle.kts b/firebase-auth/build.gradle.kts index ea20be920..a528f3302 100644 --- a/firebase-auth/build.gradle.kts +++ b/firebase-auth/build.gradle.kts @@ -49,6 +49,8 @@ android { val supportIosTarget = project.property("skipIosTarget") != "true" kotlin { + explicitApi() + @OptIn(ExperimentalKotlinGradlePluginApi::class) compilerOptions { freeCompilerArgs.add("-Xexpect-actual-classes") diff --git a/firebase-auth/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/auth/auth.kt b/firebase-auth/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/auth/auth.kt index 0d4d18e96..0b86ac10a 100644 --- a/firebase-auth/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/auth/auth.kt +++ b/firebase-auth/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/auth/auth.kt @@ -3,6 +3,7 @@ */ @file:JvmName("tests") + package dev.gitlive.firebase.auth import androidx.test.platform.app.InstrumentationRegistry diff --git a/firebase-auth/src/androidMain/kotlin/dev/gitlive/firebase/auth/auth.kt b/firebase-auth/src/androidMain/kotlin/dev/gitlive/firebase/auth/auth.kt index d0484b643..3bd7ae6f2 100644 --- a/firebase-auth/src/androidMain/kotlin/dev/gitlive/firebase/auth/auth.kt +++ b/firebase-auth/src/androidMain/kotlin/dev/gitlive/firebase/auth/auth.kt @@ -3,6 +3,7 @@ */ @file:JvmName("android") + package dev.gitlive.firebase.auth import com.google.firebase.auth.ActionCodeEmailInfo @@ -16,81 +17,82 @@ import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.callbackFlow import kotlinx.coroutines.tasks.await -actual val Firebase.auth +public actual val Firebase.auth: FirebaseAuth get() = FirebaseAuth(com.google.firebase.auth.FirebaseAuth.getInstance()) -actual fun Firebase.auth(app: FirebaseApp) = +public actual fun Firebase.auth(app: FirebaseApp): FirebaseAuth = FirebaseAuth(com.google.firebase.auth.FirebaseAuth.getInstance(app.android)) -actual class FirebaseAuth internal constructor(val android: com.google.firebase.auth.FirebaseAuth) { - actual val currentUser: FirebaseUser? +public actual class FirebaseAuth internal constructor(public val android: com.google.firebase.auth.FirebaseAuth) { + public actual val currentUser: FirebaseUser? get() = android.currentUser?.let { FirebaseUser(it) } - actual val authStateChanged: Flow get() = callbackFlow { - val listener = object : AuthStateListener { - override fun onAuthStateChanged(auth: com.google.firebase.auth.FirebaseAuth) { - trySend(auth.currentUser?.let { FirebaseUser(it) }) - } - } + public actual val authStateChanged: Flow get() = callbackFlow { + val listener = AuthStateListener { auth -> trySend(auth.currentUser?.let { FirebaseUser(it) }) } android.addAuthStateListener(listener) awaitClose { android.removeAuthStateListener(listener) } } - actual val idTokenChanged get(): Flow = callbackFlow { - val listener = object : com.google.firebase.auth.FirebaseAuth.IdTokenListener { - override fun onIdTokenChanged(auth: com.google.firebase.auth.FirebaseAuth) { - trySend(auth.currentUser?.let { FirebaseUser(it) }) - } - } + public actual val idTokenChanged: Flow get() = callbackFlow { + val listener = com.google.firebase.auth.FirebaseAuth.IdTokenListener { auth -> trySend(auth.currentUser?.let { FirebaseUser(it) }) } android.addIdTokenListener(listener) awaitClose { android.removeIdTokenListener(listener) } } - actual var languageCode: String + public actual var languageCode: String get() = android.languageCode ?: "" - set(value) { android.setLanguageCode(value) } - + set(value) { + android.setLanguageCode(value) + } - actual suspend fun applyActionCode(code: String) = android.applyActionCode(code).await().run { Unit } - actual suspend fun confirmPasswordReset(code: String, newPassword: String) = android.confirmPasswordReset(code, newPassword).await().run { Unit } + public actual suspend fun applyActionCode(code: String) { + android.applyActionCode(code).await() + } + public actual suspend fun confirmPasswordReset(code: String, newPassword: String) { + android.confirmPasswordReset(code, newPassword).await() + } - actual suspend fun createUserWithEmailAndPassword(email: String, password: String) = + public actual suspend fun createUserWithEmailAndPassword(email: String, password: String): AuthResult = AuthResult(android.createUserWithEmailAndPassword(email, password).await()) @Suppress("DEPRECATION") - actual suspend fun fetchSignInMethodsForEmail(email: String): List = android.fetchSignInMethodsForEmail(email).await().signInMethods.orEmpty() + public actual suspend fun fetchSignInMethodsForEmail(email: String): List = android.fetchSignInMethodsForEmail(email).await().signInMethods.orEmpty() - actual suspend fun sendPasswordResetEmail(email: String, actionCodeSettings: ActionCodeSettings?) { + public actual suspend fun sendPasswordResetEmail(email: String, actionCodeSettings: ActionCodeSettings?) { android.sendPasswordResetEmail(email, actionCodeSettings?.toAndroid()).await() } - actual suspend fun sendSignInLinkToEmail(email: String, actionCodeSettings: ActionCodeSettings) = android.sendSignInLinkToEmail(email, actionCodeSettings.toAndroid()).await().run { Unit } + public actual suspend fun sendSignInLinkToEmail(email: String, actionCodeSettings: ActionCodeSettings) { + android.sendSignInLinkToEmail(email, actionCodeSettings.toAndroid()).await() + } - actual fun isSignInWithEmailLink(link: String) = android.isSignInWithEmailLink(link) + public actual fun isSignInWithEmailLink(link: String): Boolean = android.isSignInWithEmailLink(link) - actual suspend fun signInWithEmailAndPassword(email: String, password: String) = + public actual suspend fun signInWithEmailAndPassword(email: String, password: String): AuthResult = AuthResult(android.signInWithEmailAndPassword(email, password).await()) - actual suspend fun signInWithCustomToken(token: String) = + public actual suspend fun signInWithCustomToken(token: String): AuthResult = AuthResult(android.signInWithCustomToken(token).await()) - actual suspend fun signInAnonymously() = AuthResult(android.signInAnonymously().await()) + public actual suspend fun signInAnonymously(): AuthResult = AuthResult(android.signInAnonymously().await()) - actual suspend fun signInWithCredential(authCredential: AuthCredential) = + public actual suspend fun signInWithCredential(authCredential: AuthCredential): AuthResult = AuthResult(android.signInWithCredential(authCredential.android).await()) - actual suspend fun signInWithEmailLink(email: String, link: String) = + public actual suspend fun signInWithEmailLink(email: String, link: String): AuthResult = AuthResult(android.signInWithEmailLink(email, link).await()) - actual suspend fun signOut() = android.signOut() + public actual suspend fun signOut(): Unit = android.signOut() - actual suspend fun updateCurrentUser(user: FirebaseUser) = android.updateCurrentUser(user.android).await().run { Unit } - actual suspend fun verifyPasswordResetCode(code: String): String = android.verifyPasswordResetCode(code).await() + public actual suspend fun updateCurrentUser(user: FirebaseUser) { + android.updateCurrentUser(user.android).await() + } + public actual suspend fun verifyPasswordResetCode(code: String): String = android.verifyPasswordResetCode(code).await() - actual suspend fun checkActionCode(code: String): T { + public actual suspend fun checkActionCode(code: String): T { val result = android.checkActionCode(code).await() @Suppress("UNCHECKED_CAST") - return when(result.operation) { + return when (result.operation) { SIGN_IN_WITH_EMAIL_LINK -> ActionCodeResult.SignInWithEmailLink VERIFY_EMAIL -> ActionCodeResult.VerifyEmail(result.info!!.email) PASSWORD_RESET -> ActionCodeResult.PasswordReset(result.info!!.email) @@ -108,26 +110,27 @@ actual class FirebaseAuth internal constructor(val android: com.google.firebase. } as T } - actual fun useEmulator(host: String, port: Int) = android.useEmulator(host, port) + public actual fun useEmulator(host: String, port: Int): Unit = android.useEmulator(host, port) } -actual class AuthResult internal constructor(val android: com.google.firebase.auth.AuthResult) { - actual val user: FirebaseUser? +public actual class AuthResult internal constructor(public val android: com.google.firebase.auth.AuthResult) { + public actual val user: FirebaseUser? get() = android.user?.let { FirebaseUser(it) } } -actual class AuthTokenResult(val android: com.google.firebase.auth.GetTokenResult) { +public actual class AuthTokenResult(public val android: com.google.firebase.auth.GetTokenResult) { // actual val authTimestamp: Long // get() = android.authTimestamp - actual val claims: Map + public actual val claims: Map get() = android.claims + // actual val expirationTimestamp: Long // get() = android.expirationTimestamp // actual val issuedAtTimestamp: Long // get() = android.issuedAtTimestamp - actual val signInProvider: String? + public actual val signInProvider: String? get() = android.signInProvider - actual val token: String? + public actual val token: String? get() = android.token } @@ -139,13 +142,13 @@ internal fun ActionCodeSettings.toAndroid() = com.google.firebase.auth.ActionCod .also { iOSBundleId?.run { it.setIOSBundleId(this) } } .build() -actual typealias FirebaseAuthException = com.google.firebase.auth.FirebaseAuthException -actual typealias FirebaseAuthActionCodeException = com.google.firebase.auth.FirebaseAuthActionCodeException -actual typealias FirebaseAuthEmailException = com.google.firebase.auth.FirebaseAuthEmailException -actual typealias FirebaseAuthInvalidCredentialsException = com.google.firebase.auth.FirebaseAuthInvalidCredentialsException -actual typealias FirebaseAuthWeakPasswordException = com.google.firebase.auth.FirebaseAuthWeakPasswordException -actual typealias FirebaseAuthInvalidUserException = com.google.firebase.auth.FirebaseAuthInvalidUserException -actual typealias FirebaseAuthMultiFactorException = com.google.firebase.auth.FirebaseAuthMultiFactorException -actual typealias FirebaseAuthRecentLoginRequiredException = com.google.firebase.auth.FirebaseAuthRecentLoginRequiredException -actual typealias FirebaseAuthUserCollisionException = com.google.firebase.auth.FirebaseAuthUserCollisionException -actual typealias FirebaseAuthWebException = com.google.firebase.auth.FirebaseAuthWebException +public actual typealias FirebaseAuthException = com.google.firebase.auth.FirebaseAuthException +public actual typealias FirebaseAuthActionCodeException = com.google.firebase.auth.FirebaseAuthActionCodeException +public actual typealias FirebaseAuthEmailException = com.google.firebase.auth.FirebaseAuthEmailException +public actual typealias FirebaseAuthInvalidCredentialsException = com.google.firebase.auth.FirebaseAuthInvalidCredentialsException +public actual typealias FirebaseAuthWeakPasswordException = com.google.firebase.auth.FirebaseAuthWeakPasswordException +public actual typealias FirebaseAuthInvalidUserException = com.google.firebase.auth.FirebaseAuthInvalidUserException +public actual typealias FirebaseAuthMultiFactorException = com.google.firebase.auth.FirebaseAuthMultiFactorException +public actual typealias FirebaseAuthRecentLoginRequiredException = com.google.firebase.auth.FirebaseAuthRecentLoginRequiredException +public actual typealias FirebaseAuthUserCollisionException = com.google.firebase.auth.FirebaseAuthUserCollisionException +public actual typealias FirebaseAuthWebException = com.google.firebase.auth.FirebaseAuthWebException diff --git a/firebase-auth/src/androidMain/kotlin/dev/gitlive/firebase/auth/credentials.kt b/firebase-auth/src/androidMain/kotlin/dev/gitlive/firebase/auth/credentials.kt index 5782f9974..de450c71e 100644 --- a/firebase-auth/src/androidMain/kotlin/dev/gitlive/firebase/auth/credentials.kt +++ b/firebase-auth/src/androidMain/kotlin/dev/gitlive/firebase/auth/credentials.kt @@ -12,40 +12,39 @@ import com.google.firebase.auth.PhoneAuthProvider import kotlinx.coroutines.CompletableDeferred import kotlinx.coroutines.coroutineScope import kotlinx.coroutines.launch -import kotlinx.coroutines.tasks.await import java.util.concurrent.TimeUnit -actual open class AuthCredential(open val android: com.google.firebase.auth.AuthCredential) { - actual val providerId: String +public actual open class AuthCredential(public open val android: com.google.firebase.auth.AuthCredential) { + public actual val providerId: String get() = android.provider } -actual class PhoneAuthCredential(override val android: com.google.firebase.auth.PhoneAuthCredential) : AuthCredential(android) +public actual class PhoneAuthCredential(override val android: com.google.firebase.auth.PhoneAuthCredential) : AuthCredential(android) -actual class OAuthCredential(override val android: com.google.firebase.auth.OAuthCredential) : AuthCredential(android) +public actual class OAuthCredential(override val android: com.google.firebase.auth.OAuthCredential) : AuthCredential(android) -actual object EmailAuthProvider { - actual fun credential( +public actual object EmailAuthProvider { + public actual fun credential( email: String, - password: String + password: String, ): AuthCredential = AuthCredential(com.google.firebase.auth.EmailAuthProvider.getCredential(email, password)) - actual fun credentialWithLink( + public actual fun credentialWithLink( email: String, - emailLink: String + emailLink: String, ): AuthCredential = AuthCredential(com.google.firebase.auth.EmailAuthProvider.getCredentialWithLink(email, emailLink)) } -actual object FacebookAuthProvider { - actual fun credential(accessToken: String): AuthCredential = AuthCredential(com.google.firebase.auth.FacebookAuthProvider.getCredential(accessToken)) +public actual object FacebookAuthProvider { + public actual fun credential(accessToken: String): AuthCredential = AuthCredential(com.google.firebase.auth.FacebookAuthProvider.getCredential(accessToken)) } -actual object GithubAuthProvider { - actual fun credential(token: String): AuthCredential = AuthCredential(com.google.firebase.auth.GithubAuthProvider.getCredential(token)) +public actual object GithubAuthProvider { + public actual fun credential(token: String): AuthCredential = AuthCredential(com.google.firebase.auth.GithubAuthProvider.getCredential(token)) } -actual object GoogleAuthProvider { - actual fun credential(idToken: String?, accessToken: String?): AuthCredential { +public actual object GoogleAuthProvider { + public actual fun credential(idToken: String?, accessToken: String?): AuthCredential { require(idToken != null || accessToken != null) { "Both parameters are optional but at least one must be present." } @@ -53,39 +52,39 @@ actual object GoogleAuthProvider { } } -actual class OAuthProvider(val android: com.google.firebase.auth.OAuthProvider) { +public actual class OAuthProvider(public val android: OAuthProvider) { - actual constructor( + public actual constructor( provider: String, scopes: List, customParameters: Map, - auth: FirebaseAuth + auth: FirebaseAuth, ) : this( - com.google.firebase.auth.OAuthProvider + OAuthProvider .newBuilder(provider, auth.android) .setScopes(scopes) .addCustomParameters(customParameters) - .build() + .build(), ) - actual companion object { - actual fun credential(providerId: String, accessToken: String?, idToken: String?, rawNonce: String?): OAuthCredential { + public actual companion object { + public actual fun credential(providerId: String, accessToken: String?, idToken: String?, rawNonce: String?): OAuthCredential { val builder = OAuthProvider.newCredentialBuilder(providerId) accessToken?.let { builder.setAccessToken(it) } idToken?.let { builder.setIdToken(it) } - rawNonce?.let { builder.setIdTokenWithRawNonce(idToken!!, it) } + rawNonce?.let { builder.setIdTokenWithRawNonce(idToken!!, it) } return OAuthCredential(builder.build() as com.google.firebase.auth.OAuthCredential) } } } -actual class PhoneAuthProvider(val createOptionsBuilder: () -> PhoneAuthOptions.Builder) { +public actual class PhoneAuthProvider(public val createOptionsBuilder: () -> PhoneAuthOptions.Builder) { - actual constructor(auth: FirebaseAuth) : this({ PhoneAuthOptions.newBuilder(auth.android) }) + public actual constructor(auth: FirebaseAuth) : this({ PhoneAuthOptions.newBuilder(auth.android) }) - actual fun credential(verificationId: String, smsCode: String): PhoneAuthCredential = PhoneAuthCredential(com.google.firebase.auth.PhoneAuthProvider.getCredential(verificationId, smsCode)) + public actual fun credential(verificationId: String, smsCode: String): PhoneAuthCredential = PhoneAuthCredential(PhoneAuthProvider.getCredential(verificationId, smsCode)) - actual suspend fun verifyPhoneNumber(phoneNumber: String, verificationProvider: PhoneVerificationProvider): AuthCredential = coroutineScope { + public actual suspend fun verifyPhoneNumber(phoneNumber: String, verificationProvider: PhoneVerificationProvider): AuthCredential = coroutineScope { val response = CompletableDeferred>() val callback = object : PhoneAuthProvider.OnVerificationStateChangedCallbacks() { @@ -121,7 +120,6 @@ actual class PhoneAuthProvider(val createOptionsBuilder: () -> PhoneAuthOptions. override fun onVerificationFailed(error: FirebaseException) { response.complete(Result.failure(error)) } - } val options = createOptionsBuilder() .setPhoneNumber(phoneNumber) @@ -135,14 +133,14 @@ actual class PhoneAuthProvider(val createOptionsBuilder: () -> PhoneAuthOptions. } } -actual interface PhoneVerificationProvider { - val activity: Activity - val timeout: Long - val unit: TimeUnit - fun codeSent(triggerResend: (Unit) -> Unit) - suspend fun getVerificationCode(): String +public actual interface PhoneVerificationProvider { + public val activity: Activity + public val timeout: Long + public val unit: TimeUnit + public fun codeSent(triggerResend: (Unit) -> Unit) + public suspend fun getVerificationCode(): String } -actual object TwitterAuthProvider { - actual fun credential(token: String, secret: String): AuthCredential = AuthCredential(com.google.firebase.auth.TwitterAuthProvider.getCredential(token, secret)) +public actual object TwitterAuthProvider { + public actual fun credential(token: String, secret: String): AuthCredential = AuthCredential(com.google.firebase.auth.TwitterAuthProvider.getCredential(token, secret)) } diff --git a/firebase-auth/src/androidMain/kotlin/dev/gitlive/firebase/auth/multifactor.kt b/firebase-auth/src/androidMain/kotlin/dev/gitlive/firebase/auth/multifactor.kt index 7b68960c2..6b60e36a7 100644 --- a/firebase-auth/src/androidMain/kotlin/dev/gitlive/firebase/auth/multifactor.kt +++ b/firebase-auth/src/androidMain/kotlin/dev/gitlive/firebase/auth/multifactor.kt @@ -6,37 +6,43 @@ package dev.gitlive.firebase.auth import kotlinx.coroutines.tasks.await -actual class MultiFactor(val android: com.google.firebase.auth.MultiFactor) { - actual val enrolledFactors: List +public actual class MultiFactor(public val android: com.google.firebase.auth.MultiFactor) { + public actual val enrolledFactors: List get() = android.enrolledFactors.map { MultiFactorInfo(it) } - actual suspend fun enroll(multiFactorAssertion: MultiFactorAssertion, displayName: String?) = android.enroll(multiFactorAssertion.android, displayName).await().run { Unit } - actual suspend fun getSession(): MultiFactorSession = MultiFactorSession(android.session.await()) - actual suspend fun unenroll(multiFactorInfo: MultiFactorInfo) = android.unenroll(multiFactorInfo.android).await().run { Unit } - actual suspend fun unenroll(factorUid: String) = android.unenroll(factorUid).await().run { Unit } + public actual suspend fun enroll(multiFactorAssertion: MultiFactorAssertion, displayName: String?) { + android.enroll(multiFactorAssertion.android, displayName).await() + } + public actual suspend fun getSession(): MultiFactorSession = MultiFactorSession(android.session.await()) + public actual suspend fun unenroll(multiFactorInfo: MultiFactorInfo) { + android.unenroll(multiFactorInfo.android).await() + } + public actual suspend fun unenroll(factorUid: String) { + android.unenroll(factorUid).await() + } } -actual class MultiFactorInfo(val android: com.google.firebase.auth.MultiFactorInfo) { - actual val displayName: String? +public actual class MultiFactorInfo(public val android: com.google.firebase.auth.MultiFactorInfo) { + public actual val displayName: String? get() = android.displayName - actual val enrollmentTime: Double + public actual val enrollmentTime: Double get() = android.enrollmentTimestamp.toDouble() - actual val factorId: String + public actual val factorId: String get() = android.factorId - actual val uid: String + public actual val uid: String get() = android.uid } -actual class MultiFactorAssertion(val android: com.google.firebase.auth.MultiFactorAssertion) { - actual val factorId: String +public actual class MultiFactorAssertion(public val android: com.google.firebase.auth.MultiFactorAssertion) { + public actual val factorId: String get() = android.factorId } -actual class MultiFactorSession(val android: com.google.firebase.auth.MultiFactorSession) +public actual class MultiFactorSession(public val android: com.google.firebase.auth.MultiFactorSession) -actual class MultiFactorResolver(val android: com.google.firebase.auth.MultiFactorResolver) { - actual val auth: FirebaseAuth = FirebaseAuth(android.firebaseAuth) - actual val hints: List = android.hints.map { MultiFactorInfo(it) } - actual val session: MultiFactorSession = MultiFactorSession(android.session) +public actual class MultiFactorResolver(public val android: com.google.firebase.auth.MultiFactorResolver) { + public actual val auth: FirebaseAuth = FirebaseAuth(android.firebaseAuth) + public actual val hints: List = android.hints.map { MultiFactorInfo(it) } + public actual val session: MultiFactorSession = MultiFactorSession(android.session) - actual suspend fun resolveSignIn(assertion: MultiFactorAssertion): AuthResult = AuthResult(android.resolveSignIn(assertion.android).await()) -} \ No newline at end of file + public actual suspend fun resolveSignIn(assertion: MultiFactorAssertion): AuthResult = AuthResult(android.resolveSignIn(assertion.android).await()) +} diff --git a/firebase-auth/src/androidMain/kotlin/dev/gitlive/firebase/auth/user.kt b/firebase-auth/src/androidMain/kotlin/dev/gitlive/firebase/auth/user.kt index 19499c6b9..8428d6a0e 100644 --- a/firebase-auth/src/androidMain/kotlin/dev/gitlive/firebase/auth/user.kt +++ b/firebase-auth/src/androidMain/kotlin/dev/gitlive/firebase/auth/user.kt @@ -8,75 +8,88 @@ import android.net.Uri import com.google.firebase.auth.UserProfileChangeRequest import kotlinx.coroutines.tasks.await -actual class FirebaseUser internal constructor(val android: com.google.firebase.auth.FirebaseUser) { - actual val uid: String +public actual class FirebaseUser internal constructor(public val android: com.google.firebase.auth.FirebaseUser) { + public actual val uid: String get() = android.uid - actual val displayName: String? + public actual val displayName: String? get() = android.displayName - actual val email: String? + public actual val email: String? get() = android.email - actual val phoneNumber: String? + public actual val phoneNumber: String? get() = android.phoneNumber - actual val photoURL: String? + public actual val photoURL: String? get() = android.photoUrl?.toString() - actual val isAnonymous: Boolean + public actual val isAnonymous: Boolean get() = android.isAnonymous - actual val isEmailVerified: Boolean + public actual val isEmailVerified: Boolean get() = android.isEmailVerified - actual val metaData: UserMetaData? - get() = android.metadata?.let{ UserMetaData(it) } - actual val multiFactor: MultiFactor + public actual val metaData: UserMetaData? + get() = android.metadata?.let { UserMetaData(it) } + public actual val multiFactor: MultiFactor get() = MultiFactor(android.multiFactor) - actual val providerData: List + public actual val providerData: List get() = android.providerData.map { UserInfo(it) } - actual val providerId: String + public actual val providerId: String get() = android.providerId - actual suspend fun delete() = android.delete().await().run { Unit } - actual suspend fun reload() = android.reload().await().run { Unit } - actual suspend fun getIdToken(forceRefresh: Boolean): String? = android.getIdToken(forceRefresh).await().token - actual suspend fun getIdTokenResult(forceRefresh: Boolean): AuthTokenResult = android.getIdToken(forceRefresh).await().run { AuthTokenResult(this) } - actual suspend fun linkWithCredential(credential: AuthCredential): AuthResult = AuthResult(android.linkWithCredential(credential.android).await()) - actual suspend fun reauthenticate(credential: AuthCredential) = android.reauthenticate(credential.android).await().run { Unit } - actual suspend fun reauthenticateAndRetrieveData(credential: AuthCredential): AuthResult = AuthResult(android.reauthenticateAndRetrieveData(credential.android).await()) - actual suspend fun sendEmailVerification(actionCodeSettings: ActionCodeSettings?) { + public actual suspend fun delete() { + android.delete().await() + } + public actual suspend fun reload() { + android.reload().await() + } + public actual suspend fun getIdToken(forceRefresh: Boolean): String? = android.getIdToken(forceRefresh).await().token + public actual suspend fun getIdTokenResult(forceRefresh: Boolean): AuthTokenResult = android.getIdToken(forceRefresh).await().run { AuthTokenResult(this) } + public actual suspend fun linkWithCredential(credential: AuthCredential): AuthResult = AuthResult(android.linkWithCredential(credential.android).await()) + public actual suspend fun reauthenticate(credential: AuthCredential) { + android.reauthenticate(credential.android).await() + } + public actual suspend fun reauthenticateAndRetrieveData(credential: AuthCredential): AuthResult = AuthResult(android.reauthenticateAndRetrieveData(credential.android).await()) + public actual suspend fun sendEmailVerification(actionCodeSettings: ActionCodeSettings?) { val request = actionCodeSettings?.let { android.sendEmailVerification(it.toAndroid()) } ?: android.sendEmailVerification() request.await() } - actual suspend fun unlink(provider: String): FirebaseUser? = android.unlink(provider).await().user?.let { FirebaseUser(it) } + public actual suspend fun unlink(provider: String): FirebaseUser? = android.unlink(provider).await().user?.let { FirebaseUser(it) } @Suppress("DEPRECATION") - actual suspend fun updateEmail(email: String) = android.updateEmail(email).await().run { Unit } - actual suspend fun updatePassword(password: String) = android.updatePassword(password).await().run { Unit } - actual suspend fun updatePhoneNumber(credential: PhoneAuthCredential) = android.updatePhoneNumber(credential.android).await().run { Unit } - actual suspend fun updateProfile(displayName: String?, photoUrl: String?) { + public actual suspend fun updateEmail(email: String) { + android.updateEmail(email).await() + } + public actual suspend fun updatePassword(password: String) { + android.updatePassword(password).await() + } + public actual suspend fun updatePhoneNumber(credential: PhoneAuthCredential) { + android.updatePhoneNumber(credential.android).await() + } + public actual suspend fun updateProfile(displayName: String?, photoUrl: String?) { val request = UserProfileChangeRequest.Builder() .apply { setDisplayName(displayName) } .apply { photoUri = photoUrl?.let { Uri.parse(it) } } .build() android.updateProfile(request).await() } - actual suspend fun verifyBeforeUpdateEmail(newEmail: String, actionCodeSettings: ActionCodeSettings?) = - android.verifyBeforeUpdateEmail(newEmail, actionCodeSettings?.toAndroid()).await().run { Unit } + public actual suspend fun verifyBeforeUpdateEmail(newEmail: String, actionCodeSettings: ActionCodeSettings?) { + android.verifyBeforeUpdateEmail(newEmail, actionCodeSettings?.toAndroid()).await() + } } -actual class UserInfo(val android: com.google.firebase.auth.UserInfo) { - actual val displayName: String? +public actual class UserInfo(public val android: com.google.firebase.auth.UserInfo) { + public actual val displayName: String? get() = android.displayName - actual val email: String? + public actual val email: String? get() = android.email - actual val phoneNumber: String? + public actual val phoneNumber: String? get() = android.phoneNumber - actual val photoURL: String? + public actual val photoURL: String? get() = android.photoUrl?.toString() - actual val providerId: String + public actual val providerId: String get() = android.providerId - actual val uid: String + public actual val uid: String get() = android.uid } -actual class UserMetaData(val android: com.google.firebase.auth.FirebaseUserMetadata) { - actual val creationTime: Double? +public actual class UserMetaData(public val android: com.google.firebase.auth.FirebaseUserMetadata) { + public actual val creationTime: Double? get() = android.creationTimestamp.toDouble() - actual val lastSignInTime: Double? + public actual val lastSignInTime: Double? get() = android.lastSignInTimestamp.toDouble() } diff --git a/firebase-auth/src/androidUnitTest/kotlin/dev/gitlive/firebase/auth/auth.kt b/firebase-auth/src/androidUnitTest/kotlin/dev/gitlive/firebase/auth/auth.kt index 216b48f4c..3b9348d5a 100644 --- a/firebase-auth/src/androidUnitTest/kotlin/dev/gitlive/firebase/auth/auth.kt +++ b/firebase-auth/src/androidUnitTest/kotlin/dev/gitlive/firebase/auth/auth.kt @@ -3,6 +3,7 @@ */ @file:JvmName("tests") + package dev.gitlive.firebase.auth import org.junit.Ignore diff --git a/firebase-auth/src/commonMain/kotlin/dev/gitlive/firebase/auth/auth.kt b/firebase-auth/src/commonMain/kotlin/dev/gitlive/firebase/auth/auth.kt index 3f5a7b5a1..f66ce3c03 100644 --- a/firebase-auth/src/commonMain/kotlin/dev/gitlive/firebase/auth/auth.kt +++ b/firebase-auth/src/commonMain/kotlin/dev/gitlive/firebase/auth/auth.kt @@ -2,8 +2,6 @@ * Copyright (c) 2020 GitLive Ltd. Use of this source code is governed by the Apache 2.0 license. */ -@file:Suppress("EXTENSION_SHADOWED_BY_MEMBER") - package dev.gitlive.firebase.auth import dev.gitlive.firebase.Firebase @@ -11,78 +9,80 @@ import dev.gitlive.firebase.FirebaseApp import dev.gitlive.firebase.FirebaseException import kotlinx.coroutines.flow.Flow -expect val Firebase.auth: FirebaseAuth +public expect val Firebase.auth: FirebaseAuth + +public expect fun Firebase.auth(app: FirebaseApp): FirebaseAuth -expect fun Firebase.auth(app: FirebaseApp): FirebaseAuth +public expect class FirebaseAuth { + public val currentUser: FirebaseUser? + public val authStateChanged: Flow + public val idTokenChanged: Flow + public var languageCode: String + public suspend fun applyActionCode(code: String) + public suspend fun checkActionCode(code: String): T + public suspend fun confirmPasswordReset(code: String, newPassword: String) + public suspend fun createUserWithEmailAndPassword(email: String, password: String): AuthResult -expect class FirebaseAuth { - val currentUser: FirebaseUser? - val authStateChanged: Flow - val idTokenChanged: Flow - var languageCode: String - suspend fun applyActionCode(code: String) - suspend fun checkActionCode(code: String): T - suspend fun confirmPasswordReset(code: String, newPassword: String) - suspend fun createUserWithEmailAndPassword(email: String, password: String): AuthResult @Deprecated("Migrating off of this method is recommended as a security best-practice. Learn more in the Identity Platform documentation for [Email Enumeration Protection](https://cloud.google.com/identity-platform/docs/admin/email-enumeration-protection).") - suspend fun fetchSignInMethodsForEmail(email: String): List - suspend fun sendPasswordResetEmail(email: String, actionCodeSettings: ActionCodeSettings? = null) - suspend fun sendSignInLinkToEmail(email: String, actionCodeSettings: ActionCodeSettings) - fun isSignInWithEmailLink(link: String): Boolean - suspend fun signInWithEmailAndPassword(email: String, password: String): AuthResult - suspend fun signInWithCustomToken(token: String): AuthResult - suspend fun signInAnonymously(): AuthResult - suspend fun signInWithCredential(authCredential: AuthCredential): AuthResult - suspend fun signInWithEmailLink(email: String, link: String): AuthResult - suspend fun signOut() - suspend fun updateCurrentUser(user: FirebaseUser) - suspend fun verifyPasswordResetCode(code: String): String - fun useEmulator(host: String, port: Int) + public suspend fun fetchSignInMethodsForEmail(email: String): List + public suspend fun sendPasswordResetEmail(email: String, actionCodeSettings: ActionCodeSettings? = null) + public suspend fun sendSignInLinkToEmail(email: String, actionCodeSettings: ActionCodeSettings) + public fun isSignInWithEmailLink(link: String): Boolean + public suspend fun signInWithEmailAndPassword(email: String, password: String): AuthResult + public suspend fun signInWithCustomToken(token: String): AuthResult + public suspend fun signInAnonymously(): AuthResult + public suspend fun signInWithCredential(authCredential: AuthCredential): AuthResult + public suspend fun signInWithEmailLink(email: String, link: String): AuthResult + public suspend fun signOut() + public suspend fun updateCurrentUser(user: FirebaseUser) + public suspend fun verifyPasswordResetCode(code: String): String + public fun useEmulator(host: String, port: Int) } -expect class AuthResult { - val user: FirebaseUser? +public expect class AuthResult { + public val user: FirebaseUser? } -expect class AuthTokenResult { +public expect class AuthTokenResult { // val authTimestamp: Long - val claims: Map + public val claims: Map + // val expirationTimestamp: Long // val issuedAtTimestamp: Long - val signInProvider: String? - val token: String? + public val signInProvider: String? + public val token: String? } -sealed class ActionCodeResult { - object SignInWithEmailLink : ActionCodeResult() - class PasswordReset internal constructor(val email: String) : ActionCodeResult() - class VerifyEmail internal constructor(val email: String) : ActionCodeResult() - class RecoverEmail internal constructor(val email: String, val previousEmail: String) : ActionCodeResult() - class VerifyBeforeChangeEmail internal constructor(val email: String, val previousEmail: String) : ActionCodeResult() - class RevertSecondFactorAddition internal constructor(val email: String, val multiFactorInfo: MultiFactorInfo?) : ActionCodeResult() +public sealed class ActionCodeResult { + public data object SignInWithEmailLink : ActionCodeResult() + public class PasswordReset internal constructor(public val email: String) : ActionCodeResult() + public class VerifyEmail internal constructor(public val email: String) : ActionCodeResult() + public class RecoverEmail internal constructor(public val email: String, public val previousEmail: String) : ActionCodeResult() + public class VerifyBeforeChangeEmail internal constructor(public val email: String, public val previousEmail: String) : ActionCodeResult() + public class RevertSecondFactorAddition internal constructor(public val email: String, public val multiFactorInfo: MultiFactorInfo?) : ActionCodeResult() } -data class ActionCodeSettings( +public data class ActionCodeSettings( val url: String, val androidPackageName: AndroidPackageName? = null, val dynamicLinkDomain: String? = null, val canHandleCodeInApp: Boolean = false, - val iOSBundleId: String? = null + val iOSBundleId: String? = null, ) -data class AndroidPackageName( +public data class AndroidPackageName( val packageName: String, val installIfNotAvailable: Boolean = true, - val minimumVersion: String? = null + val minimumVersion: String? = null, ) -expect open class FirebaseAuthException : FirebaseException -expect class FirebaseAuthActionCodeException : FirebaseAuthException -expect class FirebaseAuthEmailException : FirebaseAuthException -expect open class FirebaseAuthInvalidCredentialsException : FirebaseAuthException -expect class FirebaseAuthWeakPasswordException: FirebaseAuthInvalidCredentialsException -expect class FirebaseAuthInvalidUserException : FirebaseAuthException -expect class FirebaseAuthMultiFactorException: FirebaseAuthException -expect class FirebaseAuthRecentLoginRequiredException : FirebaseAuthException -expect class FirebaseAuthUserCollisionException : FirebaseAuthException -expect class FirebaseAuthWebException : FirebaseAuthException +public expect open class FirebaseAuthException : FirebaseException +public expect class FirebaseAuthActionCodeException : FirebaseAuthException +public expect class FirebaseAuthEmailException : FirebaseAuthException +public expect open class FirebaseAuthInvalidCredentialsException : FirebaseAuthException +public expect class FirebaseAuthWeakPasswordException : FirebaseAuthInvalidCredentialsException +public expect class FirebaseAuthInvalidUserException : FirebaseAuthException +public expect class FirebaseAuthMultiFactorException : FirebaseAuthException +public expect class FirebaseAuthRecentLoginRequiredException : FirebaseAuthException +public expect class FirebaseAuthUserCollisionException : FirebaseAuthException +public expect class FirebaseAuthWebException : FirebaseAuthException diff --git a/firebase-auth/src/commonMain/kotlin/dev/gitlive/firebase/auth/credentials.kt b/firebase-auth/src/commonMain/kotlin/dev/gitlive/firebase/auth/credentials.kt index 28ed0b801..c7ea6e450 100644 --- a/firebase-auth/src/commonMain/kotlin/dev/gitlive/firebase/auth/credentials.kt +++ b/firebase-auth/src/commonMain/kotlin/dev/gitlive/firebase/auth/credentials.kt @@ -6,48 +6,48 @@ package dev.gitlive.firebase.auth import dev.gitlive.firebase.Firebase -expect open class AuthCredential { - val providerId: String +public expect open class AuthCredential { + public val providerId: String } -expect class PhoneAuthCredential : AuthCredential +public expect class PhoneAuthCredential : AuthCredential -expect class OAuthCredential : AuthCredential +public expect class OAuthCredential : AuthCredential -expect object EmailAuthProvider { - fun credential(email: String, password: String): AuthCredential - fun credentialWithLink(email: String, emailLink: String): AuthCredential +public expect object EmailAuthProvider { + public fun credential(email: String, password: String): AuthCredential + public fun credentialWithLink(email: String, emailLink: String): AuthCredential } -expect object FacebookAuthProvider { - fun credential(accessToken: String): AuthCredential +public expect object FacebookAuthProvider { + public fun credential(accessToken: String): AuthCredential } -expect object GithubAuthProvider { - fun credential(token: String): AuthCredential +public expect object GithubAuthProvider { + public fun credential(token: String): AuthCredential } -expect object GoogleAuthProvider { - fun credential(idToken: String?, accessToken: String?): AuthCredential +public expect object GoogleAuthProvider { + public fun credential(idToken: String?, accessToken: String?): AuthCredential } -expect class OAuthProvider constructor( +public expect class OAuthProvider( provider: String, scopes: List = emptyList(), customParameters: Map = emptyMap(), - auth: FirebaseAuth = Firebase.auth + auth: FirebaseAuth = Firebase.auth, ) { - companion object { - fun credential(providerId: String, accessToken: String? = null, idToken: String? = null, rawNonce: String? = null): OAuthCredential + public companion object { + public fun credential(providerId: String, accessToken: String? = null, idToken: String? = null, rawNonce: String? = null): OAuthCredential } } -expect class PhoneAuthProvider constructor(auth: FirebaseAuth = Firebase.auth) { - fun credential(verificationId: String, smsCode: String): PhoneAuthCredential - suspend fun verifyPhoneNumber(phoneNumber: String, verificationProvider: PhoneVerificationProvider): AuthCredential +public expect class PhoneAuthProvider(auth: FirebaseAuth = Firebase.auth) { + public fun credential(verificationId: String, smsCode: String): PhoneAuthCredential + public suspend fun verifyPhoneNumber(phoneNumber: String, verificationProvider: PhoneVerificationProvider): AuthCredential } -expect interface PhoneVerificationProvider +public expect interface PhoneVerificationProvider -expect object TwitterAuthProvider { - fun credential(token: String, secret: String): AuthCredential +public expect object TwitterAuthProvider { + public fun credential(token: String, secret: String): AuthCredential } diff --git a/firebase-auth/src/commonMain/kotlin/dev/gitlive/firebase/auth/multifactor.kt b/firebase-auth/src/commonMain/kotlin/dev/gitlive/firebase/auth/multifactor.kt index 04d3b11aa..4b52aebe2 100644 --- a/firebase-auth/src/commonMain/kotlin/dev/gitlive/firebase/auth/multifactor.kt +++ b/firebase-auth/src/commonMain/kotlin/dev/gitlive/firebase/auth/multifactor.kt @@ -4,31 +4,31 @@ package dev.gitlive.firebase.auth -expect class MultiFactor { - val enrolledFactors: List - suspend fun enroll(multiFactorAssertion: MultiFactorAssertion, displayName: String?) - suspend fun getSession(): MultiFactorSession - suspend fun unenroll(multiFactorInfo: MultiFactorInfo) - suspend fun unenroll(factorUid: String) +public expect class MultiFactor { + public val enrolledFactors: List + public suspend fun enroll(multiFactorAssertion: MultiFactorAssertion, displayName: String?) + public suspend fun getSession(): MultiFactorSession + public suspend fun unenroll(multiFactorInfo: MultiFactorInfo) + public suspend fun unenroll(factorUid: String) } -expect class MultiFactorInfo { - val displayName: String? - val enrollmentTime: Double - val factorId: String - val uid: String +public expect class MultiFactorInfo { + public val displayName: String? + public val enrollmentTime: Double + public val factorId: String + public val uid: String } -expect class MultiFactorAssertion { - val factorId: String +public expect class MultiFactorAssertion { + public val factorId: String } -expect class MultiFactorSession +public expect class MultiFactorSession -expect class MultiFactorResolver { - val auth: FirebaseAuth - val hints: List - val session: MultiFactorSession +public expect class MultiFactorResolver { + public val auth: FirebaseAuth + public val hints: List + public val session: MultiFactorSession - suspend fun resolveSignIn(assertion: MultiFactorAssertion): AuthResult -} \ No newline at end of file + public suspend fun resolveSignIn(assertion: MultiFactorAssertion): AuthResult +} diff --git a/firebase-auth/src/commonMain/kotlin/dev/gitlive/firebase/auth/user.kt b/firebase-auth/src/commonMain/kotlin/dev/gitlive/firebase/auth/user.kt index e7aa36217..61422f4f3 100644 --- a/firebase-auth/src/commonMain/kotlin/dev/gitlive/firebase/auth/user.kt +++ b/firebase-auth/src/commonMain/kotlin/dev/gitlive/firebase/auth/user.kt @@ -4,45 +4,46 @@ package dev.gitlive.firebase.auth -expect class FirebaseUser { - val uid: String - val displayName: String? - val email: String? - val phoneNumber: String? - val photoURL: String? - val isAnonymous: Boolean - val isEmailVerified: Boolean - val metaData: UserMetaData? - val multiFactor: MultiFactor - val providerData: List - val providerId: String - suspend fun delete() - suspend fun reload() - suspend fun getIdToken(forceRefresh: Boolean): String? - suspend fun getIdTokenResult(forceRefresh: Boolean): AuthTokenResult - suspend fun linkWithCredential(credential: AuthCredential): AuthResult - suspend fun reauthenticate(credential: AuthCredential) - suspend fun reauthenticateAndRetrieveData(credential: AuthCredential): AuthResult - suspend fun sendEmailVerification(actionCodeSettings: ActionCodeSettings? = null) - suspend fun unlink(provider: String): FirebaseUser? +public expect class FirebaseUser { + public val uid: String + public val displayName: String? + public val email: String? + public val phoneNumber: String? + public val photoURL: String? + public val isAnonymous: Boolean + public val isEmailVerified: Boolean + public val metaData: UserMetaData? + public val multiFactor: MultiFactor + public val providerData: List + public val providerId: String + public suspend fun delete() + public suspend fun reload() + public suspend fun getIdToken(forceRefresh: Boolean): String? + public suspend fun getIdTokenResult(forceRefresh: Boolean): AuthTokenResult + public suspend fun linkWithCredential(credential: AuthCredential): AuthResult + public suspend fun reauthenticate(credential: AuthCredential) + public suspend fun reauthenticateAndRetrieveData(credential: AuthCredential): AuthResult + public suspend fun sendEmailVerification(actionCodeSettings: ActionCodeSettings? = null) + public suspend fun unlink(provider: String): FirebaseUser? + @Deprecated("Use verifyBeforeUpdateEmail instead", replaceWith = ReplaceWith("verifyBeforeUpdateEmail(email)")) - suspend fun updateEmail(email: String) - suspend fun updatePassword(password: String) - suspend fun updatePhoneNumber(credential: PhoneAuthCredential) - suspend fun updateProfile(displayName: String? = this.displayName, photoUrl: String? = this.photoURL) - suspend fun verifyBeforeUpdateEmail(newEmail: String, actionCodeSettings: ActionCodeSettings? = null) + public suspend fun updateEmail(email: String) + public suspend fun updatePassword(password: String) + public suspend fun updatePhoneNumber(credential: PhoneAuthCredential) + public suspend fun updateProfile(displayName: String? = this.displayName, photoUrl: String? = this.photoURL) + public suspend fun verifyBeforeUpdateEmail(newEmail: String, actionCodeSettings: ActionCodeSettings? = null) } -expect class UserInfo { - val displayName: String? - val email: String? - val phoneNumber: String? - val photoURL: String? - val providerId: String - val uid: String +public expect class UserInfo { + public val displayName: String? + public val email: String? + public val phoneNumber: String? + public val photoURL: String? + public val providerId: String + public val uid: String } -expect class UserMetaData { - val creationTime: Double? - val lastSignInTime: Double? +public expect class UserMetaData { + public val creationTime: Double? + public val lastSignInTime: Double? } diff --git a/firebase-auth/src/commonTest/kotlin/dev/gitlive/firebase/auth/auth.kt b/firebase-auth/src/commonTest/kotlin/dev/gitlive/firebase/auth/auth.kt index 0c36bea7b..9dcf36903 100644 --- a/firebase-auth/src/commonTest/kotlin/dev/gitlive/firebase/auth/auth.kt +++ b/firebase-auth/src/commonTest/kotlin/dev/gitlive/firebase/auth/auth.kt @@ -32,8 +32,8 @@ class FirebaseAuthTest { databaseUrl = "https://fir-kotlin-sdk.firebaseio.com", storageBucket = "fir-kotlin-sdk.appspot.com", projectId = "fir-kotlin-sdk", - gcmSenderId = "846484016111" - ) + gcmSenderId = "846484016111", + ), ) auth = Firebase.auth(app).apply { diff --git a/firebase-auth/src/iosMain/kotlin/dev/gitlive/firebase/auth/auth.kt b/firebase-auth/src/iosMain/kotlin/dev/gitlive/firebase/auth/auth.kt index 486deaefa..9e86469c9 100644 --- a/firebase-auth/src/iosMain/kotlin/dev/gitlive/firebase/auth/auth.kt +++ b/firebase-auth/src/iosMain/kotlin/dev/gitlive/firebase/auth/auth.kt @@ -14,79 +14,80 @@ import kotlinx.cinterop.* import kotlinx.coroutines.CompletableDeferred import kotlinx.coroutines.channels.awaitClose import kotlinx.coroutines.flow.callbackFlow +import kotlinx.coroutines.flow.Flow import platform.Foundation.NSError import platform.Foundation.NSURL - -actual val Firebase.auth +public actual val Firebase.auth: FirebaseAuth get() = FirebaseAuth(FIRAuth.auth()) -@Suppress("CAST_NEVER_SUCCEEDS") -actual fun Firebase.auth(app: FirebaseApp): FirebaseAuth = FirebaseAuth( - FIRAuth.authWithApp(app.ios as objcnames.classes.FIRApp) +public actual fun Firebase.auth(app: FirebaseApp): FirebaseAuth = FirebaseAuth( + FIRAuth.authWithApp(app.ios as objcnames.classes.FIRApp), ) -actual class FirebaseAuth internal constructor(val ios: FIRAuth) { +public actual class FirebaseAuth internal constructor(public val ios: FIRAuth) { - actual val currentUser: FirebaseUser? + public actual val currentUser: FirebaseUser? get() = ios.currentUser?.let { FirebaseUser(it) } - actual val authStateChanged get() = callbackFlow { + public actual val authStateChanged: Flow get() = callbackFlow { val handle = ios.addAuthStateDidChangeListener { _, user -> trySend(user?.let { FirebaseUser(it) }) } awaitClose { ios.removeAuthStateDidChangeListener(handle) } } - actual val idTokenChanged get() = callbackFlow { + public actual val idTokenChanged: Flow get() = callbackFlow { val handle = ios.addIDTokenDidChangeListener { _, user -> trySend(user?.let { FirebaseUser(it) }) } awaitClose { ios.removeIDTokenDidChangeListener(handle) } } - actual var languageCode: String + public actual var languageCode: String get() = ios.languageCode ?: "" - set(value) { ios.setLanguageCode(value) } + set(value) { + ios.setLanguageCode(value) + } - actual suspend fun applyActionCode(code: String) = ios.await { applyActionCode(code, it) }.run { Unit } - actual suspend fun confirmPasswordReset(code: String, newPassword: String) = ios.await { confirmPasswordResetWithCode(code, newPassword, it) }.run { Unit } + public actual suspend fun applyActionCode(code: String): Unit = ios.await { applyActionCode(code, it) } + public actual suspend fun confirmPasswordReset(code: String, newPassword: String): Unit = ios.await { confirmPasswordResetWithCode(code, newPassword, it) } - actual suspend fun createUserWithEmailAndPassword(email: String, password: String) = + public actual suspend fun createUserWithEmailAndPassword(email: String, password: String): AuthResult = AuthResult(ios.awaitResult { createUserWithEmail(email = email, password = password, completion = it) }) @Suppress("UNCHECKED_CAST") - actual suspend fun fetchSignInMethodsForEmail(email: String) = + public actual suspend fun fetchSignInMethodsForEmail(email: String): List = ios.awaitResult?> { fetchSignInMethodsForEmail(email, it) }.orEmpty() as List - actual suspend fun sendPasswordResetEmail(email: String, actionCodeSettings: ActionCodeSettings?) { + public actual suspend fun sendPasswordResetEmail(email: String, actionCodeSettings: ActionCodeSettings?) { ios.await { actionCodeSettings?.let { actionSettings -> sendPasswordResetWithEmail(email, actionSettings.toIos(), it) } ?: sendPasswordResetWithEmail(email = email, completion = it) } } - actual suspend fun sendSignInLinkToEmail(email: String, actionCodeSettings: ActionCodeSettings) = ios.await { sendSignInLinkToEmail(email, actionCodeSettings.toIos(), it) }.run { Unit } + public actual suspend fun sendSignInLinkToEmail(email: String, actionCodeSettings: ActionCodeSettings): Unit = ios.await { sendSignInLinkToEmail(email, actionCodeSettings.toIos(), it) } - actual fun isSignInWithEmailLink(link: String) = ios.isSignInWithEmailLink(link) + public actual fun isSignInWithEmailLink(link: String): Boolean = ios.isSignInWithEmailLink(link) - actual suspend fun signInWithEmailAndPassword(email: String, password: String) = + public actual suspend fun signInWithEmailAndPassword(email: String, password: String): AuthResult = AuthResult(ios.awaitResult { signInWithEmail(email = email, password = password, completion = it) }) - actual suspend fun signInWithCustomToken(token: String) = + public actual suspend fun signInWithCustomToken(token: String): AuthResult = AuthResult(ios.awaitResult { signInWithCustomToken(token, it) }) - actual suspend fun signInAnonymously() = + public actual suspend fun signInAnonymously(): AuthResult = AuthResult(ios.awaitResult { signInAnonymouslyWithCompletion(it) }) - actual suspend fun signInWithCredential(authCredential: AuthCredential) = + public actual suspend fun signInWithCredential(authCredential: AuthCredential): AuthResult = AuthResult(ios.awaitResult { signInWithCredential(authCredential.ios, it) }) - actual suspend fun signInWithEmailLink(email: String, link: String) = + public actual suspend fun signInWithEmailLink(email: String, link: String): AuthResult = AuthResult(ios.awaitResult { signInWithEmail(email = email, link = link, completion = it) }) - actual suspend fun signOut() = ios.throwError { signOut(it) }.run { Unit } + public actual suspend fun signOut(): Unit = ios.throwError { signOut(it) } - actual suspend fun updateCurrentUser(user: FirebaseUser) = ios.await { updateCurrentUser(user.ios, it) }.run { Unit } - actual suspend fun verifyPasswordResetCode(code: String): String = ios.awaitResult { verifyPasswordResetCode(code, it) } + public actual suspend fun updateCurrentUser(user: FirebaseUser): Unit = ios.await { updateCurrentUser(user.ios, it) } + public actual suspend fun verifyPasswordResetCode(code: String): String = ios.awaitResult { verifyPasswordResetCode(code, it) } - actual suspend fun checkActionCode(code: String): T { + public actual suspend fun checkActionCode(code: String): T { val result: FIRActionCodeInfo = ios.awaitResult { checkActionCode(code, it) } @Suppress("UNCHECKED_CAST") - return when(result.operation) { + return when (result.operation) { FIRActionCodeOperationEmailLink -> SignInWithEmailLink FIRActionCodeOperationVerifyEmail -> VerifyEmail(result.email!!) FIRActionCodeOperationPasswordReset -> PasswordReset(result.email!!) @@ -98,47 +99,48 @@ actual class FirebaseAuth internal constructor(val ios: FIRAuth) { } as T } - actual fun useEmulator(host: String, port: Int) = ios.useEmulatorWithHost(host, port.toLong()) + public actual fun useEmulator(host: String, port: Int): Unit = ios.useEmulatorWithHost(host, port.toLong()) } -actual class AuthResult internal constructor(val ios: FIRAuthDataResult) { - actual val user: FirebaseUser? +public actual class AuthResult internal constructor(public val ios: FIRAuthDataResult) { + public actual val user: FirebaseUser? get() = FirebaseUser(ios.user) } -actual class AuthTokenResult(val ios: FIRAuthTokenResult) { +public actual class AuthTokenResult(public val ios: FIRAuthTokenResult) { // actual val authTimestamp: Long // get() = ios.authDate - actual val claims: Map + public actual val claims: Map get() = ios.claims.map { it.key.toString() to it.value as Any }.toMap() + // actual val expirationTimestamp: Long // get() = ios.expirationDate // actual val issuedAtTimestamp: Long // get() = ios.issuedAtDate - actual val signInProvider: String? + public actual val signInProvider: String? get() = ios.signInProvider - actual val token: String? + public actual val token: String? get() = ios.token } internal fun ActionCodeSettings.toIos() = FIRActionCodeSettings().also { - it.URL = NSURL.URLWithString(url) + it.URL = NSURL.URLWithString(url) androidPackageName?.run { it.setAndroidPackageName(packageName, installIfNotAvailable, minimumVersion) } it.dynamicLinkDomain = dynamicLinkDomain it.handleCodeInApp = canHandleCodeInApp iOSBundleId?.run { it.setIOSBundleID(this) } } -actual open class FirebaseAuthException(message: String): FirebaseException(message) -actual open class FirebaseAuthActionCodeException(message: String): FirebaseAuthException(message) -actual open class FirebaseAuthEmailException(message: String): FirebaseAuthException(message) -actual open class FirebaseAuthInvalidCredentialsException(message: String): FirebaseAuthException(message) -actual open class FirebaseAuthWeakPasswordException(message: String): FirebaseAuthInvalidCredentialsException(message) -actual open class FirebaseAuthInvalidUserException(message: String): FirebaseAuthException(message) -actual open class FirebaseAuthMultiFactorException(message: String): FirebaseAuthException(message) -actual open class FirebaseAuthRecentLoginRequiredException(message: String): FirebaseAuthException(message) -actual open class FirebaseAuthUserCollisionException(message: String): FirebaseAuthException(message) -actual open class FirebaseAuthWebException(message: String): FirebaseAuthException(message) +public actual open class FirebaseAuthException(message: String) : FirebaseException(message) +public actual open class FirebaseAuthActionCodeException(message: String) : FirebaseAuthException(message) +public actual open class FirebaseAuthEmailException(message: String) : FirebaseAuthException(message) +public actual open class FirebaseAuthInvalidCredentialsException(message: String) : FirebaseAuthException(message) +public actual open class FirebaseAuthWeakPasswordException(message: String) : FirebaseAuthInvalidCredentialsException(message) +public actual open class FirebaseAuthInvalidUserException(message: String) : FirebaseAuthException(message) +public actual open class FirebaseAuthMultiFactorException(message: String) : FirebaseAuthException(message) +public actual open class FirebaseAuthRecentLoginRequiredException(message: String) : FirebaseAuthException(message) +public actual open class FirebaseAuthUserCollisionException(message: String) : FirebaseAuthException(message) +public actual open class FirebaseAuthWebException(message: String) : FirebaseAuthException(message) internal fun T.throwError(block: T.(errorPointer: CPointer>) -> R): R { memScoped { @@ -155,7 +157,7 @@ internal fun T.throwError(block: T.(errorPointer: CPointer T.awaitResult(function: T.(callback: (R?, NSError?) -> Unit) -> Unit): R { val job = CompletableDeferred() function { result, error -> - if(error == null) { + if (error == null) { job.complete(result) } else { job.completeExceptionally(error.toException()) @@ -167,7 +169,7 @@ internal suspend inline fun T.awaitResult(function: T.(callback: internal suspend inline fun T.await(function: T.(callback: (NSError?) -> Unit) -> Unit) { val job = CompletableDeferred() function { error -> - if(error == null) { + if (error == null) { job.complete(Unit) } else { job.completeExceptionally(error.toException()) @@ -176,10 +178,11 @@ internal suspend inline fun T.await(function: T.(callback: (NSError?) -> Uni job.await() } -private fun NSError.toException() = when(domain) { - FIRAuthErrorDomain -> when(code) { +private fun NSError.toException() = when (domain) { + FIRAuthErrorDomain -> when (code) { FIRAuthErrorCodeInvalidActionCode, - FIRAuthErrorCodeExpiredActionCode -> FirebaseAuthActionCodeException(toString()) + FIRAuthErrorCodeExpiredActionCode, + -> FirebaseAuthActionCodeException(toString()) FIRAuthErrorCodeInvalidEmail -> FirebaseAuthEmailException(toString()) @@ -191,7 +194,8 @@ private fun NSError.toException() = when(domain) { FIRAuthErrorCodeMissingVerificationID, FIRAuthErrorCodeMissingVerificationCode, FIRAuthErrorCodeUserTokenExpired, - FIRAuthErrorCodeInvalidCredential -> FirebaseAuthInvalidCredentialsException(toString()) + FIRAuthErrorCodeInvalidCredential, + -> FirebaseAuthInvalidCredentialsException(toString()) FIRAuthErrorCodeWeakPassword -> FirebaseAuthWeakPasswordException(toString()) @@ -202,15 +206,18 @@ private fun NSError.toException() = when(domain) { FIRAuthErrorCodeSecondFactorAlreadyEnrolled, FIRAuthErrorCodeSecondFactorRequired, FIRAuthErrorCodeMaximumSecondFactorCountExceeded, - FIRAuthErrorCodeMultiFactorInfoNotFound -> FirebaseAuthMultiFactorException(toString()) + FIRAuthErrorCodeMultiFactorInfoNotFound, + -> FirebaseAuthMultiFactorException(toString()) FIRAuthErrorCodeEmailAlreadyInUse, FIRAuthErrorCodeAccountExistsWithDifferentCredential, - FIRAuthErrorCodeCredentialAlreadyInUse -> FirebaseAuthUserCollisionException(toString()) + FIRAuthErrorCodeCredentialAlreadyInUse, + -> FirebaseAuthUserCollisionException(toString()) FIRAuthErrorCodeWebContextAlreadyPresented, FIRAuthErrorCodeWebContextCancelled, - FIRAuthErrorCodeWebInternalError -> FirebaseAuthWebException(toString()) + FIRAuthErrorCodeWebInternalError, + -> FirebaseAuthWebException(toString()) FIRAuthErrorCodeNetworkError -> FirebaseNetworkException(toString()) diff --git a/firebase-auth/src/iosMain/kotlin/dev/gitlive/firebase/auth/credentials.kt b/firebase-auth/src/iosMain/kotlin/dev/gitlive/firebase/auth/credentials.kt index ce052392f..217c4e49b 100644 --- a/firebase-auth/src/iosMain/kotlin/dev/gitlive/firebase/auth/credentials.kt +++ b/firebase-auth/src/iosMain/kotlin/dev/gitlive/firebase/auth/credentials.kt @@ -6,59 +6,59 @@ package dev.gitlive.firebase.auth import cocoapods.FirebaseAuth.* -actual open class AuthCredential(open val ios: FIRAuthCredential) { - actual val providerId: String +public actual open class AuthCredential(public open val ios: FIRAuthCredential) { + public actual val providerId: String get() = ios.provider } -actual class PhoneAuthCredential(override val ios: FIRPhoneAuthCredential) : AuthCredential(ios) -actual class OAuthCredential(override val ios: FIROAuthCredential) : AuthCredential(ios) +public actual class PhoneAuthCredential(override val ios: FIRPhoneAuthCredential) : AuthCredential(ios) +public actual class OAuthCredential(override val ios: FIROAuthCredential) : AuthCredential(ios) -actual object EmailAuthProvider { - actual fun credential( +public actual object EmailAuthProvider { + public actual fun credential( email: String, - password: String + password: String, ): AuthCredential = AuthCredential(FIREmailAuthProvider.credentialWithEmail(email = email, password = password)) - actual fun credentialWithLink( + public actual fun credentialWithLink( email: String, - emailLink: String + emailLink: String, ): AuthCredential = AuthCredential(FIREmailAuthProvider.credentialWithEmail(email = email, link = emailLink)) } -actual object FacebookAuthProvider { - actual fun credential(accessToken: String): AuthCredential = AuthCredential(FIRFacebookAuthProvider.credentialWithAccessToken(accessToken)) +public actual object FacebookAuthProvider { + public actual fun credential(accessToken: String): AuthCredential = AuthCredential(FIRFacebookAuthProvider.credentialWithAccessToken(accessToken)) } -actual object GithubAuthProvider { - actual fun credential(token: String): AuthCredential = AuthCredential(FIRGitHubAuthProvider.credentialWithToken(token)) +public actual object GithubAuthProvider { + public actual fun credential(token: String): AuthCredential = AuthCredential(FIRGitHubAuthProvider.credentialWithToken(token)) } -actual object GoogleAuthProvider { - actual fun credential(idToken: String?, accessToken: String?): AuthCredential { +public actual object GoogleAuthProvider { + public actual fun credential(idToken: String?, accessToken: String?): AuthCredential { requireNotNull(idToken) { "idToken must not be null" } requireNotNull(accessToken) { "accessToken must not be null" } return AuthCredential(FIRGoogleAuthProvider.credentialWithIDToken(idToken, accessToken)) } } -actual class OAuthProvider(val ios: FIROAuthProvider) { +public actual class OAuthProvider(public val ios: FIROAuthProvider) { - actual constructor( + public actual constructor( provider: String, scopes: List, customParameters: Map, - auth: FirebaseAuth + auth: FirebaseAuth, ) : this(FIROAuthProvider.providerWithProviderID(provider, auth.ios)) { ios.setScopes(scopes) @Suppress("UNCHECKED_CAST") ios.setCustomParameters(customParameters as Map) } - actual companion object { - actual fun credential(providerId: String, accessToken: String?, idToken: String?, rawNonce: String?): OAuthCredential { + public actual companion object { + public actual fun credential(providerId: String, accessToken: String?, idToken: String?, rawNonce: String?): OAuthCredential { val credential = when { idToken == null -> FIROAuthProvider.credentialWithProviderID(providerID = providerId, accessToken = accessToken!!) accessToken == null -> FIROAuthProvider.credentialWithProviderID(providerID = providerId, IDToken = idToken, rawNonce = rawNonce!!) @@ -70,24 +70,24 @@ actual class OAuthProvider(val ios: FIROAuthProvider) { } } -actual class PhoneAuthProvider(val ios: FIRPhoneAuthProvider) { +public actual class PhoneAuthProvider(public val ios: FIRPhoneAuthProvider) { - actual constructor(auth: FirebaseAuth) : this(FIRPhoneAuthProvider.providerWithAuth(auth.ios)) + public actual constructor(auth: FirebaseAuth) : this(FIRPhoneAuthProvider.providerWithAuth(auth.ios)) - actual fun credential(verificationId: String, smsCode: String): PhoneAuthCredential = PhoneAuthCredential(ios.credentialWithVerificationID(verificationId, smsCode)) + public actual fun credential(verificationId: String, smsCode: String): PhoneAuthCredential = PhoneAuthCredential(ios.credentialWithVerificationID(verificationId, smsCode)) - actual suspend fun verifyPhoneNumber(phoneNumber: String, verificationProvider: PhoneVerificationProvider): AuthCredential { + public actual suspend fun verifyPhoneNumber(phoneNumber: String, verificationProvider: PhoneVerificationProvider): AuthCredential { val verificationId: String = ios.awaitResult { ios.verifyPhoneNumber(phoneNumber, verificationProvider.delegate, it) } val verificationCode = verificationProvider.getVerificationCode() return credential(verificationId, verificationCode) } } -actual interface PhoneVerificationProvider { - val delegate: FIRAuthUIDelegateProtocol? - suspend fun getVerificationCode(): String +public actual interface PhoneVerificationProvider { + public val delegate: FIRAuthUIDelegateProtocol? + public suspend fun getVerificationCode(): String } -actual object TwitterAuthProvider { - actual fun credential(token: String, secret: String): AuthCredential = AuthCredential(FIRTwitterAuthProvider.credentialWithToken(token, secret)) +public actual object TwitterAuthProvider { + public actual fun credential(token: String, secret: String): AuthCredential = AuthCredential(FIRTwitterAuthProvider.credentialWithToken(token, secret)) } diff --git a/firebase-auth/src/iosMain/kotlin/dev/gitlive/firebase/auth/multifactor.kt b/firebase-auth/src/iosMain/kotlin/dev/gitlive/firebase/auth/multifactor.kt index 2822e7406..8d0a5d6e5 100644 --- a/firebase-auth/src/iosMain/kotlin/dev/gitlive/firebase/auth/multifactor.kt +++ b/firebase-auth/src/iosMain/kotlin/dev/gitlive/firebase/auth/multifactor.kt @@ -6,37 +6,37 @@ package dev.gitlive.firebase.auth import cocoapods.FirebaseAuth.* -actual class MultiFactor(val ios: FIRMultiFactor) { - actual val enrolledFactors: List - get() = ios.enrolledFactors.mapNotNull { info -> (info as? FIRMultiFactorInfo)?.let{ MultiFactorInfo(it) } } - actual suspend fun enroll(multiFactorAssertion: MultiFactorAssertion, displayName: String?) = ios.await { enrollWithAssertion(multiFactorAssertion.ios, displayName, it) }.run { Unit } - actual suspend fun getSession(): MultiFactorSession = MultiFactorSession(ios.awaitResult { getSessionWithCompletion(completion = it) }) - actual suspend fun unenroll(multiFactorInfo: MultiFactorInfo) = ios.await { unenrollWithInfo(multiFactorInfo.ios, it) }.run { Unit } - actual suspend fun unenroll(factorUid: String) = ios.await { unenrollWithFactorUID(factorUid, it) }.run { Unit } +public actual class MultiFactor(public val ios: FIRMultiFactor) { + public actual val enrolledFactors: List + get() = ios.enrolledFactors.mapNotNull { info -> (info as? FIRMultiFactorInfo)?.let { MultiFactorInfo(it) } } + public actual suspend fun enroll(multiFactorAssertion: MultiFactorAssertion, displayName: String?): Unit = ios.await { enrollWithAssertion(multiFactorAssertion.ios, displayName, it) } + public actual suspend fun getSession(): MultiFactorSession = MultiFactorSession(ios.awaitResult { getSessionWithCompletion(completion = it) }) + public actual suspend fun unenroll(multiFactorInfo: MultiFactorInfo): Unit = ios.await { unenrollWithInfo(multiFactorInfo.ios, it) } + public actual suspend fun unenroll(factorUid: String): Unit = ios.await { unenrollWithFactorUID(factorUid, it) } } -actual class MultiFactorInfo(val ios: FIRMultiFactorInfo) { - actual val displayName: String? +public actual class MultiFactorInfo(public val ios: FIRMultiFactorInfo) { + public actual val displayName: String? get() = ios.displayName - actual val enrollmentTime: Double - get() = ios.enrollmentDate.timeIntervalSinceReferenceDate.toDouble() - actual val factorId: String + public actual val enrollmentTime: Double + get() = ios.enrollmentDate.timeIntervalSinceReferenceDate + public actual val factorId: String get() = ios.factorID - actual val uid: String + public actual val uid: String get() = ios.UID } -actual class MultiFactorAssertion(val ios: FIRMultiFactorAssertion) { - actual val factorId: String +public actual class MultiFactorAssertion(public val ios: FIRMultiFactorAssertion) { + public actual val factorId: String get() = ios.factorID } -actual class MultiFactorSession(val ios: FIRMultiFactorSession) +public actual class MultiFactorSession(public val ios: FIRMultiFactorSession) -actual class MultiFactorResolver(val ios: FIRMultiFactorResolver) { - actual val auth: FirebaseAuth = FirebaseAuth(ios.auth) - actual val hints: List = ios.hints.mapNotNull { hint -> (hint as? FIRMultiFactorInfo)?.let { MultiFactorInfo(it) } } - actual val session: MultiFactorSession = MultiFactorSession(ios.session) +public actual class MultiFactorResolver(public val ios: FIRMultiFactorResolver) { + public actual val auth: FirebaseAuth = FirebaseAuth(ios.auth) + public actual val hints: List = ios.hints.mapNotNull { hint -> (hint as? FIRMultiFactorInfo)?.let { MultiFactorInfo(it) } } + public actual val session: MultiFactorSession = MultiFactorSession(ios.session) - actual suspend fun resolveSignIn(assertion: MultiFactorAssertion): AuthResult = AuthResult(ios.awaitResult { resolveSignInWithAssertion(assertion.ios, it) }) -} \ No newline at end of file + public actual suspend fun resolveSignIn(assertion: MultiFactorAssertion): AuthResult = AuthResult(ios.awaitResult { resolveSignInWithAssertion(assertion.ios, it) }) +} diff --git a/firebase-auth/src/iosMain/kotlin/dev/gitlive/firebase/auth/user.kt b/firebase-auth/src/iosMain/kotlin/dev/gitlive/firebase/auth/user.kt index 1a15122c9..3dd735a90 100644 --- a/firebase-auth/src/iosMain/kotlin/dev/gitlive/firebase/auth/user.kt +++ b/firebase-auth/src/iosMain/kotlin/dev/gitlive/firebase/auth/user.kt @@ -10,92 +10,93 @@ import cocoapods.FirebaseAuth.FIRUserInfoProtocol import cocoapods.FirebaseAuth.FIRUserMetadata import platform.Foundation.NSURL -actual class FirebaseUser internal constructor(val ios: FIRUser) { - actual val uid: String +public actual class FirebaseUser internal constructor(public val ios: FIRUser) { + public actual val uid: String get() = ios.uid - actual val displayName: String? + public actual val displayName: String? get() = ios.displayName - actual val email: String? + public actual val email: String? get() = ios.email - actual val phoneNumber: String? + public actual val phoneNumber: String? get() = ios.phoneNumber - actual val photoURL: String? + public actual val photoURL: String? get() = ios.photoURL?.absoluteString - actual val isAnonymous: Boolean + public actual val isAnonymous: Boolean get() = ios.anonymous - actual val isEmailVerified: Boolean + public actual val isEmailVerified: Boolean get() = ios.emailVerified - actual val metaData: UserMetaData? + public actual val metaData: UserMetaData? get() = UserMetaData(ios.metadata) - actual val multiFactor: MultiFactor + public actual val multiFactor: MultiFactor get() = MultiFactor(ios.multiFactor) - actual val providerData: List + public actual val providerData: List get() = ios.providerData.mapNotNull { provider -> (provider as? FIRUserInfoProtocol)?.let { UserInfo(it) } } - actual val providerId: String + public actual val providerId: String get() = ios.providerID - actual suspend fun delete() = ios.await { deleteWithCompletion(it) }.run { Unit } + public actual suspend fun delete(): Unit = ios.await { deleteWithCompletion(it) } - actual suspend fun reload() = ios.await { reloadWithCompletion(it) }.run { Unit } + public actual suspend fun reload(): Unit = ios.await { reloadWithCompletion(it) } - actual suspend fun getIdToken(forceRefresh: Boolean): String? = + public actual suspend fun getIdToken(forceRefresh: Boolean): String? = ios.awaitResult { getIDTokenForcingRefresh(forceRefresh, it) } - actual suspend fun getIdTokenResult(forceRefresh: Boolean): AuthTokenResult = + public actual suspend fun getIdTokenResult(forceRefresh: Boolean): AuthTokenResult = AuthTokenResult(ios.awaitResult { getIDTokenResultForcingRefresh(forceRefresh, it) }) - actual suspend fun linkWithCredential(credential: AuthCredential): AuthResult = + public actual suspend fun linkWithCredential(credential: AuthCredential): AuthResult = AuthResult(ios.awaitResult { linkWithCredential(credential.ios, it) }) - actual suspend fun reauthenticate(credential: AuthCredential) = - ios.awaitResult { reauthenticateWithCredential(credential.ios, it) }.run { Unit } + public actual suspend fun reauthenticate(credential: AuthCredential) { + ios.awaitResult { reauthenticateWithCredential(credential.ios, it) } + } - actual suspend fun reauthenticateAndRetrieveData(credential: AuthCredential): AuthResult = + public actual suspend fun reauthenticateAndRetrieveData(credential: AuthCredential): AuthResult = AuthResult(ios.awaitResult { reauthenticateWithCredential(credential.ios, it) }) - actual suspend fun sendEmailVerification(actionCodeSettings: ActionCodeSettings?) = ios.await { + public actual suspend fun sendEmailVerification(actionCodeSettings: ActionCodeSettings?): Unit = ios.await { actionCodeSettings?.let { settings -> sendEmailVerificationWithActionCodeSettings(settings.toIos(), it) } ?: sendEmailVerificationWithCompletion(it) } - actual suspend fun unlink(provider: String): FirebaseUser? { + public actual suspend fun unlink(provider: String): FirebaseUser? { val user: FIRUser? = ios.awaitResult { unlinkFromProvider(provider, it) } return user?.let { FirebaseUser(it) } } - actual suspend fun updateEmail(email: String) = ios.await { updateEmail(email, it) }.run { Unit } - actual suspend fun updatePassword(password: String) = ios.await { updatePassword(password, it) }.run { Unit } - actual suspend fun updatePhoneNumber(credential: PhoneAuthCredential) = ios.await { updatePhoneNumberCredential(credential.ios, it) }.run { Unit } - actual suspend fun updateProfile(displayName: String?, photoUrl: String?) { + public actual suspend fun updateEmail(email: String): Unit = ios.await { updateEmail(email, it) } + public actual suspend fun updatePassword(password: String): Unit = ios.await { updatePassword(password, it) } + public actual suspend fun updatePhoneNumber(credential: PhoneAuthCredential): Unit = ios.await { updatePhoneNumberCredential(credential.ios, it) } + public actual suspend fun updateProfile(displayName: String?, photoUrl: String?) { val request = ios.profileChangeRequest() .apply { setDisplayName(displayName) } .apply { setPhotoURL(photoUrl?.let { NSURL.URLWithString(it) }) } ios.await { request.commitChangesWithCompletion(it) } } - actual suspend fun verifyBeforeUpdateEmail(newEmail: String, actionCodeSettings: ActionCodeSettings?) = ios.await { + public actual suspend fun verifyBeforeUpdateEmail(newEmail: String, actionCodeSettings: ActionCodeSettings?): Unit = ios.await { actionCodeSettings?.let { actionSettings -> sendEmailVerificationBeforeUpdatingEmail(newEmail, actionSettings.toIos(), it) } ?: sendEmailVerificationBeforeUpdatingEmail(newEmail, it) - }.run { Unit } + } } -actual class UserInfo(val ios: FIRUserInfoProtocol) { - actual val displayName: String? +public actual class UserInfo(public val ios: FIRUserInfoProtocol) { + public actual val displayName: String? get() = ios.displayName - actual val email: String? + public actual val email: String? get() = ios.email - actual val phoneNumber: String? + public actual val phoneNumber: String? get() = ios.phoneNumber - actual val photoURL: String? + public actual val photoURL: String? get() = ios.photoURL?.absoluteString - actual val providerId: String + public actual val providerId: String get() = ios.providerID - actual val uid: String + public actual val uid: String get() = ios.uid } -actual class UserMetaData(val ios: FIRUserMetadata) { - actual val creationTime: Double? - get() = ios.creationDate?.timeIntervalSinceReferenceDate?.toDouble() - actual val lastSignInTime: Double? - get() = ios.lastSignInDate?.timeIntervalSinceReferenceDate?.toDouble() +public actual class UserMetaData(public val ios: FIRUserMetadata) { + public actual val creationTime: Double? + get() = ios.creationDate?.timeIntervalSinceReferenceDate + public actual val lastSignInTime: Double? + get() = ios.lastSignInDate?.timeIntervalSinceReferenceDate } diff --git a/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/auth.kt b/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/auth.kt index f2db371b4..c23c2a42b 100644 --- a/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/auth.kt +++ b/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/auth.kt @@ -11,120 +11,124 @@ import dev.gitlive.firebase.FirebaseNetworkException import dev.gitlive.firebase.auth.externals.* import kotlinx.coroutines.await import kotlinx.coroutines.channels.awaitClose +import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.callbackFlow import kotlin.js.json import dev.gitlive.firebase.auth.externals.AuthResult as JsAuthResult -actual val Firebase.auth +public actual val Firebase.auth: FirebaseAuth get() = rethrow { FirebaseAuth(getAuth()) } -actual fun Firebase.auth(app: FirebaseApp) = +public actual fun Firebase.auth(app: FirebaseApp): FirebaseAuth = rethrow { FirebaseAuth(getAuth(app.js)) } -actual class FirebaseAuth internal constructor(val js: Auth) { +public actual class FirebaseAuth internal constructor(public val js: Auth) { - actual val currentUser: FirebaseUser? + public actual val currentUser: FirebaseUser? get() = rethrow { js.currentUser?.let { FirebaseUser(it) } } - actual val authStateChanged get() = callbackFlow { + public actual val authStateChanged: Flow get() = callbackFlow { val unsubscribe = js.onAuthStateChanged { trySend(it?.let { FirebaseUser(it) }) } awaitClose { unsubscribe() } } - actual val idTokenChanged get() = callbackFlow { + public actual val idTokenChanged: Flow get() = callbackFlow { val unsubscribe = js.onIdTokenChanged { trySend(it?.let { FirebaseUser(it) }) } awaitClose { unsubscribe() } } - actual var languageCode: String + public actual var languageCode: String get() = js.languageCode ?: "" - set(value) { js.languageCode = value } + set(value) { + js.languageCode = value + } - actual suspend fun applyActionCode(code: String) = rethrow { applyActionCode(js, code).await() } - actual suspend fun confirmPasswordReset(code: String, newPassword: String) = rethrow { confirmPasswordReset(js, code, newPassword).await() } + public actual suspend fun applyActionCode(code: String): Unit = rethrow { applyActionCode(js, code).await() } + public actual suspend fun confirmPasswordReset(code: String, newPassword: String): Unit = rethrow { confirmPasswordReset(js, code, newPassword).await() } - actual suspend fun createUserWithEmailAndPassword(email: String, password: String) = + public actual suspend fun createUserWithEmailAndPassword(email: String, password: String): AuthResult = rethrow { AuthResult(createUserWithEmailAndPassword(js, email, password).await()) } - actual suspend fun fetchSignInMethodsForEmail(email: String): List = rethrow { fetchSignInMethodsForEmail(js, email).await().asList() } + public actual suspend fun fetchSignInMethodsForEmail(email: String): List = rethrow { fetchSignInMethodsForEmail(js, email).await().asList() } - actual suspend fun sendPasswordResetEmail(email: String, actionCodeSettings: ActionCodeSettings?) = + public actual suspend fun sendPasswordResetEmail(email: String, actionCodeSettings: ActionCodeSettings?): Unit = rethrow { sendPasswordResetEmail(js, email, actionCodeSettings?.toJson()).await() } - actual suspend fun sendSignInLinkToEmail(email: String, actionCodeSettings: ActionCodeSettings) = + public actual suspend fun sendSignInLinkToEmail(email: String, actionCodeSettings: ActionCodeSettings): Unit = rethrow { sendSignInLinkToEmail(js, email, actionCodeSettings.toJson()).await() } - actual fun isSignInWithEmailLink(link: String) = rethrow { isSignInWithEmailLink(js, link) } + public actual fun isSignInWithEmailLink(link: String): Boolean = rethrow { isSignInWithEmailLink(js, link) } - actual suspend fun signInWithEmailAndPassword(email: String, password: String) = + public actual suspend fun signInWithEmailAndPassword(email: String, password: String): AuthResult = rethrow { AuthResult(signInWithEmailAndPassword(js, email, password).await()) } - actual suspend fun signInWithCustomToken(token: String) = + public actual suspend fun signInWithCustomToken(token: String): AuthResult = rethrow { AuthResult(signInWithCustomToken(js, token).await()) } - actual suspend fun signInAnonymously() = + public actual suspend fun signInAnonymously(): AuthResult = rethrow { AuthResult(signInAnonymously(js).await()) } - actual suspend fun signInWithCredential(authCredential: AuthCredential) = + public actual suspend fun signInWithCredential(authCredential: AuthCredential): AuthResult = rethrow { AuthResult(signInWithCredential(js, authCredential.js).await()) } - actual suspend fun signInWithEmailLink(email: String, link: String) = + public actual suspend fun signInWithEmailLink(email: String, link: String): AuthResult = rethrow { AuthResult(signInWithEmailLink(js, email, link).await()) } - actual suspend fun signOut() = rethrow { signOut(js).await() } + public actual suspend fun signOut(): Unit = rethrow { signOut(js).await() } - actual suspend fun updateCurrentUser(user: FirebaseUser) = + public actual suspend fun updateCurrentUser(user: FirebaseUser): Unit = rethrow { updateCurrentUser(js, user.js).await() } - actual suspend fun verifyPasswordResetCode(code: String): String = + public actual suspend fun verifyPasswordResetCode(code: String): String = rethrow { verifyPasswordResetCode(js, code).await() } - actual suspend fun checkActionCode(code: String): T = rethrow { + public actual suspend fun checkActionCode(code: String): T = rethrow { val result = checkActionCode(js, code).await() @Suppress("UNCHECKED_CAST") - return when(result.operation) { + return when (result.operation) { "EMAIL_SIGNIN" -> ActionCodeResult.SignInWithEmailLink "VERIFY_EMAIL" -> ActionCodeResult.VerifyEmail(result.data.email!!) "PASSWORD_RESET" -> ActionCodeResult.PasswordReset(result.data.email!!) "RECOVER_EMAIL" -> ActionCodeResult.RecoverEmail(result.data.email!!, result.data.previousEmail!!) "VERIFY_AND_CHANGE_EMAIL" -> ActionCodeResult.VerifyBeforeChangeEmail( result.data.email!!, - result.data.previousEmail!! + result.data.previousEmail!!, ) "REVERT_SECOND_FACTOR_ADDITION" -> ActionCodeResult.RevertSecondFactorAddition( result.data.email!!, - result.data.multiFactorInfo?.let { MultiFactorInfo(it) } + result.data.multiFactorInfo?.let { MultiFactorInfo(it) }, ) else -> throw UnsupportedOperationException(result.operation) } as T } - actual fun useEmulator(host: String, port: Int) = rethrow { connectAuthEmulator(js, "http://$host:$port") } + public actual fun useEmulator(host: String, port: Int): Unit = rethrow { connectAuthEmulator(js, "http://$host:$port") } } -actual class AuthResult internal constructor(val js: JsAuthResult) { - actual val user: FirebaseUser? +public actual class AuthResult internal constructor(public val js: JsAuthResult) { + public actual val user: FirebaseUser? get() = rethrow { js.user?.let { FirebaseUser(it) } } } -actual class AuthTokenResult(val js: IdTokenResult) { +public actual class AuthTokenResult(public val js: IdTokenResult) { // actual val authTimestamp: Long // get() = js.authTime - actual val claims: Map - get() = (js("Object").keys(js.claims) as Array).mapNotNull { - key -> js.claims[key]?.let { key to it } + public actual val claims: Map + get() = (js("Object").keys(js.claims) as Array).mapNotNull { key -> + js.claims[key]?.let { key to it } }.toMap() + // actual val expirationTimestamp: Long // get() = android.expirationTime // actual val issuedAtTimestamp: Long // get() = js.issuedAtTime - actual val signInProvider: String? + public actual val signInProvider: String? get() = js.signInProvider - actual val token: String? + public actual val token: String? get() = js.token } @@ -133,20 +137,19 @@ internal fun ActionCodeSettings.toJson() = json( "android" to (androidPackageName?.run { json("installApp" to installIfNotAvailable, "minimumVersion" to minimumVersion, "packageName" to packageName) } ?: undefined), "dynamicLinkDomain" to (dynamicLinkDomain ?: undefined), "handleCodeInApp" to canHandleCodeInApp, - "ios" to (iOSBundleId?.run { json("bundleId" to iOSBundleId) } ?: undefined) + "ios" to (iOSBundleId?.run { json("bundleId" to iOSBundleId) } ?: undefined), ) -actual open class FirebaseAuthException(code: String?, cause: Throwable): FirebaseException(code, cause) -actual open class FirebaseAuthActionCodeException(code: String?, cause: Throwable): FirebaseAuthException(code, cause) -actual open class FirebaseAuthEmailException(code: String?, cause: Throwable): FirebaseAuthException(code, cause) -actual open class FirebaseAuthInvalidCredentialsException(code: String?, cause: Throwable): FirebaseAuthException(code, cause) -actual open class FirebaseAuthWeakPasswordException(code: String?, cause: Throwable): FirebaseAuthInvalidCredentialsException(code, cause) -actual open class FirebaseAuthInvalidUserException(code: String?, cause: Throwable): FirebaseAuthException(code, cause) -actual open class FirebaseAuthMultiFactorException(code: String?, cause: Throwable): FirebaseAuthException(code, cause) -actual open class FirebaseAuthRecentLoginRequiredException(code: String?, cause: Throwable): FirebaseAuthException(code, cause) -actual open class FirebaseAuthUserCollisionException(code: String?, cause: Throwable): FirebaseAuthException(code, cause) -actual open class FirebaseAuthWebException(code: String?, cause: Throwable): FirebaseAuthException(code, cause) - +public actual open class FirebaseAuthException(code: String?, cause: Throwable) : FirebaseException(code, cause) +public actual open class FirebaseAuthActionCodeException(code: String?, cause: Throwable) : FirebaseAuthException(code, cause) +public actual open class FirebaseAuthEmailException(code: String?, cause: Throwable) : FirebaseAuthException(code, cause) +public actual open class FirebaseAuthInvalidCredentialsException(code: String?, cause: Throwable) : FirebaseAuthException(code, cause) +public actual open class FirebaseAuthWeakPasswordException(code: String?, cause: Throwable) : FirebaseAuthInvalidCredentialsException(code, cause) +public actual open class FirebaseAuthInvalidUserException(code: String?, cause: Throwable) : FirebaseAuthException(code, cause) +public actual open class FirebaseAuthMultiFactorException(code: String?, cause: Throwable) : FirebaseAuthException(code, cause) +public actual open class FirebaseAuthRecentLoginRequiredException(code: String?, cause: Throwable) : FirebaseAuthException(code, cause) +public actual open class FirebaseAuthUserCollisionException(code: String?, cause: Throwable) : FirebaseAuthException(code, cause) +public actual open class FirebaseAuthWebException(code: String?, cause: Throwable) : FirebaseAuthException(code, cause) internal inline fun T.rethrow(function: T.() -> R): R = dev.gitlive.firebase.auth.rethrow { function() } @@ -155,30 +158,32 @@ private inline fun rethrow(function: () -> R): R { return function() } catch (e: Exception) { throw e - } catch(e: dynamic) { + } catch (e: dynamic) { throw errorToException(e) } } -private fun errorToException(cause: dynamic) = when(val code = cause.code?.toString()?.lowercase()) { - "auth/invalid-user-token" -> FirebaseAuthInvalidUserException(code, cause) - "auth/requires-recent-login" -> FirebaseAuthRecentLoginRequiredException(code, cause) - "auth/user-disabled" -> FirebaseAuthInvalidUserException(code, cause) - "auth/user-token-expired" -> FirebaseAuthInvalidUserException(code, cause) - "auth/web-storage-unsupported" -> FirebaseAuthWebException(code, cause) - "auth/network-request-failed" -> FirebaseNetworkException(code, cause) - "auth/timeout" -> FirebaseNetworkException(code, cause) - "auth/weak-password" -> FirebaseAuthWeakPasswordException(code, cause) +private fun errorToException(cause: dynamic) = when (val code = cause.code?.toString()?.lowercase()) { + "auth/invalid-user-token" -> FirebaseAuthInvalidUserException(code, cause.unsafeCast()) + "auth/requires-recent-login" -> FirebaseAuthRecentLoginRequiredException(code, cause.unsafeCast()) + "auth/user-disabled" -> FirebaseAuthInvalidUserException(code, cause.unsafeCast()) + "auth/user-token-expired" -> FirebaseAuthInvalidUserException(code, cause.unsafeCast()) + "auth/web-storage-unsupported" -> FirebaseAuthWebException(code, cause.unsafeCast()) + "auth/network-request-failed" -> FirebaseNetworkException(code, cause.unsafeCast()) + "auth/timeout" -> FirebaseNetworkException(code, cause.unsafeCast()) + "auth/weak-password" -> FirebaseAuthWeakPasswordException(code, cause.unsafeCast()) "auth/invalid-credential", "auth/invalid-verification-code", "auth/missing-verification-code", "auth/invalid-verification-id", - "auth/missing-verification-id" -> FirebaseAuthInvalidCredentialsException(code, cause) + "auth/missing-verification-id", + -> FirebaseAuthInvalidCredentialsException(code, cause.unsafeCast()) "auth/maximum-second-factor-count-exceeded", - "auth/second-factor-already-in-use" -> FirebaseAuthMultiFactorException(code, cause) - "auth/credential-already-in-use" -> FirebaseAuthUserCollisionException(code, cause) - "auth/email-already-in-use" -> FirebaseAuthUserCollisionException(code, cause) - "auth/invalid-email" -> FirebaseAuthEmailException(code, cause) + "auth/second-factor-already-in-use", + -> FirebaseAuthMultiFactorException(code, cause.unsafeCast()) + "auth/credential-already-in-use" -> FirebaseAuthUserCollisionException(code, cause.unsafeCast()) + "auth/email-already-in-use" -> FirebaseAuthUserCollisionException(code, cause.unsafeCast()) + "auth/invalid-email" -> FirebaseAuthEmailException(code, cause.unsafeCast()) // "auth/app-deleted" -> // "auth/app-not-authorized" -> // "auth/argument-error" -> @@ -188,6 +193,6 @@ private fun errorToException(cause: dynamic) = when(val code = cause.code?.toStr // "auth/unauthorized-domain" -> else -> { println("Unknown error code in ${JSON.stringify(cause)}") - FirebaseAuthException(code, cause) + FirebaseAuthException(code, cause.unsafeCast()) } } diff --git a/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/credentials.kt b/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/credentials.kt index eb6fb9efe..cebe872d6 100644 --- a/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/credentials.kt +++ b/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/credentials.kt @@ -12,36 +12,36 @@ import kotlin.js.json import dev.gitlive.firebase.auth.externals.AuthCredential as JsAuthCredential import dev.gitlive.firebase.auth.externals.OAuthProvider as JsOAuthProvider -actual open class AuthCredential(val js: JsAuthCredential) { - actual val providerId: String +public actual open class AuthCredential(public val js: JsAuthCredential) { + public actual val providerId: String get() = js.providerId } -actual class PhoneAuthCredential(js: JsAuthCredential) : AuthCredential(js) -actual class OAuthCredential(js: JsAuthCredential) : AuthCredential(js) +public actual class PhoneAuthCredential(js: JsAuthCredential) : AuthCredential(js) +public actual class OAuthCredential(js: JsAuthCredential) : AuthCredential(js) -actual object EmailAuthProvider { - actual fun credential(email: String, password: String): AuthCredential = +public actual object EmailAuthProvider { + public actual fun credential(email: String, password: String): AuthCredential = AuthCredential(EmailAuthProvider.credential(email, password)) - actual fun credentialWithLink( + public actual fun credentialWithLink( email: String, - emailLink: String + emailLink: String, ): AuthCredential = AuthCredential(EmailAuthProvider.credentialWithLink(email, emailLink)) } -actual object FacebookAuthProvider { - actual fun credential(accessToken: String): AuthCredential = +public actual object FacebookAuthProvider { + public actual fun credential(accessToken: String): AuthCredential = AuthCredential(FacebookAuthProvider.credential(accessToken)) } -actual object GithubAuthProvider { - actual fun credential(token: String): AuthCredential = +public actual object GithubAuthProvider { + public actual fun credential(token: String): AuthCredential = AuthCredential(GithubAuthProvider.credential(token)) } -actual object GoogleAuthProvider { - actual fun credential(idToken: String?, accessToken: String?): AuthCredential { +public actual object GoogleAuthProvider { + public actual fun credential(idToken: String?, accessToken: String?): AuthCredential { require(idToken != null || accessToken != null) { "Both parameters are optional but at least one must be present." } @@ -49,52 +49,52 @@ actual object GoogleAuthProvider { } } -actual class OAuthProvider(val js: JsOAuthProvider) { +public actual class OAuthProvider(public val js: JsOAuthProvider) { - actual constructor( + public actual constructor( provider: String, scopes: List, customParameters: Map, - auth: FirebaseAuth + auth: FirebaseAuth, ) : this(JsOAuthProvider(provider)) { rethrow { scopes.forEach { js.addScope(it) } js.setCustomParameters(customParameters) } } - actual companion object { - actual fun credential(providerId: String, accessToken: String?, idToken: String?, rawNonce: String?): OAuthCredential = rethrow { + public actual companion object { + public actual fun credential(providerId: String, accessToken: String?, idToken: String?, rawNonce: String?): OAuthCredential = rethrow { JsOAuthProvider(providerId) .credential( json( "accessToken" to (accessToken ?: undefined), "idToken" to (idToken ?: undefined), - "rawNonce" to (rawNonce ?: undefined) + "rawNonce" to (rawNonce ?: undefined), ), - accessToken ?: undefined + accessToken ?: undefined, ) .let { OAuthCredential(it) } } } } -actual class PhoneAuthProvider(val js: PhoneAuthProvider) { +public actual class PhoneAuthProvider(public val js: PhoneAuthProvider) { - actual constructor(auth: FirebaseAuth) : this(PhoneAuthProvider(auth.js)) + public actual constructor(auth: FirebaseAuth) : this(PhoneAuthProvider(auth.js)) - actual fun credential(verificationId: String, smsCode: String): PhoneAuthCredential = PhoneAuthCredential(PhoneAuthProvider.credential(verificationId, smsCode)) - actual suspend fun verifyPhoneNumber(phoneNumber: String, verificationProvider: PhoneVerificationProvider): AuthCredential = rethrow { + public actual fun credential(verificationId: String, smsCode: String): PhoneAuthCredential = PhoneAuthCredential(PhoneAuthProvider.credential(verificationId, smsCode)) + public actual suspend fun verifyPhoneNumber(phoneNumber: String, verificationProvider: PhoneVerificationProvider): AuthCredential = rethrow { val verificationId = js.verifyPhoneNumber(phoneNumber, verificationProvider.verifier).await() val verificationCode = verificationProvider.getVerificationCode(verificationId) credential(verificationId, verificationCode) } } -actual interface PhoneVerificationProvider { - val verifier: ApplicationVerifier - suspend fun getVerificationCode(verificationId: String): String +public actual interface PhoneVerificationProvider { + public val verifier: ApplicationVerifier + public suspend fun getVerificationCode(verificationId: String): String } -actual object TwitterAuthProvider { - actual fun credential(token: String, secret: String): AuthCredential = AuthCredential(TwitterAuthProvider.credential(token, secret)) +public actual object TwitterAuthProvider { + public actual fun credential(token: String, secret: String): AuthCredential = AuthCredential(TwitterAuthProvider.credential(token, secret)) } diff --git a/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/externals/auth.kt b/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/externals/auth.kt index e3bf651d9..e535e6c22 100644 --- a/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/externals/auth.kt +++ b/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/externals/auth.kt @@ -8,292 +8,292 @@ import dev.gitlive.firebase.externals.FirebaseApp import kotlin.js.Json import kotlin.js.Promise -external fun applyActionCode(auth: Auth, code: String): Promise +public external fun applyActionCode(auth: Auth, code: String): Promise -external fun checkActionCode(auth: Auth, code: String): Promise +public external fun checkActionCode(auth: Auth, code: String): Promise -external fun confirmPasswordReset(auth: Auth, code: String, newPassword: String): Promise +public external fun confirmPasswordReset(auth: Auth, code: String, newPassword: String): Promise -external fun connectAuthEmulator(auth: Auth, url: String, options: Any? = definedExternally) +public external fun connectAuthEmulator(auth: Auth, url: String, options: Any? = definedExternally) -external fun createUserWithEmailAndPassword( +public external fun createUserWithEmailAndPassword( auth: Auth, email: String, - password: String + password: String, ): Promise -external fun deleteUser(user: User): Promise +public external fun deleteUser(user: User): Promise -external fun fetchSignInMethodsForEmail(auth: Auth, email: String): Promise> +public external fun fetchSignInMethodsForEmail(auth: Auth, email: String): Promise> -external fun getAuth(app: FirebaseApp? = definedExternally): Auth +public external fun getAuth(app: FirebaseApp? = definedExternally): Auth -external fun initializeAuth(app: FirebaseApp? = definedExternally, deps: dynamic = definedExternally): Auth +public external fun initializeAuth(app: FirebaseApp? = definedExternally, deps: dynamic = definedExternally): Auth -external fun getIdToken(user: User, forceRefresh: Boolean?): Promise +public external fun getIdToken(user: User, forceRefresh: Boolean?): Promise -external fun getIdTokenResult(user: User, forceRefresh: Boolean?): Promise +public external fun getIdTokenResult(user: User, forceRefresh: Boolean?): Promise -external fun isSignInWithEmailLink(auth: Auth, link: String): Boolean +public external fun isSignInWithEmailLink(auth: Auth, link: String): Boolean -external fun linkWithCredential(user: User, credential: AuthCredential): Promise +public external fun linkWithCredential(user: User, credential: AuthCredential): Promise -external fun multiFactor(user: User): MultiFactorUser +public external fun multiFactor(user: User): MultiFactorUser -external fun onAuthStateChanged(auth: Auth, nextOrObserver: (User?) -> Unit): Unsubscribe +public external fun onAuthStateChanged(auth: Auth, nextOrObserver: (User?) -> Unit): Unsubscribe -external fun onIdTokenChanged(auth: Auth, nextOrObserver: (User?) -> Unit): Unsubscribe +public external fun onIdTokenChanged(auth: Auth, nextOrObserver: (User?) -> Unit): Unsubscribe -external fun sendEmailVerification(user: User, actionCodeSettings: Any?): Promise +public external fun sendEmailVerification(user: User, actionCodeSettings: Any?): Promise -external fun reauthenticateWithCredential( +public external fun reauthenticateWithCredential( user: User, - credential: AuthCredential + credential: AuthCredential, ): Promise -external fun reload(user: User): Promise +public external fun reload(user: User): Promise -external fun sendPasswordResetEmail( +public external fun sendPasswordResetEmail( auth: Auth, email: String, - actionCodeSettings: Any? + actionCodeSettings: Any?, ): Promise -external fun sendSignInLinkToEmail( +public external fun sendSignInLinkToEmail( auth: Auth, email: String, - actionCodeSettings: Any? + actionCodeSettings: Any?, ): Promise -external fun signInAnonymously(auth: Auth): Promise +public external fun signInAnonymously(auth: Auth): Promise -external fun signInWithCredential(auth: Auth, authCredential: AuthCredential): Promise +public external fun signInWithCredential(auth: Auth, authCredential: AuthCredential): Promise -external fun signInWithCustomToken(auth: Auth, token: String): Promise +public external fun signInWithCustomToken(auth: Auth, token: String): Promise -external fun signInWithEmailAndPassword( +public external fun signInWithEmailAndPassword( auth: Auth, email: String, - password: String + password: String, ): Promise -external fun signInWithEmailLink(auth: Auth, email: String, link: String): Promise +public external fun signInWithEmailLink(auth: Auth, email: String, link: String): Promise -external fun signInWithPopup(auth: Auth, provider: AuthProvider): Promise +public external fun signInWithPopup(auth: Auth, provider: AuthProvider): Promise -external fun signInWithRedirect(auth: Auth, provider: AuthProvider): Promise +public external fun signInWithRedirect(auth: Auth, provider: AuthProvider): Promise -external fun getRedirectResult(auth: Auth): Promise +public external fun getRedirectResult(auth: Auth): Promise -external fun signOut(auth: Auth): Promise +public external fun signOut(auth: Auth): Promise -external fun unlink(user: User, providerId: String): Promise +public external fun unlink(user: User, providerId: String): Promise -external fun updateCurrentUser(auth: Auth, user: User?): Promise +public external fun updateCurrentUser(auth: Auth, user: User?): Promise -external fun updateEmail(user: User, newEmail: String): Promise +public external fun updateEmail(user: User, newEmail: String): Promise -external fun updatePassword(user: User, newPassword: String): Promise +public external fun updatePassword(user: User, newPassword: String): Promise -external fun updatePhoneNumber(user: User, phoneCredential: AuthCredential): Promise +public external fun updatePhoneNumber(user: User, phoneCredential: AuthCredential): Promise -external fun updateProfile(user: User, profile: Json): Promise +public external fun updateProfile(user: User, profile: Json): Promise -external fun verifyBeforeUpdateEmail( +public external fun verifyBeforeUpdateEmail( user: User, newEmail: String, - actionCodeSettings: Any? + actionCodeSettings: Any?, ): Promise -external fun verifyPasswordResetCode(auth: Auth, code: String): Promise +public external fun verifyPasswordResetCode(auth: Auth, code: String): Promise -external interface Auth { - val currentUser: User? - var languageCode: String? +public external interface Auth { + public val currentUser: User? + public var languageCode: String? - fun onAuthStateChanged(nextOrObserver: (User?) -> Unit): Unsubscribe - fun onIdTokenChanged(nextOrObserver: (User?) -> Unit): Unsubscribe - fun signOut(): Promise - fun updateCurrentUser(user: User?): Promise + public fun onAuthStateChanged(nextOrObserver: (User?) -> Unit): Unsubscribe + public fun onIdTokenChanged(nextOrObserver: (User?) -> Unit): Unsubscribe + public fun signOut(): Promise + public fun updateCurrentUser(user: User?): Promise } -external interface UserInfo { - val displayName: String? - val email: String? - val phoneNumber: String? - val photoURL: String? - val providerId: String - val uid: String +public external interface UserInfo { + public val displayName: String? + public val email: String? + public val phoneNumber: String? + public val photoURL: String? + public val providerId: String + public val uid: String } -external interface User : UserInfo { - val emailVerified: Boolean - val isAnonymous: Boolean - val metadata: UserMetadata - val providerData: Array - val refreshToken: String - val tenantId: String? - - fun delete(): Promise - fun getIdToken(forceRefresh: Boolean?): Promise - fun getIdTokenResult(forceRefresh: Boolean?): Promise - fun reload(): Promise +public external interface User : UserInfo { + public val emailVerified: Boolean + public val isAnonymous: Boolean + public val metadata: UserMetadata + public val providerData: Array + public val refreshToken: String + public val tenantId: String? + + public fun delete(): Promise + public fun getIdToken(forceRefresh: Boolean?): Promise + public fun getIdTokenResult(forceRefresh: Boolean?): Promise + public fun reload(): Promise } -external interface UserMetadata { - val creationTime: String? - val lastSignInTime: String? +public external interface UserMetadata { + public val creationTime: String? + public val lastSignInTime: String? } -external interface IdTokenResult { - val authTime: String - val claims: Json - val expirationTime: String - val issuedAtTime: String - val signInProvider: String? - val signInSecondFactor: String? - val token: String +public external interface IdTokenResult { + public val authTime: String + public val claims: Json + public val expirationTime: String + public val issuedAtTime: String + public val signInProvider: String? + public val signInSecondFactor: String? + public val token: String } -external interface ActionCodeInfo { - val operation: String - val data: ActionCodeData +public external interface ActionCodeInfo { + public val operation: String + public val data: ActionCodeData } -external interface ActionCodeData { - val email: String? - val multiFactorInfo: MultiFactorInfo? - val previousEmail: String? +public external interface ActionCodeData { + public val email: String? + public val multiFactorInfo: MultiFactorInfo? + public val previousEmail: String? } -external interface AuthResult { - val credential: AuthCredential? - val operationType: String? - val user: User? +public external interface AuthResult { + public val credential: AuthCredential? + public val operationType: String? + public val user: User? } -external interface AuthCredential { - val providerId: String - val signInMethod: String +public external interface AuthCredential { + public val providerId: String + public val signInMethod: String } -external interface OAuthCredential : AuthCredential { - val accessToken: String? - val idToken: String? - val secret: String? +public external interface OAuthCredential : AuthCredential { + public val accessToken: String? + public val idToken: String? + public val secret: String? } -external interface UserCredential { - val operationType: String - val providerId: String? - val user: User +public external interface UserCredential { + public val operationType: String + public val providerId: String? + public val user: User } -external interface ProfileUpdateRequest { - val displayName: String? - val photoURL: String? +public external interface ProfileUpdateRequest { + public val displayName: String? + public val photoURL: String? } -external interface MultiFactorUser { - val enrolledFactors: Array +public external interface MultiFactorUser { + public val enrolledFactors: Array - fun enroll(assertion: MultiFactorAssertion, displayName: String?): Promise - fun getSession(): Promise - fun unenroll(option: MultiFactorInfo): Promise - fun unenroll(option: String): Promise + public fun enroll(assertion: MultiFactorAssertion, displayName: String?): Promise + public fun getSession(): Promise + public fun unenroll(option: MultiFactorInfo): Promise + public fun unenroll(option: String): Promise } -external interface MultiFactorInfo { - val displayName: String? - val enrollmentTime: String - val factorId: String - val uid: String +public external interface MultiFactorInfo { + public val displayName: String? + public val enrollmentTime: String + public val factorId: String + public val uid: String } -external interface MultiFactorAssertion { - val factorId: String +public external interface MultiFactorAssertion { + public val factorId: String } -external interface MultiFactorSession +public external interface MultiFactorSession -external interface MultiFactorResolver { - val auth: Auth - val hints: Array - val session: MultiFactorSession +public external interface MultiFactorResolver { + public val auth: Auth + public val hints: Array + public val session: MultiFactorSession - fun resolveSignIn(assertion: MultiFactorAssertion): Promise + public fun resolveSignIn(assertion: MultiFactorAssertion): Promise } -external interface AuthProvider +public external interface AuthProvider -external interface AuthError +public external interface AuthError -external object EmailAuthProvider : AuthProvider { - fun credential(email: String, password: String): AuthCredential - fun credentialWithLink(email: String, emailLink: String): AuthCredential +public external object EmailAuthProvider : AuthProvider { + public fun credential(email: String, password: String): AuthCredential + public fun credentialWithLink(email: String, emailLink: String): AuthCredential } -external object FacebookAuthProvider : AuthProvider { - fun credential(token: String): AuthCredential +public external object FacebookAuthProvider : AuthProvider { + public fun credential(token: String): AuthCredential } -external object GithubAuthProvider : AuthProvider { - fun credential(token: String): AuthCredential +public external object GithubAuthProvider : AuthProvider { + public fun credential(token: String): AuthCredential } -external class GoogleAuthProvider : AuthProvider { - fun addScope(scope: String) - companion object { - fun credential(idToken: String?, accessToken: String?): AuthCredential - fun credentialFromResult(userCredential: UserCredential): OAuthCredential? - fun credentialFromError(error: AuthError): OAuthCredential? +public external class GoogleAuthProvider : AuthProvider { + public fun addScope(scope: String) + public companion object { + public fun credential(idToken: String?, accessToken: String?): AuthCredential + public fun credentialFromResult(userCredential: UserCredential): OAuthCredential? + public fun credentialFromError(error: AuthError): OAuthCredential? } } -external class OAuthProvider(providerId: String) : AuthProvider { - val providerId: String - fun credential(optionsOrIdToken: Any?, accessToken: String?): AuthCredential +public external class OAuthProvider(providerId: String) : AuthProvider { + public val providerId: String + public fun credential(optionsOrIdToken: Any?, accessToken: String?): AuthCredential - fun addScope(scope: String) - fun setCustomParameters(customOAuthParameters: Map) + public fun addScope(scope: String) + public fun setCustomParameters(customOAuthParameters: Map) } -external interface OAuthCredentialOptions { - val accessToken: String? - val idToken: String? - val rawNonce: String? +public external interface OAuthCredentialOptions { + public val accessToken: String? + public val idToken: String? + public val rawNonce: String? } -external class PhoneAuthProvider(auth: Auth?) : AuthProvider { - companion object { - fun credential( +public external class PhoneAuthProvider(auth: Auth?) : AuthProvider { + public companion object { + public fun credential( verificationId: String, - verificationCode: String + verificationCode: String, ): AuthCredential } - fun verifyPhoneNumber( + public fun verifyPhoneNumber( phoneInfoOptions: String, - applicationVerifier: ApplicationVerifier + applicationVerifier: ApplicationVerifier, ): Promise } -external interface ApplicationVerifier { - val type: String - fun verify(): Promise +public external interface ApplicationVerifier { + public val type: String + public fun verify(): Promise } -external object TwitterAuthProvider : AuthProvider { - fun credential(token: String, secret: String): AuthCredential +public external object TwitterAuthProvider : AuthProvider { + public fun credential(token: String, secret: String): AuthCredential } -external interface Persistence { - val type: String +public external interface Persistence { + public val type: String } -external val browserLocalPersistence: Persistence -external val browserSessionPersistence: Persistence -external val indexedDBLocalPersistence: Persistence -external val inMemoryPersistence: Persistence +public external val browserLocalPersistence: Persistence +public external val browserSessionPersistence: Persistence +public external val indexedDBLocalPersistence: Persistence +public external val inMemoryPersistence: Persistence -external fun setPersistence(auth: Auth, persistence: Persistence): Promise; +public external fun setPersistence(auth: Auth, persistence: Persistence): Promise diff --git a/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/multifactor.kt b/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/multifactor.kt index d4ad636a7..ce4636ad5 100644 --- a/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/multifactor.kt +++ b/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/multifactor.kt @@ -8,41 +8,41 @@ import dev.gitlive.firebase.auth.externals.MultiFactorInfo as JsMultiFactorInfo import dev.gitlive.firebase.auth.externals.MultiFactorResolver as JsMultiFactorResolver import dev.gitlive.firebase.auth.externals.MultiFactorSession as JsMultiFactorSession -actual class MultiFactor(val js: MultiFactorUser) { - actual val enrolledFactors: List +public actual class MultiFactor(public val js: MultiFactorUser) { + public actual val enrolledFactors: List get() = rethrow { js.enrolledFactors.map { MultiFactorInfo(it) } } - actual suspend fun enroll(multiFactorAssertion: MultiFactorAssertion, displayName: String?) = + public actual suspend fun enroll(multiFactorAssertion: MultiFactorAssertion, displayName: String?): Unit = rethrow { js.enroll(multiFactorAssertion.js, displayName).await() } - actual suspend fun getSession(): MultiFactorSession = + public actual suspend fun getSession(): MultiFactorSession = rethrow { MultiFactorSession(js.getSession().await()) } - actual suspend fun unenroll(multiFactorInfo: MultiFactorInfo) = + public actual suspend fun unenroll(multiFactorInfo: MultiFactorInfo): Unit = rethrow { js.unenroll(multiFactorInfo.js).await() } - actual suspend fun unenroll(factorUid: String) = + public actual suspend fun unenroll(factorUid: String): Unit = rethrow { js.unenroll(factorUid).await() } } -actual class MultiFactorInfo(val js: JsMultiFactorInfo) { - actual val displayName: String? +public actual class MultiFactorInfo(public val js: JsMultiFactorInfo) { + public actual val displayName: String? get() = rethrow { js.displayName } - actual val enrollmentTime: Double + public actual val enrollmentTime: Double get() = rethrow { (Date(js.enrollmentTime).getTime() / 1000.0) } - actual val factorId: String + public actual val factorId: String get() = rethrow { js.factorId } - actual val uid: String + public actual val uid: String get() = rethrow { js.uid } } -actual class MultiFactorAssertion(val js: JsMultiFactorAssertion) { - actual val factorId: String +public actual class MultiFactorAssertion(public val js: JsMultiFactorAssertion) { + public actual val factorId: String get() = rethrow { js.factorId } } -actual class MultiFactorSession(val js: JsMultiFactorSession) +public actual class MultiFactorSession(public val js: JsMultiFactorSession) -actual class MultiFactorResolver(val js: JsMultiFactorResolver) { - actual val auth: FirebaseAuth = rethrow { FirebaseAuth(js.auth) } - actual val hints: List = rethrow { js.hints.map { MultiFactorInfo(it) } } - actual val session: MultiFactorSession = rethrow { MultiFactorSession(js.session) } +public actual class MultiFactorResolver(public val js: JsMultiFactorResolver) { + public actual val auth: FirebaseAuth = rethrow { FirebaseAuth(js.auth) } + public actual val hints: List = rethrow { js.hints.map { MultiFactorInfo(it) } } + public actual val session: MultiFactorSession = rethrow { MultiFactorSession(js.session) } - actual suspend fun resolveSignIn(assertion: MultiFactorAssertion): AuthResult = rethrow { AuthResult(js.resolveSignIn(assertion.js).await()) } + public actual suspend fun resolveSignIn(assertion: MultiFactorAssertion): AuthResult = rethrow { AuthResult(js.resolveSignIn(assertion.js).await()) } } diff --git a/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/user.kt b/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/user.kt index 2f1bccb8a..82dcc3baf 100644 --- a/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/user.kt +++ b/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/user.kt @@ -6,73 +6,73 @@ import kotlin.js.Date import dev.gitlive.firebase.auth.externals.UserInfo as JsUserInfo import kotlin.js.json -actual class FirebaseUser internal constructor(val js: User) { - actual val uid: String +public actual class FirebaseUser internal constructor(public val js: User) { + public actual val uid: String get() = rethrow { js.uid } - actual val displayName: String? + public actual val displayName: String? get() = rethrow { js.displayName } - actual val email: String? + public actual val email: String? get() = rethrow { js.email } - actual val phoneNumber: String? + public actual val phoneNumber: String? get() = rethrow { js.phoneNumber } - actual val photoURL: String? + public actual val photoURL: String? get() = rethrow { js.photoURL } - actual val isAnonymous: Boolean + public actual val isAnonymous: Boolean get() = rethrow { js.isAnonymous } - actual val isEmailVerified: Boolean + public actual val isEmailVerified: Boolean get() = rethrow { js.emailVerified } - actual val metaData: UserMetaData? + public actual val metaData: UserMetaData? get() = rethrow { UserMetaData(js.metadata) } - actual val multiFactor: MultiFactor + public actual val multiFactor: MultiFactor get() = rethrow { MultiFactor(multiFactor(js)) } - actual val providerData: List + public actual val providerData: List get() = rethrow { js.providerData.map { UserInfo(it) } } - actual val providerId: String + public actual val providerId: String get() = rethrow { js.providerId } - actual suspend fun delete() = rethrow { js.delete().await() } - actual suspend fun reload() = rethrow { js.reload().await() } - actual suspend fun getIdToken(forceRefresh: Boolean): String? = rethrow { js.getIdToken(forceRefresh).await() } - actual suspend fun getIdTokenResult(forceRefresh: Boolean): AuthTokenResult = rethrow { AuthTokenResult(getIdTokenResult(js, forceRefresh).await()) } - actual suspend fun linkWithCredential(credential: AuthCredential): AuthResult = rethrow { AuthResult( linkWithCredential(js, credential.js).await()) } - actual suspend fun reauthenticate(credential: AuthCredential) = rethrow { + public actual suspend fun delete(): Unit = rethrow { js.delete().await() } + public actual suspend fun reload(): Unit = rethrow { js.reload().await() } + public actual suspend fun getIdToken(forceRefresh: Boolean): String? = rethrow { js.getIdToken(forceRefresh).await() } + public actual suspend fun getIdTokenResult(forceRefresh: Boolean): AuthTokenResult = rethrow { AuthTokenResult(getIdTokenResult(js, forceRefresh).await()) } + public actual suspend fun linkWithCredential(credential: AuthCredential): AuthResult = rethrow { AuthResult(linkWithCredential(js, credential.js).await()) } + public actual suspend fun reauthenticate(credential: AuthCredential): Unit = rethrow { reauthenticateWithCredential(js, credential.js).await() Unit } - actual suspend fun reauthenticateAndRetrieveData(credential: AuthCredential): AuthResult = rethrow { AuthResult(reauthenticateWithCredential(js, credential.js).await()) } + public actual suspend fun reauthenticateAndRetrieveData(credential: AuthCredential): AuthResult = rethrow { AuthResult(reauthenticateWithCredential(js, credential.js).await()) } - actual suspend fun sendEmailVerification(actionCodeSettings: ActionCodeSettings?) = rethrow { sendEmailVerification(js, actionCodeSettings?.toJson()).await() } - actual suspend fun unlink(provider: String): FirebaseUser? = rethrow { FirebaseUser(unlink(js, provider).await()) } - actual suspend fun updateEmail(email: String) = rethrow { updateEmail(js, email).await() } - actual suspend fun updatePassword(password: String) = rethrow { updatePassword(js, password).await() } - actual suspend fun updatePhoneNumber(credential: PhoneAuthCredential) = rethrow { updatePhoneNumber(js, credential.js).await() } - actual suspend fun updateProfile(displayName: String?, photoUrl: String?): Unit = rethrow { + public actual suspend fun sendEmailVerification(actionCodeSettings: ActionCodeSettings?): Unit = rethrow { sendEmailVerification(js, actionCodeSettings?.toJson()).await() } + public actual suspend fun unlink(provider: String): FirebaseUser? = rethrow { FirebaseUser(unlink(js, provider).await()) } + public actual suspend fun updateEmail(email: String): Unit = rethrow { updateEmail(js, email).await() } + public actual suspend fun updatePassword(password: String): Unit = rethrow { updatePassword(js, password).await() } + public actual suspend fun updatePhoneNumber(credential: PhoneAuthCredential): Unit = rethrow { updatePhoneNumber(js, credential.js).await() } + public actual suspend fun updateProfile(displayName: String?, photoUrl: String?): Unit = rethrow { val request = listOf( "displayName" to displayName, "photoURL" to photoUrl, ) updateProfile(js, json(*request.toTypedArray())).await() } - actual suspend fun verifyBeforeUpdateEmail(newEmail: String, actionCodeSettings: ActionCodeSettings?) = rethrow { verifyBeforeUpdateEmail(js, newEmail, actionCodeSettings?.toJson()).await() } + public actual suspend fun verifyBeforeUpdateEmail(newEmail: String, actionCodeSettings: ActionCodeSettings?): Unit = rethrow { verifyBeforeUpdateEmail(js, newEmail, actionCodeSettings?.toJson()).await() } } -actual class UserInfo(val js: JsUserInfo) { - actual val displayName: String? +public actual class UserInfo(public val js: JsUserInfo) { + public actual val displayName: String? get() = rethrow { js.displayName } - actual val email: String? + public actual val email: String? get() = rethrow { js.email } - actual val phoneNumber: String? + public actual val phoneNumber: String? get() = rethrow { js.phoneNumber } - actual val photoURL: String? + public actual val photoURL: String? get() = rethrow { js.photoURL } - actual val providerId: String + public actual val providerId: String get() = rethrow { js.providerId } - actual val uid: String + public actual val uid: String get() = rethrow { js.uid } } -actual class UserMetaData(val js: UserMetadata) { - actual val creationTime: Double? - get() = rethrow {js.creationTime?.let { (Date(it).getTime() / 1000.0) } } - actual val lastSignInTime: Double? - get() = rethrow {js.lastSignInTime?.let { (Date(it).getTime() / 1000.0) } } +public actual class UserMetaData(public val js: UserMetadata) { + public actual val creationTime: Double? + get() = rethrow { js.creationTime?.let { (Date(it).getTime() / 1000.0) } } + public actual val lastSignInTime: Double? + get() = rethrow { js.lastSignInTime?.let { (Date(it).getTime() / 1000.0) } } } diff --git a/firebase-auth/src/jsTest/kotlin/dev/gitlive/firebase/auth/auth.kt b/firebase-auth/src/jsTest/kotlin/dev/gitlive/firebase/auth/auth.kt index 832712901..84c4fcca7 100644 --- a/firebase-auth/src/jsTest/kotlin/dev/gitlive/firebase/auth/auth.kt +++ b/firebase-auth/src/jsTest/kotlin/dev/gitlive/firebase/auth/auth.kt @@ -4,7 +4,6 @@ package dev.gitlive.firebase.auth - actual val emulatorHost: String = "localhost" actual val context: Any = Unit diff --git a/firebase-auth/src/jvmMain/kotlin/dev/gitlive/firebase/auth/auth.kt b/firebase-auth/src/jvmMain/kotlin/dev/gitlive/firebase/auth/auth.kt index 839a4b2a4..03716df99 100644 --- a/firebase-auth/src/jvmMain/kotlin/dev/gitlive/firebase/auth/auth.kt +++ b/firebase-auth/src/jvmMain/kotlin/dev/gitlive/firebase/auth/auth.kt @@ -3,6 +3,7 @@ */ @file:JvmName("android") + package dev.gitlive.firebase.auth import com.google.firebase.auth.ActionCodeEmailInfo @@ -16,17 +17,17 @@ import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.callbackFlow import kotlinx.coroutines.tasks.await -actual val Firebase.auth +public actual val Firebase.auth get() = FirebaseAuth(com.google.firebase.auth.FirebaseAuth.getInstance()) -actual fun Firebase.auth(app: FirebaseApp) = +public actual fun Firebase.auth(app: FirebaseApp) = FirebaseAuth(com.google.firebase.auth.FirebaseAuth.getInstance(app.android)) -actual class FirebaseAuth internal constructor(val android: com.google.firebase.auth.FirebaseAuth) { - actual val currentUser: FirebaseUser? +public actual class FirebaseAuth internal constructor(public val android: com.google.firebase.auth.FirebaseAuth) { + public actual val currentUser: FirebaseUser? get() = android.currentUser?.let { FirebaseUser(it) } - actual val authStateChanged: Flow get() = callbackFlow { + public actual val authStateChanged: Flow get() = callbackFlow { val listener = object : AuthStateListener { override fun onAuthStateChanged(auth: com.google.firebase.auth.FirebaseAuth) { trySend(auth.currentUser?.let { FirebaseUser(it) }) @@ -36,7 +37,7 @@ actual class FirebaseAuth internal constructor(val android: com.google.firebase. awaitClose { android.removeAuthStateListener(listener) } } - actual val idTokenChanged get(): Flow = callbackFlow { + public actual val idTokenChanged: Flow get() = callbackFlow { val listener = object : com.google.firebase.auth.FirebaseAuth.IdTokenListener { override fun onIdTokenChanged(auth: com.google.firebase.auth.FirebaseAuth) { trySend(auth.currentUser?.let { FirebaseUser(it) }) @@ -46,50 +47,60 @@ actual class FirebaseAuth internal constructor(val android: com.google.firebase. awaitClose { android.removeIdTokenListener(listener) } } - actual var languageCode: String + public actual var languageCode: String get() = android.languageCode.orEmpty() - set(value) { android.setLanguageCode(value) } - + set(value) { + android.setLanguageCode(value) + } - actual suspend fun applyActionCode(code: String) = android.applyActionCode(code).await().run { Unit } - actual suspend fun confirmPasswordReset(code: String, newPassword: String) = android.confirmPasswordReset(code, newPassword).await().run { Unit } + public actual suspend fun applyActionCode(code: String) { + android.applyActionCode(code).await() + } + public actual suspend fun confirmPasswordReset(code: String, newPassword: String) { + android.confirmPasswordReset(code, newPassword).await() + } - actual suspend fun createUserWithEmailAndPassword(email: String, password: String) = + public actual suspend fun createUserWithEmailAndPassword(email: String, password: String): AuthResult = AuthResult(android.createUserWithEmailAndPassword(email, password).await()) - actual suspend fun fetchSignInMethodsForEmail(email: String): List = android.fetchSignInMethodsForEmail(email).await().signInMethods.orEmpty() + public actual suspend fun fetchSignInMethodsForEmail(email: String): List = android.fetchSignInMethodsForEmail(email).await().signInMethods.orEmpty() - actual suspend fun sendPasswordResetEmail(email: String, actionCodeSettings: ActionCodeSettings?) { + public actual suspend fun sendPasswordResetEmail(email: String, actionCodeSettings: ActionCodeSettings?) { android.sendPasswordResetEmail(email, actionCodeSettings?.toAndroid()).await() } - actual suspend fun sendSignInLinkToEmail(email: String, actionCodeSettings: ActionCodeSettings) = android.sendSignInLinkToEmail(email, actionCodeSettings.toAndroid()).await().run { Unit } + public actual suspend fun sendSignInLinkToEmail(email: String, actionCodeSettings: ActionCodeSettings) { + android.sendSignInLinkToEmail(email, actionCodeSettings.toAndroid()).await() + } - actual fun isSignInWithEmailLink(link: String) = android.isSignInWithEmailLink(link) + public actual fun isSignInWithEmailLink(link: String): Boolean = android.isSignInWithEmailLink(link) - actual suspend fun signInWithEmailAndPassword(email: String, password: String) = + public actual suspend fun signInWithEmailAndPassword(email: String, password: String): AuthResult = AuthResult(android.signInWithEmailAndPassword(email, password).await()) - actual suspend fun signInWithCustomToken(token: String) = + public actual suspend fun signInWithCustomToken(token: String): AuthResult = AuthResult(android.signInWithCustomToken(token).await()) - actual suspend fun signInAnonymously() = AuthResult(android.signInAnonymously().await()) + public actual suspend fun signInAnonymously(): AuthResult = AuthResult(android.signInAnonymously().await()) - actual suspend fun signInWithCredential(authCredential: AuthCredential) = + public actual suspend fun signInWithCredential(authCredential: AuthCredential): AuthResult = AuthResult(android.signInWithCredential(authCredential.android).await()) - actual suspend fun signInWithEmailLink(email: String, link: String) = + public actual suspend fun signInWithEmailLink(email: String, link: String): AuthResult = AuthResult(android.signInWithEmailLink(email, link).await()) - actual suspend fun signOut() = android.signOut() + public actual suspend fun signOut() { + android.signOut() + } - actual suspend fun updateCurrentUser(user: FirebaseUser) = android.updateCurrentUser(user.android).await().run { Unit } - actual suspend fun verifyPasswordResetCode(code: String): String = android.verifyPasswordResetCode(code).await() + public actual suspend fun updateCurrentUser(user: FirebaseUser) { + android.updateCurrentUser(user.android).await() + } + public actual suspend fun verifyPasswordResetCode(code: String): String = android.verifyPasswordResetCode(code).await() - actual suspend fun checkActionCode(code: String): T { + public actual suspend fun checkActionCode(code: String): T { val result = android.checkActionCode(code).await() - @Suppress("UNCHECKED_CAST") - return when(result.operation) { + return when (result.operation) { SIGN_IN_WITH_EMAIL_LINK -> ActionCodeResult.SignInWithEmailLink VERIFY_EMAIL -> ActionCodeResult.VerifyEmail(result.info!!.email) PASSWORD_RESET -> ActionCodeResult.PasswordReset(result.info!!.email) @@ -107,26 +118,29 @@ actual class FirebaseAuth internal constructor(val android: com.google.firebase. } as T } - actual fun useEmulator(host: String, port: Int) = android.useEmulator(host, port) + public actual fun useEmulator(host: String, port: Int) { + android.useEmulator(host, port) + } } -actual class AuthResult internal constructor(val android: com.google.firebase.auth.AuthResult) { - actual val user: FirebaseUser? +public actual class AuthResult internal constructor(public val android: com.google.firebase.auth.AuthResult) { + public actual val user: FirebaseUser? get() = android.user?.let { FirebaseUser(it) } } -actual class AuthTokenResult(val android: com.google.firebase.auth.GetTokenResult) { +public actual class AuthTokenResult(public val android: com.google.firebase.auth.GetTokenResult) { // actual val authTimestamp: Long // get() = android.authTimestamp - actual val claims: Map + public actual val claims: Map get() = android.claims + // actual val expirationTimestamp: Long // get() = android.expirationTimestamp // actual val issuedAtTimestamp: Long // get() = android.issuedAtTimestamp - actual val signInProvider: String? + public actual val signInProvider: String? get() = android.signInProvider - actual val token: String? + public actual val token: String? get() = android.token } @@ -138,13 +152,13 @@ internal fun ActionCodeSettings.toAndroid() = com.google.firebase.auth.ActionCod .also { iOSBundleId?.run { it.setIOSBundleId(this) } } .build() -actual typealias FirebaseAuthException = com.google.firebase.auth.FirebaseAuthException -actual typealias FirebaseAuthActionCodeException = com.google.firebase.auth.FirebaseAuthActionCodeException -actual typealias FirebaseAuthEmailException = com.google.firebase.auth.FirebaseAuthEmailException -actual typealias FirebaseAuthInvalidCredentialsException = com.google.firebase.auth.FirebaseAuthInvalidCredentialsException -actual typealias FirebaseAuthWeakPasswordException = com.google.firebase.auth.FirebaseAuthWeakPasswordException -actual typealias FirebaseAuthInvalidUserException = com.google.firebase.auth.FirebaseAuthInvalidUserException -actual typealias FirebaseAuthMultiFactorException = com.google.firebase.auth.FirebaseAuthMultiFactorException -actual typealias FirebaseAuthRecentLoginRequiredException = com.google.firebase.auth.FirebaseAuthRecentLoginRequiredException -actual typealias FirebaseAuthUserCollisionException = com.google.firebase.auth.FirebaseAuthUserCollisionException -actual typealias FirebaseAuthWebException = com.google.firebase.auth.FirebaseAuthWebException +public actual typealias FirebaseAuthException = com.google.firebase.auth.FirebaseAuthException +public actual typealias FirebaseAuthActionCodeException = com.google.firebase.auth.FirebaseAuthActionCodeException +public actual typealias FirebaseAuthEmailException = com.google.firebase.auth.FirebaseAuthEmailException +public actual typealias FirebaseAuthInvalidCredentialsException = com.google.firebase.auth.FirebaseAuthInvalidCredentialsException +public actual typealias FirebaseAuthWeakPasswordException = com.google.firebase.auth.FirebaseAuthWeakPasswordException +public actual typealias FirebaseAuthInvalidUserException = com.google.firebase.auth.FirebaseAuthInvalidUserException +public actual typealias FirebaseAuthMultiFactorException = com.google.firebase.auth.FirebaseAuthMultiFactorException +public actual typealias FirebaseAuthRecentLoginRequiredException = com.google.firebase.auth.FirebaseAuthRecentLoginRequiredException +public actual typealias FirebaseAuthUserCollisionException = com.google.firebase.auth.FirebaseAuthUserCollisionException +public actual typealias FirebaseAuthWebException = com.google.firebase.auth.FirebaseAuthWebException diff --git a/firebase-auth/src/jvmMain/kotlin/dev/gitlive/firebase/auth/credentials.kt b/firebase-auth/src/jvmMain/kotlin/dev/gitlive/firebase/auth/credentials.kt index c44acfadd..7c372681d 100644 --- a/firebase-auth/src/jvmMain/kotlin/dev/gitlive/firebase/auth/credentials.kt +++ b/firebase-auth/src/jvmMain/kotlin/dev/gitlive/firebase/auth/credentials.kt @@ -14,37 +14,37 @@ import kotlinx.coroutines.launch import kotlinx.coroutines.tasks.await import java.util.concurrent.TimeUnit -actual open class AuthCredential(open val android: com.google.firebase.auth.AuthCredential) { - actual val providerId: String +public actual open class AuthCredential(public open val android: com.google.firebase.auth.AuthCredential) { + public actual val providerId: String get() = android.provider } -actual class PhoneAuthCredential(override val android: com.google.firebase.auth.PhoneAuthCredential) : AuthCredential(android) +public actual class PhoneAuthCredential(override val android: com.google.firebase.auth.PhoneAuthCredential) : AuthCredential(android) -actual class OAuthCredential(override val android: com.google.firebase.auth.OAuthCredential) : AuthCredential(android) +public actual class OAuthCredential(override val android: com.google.firebase.auth.OAuthCredential) : AuthCredential(android) -actual object EmailAuthProvider { - actual fun credential( +public actual object EmailAuthProvider { + public actual fun credential( email: String, - password: String + password: String, ): AuthCredential = AuthCredential(com.google.firebase.auth.EmailAuthProvider.getCredential(email, password)) - actual fun credentialWithLink( + public actual fun credentialWithLink( email: String, - emailLink: String + emailLink: String, ): AuthCredential = AuthCredential(com.google.firebase.auth.EmailAuthProvider.getCredentialWithLink(email, emailLink)) } -actual object FacebookAuthProvider { - actual fun credential(accessToken: String): AuthCredential = AuthCredential(com.google.firebase.auth.FacebookAuthProvider.getCredential(accessToken)) +public actual object FacebookAuthProvider { + public actual fun credential(accessToken: String): AuthCredential = AuthCredential(com.google.firebase.auth.FacebookAuthProvider.getCredential(accessToken)) } -actual object GithubAuthProvider { - actual fun credential(token: String): AuthCredential = AuthCredential(com.google.firebase.auth.GithubAuthProvider.getCredential(token)) +public actual object GithubAuthProvider { + public actual fun credential(token: String): AuthCredential = AuthCredential(com.google.firebase.auth.GithubAuthProvider.getCredential(token)) } -actual object GoogleAuthProvider { - actual fun credential(idToken: String?, accessToken: String?): AuthCredential { +public actual object GoogleAuthProvider { + public actual fun credential(idToken: String?, accessToken: String?): AuthCredential { require(idToken != null || accessToken != null) { "Both parameters are optional but at least one must be present." } @@ -52,39 +52,39 @@ actual object GoogleAuthProvider { } } -actual class OAuthProvider(val android: com.google.firebase.auth.OAuthProvider) { +public actual class OAuthProvider(public val android: com.google.firebase.auth.OAuthProvider) { - actual constructor( + public actual constructor( provider: String, scopes: List, customParameters: Map, - auth: FirebaseAuth + auth: FirebaseAuth, ) : this( com.google.firebase.auth.OAuthProvider .newBuilder(provider, auth.android) .setScopes(scopes) .addCustomParameters(customParameters) - .build() + .build(), ) - actual companion object { - actual fun credential(providerId: String, accessToken: String?, idToken: String?, rawNonce: String?): OAuthCredential { + public actual companion object { + public actual fun credential(providerId: String, accessToken: String?, idToken: String?, rawNonce: String?): OAuthCredential { val builder = OAuthProvider.newCredentialBuilder(providerId) accessToken?.let { builder.setAccessToken(it) } idToken?.let { builder.setIdToken(it) } - rawNonce?.let { builder.setIdTokenWithRawNonce(idToken!!, it) } + rawNonce?.let { builder.setIdTokenWithRawNonce(idToken!!, it) } return OAuthCredential(builder.build() as com.google.firebase.auth.OAuthCredential) } } } -actual class PhoneAuthProvider(val android: com.google.firebase.auth.PhoneAuthProvider) { +public actual class PhoneAuthProvider(public val android: com.google.firebase.auth.PhoneAuthProvider) { - actual constructor(auth: FirebaseAuth) : this(com.google.firebase.auth.PhoneAuthProvider.getInstance(auth.android)) + public actual constructor(auth: FirebaseAuth) : this(com.google.firebase.auth.PhoneAuthProvider.getInstance(auth.android)) - actual fun credential(verificationId: String, smsCode: String): PhoneAuthCredential = PhoneAuthCredential(com.google.firebase.auth.PhoneAuthProvider.getCredential(verificationId, smsCode)) + public actual fun credential(verificationId: String, smsCode: String): PhoneAuthCredential = PhoneAuthCredential(com.google.firebase.auth.PhoneAuthProvider.getCredential(verificationId, smsCode)) - actual suspend fun verifyPhoneNumber(phoneNumber: String, verificationProvider: PhoneVerificationProvider): AuthCredential = coroutineScope { + public actual suspend fun verifyPhoneNumber(phoneNumber: String, verificationProvider: PhoneVerificationProvider): AuthCredential = coroutineScope { val response = CompletableDeferred>() val callback = object : PhoneAuthProvider.OnVerificationStateChangedCallbacks() { @@ -113,7 +113,6 @@ actual class PhoneAuthProvider(val android: com.google.firebase.auth.PhoneAuthPr override fun onVerificationFailed(error: FirebaseException) { response.complete(Result.failure(error)) } - } android.verifyPhoneNumber(phoneNumber, verificationProvider.timeout, verificationProvider.unit, verificationProvider.activity, callback) @@ -121,14 +120,14 @@ actual class PhoneAuthProvider(val android: com.google.firebase.auth.PhoneAuthPr } } -actual interface PhoneVerificationProvider { - val activity: Activity - val timeout: Long - val unit: TimeUnit - fun codeSent(triggerResend: (Unit) -> Unit) - suspend fun getVerificationCode(): String +public actual interface PhoneVerificationProvider { + public val activity: Activity + public val timeout: Long + public val unit: TimeUnit + public fun codeSent(triggerResend: (Unit) -> Unit) + public suspend fun getVerificationCode(): String } -actual object TwitterAuthProvider { - actual fun credential(token: String, secret: String): AuthCredential = AuthCredential(com.google.firebase.auth.TwitterAuthProvider.getCredential(token, secret)) +public actual object TwitterAuthProvider { + public actual fun credential(token: String, secret: String): AuthCredential = AuthCredential(com.google.firebase.auth.TwitterAuthProvider.getCredential(token, secret)) } diff --git a/firebase-auth/src/jvmMain/kotlin/dev/gitlive/firebase/auth/multifactor.kt b/firebase-auth/src/jvmMain/kotlin/dev/gitlive/firebase/auth/multifactor.kt index 84b216a4d..6b60e36a7 100644 --- a/firebase-auth/src/jvmMain/kotlin/dev/gitlive/firebase/auth/multifactor.kt +++ b/firebase-auth/src/jvmMain/kotlin/dev/gitlive/firebase/auth/multifactor.kt @@ -6,37 +6,43 @@ package dev.gitlive.firebase.auth import kotlinx.coroutines.tasks.await -actual class MultiFactor(val android: com.google.firebase.auth.MultiFactor) { - actual val enrolledFactors: List +public actual class MultiFactor(public val android: com.google.firebase.auth.MultiFactor) { + public actual val enrolledFactors: List get() = android.enrolledFactors.map { MultiFactorInfo(it) } - actual suspend fun enroll(multiFactorAssertion: MultiFactorAssertion, displayName: String?) = android.enroll(multiFactorAssertion.android, displayName).await().run { Unit } - actual suspend fun getSession(): MultiFactorSession = MultiFactorSession(android.session.await()) - actual suspend fun unenroll(multiFactorInfo: MultiFactorInfo) = android.unenroll(multiFactorInfo.android).await().run { Unit } - actual suspend fun unenroll(factorUid: String) = android.unenroll(factorUid).await().run { Unit } + public actual suspend fun enroll(multiFactorAssertion: MultiFactorAssertion, displayName: String?) { + android.enroll(multiFactorAssertion.android, displayName).await() + } + public actual suspend fun getSession(): MultiFactorSession = MultiFactorSession(android.session.await()) + public actual suspend fun unenroll(multiFactorInfo: MultiFactorInfo) { + android.unenroll(multiFactorInfo.android).await() + } + public actual suspend fun unenroll(factorUid: String) { + android.unenroll(factorUid).await() + } } -actual class MultiFactorInfo(val android: com.google.firebase.auth.MultiFactorInfo) { - actual val displayName: String? +public actual class MultiFactorInfo(public val android: com.google.firebase.auth.MultiFactorInfo) { + public actual val displayName: String? get() = android.displayName - actual val enrollmentTime: Double + public actual val enrollmentTime: Double get() = android.enrollmentTimestamp.toDouble() - actual val factorId: String + public actual val factorId: String get() = android.factorId - actual val uid: String + public actual val uid: String get() = android.uid } -actual class MultiFactorAssertion(val android: com.google.firebase.auth.MultiFactorAssertion) { - actual val factorId: String +public actual class MultiFactorAssertion(public val android: com.google.firebase.auth.MultiFactorAssertion) { + public actual val factorId: String get() = android.factorId } -actual class MultiFactorSession(val android: com.google.firebase.auth.MultiFactorSession) +public actual class MultiFactorSession(public val android: com.google.firebase.auth.MultiFactorSession) -actual class MultiFactorResolver(val android: com.google.firebase.auth.MultiFactorResolver) { - actual val auth: FirebaseAuth = FirebaseAuth(android.firebaseAuth) - actual val hints: List = android.hints.map { MultiFactorInfo(it) } - actual val session: MultiFactorSession = MultiFactorSession(android.session) +public actual class MultiFactorResolver(public val android: com.google.firebase.auth.MultiFactorResolver) { + public actual val auth: FirebaseAuth = FirebaseAuth(android.firebaseAuth) + public actual val hints: List = android.hints.map { MultiFactorInfo(it) } + public actual val session: MultiFactorSession = MultiFactorSession(android.session) - actual suspend fun resolveSignIn(assertion: MultiFactorAssertion): AuthResult = AuthResult(android.resolveSignIn(assertion.android).await()) + public actual suspend fun resolveSignIn(assertion: MultiFactorAssertion): AuthResult = AuthResult(android.resolveSignIn(assertion.android).await()) } diff --git a/firebase-auth/src/jvmMain/kotlin/dev/gitlive/firebase/auth/user.kt b/firebase-auth/src/jvmMain/kotlin/dev/gitlive/firebase/auth/user.kt index 3a8ea3b92..812dc5ac3 100644 --- a/firebase-auth/src/jvmMain/kotlin/dev/gitlive/firebase/auth/user.kt +++ b/firebase-auth/src/jvmMain/kotlin/dev/gitlive/firebase/auth/user.kt @@ -8,73 +8,86 @@ import android.net.Uri import com.google.firebase.auth.UserProfileChangeRequest import kotlinx.coroutines.tasks.await -actual class FirebaseUser internal constructor(val android: com.google.firebase.auth.FirebaseUser) { - actual val uid: String +public actual class FirebaseUser internal constructor(public val android: com.google.firebase.auth.FirebaseUser) { + public actual val uid: String get() = android.uid - actual val displayName: String? + public actual val displayName: String? get() = android.displayName - actual val email: String? + public actual val email: String? get() = android.email - actual val phoneNumber: String? + public actual val phoneNumber: String? get() = android.phoneNumber - actual val photoURL: String? + public actual val photoURL: String? get() = android.photoUrl?.toString() - actual val isAnonymous: Boolean + public actual val isAnonymous: Boolean get() = android.isAnonymous - actual val isEmailVerified: Boolean + public actual val isEmailVerified: Boolean get() = android.isEmailVerified - actual val metaData: UserMetaData? - get() = android.metadata?.let{ UserMetaData(it) } - actual val multiFactor: MultiFactor + public actual val metaData: UserMetaData? + get() = android.metadata?.let { UserMetaData(it) } + public actual val multiFactor: MultiFactor get() = MultiFactor(android.multiFactor) - actual val providerData: List + public actual val providerData: List get() = android.providerData.map { UserInfo(it) } - actual val providerId: String + public actual val providerId: String get() = android.providerId - actual suspend fun delete() = android.delete().await().run { Unit } - actual suspend fun reload() = android.reload().await().run { Unit } - actual suspend fun getIdToken(forceRefresh: Boolean): String? = android.getIdToken(forceRefresh).await().token - actual suspend fun getIdTokenResult(forceRefresh: Boolean): AuthTokenResult = android.getIdToken(forceRefresh).await().run { AuthTokenResult(this) } - actual suspend fun linkWithCredential(credential: AuthCredential): AuthResult = AuthResult(android.linkWithCredential(credential.android).await()) - actual suspend fun reauthenticate(credential: AuthCredential) = android.reauthenticate(credential.android).await().run { Unit } - actual suspend fun reauthenticateAndRetrieveData(credential: AuthCredential): AuthResult = AuthResult(android.reauthenticateAndRetrieveData(credential.android).await()) - actual suspend fun sendEmailVerification(actionCodeSettings: ActionCodeSettings?) { + public actual suspend fun delete() { + android.delete().await() + } + public actual suspend fun reload() { + android.reload().await() + } + public actual suspend fun getIdToken(forceRefresh: Boolean): String? = android.getIdToken(forceRefresh).await().token + public actual suspend fun getIdTokenResult(forceRefresh: Boolean): AuthTokenResult = android.getIdToken(forceRefresh).await().run { AuthTokenResult(this) } + public actual suspend fun linkWithCredential(credential: AuthCredential): AuthResult = AuthResult(android.linkWithCredential(credential.android).await()) + public actual suspend fun reauthenticate(credential: AuthCredential) { + android.reauthenticate(credential.android).await() + } + public actual suspend fun reauthenticateAndRetrieveData(credential: AuthCredential): AuthResult = AuthResult(android.reauthenticateAndRetrieveData(credential.android).await()) + public actual suspend fun sendEmailVerification(actionCodeSettings: ActionCodeSettings?) { val request = actionCodeSettings?.let { android.sendEmailVerification(it.toAndroid()) } ?: android.sendEmailVerification() request.await() } - actual suspend fun unlink(provider: String): FirebaseUser? = android.unlink(provider).await().user?.let { FirebaseUser(it) } - actual suspend fun updateEmail(email: String) = android.updateEmail(email).await().run { Unit } - actual suspend fun updatePassword(password: String) = android.updatePassword(password).await().run { Unit } - actual suspend fun updatePhoneNumber(credential: PhoneAuthCredential) = android.updatePhoneNumber(credential.android).await().run { Unit } - actual suspend fun updateProfile(displayName: String?, photoUrl: String?) { + public actual suspend fun unlink(provider: String): FirebaseUser? = android.unlink(provider).await().user?.let { FirebaseUser(it) } + public actual suspend fun updateEmail(email: String) { + android.updateEmail(email).await() + } + public actual suspend fun updatePassword(password: String) { + android.updatePassword(password).await() + } + public actual suspend fun updatePhoneNumber(credential: PhoneAuthCredential) { + android.updatePhoneNumber(credential.android).await() + } + public actual suspend fun updateProfile(displayName: String?, photoUrl: String?) { val request = UserProfileChangeRequest.Builder() .apply { setDisplayName(displayName) } .apply { setPhotoUri(photoUrl?.let { Uri.parse(it) }) } .build() android.updateProfile(request).await() } - actual suspend fun verifyBeforeUpdateEmail(newEmail: String, actionCodeSettings: ActionCodeSettings?) = - android.verifyBeforeUpdateEmail(newEmail, actionCodeSettings?.toAndroid()).await().run { Unit } + public actual suspend fun verifyBeforeUpdateEmail(newEmail: String, actionCodeSettings: ActionCodeSettings?) { + android.verifyBeforeUpdateEmail(newEmail, actionCodeSettings?.toAndroid()).await() + } } -actual class UserInfo(val android: com.google.firebase.auth.UserInfo) { - actual val displayName: String? +public actual class UserInfo(public val android: com.google.firebase.auth.UserInfo) { + public actual val displayName: String? get() = android.displayName - actual val email: String? + public actual val email: String? get() = android.email - actual val phoneNumber: String? + public actual val phoneNumber: String? get() = android.phoneNumber - actual val photoURL: String? + public actual val photoURL: String? get() = android.photoUrl?.toString() - actual val providerId: String + public actual val providerId: String get() = android.providerId - actual val uid: String + public actual val uid: String get() = android.uid } -actual class UserMetaData(val android: com.google.firebase.auth.FirebaseUserMetadata) { - actual val creationTime: Double? +public actual class UserMetaData(public val android: com.google.firebase.auth.FirebaseUserMetadata) { + public actual val creationTime: Double? get() = android.creationTimestamp.toDouble() - actual val lastSignInTime: Double? + public actual val lastSignInTime: Double? get() = android.lastSignInTimestamp.toDouble() } diff --git a/firebase-auth/src/jvmTest/kotlin/dev/gitlive/firebase/auth/auth.kt b/firebase-auth/src/jvmTest/kotlin/dev/gitlive/firebase/auth/auth.kt index 87a640e75..f0d16373b 100644 --- a/firebase-auth/src/jvmTest/kotlin/dev/gitlive/firebase/auth/auth.kt +++ b/firebase-auth/src/jvmTest/kotlin/dev/gitlive/firebase/auth/auth.kt @@ -3,6 +3,7 @@ */ @file:JvmName("tests") + package dev.gitlive.firebase.auth import dev.gitlive.firebase.testContext diff --git a/firebase-common-internal/api/android/firebase-common-internal.api b/firebase-common-internal/api/android/firebase-common-internal.api new file mode 100644 index 000000000..f992ea5a9 --- /dev/null +++ b/firebase-common-internal/api/android/firebase-common-internal.api @@ -0,0 +1,243 @@ +public final class dev/gitlive/firebase/internal/AndroidEncodedObject { + public static final fun asNativeMap (Ljava/lang/Object;)Ljava/util/Map; + public static final fun getAndroid (Ldev/gitlive/firebase/internal/EncodedObject;)Ljava/util/Map; +} + +public final class dev/gitlive/firebase/internal/DecodeSettingsImpl : dev/gitlive/firebase/DecodeSettings { + public fun ()V + public fun getSerializersModule ()Lkotlinx/serialization/modules/SerializersModule; +} + +public final class dev/gitlive/firebase/internal/DecodeSettingsImpl$Builder : dev/gitlive/firebase/DecodeSettings$Builder { + public fun ()V + public fun getSerializersModule ()Lkotlinx/serialization/modules/SerializersModule; + public fun setSerializersModule (Lkotlinx/serialization/modules/SerializersModule;)V +} + +public final class dev/gitlive/firebase/internal/DecodersKt { + public static final fun decode (Lkotlinx/serialization/DeserializationStrategy;Ljava/lang/Object;)Ljava/lang/Object; + public static final fun decode (Lkotlinx/serialization/DeserializationStrategy;Ljava/lang/Object;Ldev/gitlive/firebase/DecodeSettings;)Ljava/lang/Object; + public static final fun decode (Lkotlinx/serialization/DeserializationStrategy;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; +} + +public final class dev/gitlive/firebase/internal/EncodeDecodeSettingsBuilderImpl : dev/gitlive/firebase/EncodeDecodeSettingsBuilder { + public fun ()V + public fun getEncodeDefaults ()Z + public fun getSerializersModule ()Lkotlinx/serialization/modules/SerializersModule; + public fun setEncodeDefaults (Z)V + public fun setSerializersModule (Lkotlinx/serialization/modules/SerializersModule;)V +} + +public final class dev/gitlive/firebase/internal/EncodeDecodeSettingsKt { + public static final fun buildDecodeSettings (Ldev/gitlive/firebase/DecodeSettings$Builder;)Ldev/gitlive/firebase/DecodeSettings; + public static final fun buildEncodeSettings (Ldev/gitlive/firebase/EncodeSettings$Builder;)Ldev/gitlive/firebase/EncodeSettings; +} + +public final class dev/gitlive/firebase/internal/EncodeSettingsImpl : dev/gitlive/firebase/EncodeSettings { + public final fun component1 ()Z + public final fun component2 ()Lkotlinx/serialization/modules/SerializersModule; + public final fun copy (ZLkotlinx/serialization/modules/SerializersModule;)Ldev/gitlive/firebase/internal/EncodeSettingsImpl; + public static synthetic fun copy$default (Ldev/gitlive/firebase/internal/EncodeSettingsImpl;ZLkotlinx/serialization/modules/SerializersModule;ILjava/lang/Object;)Ldev/gitlive/firebase/internal/EncodeSettingsImpl; + public fun equals (Ljava/lang/Object;)Z + public fun getEncodeDefaults ()Z + public fun getSerializersModule ()Lkotlinx/serialization/modules/SerializersModule; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/internal/EncodeSettingsImpl$Builder : dev/gitlive/firebase/EncodeSettings$Builder { + public fun ()V + public fun getEncodeDefaults ()Z + public fun getSerializersModule ()Lkotlinx/serialization/modules/SerializersModule; + public fun setEncodeDefaults (Z)V + public fun setSerializersModule (Lkotlinx/serialization/modules/SerializersModule;)V +} + +public abstract interface class dev/gitlive/firebase/internal/EncodedObject { +} + +public final class dev/gitlive/firebase/internal/EncodedObjectImpl : dev/gitlive/firebase/internal/EncodedObject { + public static final synthetic fun box-impl (Ljava/util/Map;)Ldev/gitlive/firebase/internal/EncodedObjectImpl; + public static fun constructor-impl (Ljava/util/Map;)Ljava/util/Map; + public fun equals (Ljava/lang/Object;)Z + public static fun equals-impl (Ljava/util/Map;Ljava/lang/Object;)Z + public static final fun equals-impl0 (Ljava/util/Map;Ljava/util/Map;)Z + public final fun getRaw ()Ljava/util/Map; + public fun hashCode ()I + public static fun hashCode-impl (Ljava/util/Map;)I + public fun toString ()Ljava/lang/String; + public static fun toString-impl (Ljava/util/Map;)Ljava/lang/String; + public final synthetic fun unbox-impl ()Ljava/util/Map; +} + +public final class dev/gitlive/firebase/internal/EncodedObjectKt { + public static final fun asEncodedObject (Ljava/util/Map;)Ldev/gitlive/firebase/internal/EncodedObject; +} + +public final class dev/gitlive/firebase/internal/EncodersKt { + public static final fun encode (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Ldev/gitlive/firebase/EncodeSettings;)Ljava/lang/Object; + public static final fun encode (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; + public static final fun encode (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Z)Ljava/lang/Object; + public static final fun encodeAsObject (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/internal/EncodedObject; + public static synthetic fun encodeAsObject$default (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/internal/EncodedObject; + public static final fun withSerializer (Ljava/lang/Object;Lkotlinx/serialization/SerializationStrategy;)Ljava/lang/Object; +} + +public final class dev/gitlive/firebase/internal/FirebaseClassDecoder : dev/gitlive/firebase/internal/FirebaseCompositeDecoder { + public fun (ILdev/gitlive/firebase/DecodeSettings;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;)V + public fun decodeElementIndex (Lkotlinx/serialization/descriptors/SerialDescriptor;)I + public fun decodeSequentially ()Z +} + +public class dev/gitlive/firebase/internal/FirebaseCompositeDecoder : kotlinx/serialization/encoding/CompositeDecoder { + public fun (ILdev/gitlive/firebase/DecodeSettings;Lkotlin/jvm/functions/Function2;)V + public fun decodeBooleanElement (Lkotlinx/serialization/descriptors/SerialDescriptor;I)Z + public fun decodeByteElement (Lkotlinx/serialization/descriptors/SerialDescriptor;I)B + public fun decodeCharElement (Lkotlinx/serialization/descriptors/SerialDescriptor;I)C + public fun decodeCollectionSize (Lkotlinx/serialization/descriptors/SerialDescriptor;)I + public fun decodeDoubleElement (Lkotlinx/serialization/descriptors/SerialDescriptor;I)D + public fun decodeElementIndex (Lkotlinx/serialization/descriptors/SerialDescriptor;)I + public fun decodeFloatElement (Lkotlinx/serialization/descriptors/SerialDescriptor;I)F + public fun decodeInlineElement (Lkotlinx/serialization/descriptors/SerialDescriptor;I)Lkotlinx/serialization/encoding/Decoder; + public fun decodeIntElement (Lkotlinx/serialization/descriptors/SerialDescriptor;I)I + public fun decodeLongElement (Lkotlinx/serialization/descriptors/SerialDescriptor;I)J + public fun decodeNullableSerializableElement (Lkotlinx/serialization/descriptors/SerialDescriptor;ILkotlinx/serialization/DeserializationStrategy;Ljava/lang/Object;)Ljava/lang/Object; + public fun decodeSequentially ()Z + public fun decodeSerializableElement (Lkotlinx/serialization/descriptors/SerialDescriptor;ILkotlinx/serialization/DeserializationStrategy;Ljava/lang/Object;)Ljava/lang/Object; + public fun decodeShortElement (Lkotlinx/serialization/descriptors/SerialDescriptor;I)S + public fun decodeStringElement (Lkotlinx/serialization/descriptors/SerialDescriptor;I)Ljava/lang/String; + public fun endStructure (Lkotlinx/serialization/descriptors/SerialDescriptor;)V + public fun getSerializersModule ()Lkotlinx/serialization/modules/SerializersModule; +} + +public class dev/gitlive/firebase/internal/FirebaseCompositeEncoder : kotlinx/serialization/encoding/CompositeEncoder { + public fun (Ldev/gitlive/firebase/EncodeSettings;Lkotlin/jvm/functions/Function0;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function3;)V + public synthetic fun (Ldev/gitlive/firebase/EncodeSettings;Lkotlin/jvm/functions/Function0;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function3;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public fun encodeBooleanElement (Lkotlinx/serialization/descriptors/SerialDescriptor;IZ)V + public fun encodeByteElement (Lkotlinx/serialization/descriptors/SerialDescriptor;IB)V + public fun encodeCharElement (Lkotlinx/serialization/descriptors/SerialDescriptor;IC)V + public fun encodeDoubleElement (Lkotlinx/serialization/descriptors/SerialDescriptor;ID)V + public fun encodeFloatElement (Lkotlinx/serialization/descriptors/SerialDescriptor;IF)V + public fun encodeInlineElement (Lkotlinx/serialization/descriptors/SerialDescriptor;I)Lkotlinx/serialization/encoding/Encoder; + public fun encodeIntElement (Lkotlinx/serialization/descriptors/SerialDescriptor;II)V + public fun encodeLongElement (Lkotlinx/serialization/descriptors/SerialDescriptor;IJ)V + public fun encodeNullableSerializableElement (Lkotlinx/serialization/descriptors/SerialDescriptor;ILkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;)V + public final fun encodeObject (Lkotlinx/serialization/descriptors/SerialDescriptor;ILjava/lang/Object;)V + public final fun encodePolymorphicClassDiscriminator (Ljava/lang/String;Ljava/lang/String;)V + public fun encodeSerializableElement (Lkotlinx/serialization/descriptors/SerialDescriptor;ILkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;)V + public fun encodeShortElement (Lkotlinx/serialization/descriptors/SerialDescriptor;IS)V + public fun encodeStringElement (Lkotlinx/serialization/descriptors/SerialDescriptor;ILjava/lang/String;)V + public fun endStructure (Lkotlinx/serialization/descriptors/SerialDescriptor;)V + public fun getSerializersModule ()Lkotlinx/serialization/modules/SerializersModule; + public fun shouldEncodeElementDefault (Lkotlinx/serialization/descriptors/SerialDescriptor;I)Z +} + +public final class dev/gitlive/firebase/internal/FirebaseDecoder : kotlinx/serialization/encoding/Decoder { + public fun (Ljava/lang/Object;)V + public fun (Ljava/lang/Object;Ldev/gitlive/firebase/DecodeSettings;)V + public fun beginStructure (Lkotlinx/serialization/descriptors/SerialDescriptor;)Lkotlinx/serialization/encoding/CompositeDecoder; + public fun decodeBoolean ()Z + public fun decodeByte ()B + public fun decodeChar ()C + public fun decodeDouble ()D + public fun decodeEnum (Lkotlinx/serialization/descriptors/SerialDescriptor;)I + public fun decodeFloat ()F + public fun decodeInline (Lkotlinx/serialization/descriptors/SerialDescriptor;)Lkotlinx/serialization/encoding/Decoder; + public fun decodeInt ()I + public fun decodeLong ()J + public fun decodeNotNullMark ()Z + public fun decodeNull ()Ljava/lang/Void; + public fun decodeNullableSerializableValue (Lkotlinx/serialization/DeserializationStrategy;)Ljava/lang/Object; + public fun decodeSerializableValue (Lkotlinx/serialization/DeserializationStrategy;)Ljava/lang/Object; + public fun decodeShort ()S + public fun decodeString ()Ljava/lang/String; + public fun getSerializersModule ()Lkotlinx/serialization/modules/SerializersModule; + public final fun getValue ()Ljava/lang/Object; +} + +public final class dev/gitlive/firebase/internal/FirebaseEncoder : kotlinx/serialization/encoding/Encoder { + public fun (Ldev/gitlive/firebase/EncodeSettings;)V + public fun (Z)V + public fun beginCollection (Lkotlinx/serialization/descriptors/SerialDescriptor;I)Lkotlinx/serialization/encoding/CompositeEncoder; + public fun beginStructure (Lkotlinx/serialization/descriptors/SerialDescriptor;)Lkotlinx/serialization/encoding/CompositeEncoder; + public fun encodeBoolean (Z)V + public fun encodeByte (B)V + public fun encodeChar (C)V + public fun encodeDouble (D)V + public fun encodeEnum (Lkotlinx/serialization/descriptors/SerialDescriptor;I)V + public fun encodeFloat (F)V + public fun encodeInline (Lkotlinx/serialization/descriptors/SerialDescriptor;)Lkotlinx/serialization/encoding/Encoder; + public fun encodeInt (I)V + public fun encodeLong (J)V + public fun encodeNotNullMark ()V + public fun encodeNull ()V + public fun encodeNullableSerializableValue (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;)V + public fun encodeSerializableValue (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;)V + public fun encodeShort (S)V + public fun encodeString (Ljava/lang/String;)V + public fun getSerializersModule ()Lkotlinx/serialization/modules/SerializersModule; + public final fun getValue ()Ljava/lang/Object; + public final fun setValue (Ljava/lang/Object;)V +} + +public final class dev/gitlive/firebase/internal/FirebaseListSerializer : kotlinx/serialization/KSerializer { + public field list Ljava/util/List; + public fun ()V + public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; + public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/util/List; + public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; + public final fun getList ()Ljava/util/List; + public fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Iterable;)V + public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V + public final fun setList (Ljava/util/List;)V +} + +public final class dev/gitlive/firebase/internal/FirebaseMapSerializer : kotlinx/serialization/KSerializer { + public field keys Ljava/util/List; + public field map Ljava/util/Map; + public fun ()V + public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; + public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/util/Map; + public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; + public final fun getKeys ()Ljava/util/List; + public final fun getMap ()Ljava/util/Map; + public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V + public fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/util/Map;)V + public final fun setKeys (Ljava/util/List;)V + public final fun setMap (Ljava/util/Map;)V +} + +public final class dev/gitlive/firebase/internal/ReencodeTransformationKt { + public static final fun reencodeTransformation (Lkotlinx/serialization/KSerializer;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; + public static synthetic fun reencodeTransformation$default (Lkotlinx/serialization/KSerializer;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/lang/Object; +} + +public final class dev/gitlive/firebase/internal/SpecialValueSerializer : kotlinx/serialization/KSerializer { + public fun (Ljava/lang/String;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;)V + public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; + public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; + public fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V +} + +public final class dev/gitlive/firebase/internal/ValueWithSerializer { + public fun (Ljava/lang/Object;Lkotlinx/serialization/SerializationStrategy;)V + public final fun component1 ()Ljava/lang/Object; + public final fun component2 ()Lkotlinx/serialization/SerializationStrategy; + public final fun copy (Ljava/lang/Object;Lkotlinx/serialization/SerializationStrategy;)Ldev/gitlive/firebase/internal/ValueWithSerializer; + public static synthetic fun copy$default (Ldev/gitlive/firebase/internal/ValueWithSerializer;Ljava/lang/Object;Lkotlinx/serialization/SerializationStrategy;ILjava/lang/Object;)Ldev/gitlive/firebase/internal/ValueWithSerializer; + public fun equals (Ljava/lang/Object;)Z + public final fun getSerializer ()Lkotlinx/serialization/SerializationStrategy; + public final fun getValue ()Ljava/lang/Object; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/internal/_decodersKt { + public static final fun getPolymorphicType (Ljava/lang/Object;Ljava/lang/String;)Ljava/lang/String; + public static final fun structureDecoder (Ldev/gitlive/firebase/internal/FirebaseDecoder;Lkotlinx/serialization/descriptors/SerialDescriptor;Z)Lkotlinx/serialization/encoding/CompositeDecoder; +} + +public final class dev/gitlive/firebase/internal/_encodersKt { + public static final fun structureEncoder (Ldev/gitlive/firebase/internal/FirebaseEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)Ldev/gitlive/firebase/internal/FirebaseCompositeEncoder; +} + diff --git a/firebase-common-internal/api/jvm/firebase-common-internal.api b/firebase-common-internal/api/jvm/firebase-common-internal.api new file mode 100644 index 000000000..f992ea5a9 --- /dev/null +++ b/firebase-common-internal/api/jvm/firebase-common-internal.api @@ -0,0 +1,243 @@ +public final class dev/gitlive/firebase/internal/AndroidEncodedObject { + public static final fun asNativeMap (Ljava/lang/Object;)Ljava/util/Map; + public static final fun getAndroid (Ldev/gitlive/firebase/internal/EncodedObject;)Ljava/util/Map; +} + +public final class dev/gitlive/firebase/internal/DecodeSettingsImpl : dev/gitlive/firebase/DecodeSettings { + public fun ()V + public fun getSerializersModule ()Lkotlinx/serialization/modules/SerializersModule; +} + +public final class dev/gitlive/firebase/internal/DecodeSettingsImpl$Builder : dev/gitlive/firebase/DecodeSettings$Builder { + public fun ()V + public fun getSerializersModule ()Lkotlinx/serialization/modules/SerializersModule; + public fun setSerializersModule (Lkotlinx/serialization/modules/SerializersModule;)V +} + +public final class dev/gitlive/firebase/internal/DecodersKt { + public static final fun decode (Lkotlinx/serialization/DeserializationStrategy;Ljava/lang/Object;)Ljava/lang/Object; + public static final fun decode (Lkotlinx/serialization/DeserializationStrategy;Ljava/lang/Object;Ldev/gitlive/firebase/DecodeSettings;)Ljava/lang/Object; + public static final fun decode (Lkotlinx/serialization/DeserializationStrategy;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; +} + +public final class dev/gitlive/firebase/internal/EncodeDecodeSettingsBuilderImpl : dev/gitlive/firebase/EncodeDecodeSettingsBuilder { + public fun ()V + public fun getEncodeDefaults ()Z + public fun getSerializersModule ()Lkotlinx/serialization/modules/SerializersModule; + public fun setEncodeDefaults (Z)V + public fun setSerializersModule (Lkotlinx/serialization/modules/SerializersModule;)V +} + +public final class dev/gitlive/firebase/internal/EncodeDecodeSettingsKt { + public static final fun buildDecodeSettings (Ldev/gitlive/firebase/DecodeSettings$Builder;)Ldev/gitlive/firebase/DecodeSettings; + public static final fun buildEncodeSettings (Ldev/gitlive/firebase/EncodeSettings$Builder;)Ldev/gitlive/firebase/EncodeSettings; +} + +public final class dev/gitlive/firebase/internal/EncodeSettingsImpl : dev/gitlive/firebase/EncodeSettings { + public final fun component1 ()Z + public final fun component2 ()Lkotlinx/serialization/modules/SerializersModule; + public final fun copy (ZLkotlinx/serialization/modules/SerializersModule;)Ldev/gitlive/firebase/internal/EncodeSettingsImpl; + public static synthetic fun copy$default (Ldev/gitlive/firebase/internal/EncodeSettingsImpl;ZLkotlinx/serialization/modules/SerializersModule;ILjava/lang/Object;)Ldev/gitlive/firebase/internal/EncodeSettingsImpl; + public fun equals (Ljava/lang/Object;)Z + public fun getEncodeDefaults ()Z + public fun getSerializersModule ()Lkotlinx/serialization/modules/SerializersModule; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/internal/EncodeSettingsImpl$Builder : dev/gitlive/firebase/EncodeSettings$Builder { + public fun ()V + public fun getEncodeDefaults ()Z + public fun getSerializersModule ()Lkotlinx/serialization/modules/SerializersModule; + public fun setEncodeDefaults (Z)V + public fun setSerializersModule (Lkotlinx/serialization/modules/SerializersModule;)V +} + +public abstract interface class dev/gitlive/firebase/internal/EncodedObject { +} + +public final class dev/gitlive/firebase/internal/EncodedObjectImpl : dev/gitlive/firebase/internal/EncodedObject { + public static final synthetic fun box-impl (Ljava/util/Map;)Ldev/gitlive/firebase/internal/EncodedObjectImpl; + public static fun constructor-impl (Ljava/util/Map;)Ljava/util/Map; + public fun equals (Ljava/lang/Object;)Z + public static fun equals-impl (Ljava/util/Map;Ljava/lang/Object;)Z + public static final fun equals-impl0 (Ljava/util/Map;Ljava/util/Map;)Z + public final fun getRaw ()Ljava/util/Map; + public fun hashCode ()I + public static fun hashCode-impl (Ljava/util/Map;)I + public fun toString ()Ljava/lang/String; + public static fun toString-impl (Ljava/util/Map;)Ljava/lang/String; + public final synthetic fun unbox-impl ()Ljava/util/Map; +} + +public final class dev/gitlive/firebase/internal/EncodedObjectKt { + public static final fun asEncodedObject (Ljava/util/Map;)Ldev/gitlive/firebase/internal/EncodedObject; +} + +public final class dev/gitlive/firebase/internal/EncodersKt { + public static final fun encode (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Ldev/gitlive/firebase/EncodeSettings;)Ljava/lang/Object; + public static final fun encode (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; + public static final fun encode (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Z)Ljava/lang/Object; + public static final fun encodeAsObject (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/internal/EncodedObject; + public static synthetic fun encodeAsObject$default (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/internal/EncodedObject; + public static final fun withSerializer (Ljava/lang/Object;Lkotlinx/serialization/SerializationStrategy;)Ljava/lang/Object; +} + +public final class dev/gitlive/firebase/internal/FirebaseClassDecoder : dev/gitlive/firebase/internal/FirebaseCompositeDecoder { + public fun (ILdev/gitlive/firebase/DecodeSettings;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;)V + public fun decodeElementIndex (Lkotlinx/serialization/descriptors/SerialDescriptor;)I + public fun decodeSequentially ()Z +} + +public class dev/gitlive/firebase/internal/FirebaseCompositeDecoder : kotlinx/serialization/encoding/CompositeDecoder { + public fun (ILdev/gitlive/firebase/DecodeSettings;Lkotlin/jvm/functions/Function2;)V + public fun decodeBooleanElement (Lkotlinx/serialization/descriptors/SerialDescriptor;I)Z + public fun decodeByteElement (Lkotlinx/serialization/descriptors/SerialDescriptor;I)B + public fun decodeCharElement (Lkotlinx/serialization/descriptors/SerialDescriptor;I)C + public fun decodeCollectionSize (Lkotlinx/serialization/descriptors/SerialDescriptor;)I + public fun decodeDoubleElement (Lkotlinx/serialization/descriptors/SerialDescriptor;I)D + public fun decodeElementIndex (Lkotlinx/serialization/descriptors/SerialDescriptor;)I + public fun decodeFloatElement (Lkotlinx/serialization/descriptors/SerialDescriptor;I)F + public fun decodeInlineElement (Lkotlinx/serialization/descriptors/SerialDescriptor;I)Lkotlinx/serialization/encoding/Decoder; + public fun decodeIntElement (Lkotlinx/serialization/descriptors/SerialDescriptor;I)I + public fun decodeLongElement (Lkotlinx/serialization/descriptors/SerialDescriptor;I)J + public fun decodeNullableSerializableElement (Lkotlinx/serialization/descriptors/SerialDescriptor;ILkotlinx/serialization/DeserializationStrategy;Ljava/lang/Object;)Ljava/lang/Object; + public fun decodeSequentially ()Z + public fun decodeSerializableElement (Lkotlinx/serialization/descriptors/SerialDescriptor;ILkotlinx/serialization/DeserializationStrategy;Ljava/lang/Object;)Ljava/lang/Object; + public fun decodeShortElement (Lkotlinx/serialization/descriptors/SerialDescriptor;I)S + public fun decodeStringElement (Lkotlinx/serialization/descriptors/SerialDescriptor;I)Ljava/lang/String; + public fun endStructure (Lkotlinx/serialization/descriptors/SerialDescriptor;)V + public fun getSerializersModule ()Lkotlinx/serialization/modules/SerializersModule; +} + +public class dev/gitlive/firebase/internal/FirebaseCompositeEncoder : kotlinx/serialization/encoding/CompositeEncoder { + public fun (Ldev/gitlive/firebase/EncodeSettings;Lkotlin/jvm/functions/Function0;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function3;)V + public synthetic fun (Ldev/gitlive/firebase/EncodeSettings;Lkotlin/jvm/functions/Function0;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function3;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public fun encodeBooleanElement (Lkotlinx/serialization/descriptors/SerialDescriptor;IZ)V + public fun encodeByteElement (Lkotlinx/serialization/descriptors/SerialDescriptor;IB)V + public fun encodeCharElement (Lkotlinx/serialization/descriptors/SerialDescriptor;IC)V + public fun encodeDoubleElement (Lkotlinx/serialization/descriptors/SerialDescriptor;ID)V + public fun encodeFloatElement (Lkotlinx/serialization/descriptors/SerialDescriptor;IF)V + public fun encodeInlineElement (Lkotlinx/serialization/descriptors/SerialDescriptor;I)Lkotlinx/serialization/encoding/Encoder; + public fun encodeIntElement (Lkotlinx/serialization/descriptors/SerialDescriptor;II)V + public fun encodeLongElement (Lkotlinx/serialization/descriptors/SerialDescriptor;IJ)V + public fun encodeNullableSerializableElement (Lkotlinx/serialization/descriptors/SerialDescriptor;ILkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;)V + public final fun encodeObject (Lkotlinx/serialization/descriptors/SerialDescriptor;ILjava/lang/Object;)V + public final fun encodePolymorphicClassDiscriminator (Ljava/lang/String;Ljava/lang/String;)V + public fun encodeSerializableElement (Lkotlinx/serialization/descriptors/SerialDescriptor;ILkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;)V + public fun encodeShortElement (Lkotlinx/serialization/descriptors/SerialDescriptor;IS)V + public fun encodeStringElement (Lkotlinx/serialization/descriptors/SerialDescriptor;ILjava/lang/String;)V + public fun endStructure (Lkotlinx/serialization/descriptors/SerialDescriptor;)V + public fun getSerializersModule ()Lkotlinx/serialization/modules/SerializersModule; + public fun shouldEncodeElementDefault (Lkotlinx/serialization/descriptors/SerialDescriptor;I)Z +} + +public final class dev/gitlive/firebase/internal/FirebaseDecoder : kotlinx/serialization/encoding/Decoder { + public fun (Ljava/lang/Object;)V + public fun (Ljava/lang/Object;Ldev/gitlive/firebase/DecodeSettings;)V + public fun beginStructure (Lkotlinx/serialization/descriptors/SerialDescriptor;)Lkotlinx/serialization/encoding/CompositeDecoder; + public fun decodeBoolean ()Z + public fun decodeByte ()B + public fun decodeChar ()C + public fun decodeDouble ()D + public fun decodeEnum (Lkotlinx/serialization/descriptors/SerialDescriptor;)I + public fun decodeFloat ()F + public fun decodeInline (Lkotlinx/serialization/descriptors/SerialDescriptor;)Lkotlinx/serialization/encoding/Decoder; + public fun decodeInt ()I + public fun decodeLong ()J + public fun decodeNotNullMark ()Z + public fun decodeNull ()Ljava/lang/Void; + public fun decodeNullableSerializableValue (Lkotlinx/serialization/DeserializationStrategy;)Ljava/lang/Object; + public fun decodeSerializableValue (Lkotlinx/serialization/DeserializationStrategy;)Ljava/lang/Object; + public fun decodeShort ()S + public fun decodeString ()Ljava/lang/String; + public fun getSerializersModule ()Lkotlinx/serialization/modules/SerializersModule; + public final fun getValue ()Ljava/lang/Object; +} + +public final class dev/gitlive/firebase/internal/FirebaseEncoder : kotlinx/serialization/encoding/Encoder { + public fun (Ldev/gitlive/firebase/EncodeSettings;)V + public fun (Z)V + public fun beginCollection (Lkotlinx/serialization/descriptors/SerialDescriptor;I)Lkotlinx/serialization/encoding/CompositeEncoder; + public fun beginStructure (Lkotlinx/serialization/descriptors/SerialDescriptor;)Lkotlinx/serialization/encoding/CompositeEncoder; + public fun encodeBoolean (Z)V + public fun encodeByte (B)V + public fun encodeChar (C)V + public fun encodeDouble (D)V + public fun encodeEnum (Lkotlinx/serialization/descriptors/SerialDescriptor;I)V + public fun encodeFloat (F)V + public fun encodeInline (Lkotlinx/serialization/descriptors/SerialDescriptor;)Lkotlinx/serialization/encoding/Encoder; + public fun encodeInt (I)V + public fun encodeLong (J)V + public fun encodeNotNullMark ()V + public fun encodeNull ()V + public fun encodeNullableSerializableValue (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;)V + public fun encodeSerializableValue (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;)V + public fun encodeShort (S)V + public fun encodeString (Ljava/lang/String;)V + public fun getSerializersModule ()Lkotlinx/serialization/modules/SerializersModule; + public final fun getValue ()Ljava/lang/Object; + public final fun setValue (Ljava/lang/Object;)V +} + +public final class dev/gitlive/firebase/internal/FirebaseListSerializer : kotlinx/serialization/KSerializer { + public field list Ljava/util/List; + public fun ()V + public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; + public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/util/List; + public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; + public final fun getList ()Ljava/util/List; + public fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Iterable;)V + public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V + public final fun setList (Ljava/util/List;)V +} + +public final class dev/gitlive/firebase/internal/FirebaseMapSerializer : kotlinx/serialization/KSerializer { + public field keys Ljava/util/List; + public field map Ljava/util/Map; + public fun ()V + public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; + public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/util/Map; + public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; + public final fun getKeys ()Ljava/util/List; + public final fun getMap ()Ljava/util/Map; + public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V + public fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/util/Map;)V + public final fun setKeys (Ljava/util/List;)V + public final fun setMap (Ljava/util/Map;)V +} + +public final class dev/gitlive/firebase/internal/ReencodeTransformationKt { + public static final fun reencodeTransformation (Lkotlinx/serialization/KSerializer;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; + public static synthetic fun reencodeTransformation$default (Lkotlinx/serialization/KSerializer;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/lang/Object; +} + +public final class dev/gitlive/firebase/internal/SpecialValueSerializer : kotlinx/serialization/KSerializer { + public fun (Ljava/lang/String;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;)V + public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; + public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; + public fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V +} + +public final class dev/gitlive/firebase/internal/ValueWithSerializer { + public fun (Ljava/lang/Object;Lkotlinx/serialization/SerializationStrategy;)V + public final fun component1 ()Ljava/lang/Object; + public final fun component2 ()Lkotlinx/serialization/SerializationStrategy; + public final fun copy (Ljava/lang/Object;Lkotlinx/serialization/SerializationStrategy;)Ldev/gitlive/firebase/internal/ValueWithSerializer; + public static synthetic fun copy$default (Ldev/gitlive/firebase/internal/ValueWithSerializer;Ljava/lang/Object;Lkotlinx/serialization/SerializationStrategy;ILjava/lang/Object;)Ldev/gitlive/firebase/internal/ValueWithSerializer; + public fun equals (Ljava/lang/Object;)Z + public final fun getSerializer ()Lkotlinx/serialization/SerializationStrategy; + public final fun getValue ()Ljava/lang/Object; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/internal/_decodersKt { + public static final fun getPolymorphicType (Ljava/lang/Object;Ljava/lang/String;)Ljava/lang/String; + public static final fun structureDecoder (Ldev/gitlive/firebase/internal/FirebaseDecoder;Lkotlinx/serialization/descriptors/SerialDescriptor;Z)Lkotlinx/serialization/encoding/CompositeDecoder; +} + +public final class dev/gitlive/firebase/internal/_encodersKt { + public static final fun structureEncoder (Ldev/gitlive/firebase/internal/FirebaseEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)Ldev/gitlive/firebase/internal/FirebaseCompositeEncoder; +} + diff --git a/firebase-common-internal/build.gradle.kts b/firebase-common-internal/build.gradle.kts index 87ab100e9..3ba8ed69c 100644 --- a/firebase-common-internal/build.gradle.kts +++ b/firebase-common-internal/build.gradle.kts @@ -45,6 +45,8 @@ android { } kotlin { + explicitApi() + @OptIn(ExperimentalKotlinGradlePluginApi::class) compilerOptions { freeCompilerArgs.add("-Xexpect-actual-classes") diff --git a/firebase-common-internal/src/androidMain/kotlin/dev/gitlive/firebase/internal/EncodedObject.kt b/firebase-common-internal/src/androidMain/kotlin/dev/gitlive/firebase/internal/EncodedObject.kt index 1e5fc20a8..ddae0e54d 100644 --- a/firebase-common-internal/src/androidMain/kotlin/dev/gitlive/firebase/internal/EncodedObject.kt +++ b/firebase-common-internal/src/androidMain/kotlin/dev/gitlive/firebase/internal/EncodedObject.kt @@ -1,7 +1,8 @@ @file:JvmName("AndroidEncodedObject") + package dev.gitlive.firebase.internal -val EncodedObject.android: Map get() = getRaw() +public val EncodedObject.android: Map get() = getRaw() @PublishedApi internal actual fun Any.asNativeMap(): Map<*, *>? = this as? Map<*, *> diff --git a/firebase-common-internal/src/androidMain/kotlin/dev/gitlive/firebase/internal/_decoders.kt b/firebase-common-internal/src/androidMain/kotlin/dev/gitlive/firebase/internal/_decoders.kt index 83b71cad6..77644ccfe 100644 --- a/firebase-common-internal/src/androidMain/kotlin/dev/gitlive/firebase/internal/_decoders.kt +++ b/firebase-common-internal/src/androidMain/kotlin/dev/gitlive/firebase/internal/_decoders.kt @@ -9,7 +9,7 @@ import kotlinx.serialization.descriptors.SerialDescriptor import kotlinx.serialization.descriptors.StructureKind import kotlinx.serialization.encoding.CompositeDecoder -actual fun FirebaseDecoder.structureDecoder(descriptor: SerialDescriptor, polymorphicIsNested: Boolean): CompositeDecoder = when (descriptor.kind) { +public actual fun FirebaseDecoder.structureDecoder(descriptor: SerialDescriptor, polymorphicIsNested: Boolean): CompositeDecoder = when (descriptor.kind) { StructureKind.CLASS, StructureKind.OBJECT -> decodeAsMap(false) StructureKind.LIST -> (value as? List<*>).orEmpty().let { FirebaseCompositeDecoder(it.size, settings) { _, index -> it[index] } @@ -18,7 +18,7 @@ actual fun FirebaseDecoder.structureDecoder(descriptor: SerialDescriptor, polymo StructureKind.MAP -> (value as? Map<*, *>).orEmpty().entries.toList().let { FirebaseCompositeDecoder( it.size, - settings + settings, ) { _, index -> it[index / 2].run { if (index % 2 == 0) key else value } } } @@ -26,15 +26,15 @@ actual fun FirebaseDecoder.structureDecoder(descriptor: SerialDescriptor, polymo else -> TODO("The firebase-kotlin-sdk does not support $descriptor for serialization yet") } -actual fun getPolymorphicType(value: Any?, discriminator: String): String = - (value as? Map<*,*>).orEmpty()[discriminator] as String +public actual fun getPolymorphicType(value: Any?, discriminator: String): String = + (value as? Map<*, *>).orEmpty()[discriminator] as String private fun FirebaseDecoder.decodeAsMap(isNestedPolymorphic: Boolean): CompositeDecoder = (value as? Map<*, *>).orEmpty().let { map -> FirebaseClassDecoder(map.size, settings, { map.containsKey(it) }) { desc, index -> if (isNestedPolymorphic) { - if (desc.getElementName(index) == "value") + if (desc.getElementName(index) == "value") { map - else { + } else { map[desc.getElementName(index)] } } else { diff --git a/firebase-common-internal/src/androidMain/kotlin/dev/gitlive/firebase/internal/_encoders.kt b/firebase-common-internal/src/androidMain/kotlin/dev/gitlive/firebase/internal/_encoders.kt index d4f8316fc..e8d3aca10 100644 --- a/firebase-common-internal/src/androidMain/kotlin/dev/gitlive/firebase/internal/_encoders.kt +++ b/firebase-common-internal/src/androidMain/kotlin/dev/gitlive/firebase/internal/_encoders.kt @@ -9,13 +9,13 @@ import kotlinx.serialization.descriptors.SerialDescriptor import kotlinx.serialization.descriptors.StructureKind import kotlin.collections.set -actual fun FirebaseEncoder.structureEncoder(descriptor: SerialDescriptor): FirebaseCompositeEncoder = when(descriptor.kind) { +public actual fun FirebaseEncoder.structureEncoder(descriptor: SerialDescriptor): FirebaseCompositeEncoder = when (descriptor.kind) { StructureKind.LIST -> mutableListOf() .also { value = it } .let { FirebaseCompositeEncoder(settings) { _, index, value -> it.add(index, value) } } StructureKind.MAP -> mutableListOf() .let { FirebaseCompositeEncoder(settings, { value = it.chunked(2).associate { (k, v) -> k to v } }) { _, _, value -> it.add(value) } } - StructureKind.CLASS, StructureKind.OBJECT -> encodeAsMap(descriptor) + StructureKind.CLASS, StructureKind.OBJECT -> encodeAsMap(descriptor) is PolymorphicKind -> encodeAsMap(descriptor) else -> TODO("The firebase-kotlin-sdk does not support $descriptor for serialization yet") } @@ -28,6 +28,6 @@ private fun FirebaseEncoder.encodeAsMap(descriptor: SerialDescriptor): FirebaseC setPolymorphicType = { discriminator, type -> it[discriminator] = type }, - set = { _, index, value -> it[descriptor.getElementName(index)] = value } + set = { _, index, value -> it[descriptor.getElementName(index)] = value }, ) } diff --git a/firebase-common-internal/src/commonMain/kotlin/dev/gitlive/firebase/internal/EncodeDecodeSettings.kt b/firebase-common-internal/src/commonMain/kotlin/dev/gitlive/firebase/internal/EncodeDecodeSettings.kt index 0a1fdda8f..b65fb949f 100644 --- a/firebase-common-internal/src/commonMain/kotlin/dev/gitlive/firebase/internal/EncodeDecodeSettings.kt +++ b/firebase-common-internal/src/commonMain/kotlin/dev/gitlive/firebase/internal/EncodeDecodeSettings.kt @@ -39,5 +39,6 @@ internal class EncodeDecodeSettingsBuilderImpl : EncodeDecodeSettingsBuilder { @PublishedApi internal fun EncodeSettings.Builder.buildEncodeSettings(): EncodeSettings = EncodeSettingsImpl(encodeDefaults, serializersModule) + @PublishedApi internal fun DecodeSettings.Builder.buildDecodeSettings(): DecodeSettings = DecodeSettingsImpl(serializersModule) diff --git a/firebase-common-internal/src/commonMain/kotlin/dev/gitlive/firebase/internal/EncodedObject.kt b/firebase-common-internal/src/commonMain/kotlin/dev/gitlive/firebase/internal/EncodedObject.kt index 9c070b82d..7f2bd45aa 100644 --- a/firebase-common-internal/src/commonMain/kotlin/dev/gitlive/firebase/internal/EncodedObject.kt +++ b/firebase-common-internal/src/commonMain/kotlin/dev/gitlive/firebase/internal/EncodedObject.kt @@ -6,7 +6,7 @@ import kotlin.jvm.JvmInline * Platform specific object for storing encoded data that can be used for methods that explicitly require an object. * This is essentially a [Map] of [String] and [Any]? (as represented by [raw]) but since [encode] gives a platform specific value, this method wraps that. */ -sealed interface EncodedObject +public sealed interface EncodedObject internal fun EncodedObject.getRaw(): Map = when (this) { is EncodedObjectImpl -> raw diff --git a/firebase-common-internal/src/commonMain/kotlin/dev/gitlive/firebase/internal/Polymorphic.kt b/firebase-common-internal/src/commonMain/kotlin/dev/gitlive/firebase/internal/Polymorphic.kt index 5998f26cb..77bb77dc7 100644 --- a/firebase-common-internal/src/commonMain/kotlin/dev/gitlive/firebase/internal/Polymorphic.kt +++ b/firebase-common-internal/src/commonMain/kotlin/dev/gitlive/firebase/internal/Polymorphic.kt @@ -15,7 +15,7 @@ import kotlinx.serialization.internal.AbstractPolymorphicSerializer internal fun FirebaseEncoder.encodePolymorphically( serializer: SerializationStrategy, value: T, - ifPolymorphic: (String) -> Unit + ifPolymorphic: (String) -> Unit, ) { // If serializer is not an AbstractPolymorphicSerializer we can just use the regular serializer // This will result in calling structureEncoder for complicated structures @@ -47,7 +47,7 @@ internal fun FirebaseDecoder.decodeSerializableValuePolymorphic( val type = getPolymorphicType(value, discriminator) val actualDeserializer = casted.findPolymorphicSerializerOrNull( structureDecoder(deserializer.descriptor, false), - type + type, ) as DeserializationStrategy return actualDeserializer.deserialize(this) } diff --git a/firebase-common-internal/src/commonMain/kotlin/dev/gitlive/firebase/internal/decoders.kt b/firebase-common-internal/src/commonMain/kotlin/dev/gitlive/firebase/internal/decoders.kt index a673fb616..084bc4f62 100644 --- a/firebase-common-internal/src/commonMain/kotlin/dev/gitlive/firebase/internal/decoders.kt +++ b/firebase-common-internal/src/commonMain/kotlin/dev/gitlive/firebase/internal/decoders.kt @@ -15,8 +15,8 @@ import kotlinx.serialization.encoding.Decoder import kotlinx.serialization.modules.SerializersModule import kotlinx.serialization.serializer -inline fun decode(value: Any?): T = decode(value) {} -inline fun decode(value: Any?, buildSettings: DecodeSettings.Builder.() -> Unit): T = +public inline fun decode(value: Any?): T = decode(value) {} +public inline fun decode(value: Any?, buildSettings: DecodeSettings.Builder.() -> Unit): T = decode(value, DecodeSettingsImpl.Builder().apply(buildSettings).buildDecodeSettings()) @PublishedApi @@ -24,8 +24,8 @@ internal inline fun decode(value: Any?, decodeSettings: DecodeSettin val strategy = serializer() return decode(strategy as DeserializationStrategy, value, decodeSettings) } -fun decode(strategy: DeserializationStrategy, value: Any?): T = decode(strategy, value) {} -inline fun decode(strategy: DeserializationStrategy, value: Any?, buildSettings: DecodeSettings.Builder.() -> Unit): T = +public fun decode(strategy: DeserializationStrategy, value: Any?): T = decode(strategy, value) {} +public inline fun decode(strategy: DeserializationStrategy, value: Any?, buildSettings: DecodeSettings.Builder.() -> Unit): T = decode(strategy, value, DecodeSettingsImpl.Builder().apply(buildSettings).buildDecodeSettings()) @PublishedApi @@ -33,117 +33,113 @@ internal fun decode(strategy: DeserializationStrategy, value: Any?, decod require(value != null || strategy.descriptor.isNullable) { "Value was null for non-nullable type ${strategy.descriptor.serialName}" } return FirebaseDecoder(value, decodeSettings).decodeSerializableValue(strategy) } -expect fun FirebaseDecoder.structureDecoder(descriptor: SerialDescriptor, polymorphicIsNested: Boolean): CompositeDecoder -expect fun getPolymorphicType(value: Any?, discriminator: String): String +public expect fun FirebaseDecoder.structureDecoder(descriptor: SerialDescriptor, polymorphicIsNested: Boolean): CompositeDecoder +public expect fun getPolymorphicType(value: Any?, discriminator: String): String -class FirebaseDecoder(val value: Any?, internal val settings: DecodeSettings) : Decoder { +public class FirebaseDecoder(public val value: Any?, internal val settings: DecodeSettings) : Decoder { - constructor(value: Any?) : this(value, DecodeSettingsImpl()) + public constructor(value: Any?) : this(value, DecodeSettingsImpl()) override val serializersModule: SerializersModule = settings.serializersModule - override fun beginStructure(descriptor: SerialDescriptor) = structureDecoder(descriptor, true) + override fun beginStructure(descriptor: SerialDescriptor): CompositeDecoder = structureDecoder(descriptor, true) - override fun decodeString() = decodeString(value) + override fun decodeString(): String = decodeString(value) - override fun decodeDouble() = decodeDouble(value) + override fun decodeDouble(): Double = decodeDouble(value) - override fun decodeLong() = decodeLong(value) + override fun decodeLong(): Long = decodeLong(value) - override fun decodeByte() = decodeByte(value) + override fun decodeByte(): Byte = decodeByte(value) - override fun decodeFloat() = decodeFloat(value) + override fun decodeFloat(): Float = decodeFloat(value) - override fun decodeInt() = decodeInt(value) + override fun decodeInt(): Int = decodeInt(value) - override fun decodeShort() = decodeShort(value) + override fun decodeShort(): Short = decodeShort(value) - override fun decodeBoolean() = decodeBoolean(value) + override fun decodeBoolean(): Boolean = decodeBoolean(value) - override fun decodeChar() = decodeChar(value) + override fun decodeChar(): Char = decodeChar(value) - override fun decodeEnum(enumDescriptor: SerialDescriptor) = decodeEnum(value, enumDescriptor) + override fun decodeEnum(enumDescriptor: SerialDescriptor): Int = decodeEnum(value, enumDescriptor) - override fun decodeNotNullMark() = decodeNotNullMark(value) + override fun decodeNotNullMark(): Boolean = decodeNotNullMark(value) - override fun decodeNull() = decodeNull(value) + override fun decodeNull(): Nothing? = decodeNull(value) - override fun decodeInline(descriptor: SerialDescriptor) = FirebaseDecoder(value, settings) + override fun decodeInline(descriptor: SerialDescriptor): Decoder = FirebaseDecoder(value, settings) - override fun decodeSerializableValue(deserializer: DeserializationStrategy): T { - return decodeSerializableValuePolymorphic(value, deserializer) - } + override fun decodeSerializableValue(deserializer: DeserializationStrategy): T = decodeSerializableValuePolymorphic(value, deserializer) } -class FirebaseClassDecoder( +public class FirebaseClassDecoder( size: Int, settings: DecodeSettings, private val containsKey: (name: String) -> Boolean, - get: (descriptor: SerialDescriptor, index: Int) -> Any? + get: (descriptor: SerialDescriptor, index: Int) -> Any?, ) : FirebaseCompositeDecoder(size, settings, get) { private var index: Int = 0 - override fun decodeSequentially() = false + override fun decodeSequentially(): Boolean = false - override fun decodeElementIndex(descriptor: SerialDescriptor): Int { - return (index until descriptor.elementsCount) - .firstOrNull { - !descriptor.isElementOptional(it) || containsKey(descriptor.getElementName(it)) - } - ?.also { index = it + 1 } - ?: DECODE_DONE - } + override fun decodeElementIndex(descriptor: SerialDescriptor): Int = (index until descriptor.elementsCount) + .firstOrNull { + !descriptor.isElementOptional(it) || containsKey(descriptor.getElementName(it)) + } + ?.also { index = it + 1 } + ?: DECODE_DONE } -open class FirebaseCompositeDecoder( +public open class FirebaseCompositeDecoder( private val size: Int, internal val settings: DecodeSettings, private val get: (descriptor: SerialDescriptor, index: Int) -> Any?, -): CompositeDecoder { +) : CompositeDecoder { override val serializersModule: SerializersModule = settings.serializersModule - override fun decodeSequentially() = true + override fun decodeSequentially(): Boolean = true override fun decodeElementIndex(descriptor: SerialDescriptor): Int = throw NotImplementedError() - override fun decodeCollectionSize(descriptor: SerialDescriptor) = size + override fun decodeCollectionSize(descriptor: SerialDescriptor): Int = size override fun decodeSerializableElement( descriptor: SerialDescriptor, index: Int, deserializer: DeserializationStrategy, - previousValue: T? - ) = decodeElement(descriptor, index) { + previousValue: T?, + ): T = decodeElement(descriptor, index) { deserializer.deserialize(FirebaseDecoder(it, settings)) } - override fun decodeBooleanElement(descriptor: SerialDescriptor, index: Int) = + override fun decodeBooleanElement(descriptor: SerialDescriptor, index: Int): Boolean = decodeElement(descriptor, index, ::decodeBoolean) - override fun decodeByteElement(descriptor: SerialDescriptor, index: Int) = + override fun decodeByteElement(descriptor: SerialDescriptor, index: Int): Byte = decodeElement(descriptor, index, ::decodeByte) - override fun decodeCharElement(descriptor: SerialDescriptor, index: Int) = + override fun decodeCharElement(descriptor: SerialDescriptor, index: Int): Char = decodeElement(descriptor, index, ::decodeChar) - override fun decodeDoubleElement(descriptor: SerialDescriptor, index: Int) = + override fun decodeDoubleElement(descriptor: SerialDescriptor, index: Int): Double = decodeElement(descriptor, index, ::decodeDouble) - override fun decodeFloatElement(descriptor: SerialDescriptor, index: Int) = + override fun decodeFloatElement(descriptor: SerialDescriptor, index: Int): Float = decodeElement(descriptor, index, ::decodeFloat) - override fun decodeIntElement(descriptor: SerialDescriptor, index: Int) = + override fun decodeIntElement(descriptor: SerialDescriptor, index: Int): Int = decodeElement(descriptor, index, ::decodeInt) - override fun decodeLongElement(descriptor: SerialDescriptor, index: Int) = + override fun decodeLongElement(descriptor: SerialDescriptor, index: Int): Long = decodeElement(descriptor, index, ::decodeLong) override fun decodeNullableSerializableElement( descriptor: SerialDescriptor, index: Int, deserializer: DeserializationStrategy, - previousValue: T? + previousValue: T?, ): T? { val isNullabilitySupported = deserializer.descriptor.isNullable return if (isNullabilitySupported || decodeElement(descriptor, index, ::decodeNotNullMark)) { @@ -153,10 +149,10 @@ open class FirebaseCompositeDecoder( } } - override fun decodeShortElement(descriptor: SerialDescriptor, index: Int) = + override fun decodeShortElement(descriptor: SerialDescriptor, index: Int): Short = decodeElement(descriptor, index, ::decodeShort) - override fun decodeStringElement(descriptor: SerialDescriptor, index: Int) = + override fun decodeStringElement(descriptor: SerialDescriptor, index: Int): String = decodeElement(descriptor, index, ::decodeString) override fun endStructure(descriptor: SerialDescriptor) {} @@ -167,51 +163,49 @@ open class FirebaseCompositeDecoder( FirebaseDecoder(it, settings) } - private fun decodeElement(descriptor: SerialDescriptor, index: Int, decoder: (Any?) -> T): T { - return try { - decoder(get(descriptor, index)) - } catch (e: Exception) { - throw SerializationException( - message = "Exception during decoding ${descriptor.serialName} ${descriptor.getElementName(index)}", - cause = e - ) - } + private fun decodeElement(descriptor: SerialDescriptor, index: Int, decoder: (Any?) -> T): T = try { + decoder(get(descriptor, index)) + } catch (e: Exception) { + throw SerializationException( + message = "Exception during decoding ${descriptor.serialName} ${descriptor.getElementName(index)}", + cause = e, + ) } } private fun decodeString(value: Any?) = value.toString() -private fun decodeDouble(value: Any?) = when(value) { +private fun decodeDouble(value: Any?) = when (value) { is Number -> value.toDouble() is String -> value.toDouble() else -> throw SerializationException("Expected $value to be double") } -private fun decodeLong(value: Any?) = when(value) { +private fun decodeLong(value: Any?) = when (value) { is Number -> value.toLong() is String -> value.toLong() else -> throw SerializationException("Expected $value to be long") } -private fun decodeByte(value: Any?) = when(value) { +private fun decodeByte(value: Any?) = when (value) { is Number -> value.toByte() is String -> value.toByte() else -> throw SerializationException("Expected $value to be byte") } -private fun decodeFloat(value: Any?) = when(value) { +private fun decodeFloat(value: Any?) = when (value) { is Number -> value.toFloat() is String -> value.toFloat() else -> throw SerializationException("Expected $value to be float") } -private fun decodeInt(value: Any?) = when(value) { +private fun decodeInt(value: Any?) = when (value) { is Number -> value.toInt() is String -> value.toInt() else -> throw SerializationException("Expected $value to be int") } -private fun decodeShort(value: Any?) = when(value) { +private fun decodeShort(value: Any?) = when (value) { is Number -> value.toShort() is String -> value.toShort() else -> throw SerializationException("Expected $value to be short") @@ -224,23 +218,24 @@ private fun decodeBoolean(value: Any?) = when (value) { else -> throw SerializationException("Expected $value to be boolean") } -private fun decodeChar(value: Any?) = when(value) { +private fun decodeChar(value: Any?) = when (value) { is Number -> value.toInt().toChar() is String -> value[0] else -> throw SerializationException("Expected $value to be char") } -private fun decodeEnum(value: Any?, enumDescriptor: SerialDescriptor) = when(value) { +private fun decodeEnum(value: Any?, enumDescriptor: SerialDescriptor) = when (value) { is Number -> value.toInt() is String -> enumDescriptor.getElementIndexOrThrow(value) else -> throw SerializationException("Expected $value to be enum") } -//Made internal after 1.0 stabilization +// Made internal after 1.0 stabilization internal fun SerialDescriptor.getElementIndexOrThrow(name: String): Int { val index = getElementIndex(name) - if (index == CompositeDecoder.UNKNOWN_NAME) + if (index == CompositeDecoder.UNKNOWN_NAME) { throw SerializationException("$serialName does not contain element with name '$name'") + } return index } diff --git a/firebase-common-internal/src/commonMain/kotlin/dev/gitlive/firebase/internal/encoders.kt b/firebase-common-internal/src/commonMain/kotlin/dev/gitlive/firebase/internal/encoders.kt index 1caa20d46..c6c9e4abf 100644 --- a/firebase-common-internal/src/commonMain/kotlin/dev/gitlive/firebase/internal/encoders.kt +++ b/firebase-common-internal/src/commonMain/kotlin/dev/gitlive/firebase/internal/encoders.kt @@ -12,13 +12,12 @@ import kotlinx.serialization.encoding.CompositeEncoder import kotlinx.serialization.encoding.Encoder import kotlinx.serialization.modules.SerializersModule - @Deprecated("Deprecated. Use builder instead", replaceWith = ReplaceWith("encode(strategy, value) { encodeDefaults = shouldEncodeElementDefault }")) -fun encode(strategy: SerializationStrategy, value: T, shouldEncodeElementDefault: Boolean): Any? = encode(strategy, value) { +public fun encode(strategy: SerializationStrategy, value: T, shouldEncodeElementDefault: Boolean): Any? = encode(strategy, value) { this.encodeDefaults = shouldEncodeElementDefault } -inline fun encode(strategy: SerializationStrategy, value: T, buildSettings: EncodeSettings.Builder.() -> Unit) = +public inline fun encode(strategy: SerializationStrategy, value: T, buildSettings: EncodeSettings.Builder.() -> Unit): Any? = encode(strategy, value, EncodeSettingsImpl.Builder().apply(buildSettings).buildEncodeSettings()) @PublishedApi @@ -26,11 +25,11 @@ internal fun encode(strategy: SerializationStrategy, value: T, encodeSett FirebaseEncoder(encodeSettings).apply { encodeSerializableValue(strategy, value) }.value @Deprecated("Deprecated. Use builder instead", replaceWith = ReplaceWith("encode(value) { this.encodeDefaults = shouldEncodeElementDefault }")) -inline fun encode(value: T, shouldEncodeElementDefault: Boolean): Any? = encode(value) { +public inline fun encode(value: T, shouldEncodeElementDefault: Boolean): Any? = encode(value) { this.encodeDefaults = shouldEncodeElementDefault } -inline fun encode(value: T, buildSettings: EncodeSettings.Builder.() -> Unit = {}) = +public inline fun encode(value: T, buildSettings: EncodeSettings.Builder.() -> Unit = {}): Any? = encode(value, EncodeSettingsImpl.Builder().apply(buildSettings).buildEncodeSettings()) /** @@ -38,7 +37,7 @@ inline fun encode(value: T, buildSettings: EncodeSettings.Builder.() * This is not recommended for manual use, but may be done by the library internally. * @throws IllegalArgumentException if [value] is not valid as an [EncodedObject] (e.g. not encodable in the form Map */ -inline fun encodeAsObject(strategy: SerializationStrategy, value: T, buildSettings: EncodeSettings.Builder.() -> Unit = {}): EncodedObject { +public inline fun encodeAsObject(strategy: SerializationStrategy, value: T, buildSettings: EncodeSettings.Builder.() -> Unit = {}): EncodedObject { if (value is Map<*, *> && value.keys.any { it !is String }) { throw IllegalArgumentException("$value is a Map containing non-String keys. Must be of the form Map") } @@ -51,7 +50,7 @@ inline fun encodeAsObject(strategy: SerializationStrategy, value: T * This is not recommended for manual use, but may be done by the library internally. * @throws IllegalArgumentException if [value] is not valid as an [EncodedObject] (e.g. not encodable in the form Map */ -inline fun encodeAsObject(value: T, buildSettings: EncodeSettings.Builder.() -> Unit = {}): EncodedObject { +public inline fun encodeAsObject(value: T, buildSettings: EncodeSettings.Builder.() -> Unit = {}): EncodedObject { if (value is Map<*, *> && value.keys.any { it !is String }) { throw IllegalArgumentException("$value is a Map containing non-String keys. Must be of the form Map") } @@ -78,22 +77,21 @@ internal inline fun encode(value: T, encodeSettings: EncodeSettings) * where using annotation is not possible * @return a value with a custom serializer. */ -fun T.withSerializer(serializer: SerializationStrategy): Any = ValueWithSerializer(this, serializer) -data class ValueWithSerializer(val value: T, val serializer: SerializationStrategy) +public fun T.withSerializer(serializer: SerializationStrategy): Any = ValueWithSerializer(this, serializer) +public data class ValueWithSerializer(val value: T, val serializer: SerializationStrategy) -expect fun FirebaseEncoder.structureEncoder(descriptor: SerialDescriptor): FirebaseCompositeEncoder +public expect fun FirebaseEncoder.structureEncoder(descriptor: SerialDescriptor): FirebaseCompositeEncoder -class FirebaseEncoder( - internal val settings: EncodeSettings +public class FirebaseEncoder( + internal val settings: EncodeSettings, ) : Encoder { - constructor(shouldEncodeElementDefault: Boolean) : this( - EncodeSettingsImpl.Builder().apply { this.encodeDefaults = shouldEncodeElementDefault }.buildEncodeSettings() + public constructor(shouldEncodeElementDefault: Boolean) : this( + EncodeSettingsImpl.Builder().apply { this.encodeDefaults = shouldEncodeElementDefault }.buildEncodeSettings(), ) - var value: Any? = null + public var value: Any? = null - internal val shouldEncodeElementDefault = settings.encodeDefaults override val serializersModule: SerializersModule = settings.serializersModule private var polymorphicDiscriminator: String? = null @@ -140,7 +138,7 @@ class FirebaseEncoder( } override fun encodeNotNullMark() { - //no-op + // no-op } override fun encodeNull() { @@ -164,12 +162,12 @@ class FirebaseEncoder( } } -open class FirebaseCompositeEncoder constructor( +public open class FirebaseCompositeEncoder( private val settings: EncodeSettings, private val end: () -> Unit = {}, private val setPolymorphicType: (String, String) -> Unit = { _, _ -> }, private val set: (descriptor: SerialDescriptor, index: Int, value: Any?) -> Unit, -): CompositeEncoder { +) : CompositeEncoder { // private fun SerializationStrategy.toFirebase(): SerializationStrategy = when(descriptor.kind) { // StructureKind.MAP -> FirebaseMapSerializer(descriptor.getElementDescriptor(1)) as SerializationStrategy @@ -179,63 +177,63 @@ open class FirebaseCompositeEncoder constructor( override val serializersModule: SerializersModule = settings.serializersModule - override fun endStructure(descriptor: SerialDescriptor) = end() + override fun endStructure(descriptor: SerialDescriptor): Unit = end() - override fun shouldEncodeElementDefault(descriptor: SerialDescriptor, index: Int) = settings.encodeDefaults + override fun shouldEncodeElementDefault(descriptor: SerialDescriptor, index: Int): Boolean = settings.encodeDefaults override fun encodeNullableSerializableElement( descriptor: SerialDescriptor, index: Int, serializer: SerializationStrategy, - value: T? - ) = set( + value: T?, + ): Unit = set( descriptor, index, value?.let { FirebaseEncoder(settings).apply { encodeSerializableValue(serializer, value) }.value - } + }, ) override fun encodeSerializableElement( descriptor: SerialDescriptor, index: Int, serializer: SerializationStrategy, - value: T - ) = set( + value: T, + ): Unit = set( descriptor, index, FirebaseEncoder(settings).apply { encodeSerializableValue(serializer, value) - }.value + }.value, ) - fun encodeObject(descriptor: SerialDescriptor, index: Int, value: T) = set(descriptor, index, value) + public fun encodeObject(descriptor: SerialDescriptor, index: Int, value: T): Unit = set(descriptor, index, value) - override fun encodeBooleanElement(descriptor: SerialDescriptor, index: Int, value: Boolean) = set(descriptor, index, value) + override fun encodeBooleanElement(descriptor: SerialDescriptor, index: Int, value: Boolean): Unit = set(descriptor, index, value) - override fun encodeByteElement(descriptor: SerialDescriptor, index: Int, value: Byte) = set(descriptor, index, value) + override fun encodeByteElement(descriptor: SerialDescriptor, index: Int, value: Byte): Unit = set(descriptor, index, value) - override fun encodeCharElement(descriptor: SerialDescriptor, index: Int, value: Char) = set(descriptor, index, value) + override fun encodeCharElement(descriptor: SerialDescriptor, index: Int, value: Char): Unit = set(descriptor, index, value) - override fun encodeDoubleElement(descriptor: SerialDescriptor, index: Int, value: Double) = set(descriptor, index, value) + override fun encodeDoubleElement(descriptor: SerialDescriptor, index: Int, value: Double): Unit = set(descriptor, index, value) - override fun encodeFloatElement(descriptor: SerialDescriptor, index: Int, value: Float) = set(descriptor, index, value) + override fun encodeFloatElement(descriptor: SerialDescriptor, index: Int, value: Float): Unit = set(descriptor, index, value) - override fun encodeIntElement(descriptor: SerialDescriptor, index: Int, value: Int) = set(descriptor, index, value) + override fun encodeIntElement(descriptor: SerialDescriptor, index: Int, value: Int): Unit = set(descriptor, index, value) - override fun encodeLongElement(descriptor: SerialDescriptor, index: Int, value: Long) = set(descriptor, index, value) + override fun encodeLongElement(descriptor: SerialDescriptor, index: Int, value: Long): Unit = set(descriptor, index, value) - override fun encodeShortElement(descriptor: SerialDescriptor, index: Int, value: Short) = set(descriptor, index, value) + override fun encodeShortElement(descriptor: SerialDescriptor, index: Int, value: Short): Unit = set(descriptor, index, value) - override fun encodeStringElement(descriptor: SerialDescriptor, index: Int, value: String) = set(descriptor, index, value) + override fun encodeStringElement(descriptor: SerialDescriptor, index: Int, value: String): Unit = set(descriptor, index, value) @ExperimentalSerializationApi override fun encodeInlineElement(descriptor: SerialDescriptor, index: Int): Encoder = FirebaseEncoder(settings) - fun encodePolymorphicClassDiscriminator(discriminator: String, type: String) { + public fun encodePolymorphicClassDiscriminator(discriminator: String, type: String) { setPolymorphicType(discriminator, type) } } diff --git a/firebase-common-internal/src/commonMain/kotlin/dev/gitlive/firebase/internal/reencodeTransformation.kt b/firebase-common-internal/src/commonMain/kotlin/dev/gitlive/firebase/internal/reencodeTransformation.kt index f7e08d1a1..288e28c1e 100644 --- a/firebase-common-internal/src/commonMain/kotlin/dev/gitlive/firebase/internal/reencodeTransformation.kt +++ b/firebase-common-internal/src/commonMain/kotlin/dev/gitlive/firebase/internal/reencodeTransformation.kt @@ -3,21 +3,21 @@ package dev.gitlive.firebase.internal import dev.gitlive.firebase.EncodeDecodeSettingsBuilder import kotlinx.serialization.KSerializer -inline fun reencodeTransformation(value: Any?, builder: EncodeDecodeSettingsBuilder.() -> Unit = {}, transform: (T) -> T): Any? { +public inline fun reencodeTransformation(value: Any?, builder: EncodeDecodeSettingsBuilder.() -> Unit = {}, transform: (T) -> T): Any? { val encodeDecodeSettingsBuilder = EncodeDecodeSettingsBuilderImpl().apply(builder) val oldValue: T = decode(value, encodeDecodeSettingsBuilder.buildDecodeSettings()) return encode( transform(oldValue), - encodeDecodeSettingsBuilder.buildEncodeSettings() + encodeDecodeSettingsBuilder.buildEncodeSettings(), ) } -inline fun reencodeTransformation(strategy: KSerializer, value: Any?, builder: EncodeDecodeSettingsBuilder.() -> Unit = {}, transform: (T) -> T): Any? { +public inline fun reencodeTransformation(strategy: KSerializer, value: Any?, builder: EncodeDecodeSettingsBuilder.() -> Unit = {}, transform: (T) -> T): Any? { val encodeDecodeSettingsBuilder = EncodeDecodeSettingsBuilderImpl().apply(builder) val oldValue: T = decode(strategy, value, encodeDecodeSettingsBuilder.buildDecodeSettings()) return encode( strategy, transform(oldValue), - encodeDecodeSettingsBuilder.buildEncodeSettings() + encodeDecodeSettingsBuilder.buildEncodeSettings(), ) -} \ No newline at end of file +} diff --git a/firebase-common-internal/src/commonMain/kotlin/dev/gitlive/firebase/internal/serializers.kt b/firebase-common-internal/src/commonMain/kotlin/dev/gitlive/firebase/internal/serializers.kt index 2598bdfa6..41f319f88 100644 --- a/firebase-common-internal/src/commonMain/kotlin/dev/gitlive/firebase/internal/serializers.kt +++ b/firebase-common-internal/src/commonMain/kotlin/dev/gitlive/firebase/internal/serializers.kt @@ -16,9 +16,9 @@ import kotlinx.serialization.encoding.Encoder import kotlinx.serialization.serializer @Suppress("UNCHECKED_CAST") -inline fun T.firebaseSerializer() = runCatching { serializer() } +public inline fun T.firebaseSerializer(): SerializationStrategy = runCatching { serializer() } .getOrElse { - when(this) { + when (this) { is Map<*, *> -> FirebaseMapSerializer() is List<*> -> FirebaseListSerializer() is Set<*> -> FirebaseListSerializer() @@ -26,12 +26,12 @@ inline fun T.firebaseSerializer() = runCatching { serializer } as SerializationStrategy } -class FirebaseMapSerializer : KSerializer> { +public class FirebaseMapSerializer : KSerializer> { - lateinit var keys: List - lateinit var map: Map + public lateinit var keys: List + public lateinit var map: Map - override val descriptor = object : SerialDescriptor { + override val descriptor: SerialDescriptor = object : SerialDescriptor { override val kind = StructureKind.MAP override val serialName = "kotlin.Map" override val elementsCount get() = map.size @@ -54,7 +54,10 @@ class FirebaseMapSerializer : KSerializer> { collectionEncoder.encodeSerializableElement(it.descriptor, index * 2, it, key) } collectionEncoder.encodeNullableSerializableElement( - serializer.descriptor, index * 2 + 1, serializer, listValue + serializer.descriptor, + index * 2 + 1, + serializer, + listValue, ) } collectionEncoder.endStructure(descriptor) @@ -63,7 +66,7 @@ class FirebaseMapSerializer : KSerializer> { override fun deserialize(decoder: Decoder): Map { val collectionDecoder = decoder.beginStructure(descriptor) as FirebaseCompositeDecoder val map = mutableMapOf() - for(index in 0 until collectionDecoder.decodeCollectionSize(descriptor) * 2 step 2) { + for (index in 0 until collectionDecoder.decodeCollectionSize(descriptor) * 2 step 2) { // map[collectionDecoder.decodeNullableSerializableElement(index) as String] = // collectionDecoder.decodeNullableSerializableElement(index + 1) } @@ -71,11 +74,11 @@ class FirebaseMapSerializer : KSerializer> { } } -class FirebaseListSerializer : KSerializer> { +public class FirebaseListSerializer : KSerializer> { - lateinit var list: List + public lateinit var list: List - override val descriptor = object : SerialDescriptor { + override val descriptor: SerialDescriptor = object : SerialDescriptor { override val kind = StructureKind.LIST override val serialName = "kotlin.List" override val elementsCount get() = list.size @@ -93,7 +96,10 @@ class FirebaseListSerializer : KSerializer> { list.forEachIndexed { index, listValue -> val serializer = (listValue?.firebaseSerializer() ?: Unit.serializer()) as KSerializer collectionEncoder.encodeNullableSerializableElement( - serializer.descriptor, index, serializer, listValue + serializer.descriptor, + index, + serializer, + listValue, ) } collectionEncoder.endStructure(descriptor) @@ -114,12 +120,12 @@ class FirebaseListSerializer : KSerializer> { * A special case of serializer for values natively supported by Firebase and * don't require an additional encoding/decoding. */ -class SpecialValueSerializer( +public class SpecialValueSerializer( serialName: String, private val toNativeValue: (T) -> Any?, - private val fromNativeValue: (Any?) -> T + private val fromNativeValue: (Any?) -> T, ) : KSerializer { - override val descriptor = buildClassSerialDescriptor(serialName) { } + override val descriptor: SerialDescriptor = buildClassSerialDescriptor(serialName) { } override fun serialize(encoder: Encoder, value: T) { if (encoder is FirebaseEncoder) { @@ -129,11 +135,9 @@ class SpecialValueSerializer( } } - override fun deserialize(decoder: Decoder): T { - return if (decoder is FirebaseDecoder) { - fromNativeValue(decoder.value) - } else { - throw SerializationException("This serializer must be used with FirebaseDecoder") - } + override fun deserialize(decoder: Decoder): T = if (decoder is FirebaseDecoder) { + fromNativeValue(decoder.value) + } else { + throw SerializationException("This serializer must be used with FirebaseDecoder") } } diff --git a/firebase-common-internal/src/commonTest/kotlin/dev/gitlive/firebase/internal/EncodersTest.kt b/firebase-common-internal/src/commonTest/kotlin/dev/gitlive/firebase/internal/EncodersTest.kt index 1e2385846..145d57b74 100644 --- a/firebase-common-internal/src/commonTest/kotlin/dev/gitlive/firebase/internal/EncodersTest.kt +++ b/firebase-common-internal/src/commonTest/kotlin/dev/gitlive/firebase/internal/EncodersTest.kt @@ -21,10 +21,11 @@ import kotlin.test.assertEquals import kotlin.test.assertFailsWith import kotlin.test.assertNull +@Suppress("unused") @Serializable object TestObject { val map = mapOf("key" to "value", "key2" to 12, "key3" to null) - val bool = false + const val BOOL = false val nullableBool: Boolean? = null } @@ -50,7 +51,7 @@ sealed class SealedClass { @Serializable data class GenericClass( - val inner: T + val inner: T, ) @Serializable @@ -72,7 +73,7 @@ data class NestedClass( val abstractList: List, val testDataMap: Map, val sealedMap: Map, - val abstractMap: Map + val abstractMap: Map, ) class EncodersTest { @@ -88,6 +89,7 @@ class EncodersTest { assertEncode(6.65f) assertEncode("Test") } + @Test fun encodeDecodeList() { val list = listOf("One", "Two", "Three") @@ -249,9 +251,9 @@ class EncodersTest { "abstractList" to nativeListOf(abstractEncoded), "testDataMap" to nativeMapOf(testDataEncoded to testDataEncoded), "sealedMap" to nativeMapOf(sealedEncoded to sealedEncoded), - "abstractMap" to nativeMapOf(abstractEncoded to abstractEncoded) + "abstractMap" to nativeMapOf(abstractEncoded to abstractEncoded), ), - encoded + encoded, ) val decoded = decode(NestedClass.serializer(), encoded) { @@ -292,7 +294,7 @@ class EncodersTest { fun reencodeTransformationValueClass() { val reencoded = reencodeTransformation( 42, - { encodeDefaults = false } + { encodeDefaults = false }, ) { assertEquals(ValueClass(42), it) ValueClass(23) @@ -305,7 +307,7 @@ class EncodersTest { fun reencodeTransformationClass() { val reencoded = reencodeTransformation( nativeMapOf("map" to nativeMapOf("key" to "value"), "otherMap" to nativeMapOf(1 to 1), "bool" to true, "nullableBool" to true, "valueClass" to 42), - { encodeDefaults = false } + { encodeDefaults = false }, ) { assertEquals(TestData(mapOf("key" to "value"), mapOf(1 to 1), bool = true, nullableBool = true, ValueClass(42)), it) it.copy(map = mapOf("newKey" to "newValue"), nullableBool = null) @@ -318,7 +320,7 @@ class EncodersTest { fun reencodeTransformationNullableValue() { val reencoded = reencodeTransformation( nativeMapOf("map" to nativeMapOf("key" to "value"), "otherMap" to nativeMapOf(1 to 1), "bool" to true, "nullableBool" to true, "valueClass" to 42), - { encodeDefaults = false } + { encodeDefaults = false }, ) { assertEquals(TestData(mapOf("key" to "value"), mapOf(1 to 1), bool = true, nullableBool = true, valueClass = ValueClass(42)), it) null @@ -332,11 +334,11 @@ class EncodersTest { val reencoded = reencodeTransformation( GenericClass.serializer(TestData.serializer()), nativeMapOf("inner" to nativeMapOf("map" to nativeMapOf("key" to "value"), "otherMap" to nativeMapOf(1 to 1), "bool" to true, "nullableBool" to false, "valueClass" to 42)), - { encodeDefaults = false } + { encodeDefaults = false }, ) { assertEquals( GenericClass(TestData(mapOf("key" to "value"), mapOf(1 to 1), bool = true, nullableBool = false, valueClass = ValueClass(42))), - it + it, ) GenericClass(it.inner.copy(map = mapOf("newKey" to "newValue"), nullableBool = null)) } @@ -367,7 +369,7 @@ class EncodersTest { nativeMapOf("type" to "implemented", "abstractValue" to "value", "otherValue" to true), builder = { serializersModule = module - } + }, ) { assertEquals(ImplementedClass("value", true), it) ImplementedClass("new-${it.abstractValue}", false) @@ -414,9 +416,9 @@ class EncodersTest { "abstractList" to nativeListOf(abstractEncoded), "testDataMap" to nativeMapOf(testDataEncoded to testDataEncoded), "sealedMap" to nativeMapOf(sealedEncoded to sealedEncoded), - "abstractMap" to nativeMapOf(abstractEncoded to abstractEncoded) + "abstractMap" to nativeMapOf(abstractEncoded to abstractEncoded), ), - reencoded + reencoded, ) } @@ -425,7 +427,7 @@ class EncodersTest { val testDataClass = TestData(mapOf("key" to "value"), mapOf(1 to 1), true, null, ValueClass(42)) val encodedObject = encodeAsObject( TestData.serializer(), - testDataClass + testDataClass, ) { encodeDefaults = false } nativeAssertEquals(mapOf("map" to nativeMapOf("key" to "value"), "otherMap" to nativeMapOf(1 to 1), "bool" to true, "valueClass" to 42), encodedObject.getRaw()) @@ -437,7 +439,7 @@ class EncodersTest { assertFailsWith { encodeAsObject( - true + true, ) } assertFailsWith { encodeAsObject(42) } @@ -445,33 +447,33 @@ class EncodersTest { assertFailsWith { encodeAsObject(Int.MAX_VALUE.toLong() + 3) } assertFailsWith { encodeAsObject( - 0x03F + 0x03F, ) } assertFailsWith { encodeAsObject( - 3.33 + 3.33, ) } assertFailsWith { encodeAsObject( - 6.65f + 6.65f, ) } assertFailsWith { encodeAsObject("Test") } assertFailsWith { encodeAsObject( - ValueClass(2) + ValueClass(2), ) } assertFailsWith { encodeAsObject( - mapOf(1 to "one") + mapOf(1 to "one"), ) } assertFailsWith { encodeAsObject( - listOf("one") + listOf("one"), ) } } diff --git a/firebase-common-internal/src/iosMain/kotlin/dev/gitlive/firebase/internal/EncodedObject.kt b/firebase-common-internal/src/iosMain/kotlin/dev/gitlive/firebase/internal/EncodedObject.kt index 9d4e6643a..b7221bf7a 100644 --- a/firebase-common-internal/src/iosMain/kotlin/dev/gitlive/firebase/internal/EncodedObject.kt +++ b/firebase-common-internal/src/iosMain/kotlin/dev/gitlive/firebase/internal/EncodedObject.kt @@ -1,6 +1,6 @@ package dev.gitlive.firebase.internal -val EncodedObject.ios: Map get() = getRaw().mapKeys { (key, _) -> key } +public val EncodedObject.ios: Map get() = getRaw().mapKeys { (key, _) -> key } @PublishedApi internal actual fun Any.asNativeMap(): Map<*, *>? = this as? Map<*, *> diff --git a/firebase-common-internal/src/iosMain/kotlin/dev/gitlive/firebase/internal/_decoders.kt b/firebase-common-internal/src/iosMain/kotlin/dev/gitlive/firebase/internal/_decoders.kt index c479c5bd6..00400b622 100644 --- a/firebase-common-internal/src/iosMain/kotlin/dev/gitlive/firebase/internal/_decoders.kt +++ b/firebase-common-internal/src/iosMain/kotlin/dev/gitlive/firebase/internal/_decoders.kt @@ -9,18 +9,18 @@ import kotlinx.serialization.descriptors.PolymorphicKind import kotlinx.serialization.descriptors.SerialDescriptor import kotlinx.serialization.descriptors.StructureKind -actual fun FirebaseDecoder.structureDecoder(descriptor: SerialDescriptor, polymorphicIsNested: Boolean): CompositeDecoder = when(descriptor.kind) { +public actual fun FirebaseDecoder.structureDecoder(descriptor: SerialDescriptor, polymorphicIsNested: Boolean): CompositeDecoder = when (descriptor.kind) { StructureKind.CLASS, StructureKind.OBJECT -> decodeAsMap(false) StructureKind.LIST -> decodeAsList() StructureKind.MAP -> (value as? Map<*, *>).orEmpty().entries.toList().let { - FirebaseCompositeDecoder(it.size, settings) { _, index -> it[index/2].run { if(index % 2 == 0) key else value } } + FirebaseCompositeDecoder(it.size, settings) { _, index -> it[index / 2].run { if (index % 2 == 0) key else value } } } is PolymorphicKind -> decodeAsMap(polymorphicIsNested) else -> TODO("The firebase-kotlin-sdk does not support $descriptor for serialization yet") } -actual fun getPolymorphicType(value: Any?, discriminator: String): String = - (value as? Map<*,*>).orEmpty()[discriminator] as String +public actual fun getPolymorphicType(value: Any?, discriminator: String): String = + (value as? Map<*, *>).orEmpty()[discriminator] as String private fun FirebaseDecoder.decodeAsList(): CompositeDecoder = (value as? List<*>).orEmpty().let { FirebaseCompositeDecoder(it.size, settings) { _, index -> it[index] } @@ -28,9 +28,9 @@ private fun FirebaseDecoder.decodeAsList(): CompositeDecoder = (value as? List<* private fun FirebaseDecoder.decodeAsMap(isNestedPolymorphic: Boolean): CompositeDecoder = (value as? Map<*, *>).orEmpty().let { map -> FirebaseClassDecoder(map.size, settings, { map.containsKey(it) }) { desc, index -> if (isNestedPolymorphic) { - if (desc.getElementName(index) == "value") + if (desc.getElementName(index) == "value") { map - else { + } else { map[desc.getElementName(index)] } } else { diff --git a/firebase-common-internal/src/iosMain/kotlin/dev/gitlive/firebase/internal/_encoders.kt b/firebase-common-internal/src/iosMain/kotlin/dev/gitlive/firebase/internal/_encoders.kt index 966a7e64e..efd200c20 100644 --- a/firebase-common-internal/src/iosMain/kotlin/dev/gitlive/firebase/internal/_encoders.kt +++ b/firebase-common-internal/src/iosMain/kotlin/dev/gitlive/firebase/internal/_encoders.kt @@ -9,11 +9,11 @@ import kotlinx.serialization.descriptors.SerialDescriptor import kotlinx.serialization.descriptors.StructureKind import kotlin.collections.set -actual fun FirebaseEncoder.structureEncoder(descriptor: SerialDescriptor): FirebaseCompositeEncoder = when(descriptor.kind) { +public actual fun FirebaseEncoder.structureEncoder(descriptor: SerialDescriptor): FirebaseCompositeEncoder = when (descriptor.kind) { StructureKind.LIST -> encodeAsList() StructureKind.MAP -> mutableListOf() .let { FirebaseCompositeEncoder(settings, { value = it.chunked(2).associate { (k, v) -> k to v } }) { _, _, value -> it.add(value) } } - StructureKind.CLASS, StructureKind.OBJECT-> encodeAsMap(descriptor) + StructureKind.CLASS, StructureKind.OBJECT -> encodeAsMap(descriptor) is PolymorphicKind -> encodeAsMap(descriptor) else -> TODO("The firebase-kotlin-sdk does not support $descriptor for serialization yet") } @@ -29,6 +29,6 @@ private fun FirebaseEncoder.encodeAsMap(descriptor: SerialDescriptor): FirebaseC setPolymorphicType = { discriminator, type -> it[discriminator] = type }, - set = { _, index, value -> it[descriptor.getElementName(index)] = value } + set = { _, index, value -> it[descriptor.getElementName(index)] = value }, ) } diff --git a/firebase-common-internal/src/jsMain/kotlin/dev/gitlive/firebase/internal/EncodedObject.kt b/firebase-common-internal/src/jsMain/kotlin/dev/gitlive/firebase/internal/EncodedObject.kt index 6c2724233..ad90414d6 100644 --- a/firebase-common-internal/src/jsMain/kotlin/dev/gitlive/firebase/internal/EncodedObject.kt +++ b/firebase-common-internal/src/jsMain/kotlin/dev/gitlive/firebase/internal/EncodedObject.kt @@ -3,7 +3,7 @@ package dev.gitlive.firebase.internal import kotlin.js.Json import kotlin.js.json -val EncodedObject.js: Json get() = json(*getRaw().entries.map { (key, value) -> key to value }.toTypedArray()) +public val EncodedObject.js: Json get() = json(*getRaw().entries.map { (key, value) -> key to value }.toTypedArray()) @PublishedApi internal actual fun Any.asNativeMap(): Map<*, *>? { @@ -27,7 +27,7 @@ internal actual fun Any.asNativeMap(): Map<*, *>? { } ?: return null val mutableMap = mutableMapOf() for (key in js("Object").keys(json)) { - mutableMap[key as String] = json[key as String] + mutableMap[key.unsafeCast()] = json[key.unsafeCast()] } return mutableMap.toMap() } diff --git a/firebase-common-internal/src/jsMain/kotlin/dev/gitlive/firebase/internal/_decoders.kt b/firebase-common-internal/src/jsMain/kotlin/dev/gitlive/firebase/internal/_decoders.kt index 167fc7f8e..05701df40 100644 --- a/firebase-common-internal/src/jsMain/kotlin/dev/gitlive/firebase/internal/_decoders.kt +++ b/firebase-common-internal/src/jsMain/kotlin/dev/gitlive/firebase/internal/_decoders.kt @@ -11,21 +11,27 @@ import kotlinx.serialization.descriptors.StructureKind import kotlinx.serialization.encoding.CompositeDecoder import kotlin.js.Json -actual fun FirebaseDecoder.structureDecoder(descriptor: SerialDescriptor, polymorphicIsNested: Boolean): CompositeDecoder = when (descriptor.kind) { +public actual fun FirebaseDecoder.structureDecoder(descriptor: SerialDescriptor, polymorphicIsNested: Boolean): CompositeDecoder = when (descriptor.kind) { StructureKind.CLASS, StructureKind.OBJECT -> decodeAsMap(false) StructureKind.LIST -> decodeAsList() StructureKind.MAP -> (js("Object").entries(value) as Array>).let { FirebaseCompositeDecoder( it.size, - settings - ) { desc, index -> it[index / 2].run { if (index % 2 == 0) { - val key = get(0) as String - if (desc.getElementDescriptor(index).kind == PrimitiveKind.STRING) { - key - } else { - JSON.parse(key) + settings, + ) { desc, index -> + it[index / 2].run { + if (index % 2 == 0) { + val key = get(0) as String + if (desc.getElementDescriptor(index).kind == PrimitiveKind.STRING) { + key + } else { + JSON.parse(key) + } + } else { + get(1) + } } - } else get(1) } } + } } is PolymorphicKind -> decodeAsMap(polymorphicIsNested) @@ -33,12 +39,13 @@ actual fun FirebaseDecoder.structureDecoder(descriptor: SerialDescriptor, polymo } @Suppress("UNCHECKED_CAST_TO_EXTERNAL_INTERFACE") -actual fun getPolymorphicType(value: Any?, discriminator: String): String = +public actual fun getPolymorphicType(value: Any?, discriminator: String): String = (value as Json)[discriminator] as String private fun FirebaseDecoder.decodeAsList(): CompositeDecoder = (value as Array<*>).let { FirebaseCompositeDecoder(it.size, settings) { _, index -> it[index] } } + @Suppress("UNCHECKED_CAST_TO_EXTERNAL_INTERFACE") private fun FirebaseDecoder.decodeAsMap(isNestedPolymorphic: Boolean): CompositeDecoder = (value as Json).let { json -> FirebaseClassDecoder(js("Object").keys(value).length as Int, settings, { json[it] != undefined }) { desc, index -> @@ -52,4 +59,4 @@ private fun FirebaseDecoder.decodeAsMap(isNestedPolymorphic: Boolean): Composite json[desc.getElementName(index)] } } -} \ No newline at end of file +} diff --git a/firebase-common-internal/src/jsMain/kotlin/dev/gitlive/firebase/internal/_encoders.kt b/firebase-common-internal/src/jsMain/kotlin/dev/gitlive/firebase/internal/_encoders.kt index 5cf22b6bd..1e21549a0 100644 --- a/firebase-common-internal/src/jsMain/kotlin/dev/gitlive/firebase/internal/_encoders.kt +++ b/firebase-common-internal/src/jsMain/kotlin/dev/gitlive/firebase/internal/_encoders.kt @@ -9,7 +9,7 @@ import kotlinx.serialization.descriptors.SerialDescriptor import kotlinx.serialization.descriptors.StructureKind import kotlin.js.json -actual fun FirebaseEncoder.structureEncoder(descriptor: SerialDescriptor): FirebaseCompositeEncoder = when(descriptor.kind) { +public actual fun FirebaseEncoder.structureEncoder(descriptor: SerialDescriptor): FirebaseCompositeEncoder = when (descriptor.kind) { StructureKind.LIST -> encodeAsList(descriptor) StructureKind.MAP -> { val map = json() @@ -23,7 +23,7 @@ actual fun FirebaseEncoder.structureEncoder(descriptor: SerialDescriptor): Fireb } } } - StructureKind.CLASS, StructureKind.OBJECT -> encodeAsMap(descriptor) + StructureKind.CLASS, StructureKind.OBJECT -> encodeAsMap(descriptor) is PolymorphicKind -> encodeAsMap(descriptor) else -> TODO("The firebase-kotlin-sdk does not support $descriptor for serialization yet") } @@ -39,6 +39,6 @@ private fun FirebaseEncoder.encodeAsMap(descriptor: SerialDescriptor): FirebaseC setPolymorphicType = { discriminator, type -> it[discriminator] = type }, - set = { _, index, value -> it[descriptor.getElementName(index)] = value } + set = { _, index, value -> it[descriptor.getElementName(index)] = value }, ) } diff --git a/firebase-common/api/android/firebase-common.api b/firebase-common/api/android/firebase-common.api new file mode 100644 index 000000000..2b70a6e8a --- /dev/null +++ b/firebase-common/api/android/firebase-common.api @@ -0,0 +1,35 @@ +public abstract interface class dev/gitlive/firebase/DecodeSettings : dev/gitlive/firebase/EncodeDecodeSettings { +} + +public abstract interface class dev/gitlive/firebase/DecodeSettings$Builder { + public abstract fun getSerializersModule ()Lkotlinx/serialization/modules/SerializersModule; + public abstract fun setSerializersModule (Lkotlinx/serialization/modules/SerializersModule;)V +} + +public abstract interface class dev/gitlive/firebase/EncodeDecodeSettings { + public abstract fun getSerializersModule ()Lkotlinx/serialization/modules/SerializersModule; +} + +public abstract interface class dev/gitlive/firebase/EncodeDecodeSettingsBuilder : dev/gitlive/firebase/DecodeSettings$Builder, dev/gitlive/firebase/EncodeSettings$Builder { +} + +public abstract interface class dev/gitlive/firebase/EncodeSettings : dev/gitlive/firebase/EncodeDecodeSettings { + public abstract fun getEncodeDefaults ()Z +} + +public abstract interface class dev/gitlive/firebase/EncodeSettings$Builder { + public abstract fun getEncodeDefaults ()Z + public abstract fun getSerializersModule ()Lkotlinx/serialization/modules/SerializersModule; + public abstract fun setEncodeDefaults (Z)V + public abstract fun setSerializersModule (Lkotlinx/serialization/modules/SerializersModule;)V +} + +public abstract interface annotation class dev/gitlive/firebase/FirebaseClassDiscriminator : java/lang/annotation/Annotation { + public abstract fun discriminator ()Ljava/lang/String; +} + +public synthetic class dev/gitlive/firebase/FirebaseClassDiscriminator$Impl : dev/gitlive/firebase/FirebaseClassDiscriminator { + public fun (Ljava/lang/String;)V + public final synthetic fun discriminator ()Ljava/lang/String; +} + diff --git a/firebase-common/api/jvm/firebase-common.api b/firebase-common/api/jvm/firebase-common.api new file mode 100644 index 000000000..2b70a6e8a --- /dev/null +++ b/firebase-common/api/jvm/firebase-common.api @@ -0,0 +1,35 @@ +public abstract interface class dev/gitlive/firebase/DecodeSettings : dev/gitlive/firebase/EncodeDecodeSettings { +} + +public abstract interface class dev/gitlive/firebase/DecodeSettings$Builder { + public abstract fun getSerializersModule ()Lkotlinx/serialization/modules/SerializersModule; + public abstract fun setSerializersModule (Lkotlinx/serialization/modules/SerializersModule;)V +} + +public abstract interface class dev/gitlive/firebase/EncodeDecodeSettings { + public abstract fun getSerializersModule ()Lkotlinx/serialization/modules/SerializersModule; +} + +public abstract interface class dev/gitlive/firebase/EncodeDecodeSettingsBuilder : dev/gitlive/firebase/DecodeSettings$Builder, dev/gitlive/firebase/EncodeSettings$Builder { +} + +public abstract interface class dev/gitlive/firebase/EncodeSettings : dev/gitlive/firebase/EncodeDecodeSettings { + public abstract fun getEncodeDefaults ()Z +} + +public abstract interface class dev/gitlive/firebase/EncodeSettings$Builder { + public abstract fun getEncodeDefaults ()Z + public abstract fun getSerializersModule ()Lkotlinx/serialization/modules/SerializersModule; + public abstract fun setEncodeDefaults (Z)V + public abstract fun setSerializersModule (Lkotlinx/serialization/modules/SerializersModule;)V +} + +public abstract interface annotation class dev/gitlive/firebase/FirebaseClassDiscriminator : java/lang/annotation/Annotation { + public abstract fun discriminator ()Ljava/lang/String; +} + +public synthetic class dev/gitlive/firebase/FirebaseClassDiscriminator$Impl : dev/gitlive/firebase/FirebaseClassDiscriminator { + public fun (Ljava/lang/String;)V + public final synthetic fun discriminator ()Ljava/lang/String; +} + diff --git a/firebase-common/build.gradle.kts b/firebase-common/build.gradle.kts index 99a2fea11..2c047ba1e 100644 --- a/firebase-common/build.gradle.kts +++ b/firebase-common/build.gradle.kts @@ -45,6 +45,8 @@ android { } kotlin { + explicitApi() + @OptIn(ExperimentalKotlinGradlePluginApi::class) compilerOptions { freeCompilerArgs.add("-Xexpect-actual-classes") diff --git a/firebase-common/src/commonMain/kotlin/dev/gitlive/firebase/EncodeDecodeSettings.kt b/firebase-common/src/commonMain/kotlin/dev/gitlive/firebase/EncodeDecodeSettings.kt index 81b7690db..d73b9ede0 100644 --- a/firebase-common/src/commonMain/kotlin/dev/gitlive/firebase/EncodeDecodeSettings.kt +++ b/firebase-common/src/commonMain/kotlin/dev/gitlive/firebase/EncodeDecodeSettings.kt @@ -1,31 +1,29 @@ package dev.gitlive.firebase -import kotlinx.serialization.modules.EmptySerializersModule import kotlinx.serialization.modules.SerializersModule /** * Settings used to configure encoding/decoding */ -sealed interface EncodeDecodeSettings { +public sealed interface EncodeDecodeSettings { /** * The [SerializersModule] to use for serialization. This allows for polymorphic serialization on runtime */ - val serializersModule: SerializersModule + public val serializersModule: SerializersModule } /** * [EncodeDecodeSettings] used when encoding an object * @property encodeDefaults if `true` this will explicitly encode elements even if they are their default value */ -interface EncodeSettings : EncodeDecodeSettings { +public interface EncodeSettings : EncodeDecodeSettings { - val encodeDefaults: Boolean - - interface Builder { - var encodeDefaults: Boolean - var serializersModule: SerializersModule + public val encodeDefaults: Boolean + public interface Builder { + public var encodeDefaults: Boolean + public var serializersModule: SerializersModule } } @@ -33,11 +31,13 @@ interface EncodeSettings : EncodeDecodeSettings { * [EncodeDecodeSettings] used when decoding an object * @param serializersModule the [SerializersModule] to use for deserialization. This allows for polymorphic serialization on runtime */ -interface DecodeSettings : EncodeDecodeSettings { +public interface DecodeSettings : EncodeDecodeSettings { - interface Builder { - var serializersModule: SerializersModule + public interface Builder { + public var serializersModule: SerializersModule } } -interface EncodeDecodeSettingsBuilder : EncodeSettings.Builder, DecodeSettings.Builder +public interface EncodeDecodeSettingsBuilder : + EncodeSettings.Builder, + DecodeSettings.Builder diff --git a/firebase-common/src/commonMain/kotlin/dev/gitlive/firebase/FirebaseClassDiscriminator.kt b/firebase-common/src/commonMain/kotlin/dev/gitlive/firebase/FirebaseClassDiscriminator.kt index 2ed4bafa1..6a8fbbc4b 100644 --- a/firebase-common/src/commonMain/kotlin/dev/gitlive/firebase/FirebaseClassDiscriminator.kt +++ b/firebase-common/src/commonMain/kotlin/dev/gitlive/firebase/FirebaseClassDiscriminator.kt @@ -4,4 +4,4 @@ import kotlinx.serialization.InheritableSerialInfo @InheritableSerialInfo @Target(AnnotationTarget.CLASS) -annotation class FirebaseClassDiscriminator(val discriminator: String) \ No newline at end of file +public annotation class FirebaseClassDiscriminator(val discriminator: String) diff --git a/firebase-common/src/jsMain/kotlin/dev/gitlive/firebase/Unsubscribe.kt b/firebase-common/src/jsMain/kotlin/dev/gitlive/firebase/Unsubscribe.kt index 087d4f86b..4a0ea36c9 100644 --- a/firebase-common/src/jsMain/kotlin/dev/gitlive/firebase/Unsubscribe.kt +++ b/firebase-common/src/jsMain/kotlin/dev/gitlive/firebase/Unsubscribe.kt @@ -4,4 +4,4 @@ package dev.gitlive.firebase -typealias Unsubscribe = () -> Unit +public typealias Unsubscribe = () -> Unit diff --git a/firebase-config/api/android/firebase-config.api b/firebase-config/api/android/firebase-config.api new file mode 100644 index 000000000..5319fe7bd --- /dev/null +++ b/firebase-config/api/android/firebase-config.api @@ -0,0 +1,81 @@ +public final class dev/gitlive/firebase/remoteconfig/FetchStatus : java/lang/Enum { + public static final field Failure Ldev/gitlive/firebase/remoteconfig/FetchStatus; + public static final field NoFetchYet Ldev/gitlive/firebase/remoteconfig/FetchStatus; + public static final field Success Ldev/gitlive/firebase/remoteconfig/FetchStatus; + public static final field Throttled Ldev/gitlive/firebase/remoteconfig/FetchStatus; + public static fun getEntries ()Lkotlin/enums/EnumEntries; + public static fun valueOf (Ljava/lang/String;)Ldev/gitlive/firebase/remoteconfig/FetchStatus; + public static fun values ()[Ldev/gitlive/firebase/remoteconfig/FetchStatus; +} + +public final class dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig { + public final fun activate (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun ensureInitialized (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun fetch (Ljava/lang/Long;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static synthetic fun fetch$default (Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig;Ljava/lang/Long;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; + public final fun fetchAndActivate (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun getAll ()Ljava/util/Map; + public final fun getAndroid ()Lcom/google/firebase/remoteconfig/FirebaseRemoteConfig; + public final fun getInfo ()Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigInfo; + public final fun getKeysByPrefix (Ljava/lang/String;)Ljava/util/Set; + public final fun getValue (Ljava/lang/String;)Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigValue; + public final fun reset (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun setDefaults ([Lkotlin/Pair;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun settings (Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; +} + +public final class dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigInfo { + public fun (Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigSettings;JLdev/gitlive/firebase/remoteconfig/FetchStatus;)V + public final fun component1 ()Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigSettings; + public final fun component2 ()J + public final fun component3 ()Ldev/gitlive/firebase/remoteconfig/FetchStatus; + public final fun copy (Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigSettings;JLdev/gitlive/firebase/remoteconfig/FetchStatus;)Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigInfo; + public static synthetic fun copy$default (Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigInfo;Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigSettings;JLdev/gitlive/firebase/remoteconfig/FetchStatus;ILjava/lang/Object;)Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigInfo; + public fun equals (Ljava/lang/Object;)Z + public final fun getConfigSettings ()Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigSettings; + public final fun getFetchTimeMillis ()J + public final fun getLastFetchStatus ()Ldev/gitlive/firebase/remoteconfig/FetchStatus; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigSettings { + public fun ()V + public fun (JJ)V + public synthetic fun (JJILkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun component1 ()J + public final fun component2 ()J + public final fun copy (JJ)Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigSettings; + public static synthetic fun copy$default (Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigSettings;JJILjava/lang/Object;)Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigSettings; + public fun equals (Ljava/lang/Object;)Z + public final fun getFetchTimeoutInSeconds ()J + public final fun getMinimumFetchIntervalInSeconds ()J + public fun hashCode ()I + public final fun setFetchTimeoutInSeconds (J)V + public final fun setMinimumFetchIntervalInSeconds (J)V + public fun toString ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigValue { + public final fun asBoolean ()Z + public final fun asByteArray ()[B + public final fun asDouble ()D + public final fun asLong ()J + public final fun asString ()Ljava/lang/String; + public final fun getSource ()Ldev/gitlive/firebase/remoteconfig/ValueSource; +} + +public final class dev/gitlive/firebase/remoteconfig/ValueSource : java/lang/Enum { + public static final field Default Ldev/gitlive/firebase/remoteconfig/ValueSource; + public static final field Remote Ldev/gitlive/firebase/remoteconfig/ValueSource; + public static final field Static Ldev/gitlive/firebase/remoteconfig/ValueSource; + public static fun getEntries ()Lkotlin/enums/EnumEntries; + public static fun valueOf (Ljava/lang/String;)Ldev/gitlive/firebase/remoteconfig/ValueSource; + public static fun values ()[Ldev/gitlive/firebase/remoteconfig/ValueSource; +} + +public final class dev/gitlive/firebase/remoteconfig/android { + public static final fun getRemoteConfig (Ldev/gitlive/firebase/Firebase;)Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig; + public static final fun remoteConfig (Ldev/gitlive/firebase/Firebase;Ldev/gitlive/firebase/FirebaseApp;)Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig; +} + diff --git a/firebase-config/api/jvm/firebase-config.api b/firebase-config/api/jvm/firebase-config.api new file mode 100644 index 000000000..5319fe7bd --- /dev/null +++ b/firebase-config/api/jvm/firebase-config.api @@ -0,0 +1,81 @@ +public final class dev/gitlive/firebase/remoteconfig/FetchStatus : java/lang/Enum { + public static final field Failure Ldev/gitlive/firebase/remoteconfig/FetchStatus; + public static final field NoFetchYet Ldev/gitlive/firebase/remoteconfig/FetchStatus; + public static final field Success Ldev/gitlive/firebase/remoteconfig/FetchStatus; + public static final field Throttled Ldev/gitlive/firebase/remoteconfig/FetchStatus; + public static fun getEntries ()Lkotlin/enums/EnumEntries; + public static fun valueOf (Ljava/lang/String;)Ldev/gitlive/firebase/remoteconfig/FetchStatus; + public static fun values ()[Ldev/gitlive/firebase/remoteconfig/FetchStatus; +} + +public final class dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig { + public final fun activate (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun ensureInitialized (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun fetch (Ljava/lang/Long;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static synthetic fun fetch$default (Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig;Ljava/lang/Long;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; + public final fun fetchAndActivate (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun getAll ()Ljava/util/Map; + public final fun getAndroid ()Lcom/google/firebase/remoteconfig/FirebaseRemoteConfig; + public final fun getInfo ()Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigInfo; + public final fun getKeysByPrefix (Ljava/lang/String;)Ljava/util/Set; + public final fun getValue (Ljava/lang/String;)Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigValue; + public final fun reset (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun setDefaults ([Lkotlin/Pair;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun settings (Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; +} + +public final class dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigInfo { + public fun (Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigSettings;JLdev/gitlive/firebase/remoteconfig/FetchStatus;)V + public final fun component1 ()Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigSettings; + public final fun component2 ()J + public final fun component3 ()Ldev/gitlive/firebase/remoteconfig/FetchStatus; + public final fun copy (Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigSettings;JLdev/gitlive/firebase/remoteconfig/FetchStatus;)Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigInfo; + public static synthetic fun copy$default (Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigInfo;Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigSettings;JLdev/gitlive/firebase/remoteconfig/FetchStatus;ILjava/lang/Object;)Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigInfo; + public fun equals (Ljava/lang/Object;)Z + public final fun getConfigSettings ()Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigSettings; + public final fun getFetchTimeMillis ()J + public final fun getLastFetchStatus ()Ldev/gitlive/firebase/remoteconfig/FetchStatus; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigSettings { + public fun ()V + public fun (JJ)V + public synthetic fun (JJILkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun component1 ()J + public final fun component2 ()J + public final fun copy (JJ)Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigSettings; + public static synthetic fun copy$default (Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigSettings;JJILjava/lang/Object;)Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigSettings; + public fun equals (Ljava/lang/Object;)Z + public final fun getFetchTimeoutInSeconds ()J + public final fun getMinimumFetchIntervalInSeconds ()J + public fun hashCode ()I + public final fun setFetchTimeoutInSeconds (J)V + public final fun setMinimumFetchIntervalInSeconds (J)V + public fun toString ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigValue { + public final fun asBoolean ()Z + public final fun asByteArray ()[B + public final fun asDouble ()D + public final fun asLong ()J + public final fun asString ()Ljava/lang/String; + public final fun getSource ()Ldev/gitlive/firebase/remoteconfig/ValueSource; +} + +public final class dev/gitlive/firebase/remoteconfig/ValueSource : java/lang/Enum { + public static final field Default Ldev/gitlive/firebase/remoteconfig/ValueSource; + public static final field Remote Ldev/gitlive/firebase/remoteconfig/ValueSource; + public static final field Static Ldev/gitlive/firebase/remoteconfig/ValueSource; + public static fun getEntries ()Lkotlin/enums/EnumEntries; + public static fun valueOf (Ljava/lang/String;)Ldev/gitlive/firebase/remoteconfig/ValueSource; + public static fun values ()[Ldev/gitlive/firebase/remoteconfig/ValueSource; +} + +public final class dev/gitlive/firebase/remoteconfig/android { + public static final fun getRemoteConfig (Ldev/gitlive/firebase/Firebase;)Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig; + public static final fun remoteConfig (Ldev/gitlive/firebase/Firebase;Ldev/gitlive/firebase/FirebaseApp;)Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig; +} + diff --git a/firebase-config/build.gradle.kts b/firebase-config/build.gradle.kts index a5d672835..f07b7c3ee 100644 --- a/firebase-config/build.gradle.kts +++ b/firebase-config/build.gradle.kts @@ -47,6 +47,8 @@ android { val supportIosTarget = project.property("skipIosTarget") != "true" kotlin { + explicitApi() + @OptIn(ExperimentalKotlinGradlePluginApi::class) compilerOptions { freeCompilerArgs.add("-Xexpect-actual-classes") diff --git a/firebase-config/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/remoteconfig/RemoteConfig.kt b/firebase-config/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/remoteconfig/RemoteConfig.kt index 492af89bc..c8b9c6e1f 100644 --- a/firebase-config/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/remoteconfig/RemoteConfig.kt +++ b/firebase-config/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/remoteconfig/RemoteConfig.kt @@ -3,6 +3,7 @@ */ @file:JvmName("tests") + package dev.gitlive.firebase.remoteconfig import androidx.test.platform.app.InstrumentationRegistry diff --git a/firebase-config/src/androidMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt b/firebase-config/src/androidMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt index 2e43b9a10..6067b4ed0 100644 --- a/firebase-config/src/androidMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt +++ b/firebase-config/src/androidMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt @@ -1,4 +1,5 @@ @file:JvmName("android") + package dev.gitlive.firebase.remoteconfig import com.google.firebase.remoteconfig.FirebaseRemoteConfigClientException @@ -11,20 +12,20 @@ import com.google.firebase.remoteconfig.FirebaseRemoteConfig as AndroidFirebaseR import com.google.firebase.remoteconfig.FirebaseRemoteConfigInfo as AndroidFirebaseRemoteConfigInfo import com.google.firebase.remoteconfig.FirebaseRemoteConfigSettings as AndroidFirebaseRemoteConfigSettings -actual val Firebase.remoteConfig: FirebaseRemoteConfig +public actual val Firebase.remoteConfig: FirebaseRemoteConfig get() = FirebaseRemoteConfig(com.google.firebase.remoteconfig.FirebaseRemoteConfig.getInstance()) -actual fun Firebase.remoteConfig(app: FirebaseApp): FirebaseRemoteConfig = +public actual fun Firebase.remoteConfig(app: FirebaseApp): FirebaseRemoteConfig = FirebaseRemoteConfig(com.google.firebase.remoteconfig.FirebaseRemoteConfig.getInstance(app.android)) -actual class FirebaseRemoteConfig internal constructor(val android: AndroidFirebaseRemoteConfig) { - actual val all: Map +public actual class FirebaseRemoteConfig internal constructor(public val android: AndroidFirebaseRemoteConfig) { + public actual val all: Map get() = android.all.mapValues { FirebaseRemoteConfigValue(it.value) } - actual val info: FirebaseRemoteConfigInfo + public actual val info: FirebaseRemoteConfigInfo get() = android.info.asCommon() - actual suspend fun settings(init: FirebaseRemoteConfigSettings.() -> Unit) { + public actual suspend fun settings(init: FirebaseRemoteConfigSettings.() -> Unit) { val settings = FirebaseRemoteConfigSettings().apply(init) val androidSettings = com.google.firebase.remoteconfig.FirebaseRemoteConfigSettings.Builder() .setMinimumFetchIntervalInSeconds(settings.minimumFetchIntervalInSeconds) @@ -33,29 +34,31 @@ actual class FirebaseRemoteConfig internal constructor(val android: AndroidFireb android.setConfigSettingsAsync(androidSettings).await() } - actual suspend fun setDefaults(vararg defaults: Pair) { + public actual suspend fun setDefaults(vararg defaults: Pair) { android.setDefaultsAsync(defaults.toMap()).await() } - actual suspend fun fetch(minimumFetchIntervalInSeconds: Long?) { + public actual suspend fun fetch(minimumFetchIntervalInSeconds: Long?) { minimumFetchIntervalInSeconds ?.also { android.fetch(it).await() } ?: run { android.fetch().await() } } - actual suspend fun activate(): Boolean = android.activate().await() - actual suspend fun ensureInitialized() = android.ensureInitialized().await().let { } - actual suspend fun fetchAndActivate(): Boolean = android.fetchAndActivate().await() - actual fun getKeysByPrefix(prefix: String): Set = android.getKeysByPrefix(prefix) - actual fun getValue(key: String) = FirebaseRemoteConfigValue(android.getValue(key)) - actual suspend fun reset() = android.reset().await().let { } - - private fun AndroidFirebaseRemoteConfigSettings.asCommon(): FirebaseRemoteConfigSettings { - return FirebaseRemoteConfigSettings( - fetchTimeoutInSeconds = fetchTimeoutInSeconds, - minimumFetchIntervalInSeconds = minimumFetchIntervalInSeconds, - ) + public actual suspend fun activate(): Boolean = android.activate().await() + public actual suspend fun ensureInitialized() { + android.ensureInitialized().await() } + public actual suspend fun fetchAndActivate(): Boolean = android.fetchAndActivate().await() + public actual fun getKeysByPrefix(prefix: String): Set = android.getKeysByPrefix(prefix) + public actual fun getValue(key: String): FirebaseRemoteConfigValue = FirebaseRemoteConfigValue(android.getValue(key)) + public actual suspend fun reset() { + android.reset().await() + } + + private fun AndroidFirebaseRemoteConfigSettings.asCommon(): FirebaseRemoteConfigSettings = FirebaseRemoteConfigSettings( + fetchTimeoutInSeconds = fetchTimeoutInSeconds, + minimumFetchIntervalInSeconds = minimumFetchIntervalInSeconds, + ) private fun AndroidFirebaseRemoteConfigInfo.asCommon(): FirebaseRemoteConfigInfo { val lastFetchStatus = when (lastFetchStatus) { @@ -69,12 +72,12 @@ actual class FirebaseRemoteConfig internal constructor(val android: AndroidFireb return FirebaseRemoteConfigInfo( configSettings = configSettings.asCommon(), fetchTimeMillis = fetchTimeMillis, - lastFetchStatus = lastFetchStatus + lastFetchStatus = lastFetchStatus, ) } } -actual typealias FirebaseRemoteConfigException = com.google.firebase.remoteconfig.FirebaseRemoteConfigException -actual typealias FirebaseRemoteConfigClientException = FirebaseRemoteConfigClientException -actual typealias FirebaseRemoteConfigFetchThrottledException = FirebaseRemoteConfigFetchThrottledException -actual typealias FirebaseRemoteConfigServerException = FirebaseRemoteConfigServerException +public actual typealias FirebaseRemoteConfigException = com.google.firebase.remoteconfig.FirebaseRemoteConfigException +public actual typealias FirebaseRemoteConfigClientException = FirebaseRemoteConfigClientException +public actual typealias FirebaseRemoteConfigFetchThrottledException = FirebaseRemoteConfigFetchThrottledException +public actual typealias FirebaseRemoteConfigServerException = FirebaseRemoteConfigServerException diff --git a/firebase-config/src/androidMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigValue.kt b/firebase-config/src/androidMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigValue.kt index 89c470f0a..b0262cef3 100644 --- a/firebase-config/src/androidMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigValue.kt +++ b/firebase-config/src/androidMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigValue.kt @@ -3,15 +3,15 @@ package dev.gitlive.firebase.remoteconfig import com.google.firebase.remoteconfig.FirebaseRemoteConfig import com.google.firebase.remoteconfig.FirebaseRemoteConfigValue as AndroidFirebaseRemoteConfigValue -actual class FirebaseRemoteConfigValue internal constructor( - private val android: AndroidFirebaseRemoteConfigValue +public actual class FirebaseRemoteConfigValue internal constructor( + private val android: AndroidFirebaseRemoteConfigValue, ) { - actual fun asBoolean(): Boolean = android.asBoolean() - actual fun asByteArray(): ByteArray = android.asByteArray() - actual fun asDouble(): Double = android.asDouble() - actual fun asLong(): Long = android.asLong() - actual fun asString(): String = android.asString() - actual fun getSource(): ValueSource = when (android.source) { + public actual fun asBoolean(): Boolean = android.asBoolean() + public actual fun asByteArray(): ByteArray = android.asByteArray() + public actual fun asDouble(): Double = android.asDouble() + public actual fun asLong(): Long = android.asLong() + public actual fun asString(): String = android.asString() + public actual fun getSource(): ValueSource = when (android.source) { FirebaseRemoteConfig.VALUE_SOURCE_STATIC -> ValueSource.Static FirebaseRemoteConfig.VALUE_SOURCE_DEFAULT -> ValueSource.Default FirebaseRemoteConfig.VALUE_SOURCE_REMOTE -> ValueSource.Remote diff --git a/firebase-config/src/androidUnitTest/kotlin/dev/gitlive/firebase/remoteconfig/RemoteConfig.kt b/firebase-config/src/androidUnitTest/kotlin/dev/gitlive/firebase/remoteconfig/RemoteConfig.kt index 19d69bba3..59f922920 100644 --- a/firebase-config/src/androidUnitTest/kotlin/dev/gitlive/firebase/remoteconfig/RemoteConfig.kt +++ b/firebase-config/src/androidUnitTest/kotlin/dev/gitlive/firebase/remoteconfig/RemoteConfig.kt @@ -3,6 +3,7 @@ */ @file:JvmName("tests") + package dev.gitlive.firebase.remoteconfig import org.junit.Ignore diff --git a/firebase-config/src/commonMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt b/firebase-config/src/commonMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt index ccd5e48f5..dd821269b 100644 --- a/firebase-config/src/commonMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt +++ b/firebase-config/src/commonMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt @@ -5,10 +5,10 @@ import dev.gitlive.firebase.FirebaseApp import dev.gitlive.firebase.FirebaseException /** Returns the [FirebaseRemoteConfig] instance of the default [FirebaseApp]. */ -expect val Firebase.remoteConfig: FirebaseRemoteConfig +public expect val Firebase.remoteConfig: FirebaseRemoteConfig /** Returns the [FirebaseRemoteConfig] instance of a given [FirebaseApp]. */ -expect fun Firebase.remoteConfig(app: FirebaseApp): FirebaseRemoteConfig +public expect fun Firebase.remoteConfig(app: FirebaseApp): FirebaseRemoteConfig /** * Entry point for the Firebase Remote Config API. @@ -18,7 +18,7 @@ expect fun Firebase.remoteConfig(app: FirebaseApp): FirebaseRemoteConfig * parameter values available to your app. The singleton also stores values fetched from the Remote * Config server until they are made available for use with a call to [activate]. */ -expect class FirebaseRemoteConfig { +public expect class FirebaseRemoteConfig { /** * Returns a [Map] of Firebase Remote Config key value pairs. * @@ -27,12 +27,12 @@ expect class FirebaseRemoteConfig { * - The activated value, if the last successful [activate] contained the key. * - The default value, if the key was set with [setDefaults]. */ - val all: Map + public val all: Map /** * Returns the state of this [FirebaseRemoteConfig] instance as a [FirebaseRemoteConfigInfo]. */ - val info: FirebaseRemoteConfigInfo + public val info: FirebaseRemoteConfigInfo /** * Asynchronously activates the most recently fetched configs, so that the fetched key value pairs @@ -42,12 +42,12 @@ expect class FirebaseRemoteConfig { * configs; if the fetched configs were already activated by a previous call, it instead * returns a false result. */ - suspend fun activate(): Boolean + public suspend fun activate(): Boolean /** * Ensures the last activated config are available to the app. */ - suspend fun ensureInitialized() + public suspend fun ensureInitialized() /** * Starts fetching configs, adhering to the specified minimum fetch interval. @@ -66,7 +66,7 @@ expect class FirebaseRemoteConfig { * @param minimumFetchIntervalInSeconds If configs in the local storage were fetched more than * this many seconds ago, configs are served from the backend instead of local storage. */ - suspend fun fetch(minimumFetchIntervalInSeconds: Long? = null) + public suspend fun fetch(minimumFetchIntervalInSeconds: Long? = null) /** * Asynchronously fetches and then activates the fetched configs. @@ -81,7 +81,7 @@ expect class FirebaseRemoteConfig { * configs; if no configs were fetched from the backend and the local fetched configs have * already been activated, returns a [Boolean] with a false result. */ - suspend fun fetchAndActivate(): Boolean + public suspend fun fetchAndActivate(): Boolean /** * Returns a [Set] of all Firebase Remote Config parameter keys with the given prefix. @@ -89,7 +89,7 @@ expect class FirebaseRemoteConfig { * @param prefix The key prefix to look for. If the prefix is empty, all keys are returned. * @return [Set] of Remote Config parameter keys that start with the specified prefix. */ - fun getKeysByPrefix(prefix: String): Set + public fun getKeysByPrefix(prefix: String): Set /** * Returns the parameter value for the given key as a [FirebaseRemoteConfigValue]. @@ -104,20 +104,20 @@ expect class FirebaseRemoteConfig { * @return [FirebaseRemoteConfigValue] representing the value of the Firebase Remote Config * parameter with the given key. */ - fun getValue(key: String): FirebaseRemoteConfigValue + public fun getValue(key: String): FirebaseRemoteConfigValue /** * Deletes all activated, fetched and defaults configs and resets all Firebase Remote Config * settings. */ - suspend fun reset() + public suspend fun reset() /** * Asynchronously changes the settings for this [FirebaseRemoteConfig] instance. * * @param init A builder to set the settings. */ - suspend fun settings(init: FirebaseRemoteConfigSettings.() -> Unit) + public suspend fun settings(init: FirebaseRemoteConfigSettings.() -> Unit) /** * Asynchronously sets default configs using the given [Map]. @@ -125,13 +125,13 @@ expect class FirebaseRemoteConfig { * @param defaults [Map] of key value pairs representing Firebase Remote Config parameter * keys and values. */ - suspend fun setDefaults(vararg defaults: Pair) + public suspend fun setDefaults(vararg defaults: Pair) } @Suppress("IMPLICIT_CAST_TO_ANY") -inline operator fun FirebaseRemoteConfig.get(key: String): T { +public inline operator fun FirebaseRemoteConfig.get(key: String): T { val configValue = getValue(key) - return when(T::class) { + return when (T::class) { Boolean::class -> configValue.asBoolean() Double::class -> configValue.asDouble() Long::class -> configValue.asLong() @@ -144,19 +144,19 @@ inline operator fun FirebaseRemoteConfig.get(key: String): T { /** * Exception that gets thrown when an operation on Firebase Remote Config fails. */ -expect open class FirebaseRemoteConfigException : FirebaseException +public expect open class FirebaseRemoteConfigException : FirebaseException /** * Exception that gets thrown when an operation on Firebase Remote Config fails. */ -expect class FirebaseRemoteConfigClientException : FirebaseRemoteConfigException +public expect class FirebaseRemoteConfigClientException : FirebaseRemoteConfigException /** * Exception that gets thrown when an operation on Firebase Remote Config fails. */ -expect class FirebaseRemoteConfigFetchThrottledException : FirebaseRemoteConfigException +public expect class FirebaseRemoteConfigFetchThrottledException : FirebaseRemoteConfigException /** * Exception that gets thrown when an operation on Firebase Remote Config fails. */ -expect class FirebaseRemoteConfigServerException : FirebaseRemoteConfigException +public expect class FirebaseRemoteConfigServerException : FirebaseRemoteConfigException diff --git a/firebase-config/src/commonMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigInfo.kt b/firebase-config/src/commonMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigInfo.kt index 7eae3e53e..01d2c9124 100644 --- a/firebase-config/src/commonMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigInfo.kt +++ b/firebase-config/src/commonMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigInfo.kt @@ -1,7 +1,7 @@ package dev.gitlive.firebase.remoteconfig /** Wraps the current state of the [FirebaseRemoteConfig] singleton object. */ -data class FirebaseRemoteConfigInfo( +public data class FirebaseRemoteConfigInfo( /** * Gets the current settings of the [FirebaseRemoteConfig] singleton object. * @@ -26,7 +26,7 @@ data class FirebaseRemoteConfigInfo( val lastFetchStatus: FetchStatus, ) -enum class FetchStatus { +public enum class FetchStatus { /** * Indicates that the most recent fetch of parameter values from the Firebase Remote Config server * was completed successfully. @@ -49,5 +49,5 @@ enum class FetchStatus { * Indicates that the FirebaseRemoteConfig singleton object has not yet attempted to fetch * parameter values from the Firebase Remote Config server. */ - NoFetchYet + NoFetchYet, } diff --git a/firebase-config/src/commonMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigSettings.kt b/firebase-config/src/commonMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigSettings.kt index 4300dd7a7..140165075 100644 --- a/firebase-config/src/commonMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigSettings.kt +++ b/firebase-config/src/commonMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigSettings.kt @@ -6,7 +6,7 @@ private const val CONNECTION_TIMEOUT_IN_SECONDS = 60L private const val DEFAULT_FETCH_INTERVAL_IN_SECONDS = 12 * 3600L /** Wraps the settings for [FirebaseRemoteConfig] operations. */ -data class FirebaseRemoteConfigSettings( +public data class FirebaseRemoteConfigSettings( /** * Returns the fetch timeout in seconds. * diff --git a/firebase-config/src/commonMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigValue.kt b/firebase-config/src/commonMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigValue.kt index 5da6e38d3..fb255f315 100644 --- a/firebase-config/src/commonMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigValue.kt +++ b/firebase-config/src/commonMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigValue.kt @@ -1,51 +1,51 @@ package dev.gitlive.firebase.remoteconfig /** Wrapper for a Remote Config parameter value, with methods to get it as different types. */ -expect class FirebaseRemoteConfigValue { +public expect class FirebaseRemoteConfigValue { /** * Gets the value as a [Boolean]. * * @return [Boolean] representation of this parameter value. */ - fun asBoolean(): Boolean + public fun asBoolean(): Boolean /** * Gets the value as a [ByteArray]. * * @return [ByteArray] representation of this parameter value. */ - fun asByteArray(): ByteArray + public fun asByteArray(): ByteArray /** * Gets the value as a [Double]. * * @return [Double] representation of this parameter value. */ - fun asDouble(): Double + public fun asDouble(): Double /** * Gets the value as a [Long]. * * @return [Long] representation of this parameter value. */ - fun asLong(): Long + public fun asLong(): Long /** * Gets the value as a [String]. * * @return [String] representation of this parameter value. */ - fun asString(): String + public fun asString(): String /** * Indicates at which source this value came from. * * @return [ValueSource.Remote] if the value was retrieved from the server, [ValueSource.Default] if the value was set as a default, or [ValueSource.Stataic] if no value was found and a static default value was returned instead. */ - fun getSource(): ValueSource + public fun getSource(): ValueSource } -enum class ValueSource { +public enum class ValueSource { /** Indicates that the value returned is the static default value. */ Static, @@ -53,5 +53,5 @@ enum class ValueSource { Default, /** Indicates that the value returned was retrieved from the Firebase Remote Config server. */ - Remote + Remote, } diff --git a/firebase-config/src/commonTest/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt b/firebase-config/src/commonTest/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt index 426a7f23e..7d3f94b4b 100644 --- a/firebase-config/src/commonTest/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt +++ b/firebase-config/src/commonTest/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt @@ -39,8 +39,8 @@ class FirebaseRemoteConfigTest { databaseUrl = "https://fir-kotlin-sdk.firebaseio.com", storageBucket = "fir-kotlin-sdk.appspot.com", projectId = "fir-kotlin-sdk", - gcmSenderId = "846484016111" - ) + gcmSenderId = "846484016111", + ), ) remoteConfig = Firebase.remoteConfig(app) @@ -90,9 +90,9 @@ class FirebaseRemoteConfigTest { "test_default_boolean", "test_default_double", "test_default_long", - "test_default_string" + "test_default_string", ), - keys + keys, ) } @@ -102,9 +102,9 @@ class FirebaseRemoteConfigTest { FirebaseRemoteConfigInfo( configSettings = FirebaseRemoteConfigSettings(), fetchTimeMillis = -1, - lastFetchStatus = FetchStatus.NoFetchYet + lastFetchStatus = FetchStatus.NoFetchYet, ).toString(), - remoteConfig.info.toString() + remoteConfig.info.toString(), ) } diff --git a/firebase-config/src/iosMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt b/firebase-config/src/iosMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt index 74e65641d..d99bc49e6 100644 --- a/firebase-config/src/iosMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt +++ b/firebase-config/src/iosMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt @@ -16,16 +16,16 @@ import kotlinx.coroutines.CompletableDeferred import platform.Foundation.NSError import platform.Foundation.timeIntervalSince1970 -actual val Firebase.remoteConfig: FirebaseRemoteConfig +public actual val Firebase.remoteConfig: FirebaseRemoteConfig get() = FirebaseRemoteConfig(FIRRemoteConfig.remoteConfig()) -actual fun Firebase.remoteConfig(app: FirebaseApp): FirebaseRemoteConfig = FirebaseRemoteConfig( - FIRRemoteConfig.remoteConfigWithApp(Firebase.app.ios as objcnames.classes.FIRApp) +public actual fun Firebase.remoteConfig(app: FirebaseApp): FirebaseRemoteConfig = FirebaseRemoteConfig( + FIRRemoteConfig.remoteConfigWithApp(Firebase.app.ios as objcnames.classes.FIRApp), ) -actual class FirebaseRemoteConfig internal constructor(val ios: FIRRemoteConfig) { +public actual class FirebaseRemoteConfig internal constructor(public val ios: FIRRemoteConfig) { @Suppress("UNCHECKED_CAST") - actual val all: Map + public actual val all: Map get() { return listOf( FIRRemoteConfigSource.FIRRemoteConfigSourceStatic, @@ -37,7 +37,7 @@ actual class FirebaseRemoteConfig internal constructor(val ios: FIRRemoteConfig) }.flatten().toMap() } - actual val info: FirebaseRemoteConfigInfo + public actual val info: FirebaseRemoteConfigInfo get() { return FirebaseRemoteConfigInfo( configSettings = ios.configSettings.asCommon(), @@ -46,16 +46,16 @@ actual class FirebaseRemoteConfig internal constructor(val ios: FIRRemoteConfig) ?.let { it.toLong() * 1000 } ?.takeIf { it > 0 } ?: -1L, - lastFetchStatus = ios.lastFetchStatus.asCommon() + lastFetchStatus = ios.lastFetchStatus.asCommon(), ) } - actual suspend fun activate(): Boolean = ios.awaitResult { activateWithCompletion(it) } + public actual suspend fun activate(): Boolean = ios.awaitResult { activateWithCompletion(it) } - actual suspend fun ensureInitialized() = + public actual suspend fun ensureInitialized(): Unit = ios.await { ensureInitializedWithCompletionHandler(it) } - actual suspend fun fetch(minimumFetchIntervalInSeconds: Long?) { + public actual suspend fun fetch(minimumFetchIntervalInSeconds: Long?) { if (minimumFetchIntervalInSeconds != null) { ios.awaitResult { fetchWithExpirationDuration(minimumFetchIntervalInSeconds.toDouble(), it) @@ -65,24 +65,24 @@ actual class FirebaseRemoteConfig internal constructor(val ios: FIRRemoteConfig) } } - actual suspend fun fetchAndActivate(): Boolean { + public actual suspend fun fetchAndActivate(): Boolean { val status: FIRRemoteConfigFetchAndActivateStatus = ios.awaitResult { fetchAndActivateWithCompletionHandler(it) } return status == FIRRemoteConfigFetchAndActivateStatus.FIRRemoteConfigFetchAndActivateStatusSuccessFetchedFromRemote } - actual fun getKeysByPrefix(prefix: String): Set = + public actual fun getKeysByPrefix(prefix: String): Set = all.keys.filter { it.startsWith(prefix) }.toSet() - actual fun getValue(key: String): FirebaseRemoteConfigValue = + public actual fun getValue(key: String): FirebaseRemoteConfigValue = FirebaseRemoteConfigValue(ios.configValueForKey(key)) - actual suspend fun reset() { + public actual suspend fun reset() { // not implemented for iOS target } - actual suspend fun settings(init: FirebaseRemoteConfigSettings.() -> Unit) { + public actual suspend fun settings(init: FirebaseRemoteConfigSettings.() -> Unit) { val settings = FirebaseRemoteConfigSettings().apply(init) val iosSettings = FIRRemoteConfigSettings().apply { minimumFetchInterval = settings.minimumFetchIntervalInSeconds.toDouble() @@ -91,30 +91,26 @@ actual class FirebaseRemoteConfig internal constructor(val ios: FIRRemoteConfig) ios.setConfigSettings(iosSettings) } - actual suspend fun setDefaults(vararg defaults: Pair) { + public actual suspend fun setDefaults(vararg defaults: Pair) { ios.setDefaults(defaults.toMap()) } - private fun FIRRemoteConfigSettings.asCommon(): FirebaseRemoteConfigSettings { - return FirebaseRemoteConfigSettings( - fetchTimeoutInSeconds = fetchTimeout.toLong(), - minimumFetchIntervalInSeconds = minimumFetchInterval.toLong(), - ) - } - - private fun FIRRemoteConfigFetchStatus.asCommon(): FetchStatus { - return when (this) { - FIRRemoteConfigFetchStatus.FIRRemoteConfigFetchStatusSuccess -> FetchStatus.Success - FIRRemoteConfigFetchStatus.FIRRemoteConfigFetchStatusNoFetchYet -> FetchStatus.NoFetchYet - FIRRemoteConfigFetchStatus.FIRRemoteConfigFetchStatusFailure -> FetchStatus.Failure - FIRRemoteConfigFetchStatus.FIRRemoteConfigFetchStatusThrottled -> FetchStatus.Throttled - else -> FetchStatus.Failure - } + private fun FIRRemoteConfigSettings.asCommon(): FirebaseRemoteConfigSettings = FirebaseRemoteConfigSettings( + fetchTimeoutInSeconds = fetchTimeout.toLong(), + minimumFetchIntervalInSeconds = minimumFetchInterval.toLong(), + ) + + private fun FIRRemoteConfigFetchStatus.asCommon(): FetchStatus = when (this) { + FIRRemoteConfigFetchStatus.FIRRemoteConfigFetchStatusSuccess -> FetchStatus.Success + FIRRemoteConfigFetchStatus.FIRRemoteConfigFetchStatusNoFetchYet -> FetchStatus.NoFetchYet + FIRRemoteConfigFetchStatus.FIRRemoteConfigFetchStatusFailure -> FetchStatus.Failure + FIRRemoteConfigFetchStatus.FIRRemoteConfigFetchStatusThrottled -> FetchStatus.Throttled + else -> FetchStatus.Failure } } private suspend inline fun T.awaitResult( - function: T.(callback: (R?, NSError?) -> Unit) -> Unit + function: T.(callback: (R?, NSError?) -> Unit) -> Unit, ): R { val job = CompletableDeferred() function { result, error -> @@ -139,16 +135,15 @@ private suspend inline fun T.await(function: T.(callback: (NSError?) -> Unit job.await() } - private fun NSError.toException() = when (domain) { FIRRemoteConfigErrorDomain -> { when (code) { FIRRemoteConfigErrorThrottled -> FirebaseRemoteConfigFetchThrottledException( - localizedDescription + localizedDescription, ) FIRRemoteConfigErrorInternalError -> FirebaseRemoteConfigServerException( - localizedDescription + localizedDescription, ) else -> FirebaseRemoteConfigClientException(localizedDescription) @@ -158,14 +153,10 @@ private fun NSError.toException() = when (domain) { else -> FirebaseException(localizedDescription) } +public actual open class FirebaseRemoteConfigException(message: String) : FirebaseException(message) -actual open class FirebaseRemoteConfigException(message: String) : FirebaseException(message) - -actual class FirebaseRemoteConfigClientException(message: String) : - FirebaseRemoteConfigException(message) +public actual class FirebaseRemoteConfigClientException(message: String) : FirebaseRemoteConfigException(message) -actual class FirebaseRemoteConfigFetchThrottledException(message: String) : - FirebaseRemoteConfigException(message) +public actual class FirebaseRemoteConfigFetchThrottledException(message: String) : FirebaseRemoteConfigException(message) -actual class FirebaseRemoteConfigServerException(message: String) : - FirebaseRemoteConfigException(message) +public actual class FirebaseRemoteConfigServerException(message: String) : FirebaseRemoteConfigException(message) diff --git a/firebase-config/src/iosMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigValue.kt b/firebase-config/src/iosMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigValue.kt index 1bf3e1f17..3d723d271 100644 --- a/firebase-config/src/iosMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigValue.kt +++ b/firebase-config/src/iosMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigValue.kt @@ -3,15 +3,15 @@ package dev.gitlive.firebase.remoteconfig import cocoapods.FirebaseRemoteConfig.FIRRemoteConfigSource import cocoapods.FirebaseRemoteConfig.FIRRemoteConfigValue -actual class FirebaseRemoteConfigValue internal constructor(private val ios: FIRRemoteConfigValue) { +public actual class FirebaseRemoteConfigValue internal constructor(private val ios: FIRRemoteConfigValue) { @ExperimentalUnsignedTypes - actual fun asByteArray(): ByteArray = ios.dataValue.toByteArray() + public actual fun asByteArray(): ByteArray = ios.dataValue.toByteArray() - actual fun asBoolean(): Boolean = ios.boolValue - actual fun asDouble(): Double = ios.numberValue.doubleValue - actual fun asLong(): Long = ios.numberValue.longValue - actual fun asString(): String = ios.stringValue ?: "" - actual fun getSource(): ValueSource = when (ios.source) { + public actual fun asBoolean(): Boolean = ios.boolValue + public actual fun asDouble(): Double = ios.numberValue.doubleValue + public actual fun asLong(): Long = ios.numberValue.longValue + public actual fun asString(): String = ios.stringValue ?: "" + public actual fun getSource(): ValueSource = when (ios.source) { FIRRemoteConfigSource.FIRRemoteConfigSourceStatic -> ValueSource.Static FIRRemoteConfigSource.FIRRemoteConfigSourceDefault -> ValueSource.Default FIRRemoteConfigSource.FIRRemoteConfigSourceRemote -> ValueSource.Remote diff --git a/firebase-config/src/iosMain/kotlin/dev/gitlive/firebase/remoteconfig/NSDataExtension.kt b/firebase-config/src/iosMain/kotlin/dev/gitlive/firebase/remoteconfig/NSDataExtension.kt index 3ea2cf992..f39b5acea 100644 --- a/firebase-config/src/iosMain/kotlin/dev/gitlive/firebase/remoteconfig/NSDataExtension.kt +++ b/firebase-config/src/iosMain/kotlin/dev/gitlive/firebase/remoteconfig/NSDataExtension.kt @@ -6,8 +6,6 @@ import platform.Foundation.NSData import platform.posix.memcpy @ExperimentalUnsignedTypes -fun NSData.toByteArray(): ByteArray { - return ByteArray(length.toInt()).apply { - usePinned { memcpy(it.addressOf(0), bytes, length) } - } +public fun NSData.toByteArray(): ByteArray = ByteArray(length.toInt()).apply { + usePinned { memcpy(it.addressOf(0), bytes, length) } } diff --git a/firebase-config/src/jsMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt b/firebase-config/src/jsMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt index bba268c12..410222224 100644 --- a/firebase-config/src/jsMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt +++ b/firebase-config/src/jsMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt @@ -7,52 +7,50 @@ import dev.gitlive.firebase.remoteconfig.externals.* import kotlinx.coroutines.await import kotlin.js.json -actual val Firebase.remoteConfig: FirebaseRemoteConfig +public actual val Firebase.remoteConfig: FirebaseRemoteConfig get() = rethrow { FirebaseRemoteConfig(getRemoteConfig()) } -actual fun Firebase.remoteConfig(app: FirebaseApp): FirebaseRemoteConfig = rethrow { +public actual fun Firebase.remoteConfig(app: FirebaseApp): FirebaseRemoteConfig = rethrow { FirebaseRemoteConfig(getRemoteConfig(app.js)) } -actual class FirebaseRemoteConfig internal constructor(val js: RemoteConfig) { - actual val all: Map - get() = rethrow { getAllKeys().map { Pair(it, getValue(it)) }.toMap() } +public actual class FirebaseRemoteConfig internal constructor(public val js: RemoteConfig) { + public actual val all: Map + get() = rethrow { getAllKeys().associateWith { getValue(it) } } - actual val info: FirebaseRemoteConfigInfo + public actual val info: FirebaseRemoteConfigInfo get() = rethrow { FirebaseRemoteConfigInfo( configSettings = js.settings.toFirebaseRemoteConfigSettings(), fetchTimeMillis = js.fetchTimeMillis, - lastFetchStatus = js.lastFetchStatus.toFetchStatus() + lastFetchStatus = js.lastFetchStatus.toFetchStatus(), ) } - actual suspend fun activate(): Boolean = rethrow { activate(js).await() } - actual suspend fun ensureInitialized(): Unit = rethrow { ensureInitialized(js).await() } + public actual suspend fun activate(): Boolean = rethrow { activate(js).await() } + public actual suspend fun ensureInitialized(): Unit = rethrow { ensureInitialized(js).await() } - actual suspend fun fetch(minimumFetchIntervalInSeconds: Long?): Unit = + public actual suspend fun fetch(minimumFetchIntervalInSeconds: Long?): Unit = rethrow { fetchConfig(js).await() } - actual suspend fun fetchAndActivate(): Boolean = rethrow { fetchAndActivate(js).await() } + public actual suspend fun fetchAndActivate(): Boolean = rethrow { fetchAndActivate(js).await() } - actual fun getValue(key: String): FirebaseRemoteConfigValue = rethrow { + public actual fun getValue(key: String): FirebaseRemoteConfigValue = rethrow { FirebaseRemoteConfigValue(getValue(js, key)) } - actual fun getKeysByPrefix(prefix: String): Set { - return getAllKeys().filter { it.startsWith(prefix) }.toSet() - } + public actual fun getKeysByPrefix(prefix: String): Set = getAllKeys().filter { it.startsWith(prefix) }.toSet() private fun getAllKeys(): Set { val objectKeys = js("Object.keys") return objectKeys(getAll(js)).unsafeCast>().toSet() } - actual suspend fun reset() { + public actual suspend fun reset() { // not implemented for JS target } - actual suspend fun settings(init: FirebaseRemoteConfigSettings.() -> Unit) { + public actual suspend fun settings(init: FirebaseRemoteConfigSettings.() -> Unit) { val settings = FirebaseRemoteConfigSettings().apply(init) js.settings.apply { fetchTimeoutMillis = settings.fetchTimeoutInSeconds * 1000 @@ -60,40 +58,31 @@ actual class FirebaseRemoteConfig internal constructor(val js: RemoteConfig) { } } - actual suspend fun setDefaults(vararg defaults: Pair) = rethrow { + public actual suspend fun setDefaults(vararg defaults: Pair): Unit = rethrow { js.defaultConfig = json(*defaults) } - private fun Settings.toFirebaseRemoteConfigSettings(): FirebaseRemoteConfigSettings { - return FirebaseRemoteConfigSettings( - fetchTimeoutInSeconds = fetchTimeoutMillis.toLong() / 1000, - minimumFetchIntervalInSeconds = minimumFetchIntervalMillis.toLong() / 1000 - ) - } - - private fun String.toFetchStatus(): FetchStatus { - return when (this) { - "no-fetch-yet" -> FetchStatus.NoFetchYet - "success" -> FetchStatus.Success - "failure" -> FetchStatus.Failure - "throttle" -> FetchStatus.Throttled - else -> error("Unknown FetchStatus: $this") - } + private fun Settings.toFirebaseRemoteConfigSettings(): FirebaseRemoteConfigSettings = FirebaseRemoteConfigSettings( + fetchTimeoutInSeconds = fetchTimeoutMillis.toLong() / 1000, + minimumFetchIntervalInSeconds = minimumFetchIntervalMillis.toLong() / 1000, + ) + + private fun String.toFetchStatus(): FetchStatus = when (this) { + "no-fetch-yet" -> FetchStatus.NoFetchYet + "success" -> FetchStatus.Success + "failure" -> FetchStatus.Failure + "throttle" -> FetchStatus.Throttled + else -> error("Unknown FetchStatus: $this") } } -actual open class FirebaseRemoteConfigException(code: String, cause: Throwable) : - FirebaseException(code, cause) - -actual class FirebaseRemoteConfigClientException(code: String, cause: Throwable) : - FirebaseRemoteConfigException(code, cause) +public actual open class FirebaseRemoteConfigException(code: String, cause: Throwable) : FirebaseException(code, cause) -actual class FirebaseRemoteConfigFetchThrottledException(code: String, cause: Throwable) : - FirebaseRemoteConfigException(code, cause) +public actual class FirebaseRemoteConfigClientException(code: String, cause: Throwable) : FirebaseRemoteConfigException(code, cause) -actual class FirebaseRemoteConfigServerException(code: String, cause: Throwable) : - FirebaseRemoteConfigException(code, cause) +public actual class FirebaseRemoteConfigFetchThrottledException(code: String, cause: Throwable) : FirebaseRemoteConfigException(code, cause) +public actual class FirebaseRemoteConfigServerException(code: String, cause: Throwable) : FirebaseRemoteConfigException(code, cause) internal inline fun rethrow(function: () -> R): R { try { @@ -112,7 +101,7 @@ internal fun errorToException(error: dynamic) = (error?.code ?: error?.message ? when { else -> { println("Unknown error code in ${JSON.stringify(error)}") - FirebaseRemoteConfigException(code, error) + FirebaseRemoteConfigException(code, error as Throwable) } } } diff --git a/firebase-config/src/jsMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigValue.kt b/firebase-config/src/jsMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigValue.kt index 2891f926a..ddec60af4 100644 --- a/firebase-config/src/jsMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigValue.kt +++ b/firebase-config/src/jsMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigValue.kt @@ -2,13 +2,13 @@ package dev.gitlive.firebase.remoteconfig import dev.gitlive.firebase.remoteconfig.externals.Value -actual class FirebaseRemoteConfigValue(val js: Value) { - actual fun asBoolean(): Boolean = rethrow { js.asBoolean() } - actual fun asByteArray(): ByteArray = rethrow { js.asString()?.encodeToByteArray() ?: byteArrayOf() } - actual fun asDouble(): Double = rethrow { js.asNumber().toDouble() } - actual fun asLong(): Long = rethrow { js.asNumber().toLong() } - actual fun asString(): String = rethrow { js.asString() ?: "" } - actual fun getSource(): ValueSource = rethrow { js.getSource().toSource() } +public actual class FirebaseRemoteConfigValue(public val js: Value) { + public actual fun asBoolean(): Boolean = rethrow { js.asBoolean() } + public actual fun asByteArray(): ByteArray = rethrow { js.asString()?.encodeToByteArray() ?: byteArrayOf() } + public actual fun asDouble(): Double = rethrow { js.asNumber().toDouble() } + public actual fun asLong(): Long = rethrow { js.asNumber().toLong() } + public actual fun asString(): String = rethrow { js.asString() ?: "" } + public actual fun getSource(): ValueSource = rethrow { js.getSource().toSource() } private fun String.toSource() = when (this) { "default" -> ValueSource.Default diff --git a/firebase-config/src/jsMain/kotlin/dev/gitlive/firebase/remoteconfig/externals/remoteconfig.kt b/firebase-config/src/jsMain/kotlin/dev/gitlive/firebase/remoteconfig/externals/remoteconfig.kt index b2a42dc84..92d62feda 100644 --- a/firebase-config/src/jsMain/kotlin/dev/gitlive/firebase/remoteconfig/externals/remoteconfig.kt +++ b/firebase-config/src/jsMain/kotlin/dev/gitlive/firebase/remoteconfig/externals/remoteconfig.kt @@ -7,41 +7,41 @@ import dev.gitlive.firebase.externals.FirebaseApp import kotlin.js.Json import kotlin.js.Promise -external fun activate(remoteConfig: RemoteConfig): Promise +public external fun activate(remoteConfig: RemoteConfig): Promise -external fun ensureInitialized(remoteConfig: RemoteConfig): Promise +public external fun ensureInitialized(remoteConfig: RemoteConfig): Promise -external fun fetchAndActivate(remoteConfig: RemoteConfig): Promise +public external fun fetchAndActivate(remoteConfig: RemoteConfig): Promise -external fun fetchConfig(remoteConfig: RemoteConfig): Promise +public external fun fetchConfig(remoteConfig: RemoteConfig): Promise -external fun getAll(remoteConfig: RemoteConfig): Json +public external fun getAll(remoteConfig: RemoteConfig): Json -external fun getBoolean(remoteConfig: RemoteConfig, key: String): Boolean +public external fun getBoolean(remoteConfig: RemoteConfig, key: String): Boolean -external fun getNumber(remoteConfig: RemoteConfig, key: String): Number +public external fun getNumber(remoteConfig: RemoteConfig, key: String): Number -external fun getRemoteConfig(app: FirebaseApp? = definedExternally): RemoteConfig +public external fun getRemoteConfig(app: FirebaseApp? = definedExternally): RemoteConfig -external fun getString(remoteConfig: RemoteConfig, key: String): String? +public external fun getString(remoteConfig: RemoteConfig, key: String): String? -external fun getValue(remoteConfig: RemoteConfig, key: String): Value +public external fun getValue(remoteConfig: RemoteConfig, key: String): Value -external interface RemoteConfig { - var defaultConfig: Any - var fetchTimeMillis: Long - var lastFetchStatus: String - val settings: Settings +public external interface RemoteConfig { + public var defaultConfig: Any + public var fetchTimeMillis: Long + public var lastFetchStatus: String + public val settings: Settings } -external interface Settings { - var fetchTimeoutMillis: Number - var minimumFetchIntervalMillis: Number +public external interface Settings { + public var fetchTimeoutMillis: Number + public var minimumFetchIntervalMillis: Number } -external interface Value { - fun asBoolean(): Boolean - fun asNumber(): Number - fun asString(): String? - fun getSource(): String +public external interface Value { + public fun asBoolean(): Boolean + public fun asNumber(): Number + public fun asString(): String? + public fun getSource(): String } diff --git a/firebase-config/src/jvmTest/kotlin/dev/gitlive/firebase/remoteconfig/RemoteConfig.kt b/firebase-config/src/jvmTest/kotlin/dev/gitlive/firebase/remoteconfig/RemoteConfig.kt index d03ab2fb6..172082cc1 100644 --- a/firebase-config/src/jvmTest/kotlin/dev/gitlive/firebase/remoteconfig/RemoteConfig.kt +++ b/firebase-config/src/jvmTest/kotlin/dev/gitlive/firebase/remoteconfig/RemoteConfig.kt @@ -3,6 +3,7 @@ */ @file:JvmName("tests") + package dev.gitlive.firebase.remoteconfig import dev.gitlive.firebase.testContext diff --git a/firebase-crashlytics/api/firebase-crashlytics.api b/firebase-crashlytics/api/firebase-crashlytics.api new file mode 100644 index 000000000..ffa13340a --- /dev/null +++ b/firebase-crashlytics/api/firebase-crashlytics.api @@ -0,0 +1,27 @@ +public final class dev/gitlive/firebase/crashlytics/CrashlyticsKt { + public static final fun crashlytics (Ldev/gitlive/firebase/Firebase;Ldev/gitlive/firebase/FirebaseApp;)Ldev/gitlive/firebase/crashlytics/FirebaseCrashlytics; + public static final fun getCrashlytics (Ldev/gitlive/firebase/Firebase;)Ldev/gitlive/firebase/crashlytics/FirebaseCrashlytics; +} + +public final class dev/gitlive/firebase/crashlytics/FirebaseCrashlytics { + public final fun deleteUnsentReports ()V + public final fun didCrashOnPreviousExecution ()Z + public final fun getAndroid ()Lcom/google/firebase/crashlytics/FirebaseCrashlytics; + public final fun log (Ljava/lang/String;)V + public final fun recordException (Ljava/lang/Throwable;)V + public final fun sendUnsentReports ()V + public final fun setCrashlyticsCollectionEnabled (Z)V + public final fun setCustomKey (Ljava/lang/String;D)V + public final fun setCustomKey (Ljava/lang/String;F)V + public final fun setCustomKey (Ljava/lang/String;I)V + public final fun setCustomKey (Ljava/lang/String;J)V + public final fun setCustomKey (Ljava/lang/String;Ljava/lang/String;)V + public final fun setCustomKey (Ljava/lang/String;Z)V + public final fun setCustomKeys (Ljava/util/Map;)V + public final fun setUserId (Ljava/lang/String;)V +} + +public class dev/gitlive/firebase/crashlytics/FirebaseCrashlyticsException : com/google/firebase/FirebaseException { + public fun (Ljava/lang/String;)V +} + diff --git a/firebase-crashlytics/build.gradle.kts b/firebase-crashlytics/build.gradle.kts index 692207800..4c59074a0 100644 --- a/firebase-crashlytics/build.gradle.kts +++ b/firebase-crashlytics/build.gradle.kts @@ -48,6 +48,8 @@ android { val supportIosTarget = project.property("skipIosTarget") != "true" kotlin { + explicitApi() + @OptIn(ExperimentalKotlinGradlePluginApi::class) compilerOptions { freeCompilerArgs.add("-Xexpect-actual-classes") diff --git a/firebase-crashlytics/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt b/firebase-crashlytics/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt index aa0ff306f..8f3160c49 100644 --- a/firebase-crashlytics/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt +++ b/firebase-crashlytics/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt @@ -3,12 +3,11 @@ */ @file:JvmName("tests") + package dev.gitlive.firebase.crashlytics import androidx.test.platform.app.InstrumentationRegistry -actual val emulatorHost: String = "10.0.2.2" - actual val context: Any = InstrumentationRegistry.getInstrumentation().targetContext @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) diff --git a/firebase-crashlytics/src/androidMain/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt b/firebase-crashlytics/src/androidMain/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt index 680ebb8e0..c58bcfcf5 100644 --- a/firebase-crashlytics/src/androidMain/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt +++ b/firebase-crashlytics/src/androidMain/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt @@ -5,28 +5,52 @@ import com.google.firebase.crashlytics.CustomKeysAndValues.Builder import dev.gitlive.firebase.Firebase import dev.gitlive.firebase.FirebaseApp -actual val Firebase.crashlytics get() = +public actual val Firebase.crashlytics: FirebaseCrashlytics get() = FirebaseCrashlytics(com.google.firebase.crashlytics.FirebaseCrashlytics.getInstance()) -actual fun Firebase.crashlytics(app: FirebaseApp) = +public actual fun Firebase.crashlytics(app: FirebaseApp): FirebaseCrashlytics = FirebaseCrashlytics(app.android.get(com.google.firebase.crashlytics.FirebaseCrashlytics::class.java)) -actual class FirebaseCrashlytics internal constructor(val android: com.google.firebase.crashlytics.FirebaseCrashlytics){ +public actual class FirebaseCrashlytics internal constructor(public val android: com.google.firebase.crashlytics.FirebaseCrashlytics) { - actual fun recordException(exception: Throwable) = android.recordException(exception) - actual fun log(message: String) = android.log(message) - actual fun setUserId(userId: String) = android.setUserId(userId) - actual fun setCrashlyticsCollectionEnabled(enabled: Boolean) = android.setCrashlyticsCollectionEnabled(enabled) - actual fun sendUnsentReports() = android.sendUnsentReports() - actual fun deleteUnsentReports() = android.deleteUnsentReports() - actual fun didCrashOnPreviousExecution(): Boolean = android.didCrashOnPreviousExecution() - actual fun setCustomKey(key: String, value: String) = android.setCustomKey(key, value) - actual fun setCustomKey(key: String, value: Boolean) = android.setCustomKey(key, value) - actual fun setCustomKey(key: String, value: Double) = android.setCustomKey(key, value) - actual fun setCustomKey(key: String, value: Float) = android.setCustomKey(key, value) - actual fun setCustomKey(key: String, value: Int) = android.setCustomKey(key, value) - actual fun setCustomKey(key: String, value: Long) = android.setCustomKey(key, value) - actual fun setCustomKeys(customKeys: Map) = + public actual fun recordException(exception: Throwable) { + android.recordException(exception) + } + public actual fun log(message: String) { + android.log(message) + } + public actual fun setUserId(userId: String) { + android.setUserId(userId) + } + public actual fun setCrashlyticsCollectionEnabled(enabled: Boolean) { + android.setCrashlyticsCollectionEnabled(enabled) + } + public actual fun sendUnsentReports() { + android.sendUnsentReports() + } + public actual fun deleteUnsentReports() { + android.deleteUnsentReports() + } + public actual fun didCrashOnPreviousExecution(): Boolean = android.didCrashOnPreviousExecution() + public actual fun setCustomKey(key: String, value: String) { + android.setCustomKey(key, value) + } + public actual fun setCustomKey(key: String, value: Boolean) { + android.setCustomKey(key, value) + } + public actual fun setCustomKey(key: String, value: Double) { + android.setCustomKey(key, value) + } + public actual fun setCustomKey(key: String, value: Float) { + android.setCustomKey(key, value) + } + public actual fun setCustomKey(key: String, value: Int) { + android.setCustomKey(key, value) + } + public actual fun setCustomKey(key: String, value: Long) { + android.setCustomKey(key, value) + } + public actual fun setCustomKeys(customKeys: Map) { android.setCustomKeys( Builder().apply { customKeys.forEach { (key, value) -> @@ -39,8 +63,9 @@ actual class FirebaseCrashlytics internal constructor(val android: com.google.fi is Long -> putLong(key, value) } } - }.build() + }.build(), ) + } } -actual open class FirebaseCrashlyticsException(message: String) : FirebaseException(message) \ No newline at end of file +public actual open class FirebaseCrashlyticsException(message: String) : FirebaseException(message) diff --git a/firebase-crashlytics/src/androidUnitTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt b/firebase-crashlytics/src/androidUnitTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt index 413cecca5..103d3d205 100644 --- a/firebase-crashlytics/src/androidUnitTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt +++ b/firebase-crashlytics/src/androidUnitTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt @@ -3,12 +3,11 @@ */ @file:JvmName("tests") + package dev.gitlive.firebase.crashlytics import org.junit.Ignore -actual val emulatorHost: String = "10.0.2.2" - actual val context: Any = "" actual typealias IgnoreForAndroidUnitTest = Ignore diff --git a/firebase-crashlytics/src/commonMain/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt b/firebase-crashlytics/src/commonMain/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt index 3770ab2f1..32d99aa6c 100644 --- a/firebase-crashlytics/src/commonMain/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt +++ b/firebase-crashlytics/src/commonMain/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt @@ -5,10 +5,10 @@ import dev.gitlive.firebase.FirebaseApp import dev.gitlive.firebase.FirebaseException /** Returns the [FirebaseCrashlytics] instance of the default [FirebaseApp]. */ -expect val Firebase.crashlytics: FirebaseCrashlytics +public expect val Firebase.crashlytics: FirebaseCrashlytics /** Returns the [FirebaseCrashlytics] instance of a given [FirebaseApp]. */ -expect fun Firebase.crashlytics(app: FirebaseApp): FirebaseCrashlytics +public expect fun Firebase.crashlytics(app: FirebaseApp): FirebaseCrashlytics /** * The Firebase Crashlytics API provides methods to annotate and manage fatal crashes, non-fatal @@ -19,13 +19,13 @@ expect fun Firebase.crashlytics(app: FirebaseApp): FirebaseCrashlytics * Call [Firebase.crashlytics] to get the singleton instance of * [FirebaseCrashlytics]. */ -expect class FirebaseCrashlytics { +public expect class FirebaseCrashlytics { /** * Records a non-fatal report to send to Crashlytics. * * @param exception a [Throwable] to be recorded as a non-fatal event. */ - fun recordException(exception: Throwable) + public fun recordException(exception: Throwable) /** * Logs a message that's included in the next fatal, non-fatal, or ANR report. @@ -38,7 +38,7 @@ expect class FirebaseCrashlytics { * * @param message the message to be logged */ - fun log(message: String) + public fun log(message: String) /** * Records a user ID (identifier) that's associated with subsequent fatal, non-fatal, and ANR @@ -50,7 +50,7 @@ expect class FirebaseCrashlytics { * * @param userId a unique identifier for the current user */ - fun setUserId(userId: String) + public fun setUserId(userId: String) /** * Sets a custom key and value that are associated with subsequent fatal, non-fatal, and ANR @@ -70,7 +70,7 @@ expect class FirebaseCrashlytics { * @param key A unique key * @param value A value to be associated with the given key */ - fun setCustomKey(key: String, value: String) + public fun setCustomKey(key: String, value: String) /** * Sets a custom key and value that are associated with subsequent fatal, non-fatal, and ANR @@ -90,7 +90,7 @@ expect class FirebaseCrashlytics { * @param key A unique key * @param value A value to be associated with the given key */ - fun setCustomKey(key: String, value: Boolean) + public fun setCustomKey(key: String, value: Boolean) /** * Sets a custom key and value that are associated with subsequent fatal, non-fatal, and ANR @@ -110,7 +110,7 @@ expect class FirebaseCrashlytics { * @param key A unique key * @param value A value to be associated with the given key */ - fun setCustomKey(key: String, value: Double) + public fun setCustomKey(key: String, value: Double) /** * Sets a custom key and value that are associated with subsequent fatal, non-fatal, and ANR @@ -130,7 +130,7 @@ expect class FirebaseCrashlytics { * @param key A unique key * @param value A value to be associated with the given key */ - fun setCustomKey(key: String, value: Float) + public fun setCustomKey(key: String, value: Float) /** * Sets a custom key and value that are associated with subsequent fatal, non-fatal, and ANR @@ -150,7 +150,7 @@ expect class FirebaseCrashlytics { * @param key A unique key * @param value A value to be associated with the given key */ - fun setCustomKey(key: String, value: Int) + public fun setCustomKey(key: String, value: Int) /** * Sets a custom key and value that are associated with subsequent fatal, non-fatal, and ANR @@ -170,7 +170,7 @@ expect class FirebaseCrashlytics { * @param key A unique key * @param value A value to be associated with the given key */ - fun setCustomKey(key: String, value: Long) + public fun setCustomKey(key: String, value: Long) /** * Sets multiple custom keys and values that are associated with subsequent fatal, non-fatal, and @@ -192,7 +192,7 @@ expect class FirebaseCrashlytics { * * @param customKeys A dictionary of keys and the values to associate with each key */ - fun setCustomKeys(customKeys: Map) + public fun setCustomKeys(customKeys: Map) /** * Enables or disables the automatic data collection configuration for Crashlytics. @@ -210,29 +210,29 @@ expect class FirebaseCrashlytics { * for all app runs, add the `firebase_crashlytics_collection_enabled` flag to your * app's AndroidManifest.xml. */ - fun setCrashlyticsCollectionEnabled(enabled: Boolean) + public fun setCrashlyticsCollectionEnabled(enabled: Boolean) /** * Checks whether the app crashed on its previous run. * * @return true if a crash was recorded during the previous run of the app. */ - fun didCrashOnPreviousExecution(): Boolean + public fun didCrashOnPreviousExecution(): Boolean /** * If automatic data collection is disabled, this method queues up all the reports on a device to * send to Crashlytics. Otherwise, this method is a no-op. */ - fun sendUnsentReports() + public fun sendUnsentReports() /** * If automatic data collection is disabled, this method queues up all the reports on a device for * deletion. Otherwise, this method is a no-op. */ - fun deleteUnsentReports() + public fun deleteUnsentReports() } /** * Exception that gets thrown when an operation on Firebase Crashlytics fails. */ -expect open class FirebaseCrashlyticsException : FirebaseException \ No newline at end of file +public expect open class FirebaseCrashlyticsException : FirebaseException diff --git a/firebase-crashlytics/src/commonTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt b/firebase-crashlytics/src/commonTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt index 958f03ac3..787587bc1 100644 --- a/firebase-crashlytics/src/commonTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt +++ b/firebase-crashlytics/src/commonTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt @@ -17,7 +17,6 @@ import kotlin.test.Test import kotlin.test.assertFalse import kotlin.time.Duration.Companion.seconds -expect val emulatorHost: String expect val context: Any expect annotation class IgnoreForAndroidUnitTest() @@ -36,8 +35,8 @@ class FirebaseCrashlyticsTest { databaseUrl = "https://fir-kotlin-sdk.firebaseio.com", storageBucket = "fir-kotlin-sdk.appspot.com", projectId = "fir-kotlin-sdk", - gcmSenderId = "846484016111" - ) + gcmSenderId = "846484016111", + ), ) crashlytics = Firebase.crashlytics(app) diff --git a/firebase-crashlytics/src/iosMain/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt b/firebase-crashlytics/src/iosMain/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt index 65cb6cbd8..55534b20c 100644 --- a/firebase-crashlytics/src/iosMain/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt +++ b/firebase-crashlytics/src/iosMain/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt @@ -7,34 +7,59 @@ import dev.gitlive.firebase.Firebase import dev.gitlive.firebase.FirebaseApp import dev.gitlive.firebase.FirebaseException -actual val Firebase.crashlytics get() = +public actual val Firebase.crashlytics: FirebaseCrashlytics get() = FirebaseCrashlytics(FIRCrashlytics.crashlytics()) -actual fun Firebase.crashlytics(app: FirebaseApp) = +public actual fun Firebase.crashlytics(app: FirebaseApp): FirebaseCrashlytics = FirebaseCrashlytics(FIRCrashlytics.crashlytics()) -actual class FirebaseCrashlytics internal constructor(val ios: FIRCrashlytics) { +public actual class FirebaseCrashlytics internal constructor(public val ios: FIRCrashlytics) { - actual fun recordException(exception: Throwable) { ios.recordError(exception.asNSError()) } - actual fun log(message: String) { ios.log(message) } - actual fun setUserId(userId: String) { ios.setUserID(userId) } - actual fun setCrashlyticsCollectionEnabled(enabled: Boolean) { ios.setCrashlyticsCollectionEnabled(enabled) } - actual fun sendUnsentReports() { ios.sendUnsentReports() } - actual fun deleteUnsentReports() { ios.deleteUnsentReports() } - actual fun didCrashOnPreviousExecution(): Boolean = ios.didCrashDuringPreviousExecution() - actual fun setCustomKey(key: String, value: String) { + public actual fun recordException(exception: Throwable) { + ios.recordError(exception.asNSError()) + } + public actual fun log(message: String) { + ios.log(message) + } + public actual fun setUserId(userId: String) { + ios.setUserID(userId) + } + public actual fun setCrashlyticsCollectionEnabled(enabled: Boolean) { + ios.setCrashlyticsCollectionEnabled(enabled) + } + public actual fun sendUnsentReports() { + ios.sendUnsentReports() + } + public actual fun deleteUnsentReports() { + ios.deleteUnsentReports() + } + public actual fun didCrashOnPreviousExecution(): Boolean = ios.didCrashDuringPreviousExecution() + public actual fun setCustomKey(key: String, value: String) { ios.setCustomValue(key, value) } - actual fun setCustomKey(key: String, value: Boolean) { ios.setCustomValue(key, value.toString()) } - actual fun setCustomKey(key: String, value: Double) { ios.setCustomValue(key, value.toString()) } - actual fun setCustomKey(key: String, value: Float) { ios.setCustomValue(key, value.toString()) } - actual fun setCustomKey(key: String, value: Int) { ios.setCustomValue(key, value.toString()) } - actual fun setCustomKey(key: String, value: Long) { ios.setCustomValue(key, value.toString()) } + public actual fun setCustomKey(key: String, value: Boolean) { + ios.setCustomValue(key, value.toString()) + } + public actual fun setCustomKey(key: String, value: Double) { + ios.setCustomValue(key, value.toString()) + } + public actual fun setCustomKey(key: String, value: Float) { + ios.setCustomValue(key, value.toString()) + } + public actual fun setCustomKey(key: String, value: Int) { + ios.setCustomValue(key, value.toString()) + } + public actual fun setCustomKey(key: String, value: Long) { + ios.setCustomValue(key, value.toString()) + } + @Suppress("UNCHECKED_CAST") - actual fun setCustomKeys(customKeys: Map) { ios.setCustomKeysAndValues(customKeys as Map) } + public actual fun setCustomKeys(customKeys: Map) { + ios.setCustomKeysAndValues(customKeys as Map) + } } -actual open class FirebaseCrashlyticsException internal constructor(message: String) : FirebaseException(message) +public actual open class FirebaseCrashlyticsException internal constructor(message: String) : FirebaseException(message) private fun Throwable.asNSError(): NSError { val userInfo = mutableMapOf() @@ -44,4 +69,4 @@ private fun Throwable.asNSError(): NSError { userInfo[NSLocalizedDescriptionKey] = message } return NSError.errorWithDomain(this::class.qualifiedName, 0, userInfo) -} \ No newline at end of file +} diff --git a/firebase-crashlytics/src/iosTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt b/firebase-crashlytics/src/iosTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt index 602cd1be6..25fea7595 100644 --- a/firebase-crashlytics/src/iosTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt +++ b/firebase-crashlytics/src/iosTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt @@ -4,8 +4,6 @@ package dev.gitlive.firebase.crashlytics -actual val emulatorHost: String = "localhost" - actual val context: Any = Unit @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) diff --git a/firebase-database/api/android/firebase-database.api b/firebase-database/api/android/firebase-database.api new file mode 100644 index 000000000..d963931e0 --- /dev/null +++ b/firebase-database/api/android/firebase-database.api @@ -0,0 +1,172 @@ +public final class dev/gitlive/firebase/database/ChildEvent { + public final fun component1 ()Ldev/gitlive/firebase/database/DataSnapshot; + public final fun component2 ()Ldev/gitlive/firebase/database/ChildEvent$Type; + public final fun component3 ()Ljava/lang/String; + public final fun copy (Ldev/gitlive/firebase/database/DataSnapshot;Ldev/gitlive/firebase/database/ChildEvent$Type;Ljava/lang/String;)Ldev/gitlive/firebase/database/ChildEvent; + public static synthetic fun copy$default (Ldev/gitlive/firebase/database/ChildEvent;Ldev/gitlive/firebase/database/DataSnapshot;Ldev/gitlive/firebase/database/ChildEvent$Type;Ljava/lang/String;ILjava/lang/Object;)Ldev/gitlive/firebase/database/ChildEvent; + public fun equals (Ljava/lang/Object;)Z + public final fun getPreviousChildName ()Ljava/lang/String; + public final fun getSnapshot ()Ldev/gitlive/firebase/database/DataSnapshot; + public final fun getType ()Ldev/gitlive/firebase/database/ChildEvent$Type; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/database/ChildEvent$Type : java/lang/Enum { + public static final field ADDED Ldev/gitlive/firebase/database/ChildEvent$Type; + public static final field CHANGED Ldev/gitlive/firebase/database/ChildEvent$Type; + public static final field MOVED Ldev/gitlive/firebase/database/ChildEvent$Type; + public static final field REMOVED Ldev/gitlive/firebase/database/ChildEvent$Type; + public static fun getEntries ()Lkotlin/enums/EnumEntries; + public static fun valueOf (Ljava/lang/String;)Ldev/gitlive/firebase/database/ChildEvent$Type; + public static fun values ()[Ldev/gitlive/firebase/database/ChildEvent$Type; +} + +public final class dev/gitlive/firebase/database/DataSnapshot { + public final fun child (Ljava/lang/String;)Ldev/gitlive/firebase/database/DataSnapshot; + public final fun getAndroid ()Lcom/google/firebase/database/DataSnapshot; + public final fun getChildren ()Ljava/lang/Iterable; + public final fun getExists ()Z + public final fun getHasChildren ()Z + public final fun getKey ()Ljava/lang/String; + public final fun getRef ()Ldev/gitlive/firebase/database/DatabaseReference; + public final fun getValue ()Ljava/lang/Object; + public final fun value (Lkotlinx/serialization/DeserializationStrategy;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; + public static synthetic fun value$default (Ldev/gitlive/firebase/database/DataSnapshot;Lkotlinx/serialization/DeserializationStrategy;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/lang/Object; +} + +public final class dev/gitlive/firebase/database/DatabaseReference : dev/gitlive/firebase/database/Query { + public final fun child (Ljava/lang/String;)Ldev/gitlive/firebase/database/DatabaseReference; + public final fun getKey ()Ljava/lang/String; + public final fun getNativeReference ()Ldev/gitlive/firebase/database/NativeDatabaseReference; + public final fun onDisconnect ()Ldev/gitlive/firebase/database/OnDisconnect; + public final fun push ()Ldev/gitlive/firebase/database/DatabaseReference; + public final fun removeValue (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun runTransaction (Lkotlinx/serialization/KSerializer;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static synthetic fun runTransaction$default (Ldev/gitlive/firebase/database/DatabaseReference;Lkotlinx/serialization/KSerializer;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; + public final fun setValue (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun setValue (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static synthetic fun setValue$default (Ldev/gitlive/firebase/database/DatabaseReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; + public final fun updateChildren (Ljava/util/Map;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun updateChildren (Ljava/util/Map;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static synthetic fun updateChildren$default (Ldev/gitlive/firebase/database/DatabaseReference;Ljava/util/Map;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; +} + +public final class dev/gitlive/firebase/database/FirebaseDatabase { + public static final field Companion Ldev/gitlive/firebase/database/FirebaseDatabase$Companion; + public final fun getAndroid ()Lcom/google/firebase/database/FirebaseDatabase; + public final fun goOffline ()V + public final fun goOnline ()V + public final fun reference ()Ldev/gitlive/firebase/database/DatabaseReference; + public final fun reference (Ljava/lang/String;)Ldev/gitlive/firebase/database/DatabaseReference; + public final fun setLoggingEnabled (Z)V + public final fun setPersistenceCacheSizeBytes (J)V + public final fun setPersistenceEnabled (Z)V + public final fun useEmulator (Ljava/lang/String;I)V +} + +public final class dev/gitlive/firebase/database/FirebaseDatabase$Companion { +} + +public final class dev/gitlive/firebase/database/NativeDatabaseReference { + public final fun child (Ljava/lang/String;)Ldev/gitlive/firebase/database/NativeDatabaseReference; + public fun getAndroid ()Lcom/google/firebase/database/DatabaseReference; + public synthetic fun getAndroid ()Lcom/google/firebase/database/Query; + public final fun getDatabase ()Ldev/gitlive/firebase/database/FirebaseDatabase; + public final fun getKey ()Ljava/lang/String; + public final fun onDisconnect ()Ldev/gitlive/firebase/database/NativeOnDisconnect; + public final fun push ()Ldev/gitlive/firebase/database/NativeDatabaseReference; + public final fun removeValue (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun runTransaction (Lkotlinx/serialization/KSerializer;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static synthetic fun runTransaction$default (Ldev/gitlive/firebase/database/NativeDatabaseReference;Lkotlinx/serialization/KSerializer;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; + public final fun setValueEncoded (Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun updateEncodedChildren (Ldev/gitlive/firebase/internal/EncodedObject;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; +} + +public final class dev/gitlive/firebase/database/NativeOnDisconnect { + public final fun cancel (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun getAndroid ()Lcom/google/firebase/database/OnDisconnect; + public final fun getDatabase ()Ldev/gitlive/firebase/database/FirebaseDatabase; + public final fun getPersistenceEnabled ()Z + public final fun removeValue (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun setValue (Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun updateEncodedChildren (Ldev/gitlive/firebase/internal/EncodedObject;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; +} + +public final class dev/gitlive/firebase/database/OnDisconnect { + public final fun cancel (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun getNative ()Ldev/gitlive/firebase/database/NativeOnDisconnect; + public final fun removeValue (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun setValue (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun setValue (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static synthetic fun setValue$default (Ldev/gitlive/firebase/database/OnDisconnect;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; + public final fun updateChildren (Ljava/util/Map;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun updateChildren (Ljava/util/Map;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static synthetic fun updateChildren$default (Ldev/gitlive/firebase/database/OnDisconnect;Ljava/util/Map;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; +} + +public class dev/gitlive/firebase/database/Query { + public final fun childEvents ([Ldev/gitlive/firebase/database/ChildEvent$Type;)Lkotlinx/coroutines/flow/Flow; + public static synthetic fun childEvents$default (Ldev/gitlive/firebase/database/Query;[Ldev/gitlive/firebase/database/ChildEvent$Type;ILjava/lang/Object;)Lkotlinx/coroutines/flow/Flow; + public final fun endAt (DLjava/lang/String;)Ldev/gitlive/firebase/database/Query; + public final fun endAt (Ljava/lang/String;Ljava/lang/String;)Ldev/gitlive/firebase/database/Query; + public final fun endAt (ZLjava/lang/String;)Ldev/gitlive/firebase/database/Query; + public static synthetic fun endAt$default (Ldev/gitlive/firebase/database/Query;DLjava/lang/String;ILjava/lang/Object;)Ldev/gitlive/firebase/database/Query; + public static synthetic fun endAt$default (Ldev/gitlive/firebase/database/Query;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ldev/gitlive/firebase/database/Query; + public static synthetic fun endAt$default (Ldev/gitlive/firebase/database/Query;ZLjava/lang/String;ILjava/lang/Object;)Ldev/gitlive/firebase/database/Query; + public final fun equalTo (DLjava/lang/String;)Ldev/gitlive/firebase/database/Query; + public final fun equalTo (Ljava/lang/String;Ljava/lang/String;)Ldev/gitlive/firebase/database/Query; + public final fun equalTo (ZLjava/lang/String;)Ldev/gitlive/firebase/database/Query; + public static synthetic fun equalTo$default (Ldev/gitlive/firebase/database/Query;DLjava/lang/String;ILjava/lang/Object;)Ldev/gitlive/firebase/database/Query; + public static synthetic fun equalTo$default (Ldev/gitlive/firebase/database/Query;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ldev/gitlive/firebase/database/Query; + public static synthetic fun equalTo$default (Ldev/gitlive/firebase/database/Query;ZLjava/lang/String;ILjava/lang/Object;)Ldev/gitlive/firebase/database/Query; + public fun getAndroid ()Lcom/google/firebase/database/Query; + public final fun getPersistenceEnabled ()Z + public final fun getValueEvents ()Lkotlinx/coroutines/flow/Flow; + public final fun limitToFirst (I)Ldev/gitlive/firebase/database/Query; + public final fun limitToLast (I)Ldev/gitlive/firebase/database/Query; + public final fun orderByChild (Ljava/lang/String;)Ldev/gitlive/firebase/database/Query; + public final fun orderByKey ()Ldev/gitlive/firebase/database/Query; + public final fun orderByValue ()Ldev/gitlive/firebase/database/Query; + public final fun startAt (DLjava/lang/String;)Ldev/gitlive/firebase/database/Query; + public final fun startAt (Ljava/lang/String;Ljava/lang/String;)Ldev/gitlive/firebase/database/Query; + public final fun startAt (ZLjava/lang/String;)Ldev/gitlive/firebase/database/Query; + public static synthetic fun startAt$default (Ldev/gitlive/firebase/database/Query;DLjava/lang/String;ILjava/lang/Object;)Ldev/gitlive/firebase/database/Query; + public static synthetic fun startAt$default (Ldev/gitlive/firebase/database/Query;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ldev/gitlive/firebase/database/Query; + public static synthetic fun startAt$default (Ldev/gitlive/firebase/database/Query;ZLjava/lang/String;ILjava/lang/Object;)Ldev/gitlive/firebase/database/Query; + public fun toString ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/database/ServerValue { + public static final field Companion Ldev/gitlive/firebase/database/ServerValue$Companion; + public fun equals (Ljava/lang/Object;)Z + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/database/ServerValue$Companion { + public final fun getTIMESTAMP ()Ldev/gitlive/firebase/database/ServerValue; + public final fun increment (D)Ldev/gitlive/firebase/database/ServerValue; + public final fun serializer ()Lkotlinx/serialization/KSerializer; +} + +public final class dev/gitlive/firebase/database/ServerValueSerializer : kotlinx/serialization/KSerializer { + public static final field INSTANCE Ldev/gitlive/firebase/database/ServerValueSerializer; + public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ldev/gitlive/firebase/database/ServerValue; + public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; + public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; + public fun serialize (Lkotlinx/serialization/encoding/Encoder;Ldev/gitlive/firebase/database/ServerValue;)V + public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V +} + +public final class dev/gitlive/firebase/database/databaseAndroid { + public static final fun database (Ldev/gitlive/firebase/Firebase;Ldev/gitlive/firebase/FirebaseApp;)Ldev/gitlive/firebase/database/FirebaseDatabase; + public static final fun database (Ldev/gitlive/firebase/Firebase;Ldev/gitlive/firebase/FirebaseApp;Ljava/lang/String;)Ldev/gitlive/firebase/database/FirebaseDatabase; + public static final fun database (Ldev/gitlive/firebase/Firebase;Ljava/lang/String;)Ldev/gitlive/firebase/database/FirebaseDatabase; + public static final fun getAndroid (Ldev/gitlive/firebase/database/DatabaseReference;)Lcom/google/firebase/database/DatabaseReference; + public static final fun getAndroid (Ldev/gitlive/firebase/database/OnDisconnect;)Lcom/google/firebase/database/OnDisconnect; + public static final fun getDatabase (Ldev/gitlive/firebase/Firebase;)Ldev/gitlive/firebase/database/FirebaseDatabase; + public static final fun getDatabase (Ldev/gitlive/firebase/database/OnDisconnect;)Ldev/gitlive/firebase/database/FirebaseDatabase; + public static final fun getPersistenceEnabled (Ldev/gitlive/firebase/database/OnDisconnect;)Z +} + diff --git a/firebase-database/api/jvm/firebase-database.api b/firebase-database/api/jvm/firebase-database.api new file mode 100644 index 000000000..d963931e0 --- /dev/null +++ b/firebase-database/api/jvm/firebase-database.api @@ -0,0 +1,172 @@ +public final class dev/gitlive/firebase/database/ChildEvent { + public final fun component1 ()Ldev/gitlive/firebase/database/DataSnapshot; + public final fun component2 ()Ldev/gitlive/firebase/database/ChildEvent$Type; + public final fun component3 ()Ljava/lang/String; + public final fun copy (Ldev/gitlive/firebase/database/DataSnapshot;Ldev/gitlive/firebase/database/ChildEvent$Type;Ljava/lang/String;)Ldev/gitlive/firebase/database/ChildEvent; + public static synthetic fun copy$default (Ldev/gitlive/firebase/database/ChildEvent;Ldev/gitlive/firebase/database/DataSnapshot;Ldev/gitlive/firebase/database/ChildEvent$Type;Ljava/lang/String;ILjava/lang/Object;)Ldev/gitlive/firebase/database/ChildEvent; + public fun equals (Ljava/lang/Object;)Z + public final fun getPreviousChildName ()Ljava/lang/String; + public final fun getSnapshot ()Ldev/gitlive/firebase/database/DataSnapshot; + public final fun getType ()Ldev/gitlive/firebase/database/ChildEvent$Type; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/database/ChildEvent$Type : java/lang/Enum { + public static final field ADDED Ldev/gitlive/firebase/database/ChildEvent$Type; + public static final field CHANGED Ldev/gitlive/firebase/database/ChildEvent$Type; + public static final field MOVED Ldev/gitlive/firebase/database/ChildEvent$Type; + public static final field REMOVED Ldev/gitlive/firebase/database/ChildEvent$Type; + public static fun getEntries ()Lkotlin/enums/EnumEntries; + public static fun valueOf (Ljava/lang/String;)Ldev/gitlive/firebase/database/ChildEvent$Type; + public static fun values ()[Ldev/gitlive/firebase/database/ChildEvent$Type; +} + +public final class dev/gitlive/firebase/database/DataSnapshot { + public final fun child (Ljava/lang/String;)Ldev/gitlive/firebase/database/DataSnapshot; + public final fun getAndroid ()Lcom/google/firebase/database/DataSnapshot; + public final fun getChildren ()Ljava/lang/Iterable; + public final fun getExists ()Z + public final fun getHasChildren ()Z + public final fun getKey ()Ljava/lang/String; + public final fun getRef ()Ldev/gitlive/firebase/database/DatabaseReference; + public final fun getValue ()Ljava/lang/Object; + public final fun value (Lkotlinx/serialization/DeserializationStrategy;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; + public static synthetic fun value$default (Ldev/gitlive/firebase/database/DataSnapshot;Lkotlinx/serialization/DeserializationStrategy;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/lang/Object; +} + +public final class dev/gitlive/firebase/database/DatabaseReference : dev/gitlive/firebase/database/Query { + public final fun child (Ljava/lang/String;)Ldev/gitlive/firebase/database/DatabaseReference; + public final fun getKey ()Ljava/lang/String; + public final fun getNativeReference ()Ldev/gitlive/firebase/database/NativeDatabaseReference; + public final fun onDisconnect ()Ldev/gitlive/firebase/database/OnDisconnect; + public final fun push ()Ldev/gitlive/firebase/database/DatabaseReference; + public final fun removeValue (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun runTransaction (Lkotlinx/serialization/KSerializer;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static synthetic fun runTransaction$default (Ldev/gitlive/firebase/database/DatabaseReference;Lkotlinx/serialization/KSerializer;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; + public final fun setValue (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun setValue (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static synthetic fun setValue$default (Ldev/gitlive/firebase/database/DatabaseReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; + public final fun updateChildren (Ljava/util/Map;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun updateChildren (Ljava/util/Map;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static synthetic fun updateChildren$default (Ldev/gitlive/firebase/database/DatabaseReference;Ljava/util/Map;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; +} + +public final class dev/gitlive/firebase/database/FirebaseDatabase { + public static final field Companion Ldev/gitlive/firebase/database/FirebaseDatabase$Companion; + public final fun getAndroid ()Lcom/google/firebase/database/FirebaseDatabase; + public final fun goOffline ()V + public final fun goOnline ()V + public final fun reference ()Ldev/gitlive/firebase/database/DatabaseReference; + public final fun reference (Ljava/lang/String;)Ldev/gitlive/firebase/database/DatabaseReference; + public final fun setLoggingEnabled (Z)V + public final fun setPersistenceCacheSizeBytes (J)V + public final fun setPersistenceEnabled (Z)V + public final fun useEmulator (Ljava/lang/String;I)V +} + +public final class dev/gitlive/firebase/database/FirebaseDatabase$Companion { +} + +public final class dev/gitlive/firebase/database/NativeDatabaseReference { + public final fun child (Ljava/lang/String;)Ldev/gitlive/firebase/database/NativeDatabaseReference; + public fun getAndroid ()Lcom/google/firebase/database/DatabaseReference; + public synthetic fun getAndroid ()Lcom/google/firebase/database/Query; + public final fun getDatabase ()Ldev/gitlive/firebase/database/FirebaseDatabase; + public final fun getKey ()Ljava/lang/String; + public final fun onDisconnect ()Ldev/gitlive/firebase/database/NativeOnDisconnect; + public final fun push ()Ldev/gitlive/firebase/database/NativeDatabaseReference; + public final fun removeValue (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun runTransaction (Lkotlinx/serialization/KSerializer;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static synthetic fun runTransaction$default (Ldev/gitlive/firebase/database/NativeDatabaseReference;Lkotlinx/serialization/KSerializer;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; + public final fun setValueEncoded (Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun updateEncodedChildren (Ldev/gitlive/firebase/internal/EncodedObject;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; +} + +public final class dev/gitlive/firebase/database/NativeOnDisconnect { + public final fun cancel (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun getAndroid ()Lcom/google/firebase/database/OnDisconnect; + public final fun getDatabase ()Ldev/gitlive/firebase/database/FirebaseDatabase; + public final fun getPersistenceEnabled ()Z + public final fun removeValue (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun setValue (Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun updateEncodedChildren (Ldev/gitlive/firebase/internal/EncodedObject;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; +} + +public final class dev/gitlive/firebase/database/OnDisconnect { + public final fun cancel (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun getNative ()Ldev/gitlive/firebase/database/NativeOnDisconnect; + public final fun removeValue (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun setValue (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun setValue (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static synthetic fun setValue$default (Ldev/gitlive/firebase/database/OnDisconnect;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; + public final fun updateChildren (Ljava/util/Map;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun updateChildren (Ljava/util/Map;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static synthetic fun updateChildren$default (Ldev/gitlive/firebase/database/OnDisconnect;Ljava/util/Map;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; +} + +public class dev/gitlive/firebase/database/Query { + public final fun childEvents ([Ldev/gitlive/firebase/database/ChildEvent$Type;)Lkotlinx/coroutines/flow/Flow; + public static synthetic fun childEvents$default (Ldev/gitlive/firebase/database/Query;[Ldev/gitlive/firebase/database/ChildEvent$Type;ILjava/lang/Object;)Lkotlinx/coroutines/flow/Flow; + public final fun endAt (DLjava/lang/String;)Ldev/gitlive/firebase/database/Query; + public final fun endAt (Ljava/lang/String;Ljava/lang/String;)Ldev/gitlive/firebase/database/Query; + public final fun endAt (ZLjava/lang/String;)Ldev/gitlive/firebase/database/Query; + public static synthetic fun endAt$default (Ldev/gitlive/firebase/database/Query;DLjava/lang/String;ILjava/lang/Object;)Ldev/gitlive/firebase/database/Query; + public static synthetic fun endAt$default (Ldev/gitlive/firebase/database/Query;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ldev/gitlive/firebase/database/Query; + public static synthetic fun endAt$default (Ldev/gitlive/firebase/database/Query;ZLjava/lang/String;ILjava/lang/Object;)Ldev/gitlive/firebase/database/Query; + public final fun equalTo (DLjava/lang/String;)Ldev/gitlive/firebase/database/Query; + public final fun equalTo (Ljava/lang/String;Ljava/lang/String;)Ldev/gitlive/firebase/database/Query; + public final fun equalTo (ZLjava/lang/String;)Ldev/gitlive/firebase/database/Query; + public static synthetic fun equalTo$default (Ldev/gitlive/firebase/database/Query;DLjava/lang/String;ILjava/lang/Object;)Ldev/gitlive/firebase/database/Query; + public static synthetic fun equalTo$default (Ldev/gitlive/firebase/database/Query;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ldev/gitlive/firebase/database/Query; + public static synthetic fun equalTo$default (Ldev/gitlive/firebase/database/Query;ZLjava/lang/String;ILjava/lang/Object;)Ldev/gitlive/firebase/database/Query; + public fun getAndroid ()Lcom/google/firebase/database/Query; + public final fun getPersistenceEnabled ()Z + public final fun getValueEvents ()Lkotlinx/coroutines/flow/Flow; + public final fun limitToFirst (I)Ldev/gitlive/firebase/database/Query; + public final fun limitToLast (I)Ldev/gitlive/firebase/database/Query; + public final fun orderByChild (Ljava/lang/String;)Ldev/gitlive/firebase/database/Query; + public final fun orderByKey ()Ldev/gitlive/firebase/database/Query; + public final fun orderByValue ()Ldev/gitlive/firebase/database/Query; + public final fun startAt (DLjava/lang/String;)Ldev/gitlive/firebase/database/Query; + public final fun startAt (Ljava/lang/String;Ljava/lang/String;)Ldev/gitlive/firebase/database/Query; + public final fun startAt (ZLjava/lang/String;)Ldev/gitlive/firebase/database/Query; + public static synthetic fun startAt$default (Ldev/gitlive/firebase/database/Query;DLjava/lang/String;ILjava/lang/Object;)Ldev/gitlive/firebase/database/Query; + public static synthetic fun startAt$default (Ldev/gitlive/firebase/database/Query;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ldev/gitlive/firebase/database/Query; + public static synthetic fun startAt$default (Ldev/gitlive/firebase/database/Query;ZLjava/lang/String;ILjava/lang/Object;)Ldev/gitlive/firebase/database/Query; + public fun toString ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/database/ServerValue { + public static final field Companion Ldev/gitlive/firebase/database/ServerValue$Companion; + public fun equals (Ljava/lang/Object;)Z + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/database/ServerValue$Companion { + public final fun getTIMESTAMP ()Ldev/gitlive/firebase/database/ServerValue; + public final fun increment (D)Ldev/gitlive/firebase/database/ServerValue; + public final fun serializer ()Lkotlinx/serialization/KSerializer; +} + +public final class dev/gitlive/firebase/database/ServerValueSerializer : kotlinx/serialization/KSerializer { + public static final field INSTANCE Ldev/gitlive/firebase/database/ServerValueSerializer; + public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ldev/gitlive/firebase/database/ServerValue; + public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; + public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; + public fun serialize (Lkotlinx/serialization/encoding/Encoder;Ldev/gitlive/firebase/database/ServerValue;)V + public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V +} + +public final class dev/gitlive/firebase/database/databaseAndroid { + public static final fun database (Ldev/gitlive/firebase/Firebase;Ldev/gitlive/firebase/FirebaseApp;)Ldev/gitlive/firebase/database/FirebaseDatabase; + public static final fun database (Ldev/gitlive/firebase/Firebase;Ldev/gitlive/firebase/FirebaseApp;Ljava/lang/String;)Ldev/gitlive/firebase/database/FirebaseDatabase; + public static final fun database (Ldev/gitlive/firebase/Firebase;Ljava/lang/String;)Ldev/gitlive/firebase/database/FirebaseDatabase; + public static final fun getAndroid (Ldev/gitlive/firebase/database/DatabaseReference;)Lcom/google/firebase/database/DatabaseReference; + public static final fun getAndroid (Ldev/gitlive/firebase/database/OnDisconnect;)Lcom/google/firebase/database/OnDisconnect; + public static final fun getDatabase (Ldev/gitlive/firebase/Firebase;)Ldev/gitlive/firebase/database/FirebaseDatabase; + public static final fun getDatabase (Ldev/gitlive/firebase/database/OnDisconnect;)Ldev/gitlive/firebase/database/FirebaseDatabase; + public static final fun getPersistenceEnabled (Ldev/gitlive/firebase/database/OnDisconnect;)Z +} + diff --git a/firebase-database/build.gradle.kts b/firebase-database/build.gradle.kts index 0bba45ce1..09ec59fc4 100644 --- a/firebase-database/build.gradle.kts +++ b/firebase-database/build.gradle.kts @@ -53,6 +53,8 @@ android { val supportIosTarget = project.property("skipIosTarget") != "true" kotlin { + explicitApi() + @OptIn(ExperimentalKotlinGradlePluginApi::class) compilerOptions { freeCompilerArgs.add("-Xexpect-actual-classes") diff --git a/firebase-database/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/database/database.kt b/firebase-database/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/database/database.kt index c10dd8972..2cadfe271 100644 --- a/firebase-database/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/database/database.kt +++ b/firebase-database/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/database/database.kt @@ -3,6 +3,7 @@ */ @file:JvmName("tests") + package dev.gitlive.firebase.database import androidx.test.platform.app.InstrumentationRegistry @@ -11,6 +12,7 @@ import org.junit.Ignore actual val emulatorHost: String = "10.0.2.2" actual val context: Any = InstrumentationRegistry.getInstrumentation().targetContext + @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) actual annotation class IgnoreForAndroidUnitTest diff --git a/firebase-database/src/androidMain/kotlin/dev/gitlive/firebase/database/ServerValue.kt b/firebase-database/src/androidMain/kotlin/dev/gitlive/firebase/database/ServerValue.kt index 6c6755ecd..f14b0b5b5 100644 --- a/firebase-database/src/androidMain/kotlin/dev/gitlive/firebase/database/ServerValue.kt +++ b/firebase-database/src/androidMain/kotlin/dev/gitlive/firebase/database/ServerValue.kt @@ -6,12 +6,12 @@ private typealias NativeServerValue = com.google.firebase.database.ServerValue /** Represents a Firebase ServerValue. */ @Serializable(with = ServerValueSerializer::class) -actual class ServerValue internal actual constructor( - internal actual val nativeValue: Any -){ - actual companion object { - actual val TIMESTAMP: ServerValue get() = ServerValue(NativeServerValue.TIMESTAMP) - actual fun increment(delta: Double): ServerValue = ServerValue(NativeServerValue.increment(delta)) +public actual class ServerValue internal actual constructor( + internal actual val nativeValue: Any, +) { + public actual companion object { + public actual val TIMESTAMP: ServerValue get() = ServerValue(NativeServerValue.TIMESTAMP) + public actual fun increment(delta: Double): ServerValue = ServerValue(NativeServerValue.increment(delta)) } override fun equals(other: Any?): Boolean = diff --git a/firebase-database/src/androidMain/kotlin/dev/gitlive/firebase/database/database.kt b/firebase-database/src/androidMain/kotlin/dev/gitlive/firebase/database/database.kt index fd0b2fa50..ac67dca65 100644 --- a/firebase-database/src/androidMain/kotlin/dev/gitlive/firebase/database/database.kt +++ b/firebase-database/src/androidMain/kotlin/dev/gitlive/firebase/database/database.kt @@ -3,6 +3,7 @@ */ @file:JvmName("databaseAndroid") + package dev.gitlive.firebase.database import com.google.android.gms.tasks.Task @@ -47,58 +48,64 @@ internal suspend fun Task.awaitWhileOnline(database: FirebaseDatabase): T .valueEvents .debounce(2.seconds) .filterNot { it.value() } - .map { throw DatabaseException("Database not connected", null) } + .map { throw DatabaseException("Database not connected", null) }, ) .first() -actual val Firebase.database - by lazy { FirebaseDatabase.getInstance(com.google.firebase.database.FirebaseDatabase.getInstance()) } +public actual val Firebase.database: FirebaseDatabase + by lazy { FirebaseDatabase.getInstance(com.google.firebase.database.FirebaseDatabase.getInstance()) } -actual fun Firebase.database(url: String) = +public actual fun Firebase.database(url: String): FirebaseDatabase = FirebaseDatabase.getInstance(com.google.firebase.database.FirebaseDatabase.getInstance(url)) -actual fun Firebase.database(app: FirebaseApp) = +public actual fun Firebase.database(app: FirebaseApp): FirebaseDatabase = FirebaseDatabase.getInstance(com.google.firebase.database.FirebaseDatabase.getInstance(app.android)) -actual fun Firebase.database(app: FirebaseApp, url: String) = +public actual fun Firebase.database(app: FirebaseApp, url: String): FirebaseDatabase = FirebaseDatabase.getInstance(com.google.firebase.database.FirebaseDatabase.getInstance(app.android, url)) -actual class FirebaseDatabase internal constructor(val android: com.google.firebase.database.FirebaseDatabase) { +public actual class FirebaseDatabase internal constructor(public val android: com.google.firebase.database.FirebaseDatabase) { - companion object { + public companion object { private val instances = WeakHashMap() internal fun getInstance( - android: com.google.firebase.database.FirebaseDatabase - ) = instances.getOrPut(android) { dev.gitlive.firebase.database.FirebaseDatabase(android) } + android: com.google.firebase.database.FirebaseDatabase, + ) = instances.getOrPut(android) { FirebaseDatabase(android) } } private var persistenceEnabled = true - actual fun reference(path: String) = + public actual fun reference(path: String): DatabaseReference = DatabaseReference(NativeDatabaseReference(android.getReference(path), persistenceEnabled)) - actual fun reference() = + public actual fun reference(): DatabaseReference = DatabaseReference(NativeDatabaseReference(android.reference, persistenceEnabled)) - actual fun setPersistenceEnabled(enabled: Boolean) { + public actual fun setPersistenceEnabled(enabled: Boolean) { android.setPersistenceEnabled(enabled) persistenceEnabled = enabled } - actual fun setPersistenceCacheSizeBytes(cacheSizeInBytes: Long) { + public actual fun setPersistenceCacheSizeBytes(cacheSizeInBytes: Long) { android.setPersistenceCacheSizeBytes(cacheSizeInBytes) } - actual fun setLoggingEnabled(enabled: Boolean) = + public actual fun setLoggingEnabled(enabled: Boolean) { android.setLogLevel(Logger.Level.DEBUG.takeIf { enabled } ?: Logger.Level.NONE) + } - actual fun useEmulator(host: String, port: Int) = + public actual fun useEmulator(host: String, port: Int) { android.useEmulator(host, port) + } - actual fun goOffline() = android.goOffline() + public actual fun goOffline() { + android.goOffline() + } - actual fun goOnline() = android.goOnline() + public actual fun goOnline() { + android.goOnline() + } } internal actual open class NativeQuery( @@ -106,54 +113,54 @@ internal actual open class NativeQuery( val persistenceEnabled: Boolean, ) -actual open class Query internal actual constructor( - nativeQuery: NativeQuery +public actual open class Query internal actual constructor( + nativeQuery: NativeQuery, ) { internal constructor( android: com.google.firebase.database.Query, - persistenceEnabled: Boolean + persistenceEnabled: Boolean, ) : this(NativeQuery(android, persistenceEnabled)) - open val android: com.google.firebase.database.Query = nativeQuery.android - val persistenceEnabled: Boolean = nativeQuery.persistenceEnabled + public open val android: com.google.firebase.database.Query = nativeQuery.android + public val persistenceEnabled: Boolean = nativeQuery.persistenceEnabled - actual fun orderByKey() = Query(android.orderByKey(), persistenceEnabled) + public actual fun orderByKey(): Query = Query(android.orderByKey(), persistenceEnabled) - actual fun orderByValue() = Query(android.orderByValue(), persistenceEnabled) + public actual fun orderByValue(): Query = Query(android.orderByValue(), persistenceEnabled) - actual fun orderByChild(path: String) = Query(android.orderByChild(path), persistenceEnabled) + public actual fun orderByChild(path: String): Query = Query(android.orderByChild(path), persistenceEnabled) - actual fun startAt(value: String, key: String?) = Query(android.startAt(value, key), persistenceEnabled) + public actual fun startAt(value: String, key: String?): Query = Query(android.startAt(value, key), persistenceEnabled) - actual fun startAt(value: Double, key: String?) = Query(android.startAt(value, key), persistenceEnabled) + public actual fun startAt(value: Double, key: String?): Query = Query(android.startAt(value, key), persistenceEnabled) - actual fun startAt(value: Boolean, key: String?) = Query(android.startAt(value, key), persistenceEnabled) + public actual fun startAt(value: Boolean, key: String?): Query = Query(android.startAt(value, key), persistenceEnabled) - actual fun endAt(value: String, key: String?) = Query(android.endAt(value, key), persistenceEnabled) + public actual fun endAt(value: String, key: String?): Query = Query(android.endAt(value, key), persistenceEnabled) - actual fun endAt(value: Double, key: String?) = Query(android.endAt(value, key), persistenceEnabled) + public actual fun endAt(value: Double, key: String?): Query = Query(android.endAt(value, key), persistenceEnabled) - actual fun endAt(value: Boolean, key: String?) = Query(android.endAt(value, key), persistenceEnabled) + public actual fun endAt(value: Boolean, key: String?): Query = Query(android.endAt(value, key), persistenceEnabled) - actual fun limitToFirst(limit: Int) = Query(android.limitToFirst(limit), persistenceEnabled) + public actual fun limitToFirst(limit: Int): Query = Query(android.limitToFirst(limit), persistenceEnabled) - actual fun limitToLast(limit: Int) = Query(android.limitToLast(limit), persistenceEnabled) + public actual fun limitToLast(limit: Int): Query = Query(android.limitToLast(limit), persistenceEnabled) - actual fun equalTo(value: String, key: String?) = Query(android.equalTo(value, key), persistenceEnabled) + public actual fun equalTo(value: String, key: String?): Query = Query(android.equalTo(value, key), persistenceEnabled) - actual fun equalTo(value: Double, key: String?) = Query(android.equalTo(value, key), persistenceEnabled) + public actual fun equalTo(value: Double, key: String?): Query = Query(android.equalTo(value, key), persistenceEnabled) - actual fun equalTo(value: Boolean, key: String?) = Query(android.equalTo(value, key), persistenceEnabled) + public actual fun equalTo(value: Boolean, key: String?): Query = Query(android.equalTo(value, key), persistenceEnabled) - actual val valueEvents: Flow + public actual val valueEvents: Flow get() = callbackFlow { val listener = object : ValueEventListener { override fun onDataChange(snapshot: com.google.firebase.database.DataSnapshot) { trySendBlocking(DataSnapshot(snapshot, persistenceEnabled)) } - override fun onCancelled(error: com.google.firebase.database.DatabaseError) { + override fun onCancelled(error: DatabaseError) { close(error.toException()) } } @@ -161,30 +168,30 @@ actual open class Query internal actual constructor( awaitClose { android.removeEventListener(listener) } } - actual fun childEvents(vararg types: Type): Flow = callbackFlow { + public actual fun childEvents(vararg types: Type): Flow = callbackFlow { val listener = object : ChildEventListener { val moved by lazy { types.contains(Type.MOVED) } override fun onChildMoved(snapshot: com.google.firebase.database.DataSnapshot, previousChildName: String?) { - if(moved) trySend(ChildEvent(DataSnapshot(snapshot, persistenceEnabled), Type.MOVED, previousChildName)) + if (moved) trySend(ChildEvent(DataSnapshot(snapshot, persistenceEnabled), Type.MOVED, previousChildName)) } val changed by lazy { types.contains(Type.CHANGED) } override fun onChildChanged(snapshot: com.google.firebase.database.DataSnapshot, previousChildName: String?) { - if(changed) trySend(ChildEvent(DataSnapshot(snapshot, persistenceEnabled), Type.CHANGED, previousChildName)) + if (changed) trySend(ChildEvent(DataSnapshot(snapshot, persistenceEnabled), Type.CHANGED, previousChildName)) } val added by lazy { types.contains(Type.ADDED) } override fun onChildAdded(snapshot: com.google.firebase.database.DataSnapshot, previousChildName: String?) { - if(added) trySend(ChildEvent(DataSnapshot(snapshot, persistenceEnabled), Type.ADDED, previousChildName)) + if (added) trySend(ChildEvent(DataSnapshot(snapshot, persistenceEnabled), Type.ADDED, previousChildName)) } val removed by lazy { types.contains(Type.REMOVED) } override fun onChildRemoved(snapshot: com.google.firebase.database.DataSnapshot) { - if(removed) trySend(ChildEvent(DataSnapshot(snapshot, persistenceEnabled), Type.REMOVED, null)) + if (removed) trySend(ChildEvent(DataSnapshot(snapshot, persistenceEnabled), Type.REMOVED, null)) } - override fun onCancelled(error: com.google.firebase.database.DatabaseError) { + override fun onCancelled(error: DatabaseError) { close(error.toException()) } } @@ -192,14 +199,14 @@ actual open class Query internal actual constructor( awaitClose { android.removeEventListener(listener) } } - override fun toString() = android.toString() + override fun toString(): String = android.toString() } @PublishedApi internal actual class NativeDatabaseReference internal constructor( override val android: com.google.firebase.database.DatabaseReference, - persistenceEnabled: Boolean -): NativeQuery(android, persistenceEnabled) { + persistenceEnabled: Boolean, +) : NativeQuery(android, persistenceEnabled) { actual val key get() = android.key val database = FirebaseDatabase(android.database) @@ -209,18 +216,20 @@ internal actual class NativeDatabaseReference internal constructor( actual fun push() = NativeDatabaseReference(android.push(), persistenceEnabled) actual fun onDisconnect() = NativeOnDisconnect(android.onDisconnect(), persistenceEnabled, database) - actual suspend fun setValueEncoded(encodedValue: Any?) = android.setValue(encodedValue) - .run { if(persistenceEnabled) await() else awaitWhileOnline(database) } - .run { Unit } + actual suspend fun setValueEncoded(encodedValue: Any?) { + android.setValue(encodedValue) + .run { if (persistenceEnabled) await() else awaitWhileOnline(database) } + } - actual suspend fun updateEncodedChildren(encodedUpdate: EncodedObject) = + actual suspend fun updateEncodedChildren(encodedUpdate: EncodedObject) { android.updateChildren(encodedUpdate.android) - .run { if(persistenceEnabled) await() else awaitWhileOnline(database) } - .run { Unit } + .run { if (persistenceEnabled) await() else awaitWhileOnline(database) } + } - actual suspend fun removeValue() = android.removeValue() - .run { if(persistenceEnabled) await() else awaitWhileOnline(database) } - .run { Unit } + actual suspend fun removeValue() { + android.removeValue() + .run { if (persistenceEnabled) await() else awaitWhileOnline(database) } + } @OptIn(ExperimentalSerializationApi::class) actual suspend fun runTransaction(strategy: KSerializer, buildSettings: EncodeDecodeSettingsBuilder.() -> Unit, transactionUpdate: (currentData: T) -> T): DataSnapshot { @@ -235,7 +244,7 @@ internal actual class NativeDatabaseReference internal constructor( strategy, valueToReencode, buildSettings, - transactionUpdate + transactionUpdate, ) } return Transaction.success(currentData) @@ -244,7 +253,7 @@ internal actual class NativeDatabaseReference internal constructor( override fun onComplete( error: DatabaseError?, committed: Boolean, - snapshot: com.google.firebase.database.DataSnapshot? + snapshot: com.google.firebase.database.DataSnapshot?, ) { if (error != null) { deferred.completeExceptionally(error.toException()) @@ -252,36 +261,35 @@ internal actual class NativeDatabaseReference internal constructor( deferred.complete(DataSnapshot(snapshot!!, persistenceEnabled)) } } - }) return deferred.await() } } -val DatabaseReference.android get() = nativeReference.android +public val DatabaseReference.android: com.google.firebase.database.DatabaseReference get() = nativeReference.android -actual class DataSnapshot internal constructor( - val android: com.google.firebase.database.DataSnapshot, - private val persistenceEnabled: Boolean +public actual class DataSnapshot internal constructor( + public val android: com.google.firebase.database.DataSnapshot, + private val persistenceEnabled: Boolean, ) { - actual val exists get() = android.exists() + public actual val exists: Boolean get() = android.exists() - actual val key get() = android.key + public actual val key: String? get() = android.key - actual val ref: DatabaseReference get() = DatabaseReference(NativeDatabaseReference(android.ref, persistenceEnabled)) + public actual val ref: DatabaseReference get() = DatabaseReference(NativeDatabaseReference(android.ref, persistenceEnabled)) - actual val value get() = android.value + public actual val value: Any? get() = android.value - actual inline fun value() = + public actual inline fun value(): T = decode(value = android.value) - actual inline fun value(strategy: DeserializationStrategy, buildSettings: DecodeSettings.Builder.() -> Unit) = + public actual inline fun value(strategy: DeserializationStrategy, buildSettings: DecodeSettings.Builder.() -> Unit): T = decode(strategy, android.value, buildSettings) - actual fun child(path: String) = DataSnapshot(android.child(path), persistenceEnabled) - actual val hasChildren get() = android.hasChildren() - actual val children: Iterable get() = android.children.map { DataSnapshot(it, persistenceEnabled) } + public actual fun child(path: String): DataSnapshot = DataSnapshot(android.child(path), persistenceEnabled) + public actual val hasChildren: Boolean get() = android.hasChildren() + public actual val children: Iterable get() = android.children.map { DataSnapshot(it, persistenceEnabled) } } @PublishedApi @@ -291,26 +299,29 @@ internal actual class NativeOnDisconnect internal constructor( val database: FirebaseDatabase, ) { - actual suspend fun removeValue() = android.removeValue() - .run { if(persistenceEnabled) await() else awaitWhileOnline(database) } - .run { Unit } + actual suspend fun removeValue() { + android.removeValue() + .run { if (persistenceEnabled) await() else awaitWhileOnline(database) } + } - actual suspend fun cancel() = android.cancel() - .run { if(persistenceEnabled) await() else awaitWhileOnline(database) } - .run { Unit } + actual suspend fun cancel() { + android.cancel() + .run { if (persistenceEnabled) await() else awaitWhileOnline(database) } + } - actual suspend fun setValue(encodedValue: Any?) = android.setValue(encodedValue) - .run { if(persistenceEnabled) await() else awaitWhileOnline(database) } - .run { Unit } + actual suspend fun setValue(encodedValue: Any?) { + android.setValue(encodedValue) + .run { if (persistenceEnabled) await() else awaitWhileOnline(database) } + } - actual suspend fun updateEncodedChildren(encodedUpdate: EncodedObject) = + actual suspend fun updateEncodedChildren(encodedUpdate: EncodedObject) { android.updateChildren(encodedUpdate.android) - .run { if(persistenceEnabled) await() else awaitWhileOnline(database) } - .run { Unit } + .run { if (persistenceEnabled) await() else awaitWhileOnline(database) } + } } -val OnDisconnect.android get() = native.android -val OnDisconnect.persistenceEnabled get() = native.persistenceEnabled -val OnDisconnect.database get() = native.database +public val OnDisconnect.android: com.google.firebase.database.OnDisconnect get() = native.android +public val OnDisconnect.persistenceEnabled: Boolean get() = native.persistenceEnabled +public val OnDisconnect.database: FirebaseDatabase get() = native.database -actual typealias DatabaseException = com.google.firebase.database.DatabaseException +public actual typealias DatabaseException = com.google.firebase.database.DatabaseException diff --git a/firebase-database/src/androidUnitTest/kotlin/dev/gitlive/firebase/database/database.kt b/firebase-database/src/androidUnitTest/kotlin/dev/gitlive/firebase/database/database.kt index a54a41bbd..dc4878866 100644 --- a/firebase-database/src/androidUnitTest/kotlin/dev/gitlive/firebase/database/database.kt +++ b/firebase-database/src/androidUnitTest/kotlin/dev/gitlive/firebase/database/database.kt @@ -3,6 +3,7 @@ */ @file:JvmName("tests") + package dev.gitlive.firebase.database import org.junit.Ignore diff --git a/firebase-database/src/commonMain/kotlin/dev/gitlive/firebase/database/ServerValue.kt b/firebase-database/src/commonMain/kotlin/dev/gitlive/firebase/database/ServerValue.kt index b9a31cdf4..db1f7f344 100644 --- a/firebase-database/src/commonMain/kotlin/dev/gitlive/firebase/database/ServerValue.kt +++ b/firebase-database/src/commonMain/kotlin/dev/gitlive/firebase/database/ServerValue.kt @@ -9,20 +9,20 @@ import kotlinx.serialization.SerializationException /** Represents a Firebase ServerValue. */ @Serializable(with = ServerValueSerializer::class) -expect class ServerValue internal constructor(nativeValue: Any){ +public expect class ServerValue internal constructor(nativeValue: Any) { internal val nativeValue: Any - companion object { - val TIMESTAMP: ServerValue - fun increment(delta: Double): ServerValue + public companion object { + public val TIMESTAMP: ServerValue + public fun increment(delta: Double): ServerValue } } /** Serializer for [ServerValue]. Must be used with [FirebaseEncoder]/[FirebaseDecoder].*/ -object ServerValueSerializer: KSerializer by SpecialValueSerializer( +public object ServerValueSerializer : KSerializer by SpecialValueSerializer( serialName = "ServerValue", toNativeValue = ServerValue::nativeValue, fromNativeValue = { raw -> raw?.let(::ServerValue) ?: throw SerializationException("Cannot deserialize $raw") - } + }, ) diff --git a/firebase-database/src/commonMain/kotlin/dev/gitlive/firebase/database/database.kt b/firebase-database/src/commonMain/kotlin/dev/gitlive/firebase/database/database.kt index a85a3bd58..356fc1884 100644 --- a/firebase-database/src/commonMain/kotlin/dev/gitlive/firebase/database/database.kt +++ b/firebase-database/src/commonMain/kotlin/dev/gitlive/firebase/database/database.kt @@ -22,36 +22,36 @@ import kotlinx.serialization.KSerializer import kotlinx.serialization.SerializationStrategy /** Returns the [FirebaseDatabase] instance of the default [FirebaseApp]. */ -expect val Firebase.database: FirebaseDatabase +public expect val Firebase.database: FirebaseDatabase /** Returns the [FirebaseDatabase] instance for the specified [url]. */ -expect fun Firebase.database(url: String): FirebaseDatabase +public expect fun Firebase.database(url: String): FirebaseDatabase /** Returns the [FirebaseDatabase] instance of the given [FirebaseApp]. */ -expect fun Firebase.database(app: FirebaseApp): FirebaseDatabase +public expect fun Firebase.database(app: FirebaseApp): FirebaseDatabase /** Returns the [FirebaseDatabase] instance of the given [FirebaseApp] and [url]. */ -expect fun Firebase.database(app: FirebaseApp, url: String): FirebaseDatabase +public expect fun Firebase.database(app: FirebaseApp, url: String): FirebaseDatabase /** * The entry point for accessing a Firebase Database. You can get an instance by calling [Firebase.database]. To access a location in the database and read or write data, use [FirebaseDatabase.reference]. */ -expect class FirebaseDatabase { +public expect class FirebaseDatabase { /** * Gets a DatabaseReference for the provided path. * * @param path Path to a location in your FirebaseDatabase. * @return A DatabaseReference pointing to the specified path. */ - fun reference(path: String): DatabaseReference + public fun reference(path: String): DatabaseReference /** * Gets a DatabaseReference for the database root node. * * @return A DatabaseReference pointing to the root node. */ - fun reference(): DatabaseReference - fun setLoggingEnabled(enabled: Boolean) + public fun reference(): DatabaseReference + public fun setLoggingEnabled(enabled: Boolean) /** * The Firebase Database client will cache synchronized data and keep track of all writes you've @@ -66,7 +66,7 @@ expect class FirebaseDatabase { * * @param enabled Set to true to enable disk persistence, set to false to disable it. */ - fun setPersistenceEnabled(enabled: Boolean) + public fun setPersistenceEnabled(enabled: Boolean) /** * By default Firebase Database will use up to 10MB of disk space to cache data. If the cache @@ -81,7 +81,7 @@ expect class FirebaseDatabase { * * @param cacheSizeInBytes The new size of the cache in bytes. */ - fun setPersistenceCacheSizeBytes(cacheSizeInBytes: Long) + public fun setPersistenceCacheSizeBytes(cacheSizeInBytes: Long) /** * Modifies this FirebaseDatabase instance to communicate with the Realtime Database emulator. @@ -91,30 +91,30 @@ expect class FirebaseDatabase { * @param host the emulator host (for example, 10.0.2.2) * @param port the emulator port (for example, 9000) */ - fun useEmulator(host: String, port: Int) + public fun useEmulator(host: String, port: Int) /** * Shuts down our connection to the Firebase Database backend until [goOnline] is called. */ - fun goOffline() + public fun goOffline() /** * Resumes our connection to the Firebase Database backend after a previous [goOffline]. * call. */ - fun goOnline() + public fun goOnline() } /** * Used to emit events about changes in the child locations of a given [Query] when using the * [childEvents] Flow. */ -data class ChildEvent internal constructor( +public data class ChildEvent internal constructor( val snapshot: DataSnapshot, val type: Type, - val previousChildName: String? + val previousChildName: String?, ) { - enum class Type { + public enum class Type { /** * Emitted when a new child is added to the location. * @@ -153,7 +153,7 @@ data class ChildEvent internal constructor( * * @param snapshot An immutable snapshot of the data at the child that was removed. */ - REMOVED + REMOVED, } } @@ -165,23 +165,23 @@ internal expect open class NativeQuery * * Instances of Query are obtained by calling [startAt], [endAt], or [limit] on a [DatabaseReference]. */ -expect open class Query internal constructor(nativeQuery: NativeQuery) { - val valueEvents: Flow - fun childEvents(vararg types: ChildEvent.Type = arrayOf(ADDED, CHANGED, MOVED, REMOVED)): Flow +public expect open class Query internal constructor(nativeQuery: NativeQuery) { + public val valueEvents: Flow + public fun childEvents(vararg types: ChildEvent.Type = arrayOf(ADDED, CHANGED, MOVED, REMOVED)): Flow /** * Creates a query in which child nodes are ordered by their keys. * * @return A query with the new constraint */ - fun orderByKey(): Query + public fun orderByKey(): Query /** * Creates a query in which nodes are ordered by their value * * @return A query with the new constraint */ - fun orderByValue(): Query + public fun orderByValue(): Query /** * Creates a query in which child nodes are ordered by the values of the specified path. @@ -189,7 +189,7 @@ expect open class Query internal constructor(nativeQuery: NativeQuery) { * @param path The path to the child node to use for sorting * @return A query with the new constraint */ - fun orderByChild(path: String): Query + public fun orderByChild(path: String): Query /** * Creates a query constrained to only return child nodes with a value greater than or equal to @@ -198,7 +198,7 @@ expect open class Query internal constructor(nativeQuery: NativeQuery) { * @param value The value to start at, inclusive * @return A query with the new constraint */ - fun startAt(value: String, key: String? = null): Query + public fun startAt(value: String, key: String? = null): Query /** * Creates a query constrained to only return child nodes with a value greater than or equal to @@ -207,7 +207,7 @@ expect open class Query internal constructor(nativeQuery: NativeQuery) { * @param value The value to start at, inclusive * @return A query with the new constraint */ - fun startAt(value: Double, key: String? = null): Query + public fun startAt(value: Double, key: String? = null): Query /** * Creates a query constrained to only return child nodes with a value greater than or equal to @@ -216,7 +216,7 @@ expect open class Query internal constructor(nativeQuery: NativeQuery) { * @param value The value to start at, inclusive * @return A query with the new constraint */ - fun startAt(value: Boolean, key: String? = null): Query + public fun startAt(value: Boolean, key: String? = null): Query /** * Creates a query constrained to only return child nodes with a value less than or equal to the @@ -225,7 +225,7 @@ expect open class Query internal constructor(nativeQuery: NativeQuery) { * @param value The value to end at, inclusive * @return A query with the new constraint */ - fun endAt(value: String, key: String? = null): Query + public fun endAt(value: String, key: String? = null): Query /** * Creates a query constrained to only return child nodes with a value less than or equal to the @@ -234,7 +234,7 @@ expect open class Query internal constructor(nativeQuery: NativeQuery) { * @param value The value to end at, inclusive * @return A query with the new constraint */ - fun endAt(value: Double, key: String? = null): Query + public fun endAt(value: Double, key: String? = null): Query /** * Creates a query constrained to only return child nodes with a value less than or equal to the @@ -243,7 +243,7 @@ expect open class Query internal constructor(nativeQuery: NativeQuery) { * @param value The value to end at, inclusive * @return A query with the new constraint */ - fun endAt(value: Boolean, key: String? = null): Query + public fun endAt(value: Boolean, key: String? = null): Query /** * Creates a query with limit and anchor it to the start of the window. @@ -251,7 +251,7 @@ expect open class Query internal constructor(nativeQuery: NativeQuery) { * @param limit The maximum number of child nodes to return * @return A query with the new constraint */ - fun limitToFirst(limit: Int): Query + public fun limitToFirst(limit: Int): Query /** * Creates a query with limit and anchor it to the end of the window. @@ -259,7 +259,7 @@ expect open class Query internal constructor(nativeQuery: NativeQuery) { * @param limit The maximum number of child nodes to return * @return A query with the new constraint */ - fun limitToLast(limit: Int): Query + public fun limitToLast(limit: Int): Query /** * Creates a query constrained to only return child nodes with the given value. @@ -267,7 +267,7 @@ expect open class Query internal constructor(nativeQuery: NativeQuery) { * @param value The value to query for * @return A query with the new constraint */ - fun equalTo(value: String, key: String? = null): Query + public fun equalTo(value: String, key: String? = null): Query /** * Creates a query constrained to only return child nodes with the given value. @@ -275,7 +275,7 @@ expect open class Query internal constructor(nativeQuery: NativeQuery) { * @param value The value to query for * @return A query with the new constraint */ - fun equalTo(value: Double, key: String? = null): Query + public fun equalTo(value: Double, key: String? = null): Query /** * Creates a query constrained to only return child nodes with the given value. @@ -283,7 +283,7 @@ expect open class Query internal constructor(nativeQuery: NativeQuery) { * @param value The value to query for * @return A query with the new constraint */ - fun equalTo(value: Boolean, key: String? = null): Query + public fun equalTo(value: Boolean, key: String? = null): Query } @PublishedApi @@ -307,12 +307,12 @@ internal expect class NativeDatabaseReference : NativeQuery { * This class is the starting point for all Database operations. After you've initialized it with * a URL, you can use it to read data, write data, and to create new DatabaseReferences. */ -class DatabaseReference internal constructor(@PublishedApi internal val nativeReference: NativeDatabaseReference) : Query(nativeReference) { +public class DatabaseReference internal constructor(@PublishedApi internal val nativeReference: NativeDatabaseReference) : Query(nativeReference) { /** * @return The last token in the location pointed to by this reference or null if this reference * points to the database root */ - val key: String? = nativeReference.key + public val key: String? = nativeReference.key /** * Create a reference to an auto-generated child location. The child key is generated client-side @@ -322,7 +322,7 @@ class DatabaseReference internal constructor(@PublishedApi internal val nativeRe * * @return A DatabaseReference pointing to the new location */ - fun push(): DatabaseReference = DatabaseReference(nativeReference.push()) + public fun push(): DatabaseReference = DatabaseReference(nativeReference.push()) /** * Get a reference to location relative to this one @@ -330,33 +330,40 @@ class DatabaseReference internal constructor(@PublishedApi internal val nativeRe * @param path The relative path from this reference to the new one that should be created * @return A new DatabaseReference to the given path */ - fun child(path: String): DatabaseReference = DatabaseReference(nativeReference.child(path)) + public fun child(path: String): DatabaseReference = DatabaseReference(nativeReference.child(path)) /** * Provides access to disconnect operations at this location * * @return An object for managing disconnect operations at this location */ - fun onDisconnect(): OnDisconnect = OnDisconnect(nativeReference.onDisconnect()) + public fun onDisconnect(): OnDisconnect = OnDisconnect(nativeReference.onDisconnect()) @Deprecated("Deprecated. Use builder instead", replaceWith = ReplaceWith("setValue(value) { this.encodeDefaults = encodeDefaults }")) - suspend inline fun setValue(value: T?, encodeDefaults: Boolean) = + public suspend inline fun setValue(value: T?, encodeDefaults: Boolean) { setValue(value) { this.encodeDefaults = encodeDefaults } - suspend inline fun setValue(value: T?, buildSettings: EncodeSettings.Builder.() -> Unit = {}) = + } + public suspend inline fun setValue(value: T?, buildSettings: EncodeSettings.Builder.() -> Unit = {}) { nativeReference.setValueEncoded(encode(value, buildSettings)) + } @Deprecated("Deprecated. Use builder instead", replaceWith = ReplaceWith("setValue(strategy, value) { this.encodeDefaults = encodeDefaults }")) - suspend fun setValue(strategy: SerializationStrategy, value: T, encodeDefaults: Boolean) = + public suspend fun setValue(strategy: SerializationStrategy, value: T, encodeDefaults: Boolean) { setValue(strategy, value) { this.encodeDefaults = encodeDefaults } - suspend inline fun setValue(strategy: SerializationStrategy, value: T, buildSettings: EncodeSettings.Builder.() -> Unit = {}) = nativeReference.setValueEncoded(encode(strategy, value, buildSettings)) + } + public suspend inline fun setValue(strategy: SerializationStrategy, value: T, buildSettings: EncodeSettings.Builder.() -> Unit = {}) { + nativeReference.setValueEncoded(encode(strategy, value, buildSettings)) + } @Deprecated("Deprecated. Use builder instead", replaceWith = ReplaceWith("updateChildren(update) { this.encodeDefaults = encodeDefaults }")) - suspend fun updateChildren(update: Map, encodeDefaults: Boolean) = updateChildren(update) { - this.encodeDefaults = encodeDefaults + public suspend fun updateChildren(update: Map, encodeDefaults: Boolean) { + updateChildren(update) { + this.encodeDefaults = encodeDefaults + } } /** @@ -366,22 +373,27 @@ class DatabaseReference internal constructor(@PublishedApi internal val nativeRe * @param update The paths to update and their new values * @return The {@link Task} for this operation. */ - suspend inline fun updateChildren(update: Map, buildSettings: EncodeSettings.Builder.() -> Unit = {}) = nativeReference.updateEncodedChildren( - encodeAsObject(update, buildSettings)) + public suspend inline fun updateChildren(update: Map, buildSettings: EncodeSettings.Builder.() -> Unit = {}) { + nativeReference.updateEncodedChildren( + encodeAsObject(update, buildSettings), + ) + } /** * Set the value at this location to 'null' * * @return The {@link Task} for this operation. */ - suspend fun removeValue() = nativeReference.removeValue() + public suspend fun removeValue() { + nativeReference.removeValue() + } /** * Run a transaction on the data at this location. * * @param handler An object to handle running the transaction */ - suspend fun runTransaction(strategy: KSerializer, buildSettings: EncodeDecodeSettingsBuilder.() -> Unit = {}, transactionUpdate: (currentData: T) -> T): DataSnapshot = nativeReference.runTransaction(strategy, buildSettings, transactionUpdate) + public suspend fun runTransaction(strategy: KSerializer, buildSettings: EncodeDecodeSettingsBuilder.() -> Unit = {}, transactionUpdate: (currentData: T) -> T): DataSnapshot = nativeReference.runTransaction(strategy, buildSettings, transactionUpdate) } /** @@ -392,26 +404,26 @@ class DatabaseReference internal constructor(@PublishedApi internal val nativeRe * can't be modified and will never change. To modify data at a location, use a
* [DatabaseReference] reference (e.g. with [DatabaseReference.setValue]). */ -expect class DataSnapshot { +public expect class DataSnapshot { /** * Returns true if the snapshot contains a non-null value. * * @return True if the snapshot contains a non-null value, otherwise false */ - val exists: Boolean + public val exists: Boolean /** * @return The key name for the source location of this snapshot or null if this snapshot points * to the database root. */ - val key: String? + public val key: String? /** * Used to obtain a reference to the source location for this snapshot. * * @return A DatabaseReference corresponding to the location that this snapshot came from */ - val ref: DatabaseReference + public val ref: DatabaseReference /** * [value] returns the data contained in this snapshot as native types. @@ -419,7 +431,7 @@ expect class DataSnapshot { * @return The data contained in this snapshot as native types or null if there is no data at this * location. */ - val value: Any? + public val value: Any? /** * [value] returns the data contained in this snapshot as native types. @@ -427,7 +439,7 @@ expect class DataSnapshot { * @return The data contained in this snapshot as native types or null if there is no data at this * location. */ - inline fun value(): T + public inline fun value(): T /** * [value] returns the data contained in this snapshot as native types. @@ -435,17 +447,16 @@ expect class DataSnapshot { * @return The data contained in this snapshot as native types or null if there is no data at this * location. */ - inline fun value(strategy: DeserializationStrategy, buildSettings: DecodeSettings.Builder.() -> Unit = {}): T + public inline fun value(strategy: DeserializationStrategy, buildSettings: DecodeSettings.Builder.() -> Unit = {}): T - - fun child(path: String): DataSnapshot + public fun child(path: String): DataSnapshot /** * Indicates whether this snapshot has any children * * @return True if the snapshot has any children, otherwise false */ - val hasChildren: Boolean + public val hasChildren: Boolean /** * Gives access to all of the immediate children of this snapshot. Can be used in native for @@ -459,13 +470,13 @@ expect class DataSnapshot { * * @return The immediate children of this snapshot */ - val children: Iterable + public val children: Iterable } /** * Exception that gets thrown when an operation on Firebase Database fails. */ -expect class DatabaseException(message: String?, cause: Throwable?) : RuntimeException +public expect class DatabaseException(message: String?, cause: Throwable?) : RuntimeException @PublishedApi internal expect class NativeOnDisconnect { @@ -483,18 +494,22 @@ internal expect class NativeOnDisconnect { * Instances of this class are obtained by calling [DatabaseReference.onDisconnect] * on a Firebase Database ref. */ -class OnDisconnect internal constructor(@PublishedApi internal val native: NativeOnDisconnect) { +public class OnDisconnect internal constructor(@PublishedApi internal val native: NativeOnDisconnect) { /** * Remove the value at this location when the client disconnects * * @return The {@link Task} for this operation. */ - suspend fun removeValue() = native.removeValue() + public suspend fun removeValue() { + native.removeValue() + } /** * Cancel any disconnect operations that are queued up at this location */ - suspend fun cancel() = native.cancel() + public suspend fun cancel() { + native.cancel() + } /** * Ensure the data at this location is set to the specified value when the client is disconnected @@ -506,9 +521,9 @@ class OnDisconnect internal constructor(@PublishedApi internal val native: Nativ * @param value The value to be set when a disconnect occurs or null to delete the existing value */ @Deprecated("Deprecated. Use builder instead", replaceWith = ReplaceWith("setValue(value) { this.encodeDefaults = encodeDefaults }")) - suspend inline fun setValue(value: T?, encodeDefaults: Boolean) = + public suspend inline fun setValue(value: T?, encodeDefaults: Boolean) { setValue(value) { this.encodeDefaults = encodeDefaults } - + } /** * Ensure the data at this location is set to the specified value when the client is disconnected @@ -519,9 +534,9 @@ class OnDisconnect internal constructor(@PublishedApi internal val native: Nativ * * @param value The value to be set when a disconnect occurs or null to delete the existing value */ - suspend inline fun setValue(value: T?, buildSettings: EncodeSettings.Builder.() -> Unit = {}) = + public suspend inline fun setValue(value: T?, buildSettings: EncodeSettings.Builder.() -> Unit = {}) { native.setValue(encode(value, buildSettings)) - + } /** * Ensure the data at this location is set to the specified value when the client is disconnected @@ -533,9 +548,9 @@ class OnDisconnect internal constructor(@PublishedApi internal val native: Nativ * @param value The value to be set when a disconnect occurs or null to delete the existing value */ @Deprecated("Deprecated. Use builder instead", replaceWith = ReplaceWith("setValue(strategy, value) { this.encodeDefaults = encodeDefaults }")) - suspend fun setValue(strategy: SerializationStrategy, value: T, encodeDefaults: Boolean) = + public suspend fun setValue(strategy: SerializationStrategy, value: T, encodeDefaults: Boolean) { setValue(strategy, value) { this.encodeDefaults = encodeDefaults } - + } /** * Ensure the data at this location is set to the specified value when the client is disconnected @@ -546,16 +561,20 @@ class OnDisconnect internal constructor(@PublishedApi internal val native: Nativ * * @param value The value to be set when a disconnect occurs or null to delete the existing value */ - suspend inline fun setValue(strategy: SerializationStrategy, value: T, buildSettings: EncodeSettings.Builder.() -> Unit = {}) = setValue(encode(strategy, value, buildSettings)) + public suspend inline fun setValue(strategy: SerializationStrategy, value: T, buildSettings: EncodeSettings.Builder.() -> Unit = {}) { + setValue(encode(strategy, value, buildSettings)) + } /** * Ensure the data has the specified child values updated when the client is disconnected * * @param update The paths to update, along with their desired values */ - suspend inline fun updateChildren(update: Map, buildSettings: EncodeSettings.Builder.() -> Unit = {}) = native.updateEncodedChildren( - encodeAsObject(update, buildSettings) - ) + public suspend inline fun updateChildren(update: Map, buildSettings: EncodeSettings.Builder.() -> Unit = {}) { + native.updateEncodedChildren( + encodeAsObject(update, buildSettings), + ) + } /** * Ensure the data has the specified child values updated when the client is disconnected @@ -563,7 +582,9 @@ class OnDisconnect internal constructor(@PublishedApi internal val native: Nativ * @param update The paths to update, along with their desired values */ @Deprecated("Deprecated. Use builder instead", replaceWith = ReplaceWith("updateChildren(update) { this.encodeDefaults = encodeDefaults }")) - suspend fun updateChildren(update: Map, encodeDefaults: Boolean) = updateChildren(update) { - this.encodeDefaults = encodeDefaults + public suspend fun updateChildren(update: Map, encodeDefaults: Boolean) { + updateChildren(update) { + this.encodeDefaults = encodeDefaults + } } } diff --git a/firebase-database/src/commonTest/kotlin/dev/gitlive/firebase/database/database.kt b/firebase-database/src/commonTest/kotlin/dev/gitlive/firebase/database/database.kt index e8e559827..a3f49fda8 100644 --- a/firebase-database/src/commonTest/kotlin/dev/gitlive/firebase/database/database.kt +++ b/firebase-database/src/commonTest/kotlin/dev/gitlive/firebase/database/database.kt @@ -47,8 +47,8 @@ class FirebaseDatabaseTest { databaseUrl = "https://fir-kotlin-sdk-default-rtdb.firebaseio.com", storageBucket = "fir-kotlin-sdk.appspot.com", projectId = "fir-kotlin-sdk-default-rtdb", - gcmSenderId = "846484016111" - ) + gcmSenderId = "846484016111", + ), ) database = Firebase.database(app).apply { @@ -104,7 +104,7 @@ class FirebaseDatabaseTest { assertEquals(data.likes, userDocBefore.likes) // Run transaction - val transactionSnapshot = userRef.runTransaction(DatabaseTest.serializer()) { it.copy(likes = it.likes + 1) } + val transactionSnapshot = userRef.runTransaction(DatabaseTest.serializer()) { it.copy(likes = it.likes + 1) } val userDocAfter = transactionSnapshot.value(DatabaseTest.serializer()) // Check the database after transaction diff --git a/firebase-database/src/iosMain/kotlin/dev/gitlive/firebase/database/ServerValue.kt b/firebase-database/src/iosMain/kotlin/dev/gitlive/firebase/database/ServerValue.kt index 7d9ad55ee..2ce33a91d 100644 --- a/firebase-database/src/iosMain/kotlin/dev/gitlive/firebase/database/ServerValue.kt +++ b/firebase-database/src/iosMain/kotlin/dev/gitlive/firebase/database/ServerValue.kt @@ -8,13 +8,14 @@ private typealias NativeServerValue = FIRServerValue /** Represents a Firebase ServerValue. */ @Serializable(with = ServerValueSerializer::class) -actual class ServerValue internal actual constructor( - internal actual val nativeValue: Any -){ - actual companion object { - actual val TIMESTAMP: ServerValue get() = ServerValue(NativeServerValue.timestamp()) +public actual class ServerValue internal actual constructor( + internal actual val nativeValue: Any, +) { + public actual companion object { + public actual val TIMESTAMP: ServerValue get() = ServerValue(NativeServerValue.timestamp()) + @Suppress("CAST_NEVER_SUCCEEDS") - actual fun increment(delta: Double): ServerValue = ServerValue(NativeServerValue.increment(delta as NSNumber)) + public actual fun increment(delta: Double): ServerValue = ServerValue(NativeServerValue.increment(delta as NSNumber)) } override fun equals(other: Any?): Boolean = diff --git a/firebase-database/src/iosMain/kotlin/dev/gitlive/firebase/database/database.kt b/firebase-database/src/iosMain/kotlin/dev/gitlive/firebase/database/database.kt index 4377faa12..efd125363 100644 --- a/firebase-database/src/iosMain/kotlin/dev/gitlive/firebase/database/database.kt +++ b/firebase-database/src/iosMain/kotlin/dev/gitlive/firebase/database/database.kt @@ -4,6 +4,7 @@ package dev.gitlive.firebase.database +import cocoapods.FirebaseDatabase.FIRDataEventType import cocoapods.FirebaseDatabase.FIRDataEventType.FIRDataEventTypeChildAdded import cocoapods.FirebaseDatabase.FIRDataEventType.FIRDataEventTypeChildChanged import cocoapods.FirebaseDatabase.FIRDataEventType.FIRDataEventTypeChildMoved @@ -34,57 +35,61 @@ import kotlinx.coroutines.coroutineScope import kotlinx.coroutines.flow.callbackFlow import kotlinx.coroutines.flow.filter import kotlinx.coroutines.flow.produceIn +import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.selects.select import kotlinx.serialization.DeserializationStrategy import kotlinx.serialization.KSerializer import platform.Foundation.NSError import platform.Foundation.allObjects -import platform.darwin.dispatch_queue_t -import kotlin.collections.component1 -import kotlin.collections.component2 -actual val Firebase.database - by lazy { FirebaseDatabase(FIRDatabase.database()) } +public actual val Firebase.database: FirebaseDatabase + by lazy { FirebaseDatabase(FIRDatabase.database()) } -actual fun Firebase.database(url: String) = +public actual fun Firebase.database(url: String): FirebaseDatabase = FirebaseDatabase(FIRDatabase.databaseWithURL(url)) -actual fun Firebase.database(app: FirebaseApp): FirebaseDatabase = FirebaseDatabase( - FIRDatabase.databaseForApp(app.ios as objcnames.classes.FIRApp) +public actual fun Firebase.database(app: FirebaseApp): FirebaseDatabase = FirebaseDatabase( + FIRDatabase.databaseForApp(app.ios as objcnames.classes.FIRApp), ) -actual fun Firebase.database(app: FirebaseApp, url: String): FirebaseDatabase = FirebaseDatabase( - FIRDatabase.databaseForApp(app.ios as objcnames.classes.FIRApp, url) +public actual fun Firebase.database(app: FirebaseApp, url: String): FirebaseDatabase = FirebaseDatabase( + FIRDatabase.databaseForApp(app.ios as objcnames.classes.FIRApp, url), ) -actual class FirebaseDatabase internal constructor(val ios: FIRDatabase) { +public actual class FirebaseDatabase internal constructor(public val ios: FIRDatabase) { - actual fun reference(path: String) = + public actual fun reference(path: String): DatabaseReference = DatabaseReference(NativeDatabaseReference(ios.referenceWithPath(path), ios.persistenceEnabled)) - actual fun reference() = + public actual fun reference(): DatabaseReference = DatabaseReference(NativeDatabaseReference(ios.reference(), ios.persistenceEnabled)) - actual fun setPersistenceEnabled(enabled: Boolean) { + public actual fun setPersistenceEnabled(enabled: Boolean) { ios.persistenceEnabled = enabled } - actual fun setPersistenceCacheSizeBytes(cacheSizeInBytes: Long) { + public actual fun setPersistenceCacheSizeBytes(cacheSizeInBytes: Long) { ios.setPersistenceCacheSizeBytes(cacheSizeInBytes.toULong()) } - actual fun setLoggingEnabled(enabled: Boolean) = + public actual fun setLoggingEnabled(enabled: Boolean) { FIRDatabase.setLoggingEnabled(enabled) + } - actual fun useEmulator(host: String, port: Int) = + public actual fun useEmulator(host: String, port: Int) { ios.useEmulatorWithHost(host, port.toLong()) + } - actual fun goOffline() = ios.goOffline() + public actual fun goOffline() { + ios.goOffline() + } - actual fun goOnline() = ios.goOnline() + public actual fun goOnline() { + ios.goOnline() + } } -fun Type.toEventType() = when(this) { +public fun Type.toEventType(): FIRDataEventType = when (this) { ADDED -> FIRDataEventTypeChildAdded CHANGED -> FIRDataEventTypeChildChanged MOVED -> FIRDataEventTypeChildMoved @@ -93,63 +98,63 @@ fun Type.toEventType() = when(this) { internal actual open class NativeQuery( open val ios: FIRDatabaseQuery, - val persistenceEnabled: Boolean + val persistenceEnabled: Boolean, ) -actual open class Query internal actual constructor( - nativeQuery: NativeQuery +public actual open class Query internal actual constructor( + nativeQuery: NativeQuery, ) { internal constructor(ios: FIRDatabaseQuery, persistenceEnabled: Boolean) : this(NativeQuery(ios, persistenceEnabled)) - open val ios: FIRDatabaseQuery = nativeQuery.ios - val persistenceEnabled: Boolean = nativeQuery.persistenceEnabled + public open val ios: FIRDatabaseQuery = nativeQuery.ios + public val persistenceEnabled: Boolean = nativeQuery.persistenceEnabled - actual fun orderByKey() = Query(ios.queryOrderedByKey(), persistenceEnabled) + public actual fun orderByKey(): Query = Query(ios.queryOrderedByKey(), persistenceEnabled) - actual fun orderByValue() = Query(ios.queryOrderedByValue(), persistenceEnabled) + public actual fun orderByValue(): Query = Query(ios.queryOrderedByValue(), persistenceEnabled) - actual fun orderByChild(path: String) = Query(ios.queryOrderedByChild(path), persistenceEnabled) + public actual fun orderByChild(path: String): Query = Query(ios.queryOrderedByChild(path), persistenceEnabled) - actual fun startAt(value: String, key: String?) = Query(ios.queryStartingAtValue(value, key), persistenceEnabled) + public actual fun startAt(value: String, key: String?): Query = Query(ios.queryStartingAtValue(value, key), persistenceEnabled) - actual fun startAt(value: Double, key: String?) = Query(ios.queryStartingAtValue(value, key), persistenceEnabled) + public actual fun startAt(value: Double, key: String?): Query = Query(ios.queryStartingAtValue(value, key), persistenceEnabled) - actual fun startAt(value: Boolean, key: String?) = Query(ios.queryStartingAtValue(value, key), persistenceEnabled) + public actual fun startAt(value: Boolean, key: String?): Query = Query(ios.queryStartingAtValue(value, key), persistenceEnabled) - actual fun endAt(value: String, key: String?) = Query(ios.queryEndingAtValue(value, key), persistenceEnabled) + public actual fun endAt(value: String, key: String?): Query = Query(ios.queryEndingAtValue(value, key), persistenceEnabled) - actual fun endAt(value: Double, key: String?) = Query(ios.queryEndingAtValue(value, key), persistenceEnabled) + public actual fun endAt(value: Double, key: String?): Query = Query(ios.queryEndingAtValue(value, key), persistenceEnabled) - actual fun endAt(value: Boolean, key: String?) = Query(ios.queryEndingAtValue(value, key), persistenceEnabled) + public actual fun endAt(value: Boolean, key: String?): Query = Query(ios.queryEndingAtValue(value, key), persistenceEnabled) - actual fun limitToFirst(limit: Int) = Query(ios.queryLimitedToFirst(limit.toULong()), persistenceEnabled) + public actual fun limitToFirst(limit: Int): Query = Query(ios.queryLimitedToFirst(limit.toULong()), persistenceEnabled) - actual fun limitToLast(limit: Int) = Query(ios.queryLimitedToLast(limit.toULong()), persistenceEnabled) + public actual fun limitToLast(limit: Int): Query = Query(ios.queryLimitedToLast(limit.toULong()), persistenceEnabled) - actual fun equalTo(value: String, key: String?) = Query(ios.queryEqualToValue(value, key), persistenceEnabled) + public actual fun equalTo(value: String, key: String?): Query = Query(ios.queryEqualToValue(value, key), persistenceEnabled) - actual fun equalTo(value: Double, key: String?) = Query(ios.queryEqualToValue(value, key), persistenceEnabled) + public actual fun equalTo(value: Double, key: String?): Query = Query(ios.queryEqualToValue(value, key), persistenceEnabled) - actual fun equalTo(value: Boolean, key: String?) = Query(ios.queryEqualToValue(value, key), persistenceEnabled) + public actual fun equalTo(value: Boolean, key: String?): Query = Query(ios.queryEqualToValue(value, key), persistenceEnabled) - actual val valueEvents get() = callbackFlow { + public actual val valueEvents: Flow get() = callbackFlow { val handle = ios.observeEventType( FIRDataEventTypeValue, withBlock = { snapShot -> trySend(DataSnapshot(snapShot!!, persistenceEnabled)) - } + }, ) { close(DatabaseException(it.toString(), null)) } awaitClose { ios.removeObserverWithHandle(handle) } } - actual fun childEvents(vararg types: Type) = callbackFlow { + public actual fun childEvents(vararg types: Type): Flow = callbackFlow { val handles = types.map { type -> ios.observeEventType( type.toEventType(), andPreviousSiblingKeyWithBlock = { snapShot, key -> trySend(ChildEvent(DataSnapshot(snapShot!!, persistenceEnabled), type, key)) - } + }, ) { close(DatabaseException(it.toString(), null)) } } awaitClose { @@ -157,14 +162,14 @@ actual open class Query internal actual constructor( } } - override fun toString() = ios.toString() + override fun toString(): String = ios.toString() } @PublishedApi internal actual class NativeDatabaseReference internal constructor( override val ios: FIRDatabaseReference, - persistenceEnabled: Boolean -): NativeQuery(ios, persistenceEnabled) { + persistenceEnabled: Boolean, +) : NativeQuery(ios, persistenceEnabled) { actual val key get() = ios.key @@ -199,42 +204,42 @@ internal actual class NativeDatabaseReference internal constructor( deferred.complete(DataSnapshot(snapshot!!, persistenceEnabled)) } }, - withLocalEvents = false + withLocalEvents = false, ) return deferred.await() } } -val DatabaseReference.ios: FIRDatabaseReference get() = nativeReference.ios +public val DatabaseReference.ios: FIRDatabaseReference get() = nativeReference.ios -actual class DataSnapshot internal constructor( - val ios: FIRDataSnapshot, - private val persistenceEnabled: Boolean +public actual class DataSnapshot internal constructor( + public val ios: FIRDataSnapshot, + private val persistenceEnabled: Boolean, ) { - actual val exists get() = ios.exists() + public actual val exists: Boolean get() = ios.exists() - actual val key: String? get() = ios.key + public actual val key: String? get() = ios.key - actual val ref: DatabaseReference get() = DatabaseReference(NativeDatabaseReference(ios.ref, persistenceEnabled)) + public actual val ref: DatabaseReference get() = DatabaseReference(NativeDatabaseReference(ios.ref, persistenceEnabled)) - actual val value get() = ios.value + public actual val value: Any? get() = ios.value - actual inline fun value() = + public actual inline fun value(): T = decode(value = ios.value) - actual inline fun value(strategy: DeserializationStrategy, buildSettings: DecodeSettings.Builder.() -> Unit) = + public actual inline fun value(strategy: DeserializationStrategy, buildSettings: DecodeSettings.Builder.() -> Unit): T = decode(strategy, ios.value, buildSettings) - actual fun child(path: String) = DataSnapshot(ios.childSnapshotForPath(path), persistenceEnabled) - actual val hasChildren get() = ios.hasChildren() - actual val children: Iterable get() = ios.children.allObjects.map { DataSnapshot(it as FIRDataSnapshot, persistenceEnabled) } + public actual fun child(path: String): DataSnapshot = DataSnapshot(ios.childSnapshotForPath(path), persistenceEnabled) + public actual val hasChildren: Boolean get() = ios.hasChildren() + public actual val children: Iterable get() = ios.children.allObjects.map { DataSnapshot(it as FIRDataSnapshot, persistenceEnabled) } } @PublishedApi internal actual class NativeOnDisconnect internal constructor( val ios: FIRDatabaseReference, - val persistenceEnabled: Boolean + val persistenceEnabled: Boolean, ) { actual suspend fun removeValue() { ios.await(persistenceEnabled) { onDisconnectRemoveValueWithCompletionBlock(it) } @@ -253,45 +258,44 @@ internal actual class NativeOnDisconnect internal constructor( } } -val OnDisconnect.ios: FIRDatabaseReference get() = native.ios -val OnDisconnect.persistenceEnabled get() = native.persistenceEnabled +public val OnDisconnect.ios: FIRDatabaseReference get() = native.ios +public val OnDisconnect.persistenceEnabled: Boolean get() = native.persistenceEnabled -actual class DatabaseException actual constructor(message: String?, cause: Throwable?) : RuntimeException(message, cause) +public actual class DatabaseException actual constructor(message: String?, cause: Throwable?) : RuntimeException(message, cause) internal suspend inline fun T.awaitResult(whileOnline: Boolean, function: T.(callback: (NSError?, R?) -> Unit) -> Unit): R { val job = CompletableDeferred() function { error, result -> - if(error == null) { + if (error == null) { job.complete(result) } else { job.completeExceptionally(DatabaseException(error.toString(), null)) } } - return job.run { if(whileOnline) awaitWhileOnline() else await() } as R + return job.run { if (whileOnline) awaitWhileOnline() else await() } as R } internal suspend inline fun T.await(whileOnline: Boolean, function: T.(callback: (NSError?, FIRDatabaseReference?) -> Unit) -> Unit) { val job = CompletableDeferred() function { error, _ -> - if(error == null) { + if (error == null) { job.complete(Unit) } else { job.completeExceptionally(DatabaseException(error.toString(), null)) } } - job.run { if(whileOnline) awaitWhileOnline() else await() } + job.run { if (whileOnline) awaitWhileOnline() else await() } } @FlowPreview internal suspend fun CompletableDeferred.awaitWhileOnline(): T = coroutineScope { - val notConnected = Firebase.database .reference(".info/connected") .valueEvents .filter { !it.value() } .produceIn(this) - select { + select { onAwait { it.also { notConnected.cancel() } } notConnected.onReceive { throw DatabaseException("Database not connected", null) } } diff --git a/firebase-database/src/iosTest/kotlin/dev/gitlive/firebase/database/database.kt b/firebase-database/src/iosTest/kotlin/dev/gitlive/firebase/database/database.kt index 294fe1913..244b31c82 100644 --- a/firebase-database/src/iosTest/kotlin/dev/gitlive/firebase/database/database.kt +++ b/firebase-database/src/iosTest/kotlin/dev/gitlive/firebase/database/database.kt @@ -10,5 +10,6 @@ actual val context: Any = Unit @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) actual annotation class IgnoreForAndroidUnitTest + @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) actual annotation class IgnoreForAndroidTest diff --git a/firebase-database/src/jsMain/kotlin/dev/gitlive/firebase/database/ServerValue.kt b/firebase-database/src/jsMain/kotlin/dev/gitlive/firebase/database/ServerValue.kt index cfb14b69b..d2af58f7a 100644 --- a/firebase-database/src/jsMain/kotlin/dev/gitlive/firebase/database/ServerValue.kt +++ b/firebase-database/src/jsMain/kotlin/dev/gitlive/firebase/database/ServerValue.kt @@ -6,12 +6,12 @@ import dev.gitlive.firebase.database.externals.increment as jsIncrement /** Represents a Firebase ServerValue. */ @Serializable(with = ServerValueSerializer::class) -actual class ServerValue internal actual constructor( - internal actual val nativeValue: Any -){ - actual companion object { - actual val TIMESTAMP: ServerValue get() = ServerValue(serverTimestamp()) - actual fun increment(delta: Double): ServerValue = ServerValue(jsIncrement(delta)) +public actual class ServerValue internal actual constructor( + internal actual val nativeValue: Any, +) { + public actual companion object { + public actual val TIMESTAMP: ServerValue get() = ServerValue(serverTimestamp()) + public actual fun increment(delta: Double): ServerValue = ServerValue(jsIncrement(delta)) } override fun equals(other: Any?): Boolean = diff --git a/firebase-database/src/jsMain/kotlin/dev/gitlive/firebase/database/database.kt b/firebase-database/src/jsMain/kotlin/dev/gitlive/firebase/database/database.kt index 8c02908c9..daa628ec7 100644 --- a/firebase-database/src/jsMain/kotlin/dev/gitlive/firebase/database/database.kt +++ b/firebase-database/src/jsMain/kotlin/dev/gitlive/firebase/database/database.kt @@ -34,6 +34,7 @@ import dev.gitlive.firebase.internal.reencodeTransformation import kotlinx.coroutines.asDeferred import kotlinx.coroutines.channels.awaitClose import kotlinx.coroutines.coroutineScope +import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.callbackFlow import kotlinx.coroutines.flow.filter import kotlinx.coroutines.flow.produceIn @@ -58,63 +59,63 @@ import dev.gitlive.firebase.database.externals.orderByValue as jsOrderByValue import dev.gitlive.firebase.database.externals.runTransaction as jsRunTransaction import dev.gitlive.firebase.database.externals.startAt as jsStartAt -actual val Firebase.database +public actual val Firebase.database: FirebaseDatabase get() = rethrow { FirebaseDatabase(getDatabase()) } -actual fun Firebase.database(app: FirebaseApp) = +public actual fun Firebase.database(app: FirebaseApp): FirebaseDatabase = rethrow { FirebaseDatabase(getDatabase(app = app.js)) } -actual fun Firebase.database(url: String) = +public actual fun Firebase.database(url: String): FirebaseDatabase = rethrow { FirebaseDatabase(getDatabase(url = url)) } -actual fun Firebase.database(app: FirebaseApp, url: String) = +public actual fun Firebase.database(app: FirebaseApp, url: String): FirebaseDatabase = rethrow { FirebaseDatabase(getDatabase(app = app.js, url = url)) } -actual class FirebaseDatabase internal constructor(val js: Database) { +public actual class FirebaseDatabase internal constructor(public val js: Database) { - actual fun reference(path: String) = rethrow { DatabaseReference(NativeDatabaseReference(ref(js, path), js)) } - actual fun reference() = rethrow { DatabaseReference(NativeDatabaseReference(ref(js), js)) } - actual fun setPersistenceEnabled(enabled: Boolean) {} - actual fun setPersistenceCacheSizeBytes(cacheSizeInBytes: Long) {} - actual fun setLoggingEnabled(enabled: Boolean) = rethrow { enableLogging(enabled) } - actual fun useEmulator(host: String, port: Int) = rethrow { connectDatabaseEmulator(js, host, port) } + public actual fun reference(path: String): DatabaseReference = rethrow { DatabaseReference(NativeDatabaseReference(ref(js, path), js)) } + public actual fun reference(): DatabaseReference = rethrow { DatabaseReference(NativeDatabaseReference(ref(js), js)) } + public actual fun setPersistenceEnabled(enabled: Boolean) {} + public actual fun setPersistenceCacheSizeBytes(cacheSizeInBytes: Long) {} + public actual fun setLoggingEnabled(enabled: Boolean): Unit = rethrow { enableLogging(enabled) } + public actual fun useEmulator(host: String, port: Int): Unit = rethrow { connectDatabaseEmulator(js, host, port) } - actual fun goOffline() = rethrow { jsGoOffline(js) } + public actual fun goOffline(): Unit = rethrow { jsGoOffline(js) } - actual fun goOnline() = rethrow { jsGoOnline(js) } + public actual fun goOnline(): Unit = rethrow { jsGoOnline(js) } } internal actual open class NativeQuery( open val js: JsQuery, - val database: Database + val database: Database, ) -actual open class Query internal actual constructor( - nativeQuery: NativeQuery +public actual open class Query internal actual constructor( + nativeQuery: NativeQuery, ) { internal constructor(js: JsQuery, database: Database) : this(NativeQuery(js, database)) - open val js: JsQuery = nativeQuery.js - val database: Database = nativeQuery.database + public open val js: JsQuery = nativeQuery.js + public val database: Database = nativeQuery.database - actual fun orderByKey() = Query(query(js, jsOrderByKey()), database) - actual fun orderByValue() = Query(query(js, jsOrderByValue()), database) - actual fun orderByChild(path: String) = Query(query(js, jsOrderByChild(path)), database) + public actual fun orderByKey(): Query = Query(query(js, jsOrderByKey()), database) + public actual fun orderByValue(): Query = Query(query(js, jsOrderByValue()), database) + public actual fun orderByChild(path: String): Query = Query(query(js, jsOrderByChild(path)), database) - actual val valueEvents - get() = callbackFlow { + public actual val valueEvents: Flow + get() = callbackFlow { val unsubscribe = rethrow { onValue( query = js, callback = { trySend(DataSnapshot(it, database)) }, - cancelCallback = { close(DatabaseException(it)).run { } } + cancelCallback = { close(DatabaseException(it)).run { } }, ) } awaitClose { rethrow { unsubscribe() } } } - actual fun childEvents(vararg types: ChildEvent.Type) = callbackFlow { + public actual fun childEvents(vararg types: ChildEvent.Type): Flow = callbackFlow { val unsubscribes = rethrow { types.map { type -> val callback: ChangeSnapshotCallback = { snapshot, previousChildName -> @@ -122,8 +123,8 @@ actual open class Query internal actual constructor( ChildEvent( DataSnapshot(snapshot, database), type, - previousChildName - ) + previousChildName, + ), ) } @@ -142,35 +143,35 @@ actual open class Query internal actual constructor( awaitClose { rethrow { unsubscribes.forEach { it.invoke() } } } } - actual fun startAt(value: String, key: String?) = Query(query(js, jsStartAt(value, key ?: undefined)), database) + public actual fun startAt(value: String, key: String?): Query = Query(query(js, jsStartAt(value, key ?: undefined)), database) - actual fun startAt(value: Double, key: String?) = Query(query(js, jsStartAt(value, key ?: undefined)), database) + public actual fun startAt(value: Double, key: String?): Query = Query(query(js, jsStartAt(value, key ?: undefined)), database) - actual fun startAt(value: Boolean, key: String?) = Query(query(js, jsStartAt(value, key ?: undefined)), database) + public actual fun startAt(value: Boolean, key: String?): Query = Query(query(js, jsStartAt(value, key ?: undefined)), database) - actual fun endAt(value: String, key: String?) = Query(query(js, jsEndAt(value, key ?: undefined)), database) + public actual fun endAt(value: String, key: String?): Query = Query(query(js, jsEndAt(value, key ?: undefined)), database) - actual fun endAt(value: Double, key: String?) = Query(query(js, jsEndAt(value, key ?: undefined)), database) + public actual fun endAt(value: Double, key: String?): Query = Query(query(js, jsEndAt(value, key ?: undefined)), database) - actual fun endAt(value: Boolean, key: String?) = Query(query(js, jsEndAt(value, key ?: undefined)), database) + public actual fun endAt(value: Boolean, key: String?): Query = Query(query(js, jsEndAt(value, key ?: undefined)), database) - actual fun limitToFirst(limit: Int) = Query(query(js, jsLimitToFirst(limit)), database) + public actual fun limitToFirst(limit: Int): Query = Query(query(js, jsLimitToFirst(limit)), database) - actual fun limitToLast(limit: Int) = Query(query(js, jsLimitToLast(limit)), database) + public actual fun limitToLast(limit: Int): Query = Query(query(js, jsLimitToLast(limit)), database) - actual fun equalTo(value: String, key: String?) = Query(query(js, jsEqualTo(value, key ?: undefined)), database) + public actual fun equalTo(value: String, key: String?): Query = Query(query(js, jsEqualTo(value, key ?: undefined)), database) - actual fun equalTo(value: Double, key: String?) = Query(query(js, jsEqualTo(value, key ?: undefined)), database) + public actual fun equalTo(value: Double, key: String?): Query = Query(query(js, jsEqualTo(value, key ?: undefined)), database) - actual fun equalTo(value: Boolean, key: String?) = Query(query(js, jsEqualTo(value, key ?: undefined)), database) + public actual fun equalTo(value: Boolean, key: String?): Query = Query(query(js, jsEqualTo(value, key ?: undefined)), database) - override fun toString() = js.toString() + override fun toString(): String = js.toString() } @PublishedApi internal actual class NativeDatabaseReference internal constructor( override val js: JsDatabaseReference, - database: Database + database: Database, ) : NativeQuery(js, database) { actual val key get() = rethrow { js.key } @@ -188,65 +189,66 @@ internal actual class NativeDatabaseReference internal constructor( actual suspend fun updateEncodedChildren(encodedUpdate: EncodedObject) = rethrow { update(js, encodedUpdate.js).awaitWhileOnline(database) } - - actual suspend fun runTransaction(strategy: KSerializer, buildSettings: EncodeDecodeSettingsBuilder.() -> Unit, transactionUpdate: (currentData: T) -> T): DataSnapshot { - return DataSnapshot(jsRunTransaction(js, transactionUpdate = { currentData -> + actual suspend fun runTransaction(strategy: KSerializer, buildSettings: EncodeDecodeSettingsBuilder.() -> Unit, transactionUpdate: (currentData: T) -> T): DataSnapshot = DataSnapshot( + jsRunTransaction(js, transactionUpdate = { currentData -> reencodeTransformation(strategy, currentData ?: json(), buildSettings, transactionUpdate) - }).awaitWhileOnline(database).snapshot, database) - } + }).awaitWhileOnline(database).snapshot, + database, + ) } -actual class DataSnapshot internal constructor( - val js: JsDataSnapshot, - val database: Database +public actual class DataSnapshot internal constructor( + public val js: JsDataSnapshot, + public val database: Database, ) { - actual val value get(): Any? { + public actual val value: Any? get() { check(!hasChildren) { "DataSnapshot.value can only be used for primitive values (snapshots without children)" } return js.`val`() } - actual inline fun value() = + public actual inline fun value(): T = rethrow { decode(value = js.`val`()) } - actual inline fun value(strategy: DeserializationStrategy, buildSettings: DecodeSettings.Builder.() -> Unit) = + public actual inline fun value(strategy: DeserializationStrategy, buildSettings: DecodeSettings.Builder.() -> Unit): T = rethrow { decode(strategy, js.`val`(), buildSettings) } - actual val exists get() = rethrow { js.exists() } - actual val key get() = rethrow { js.key } - actual fun child(path: String) = DataSnapshot(js.child(path), database) - actual val hasChildren get() = js.hasChildren() - actual val children: Iterable = rethrow { + public actual val exists: Boolean get() = rethrow { js.exists() } + public actual val key: String? get() = rethrow { js.key } + public actual fun child(path: String): DataSnapshot = DataSnapshot(js.child(path), database) + public actual val hasChildren: Boolean get() = js.hasChildren() + public actual val children: Iterable = rethrow { ArrayList(js.size).also { - js.forEach { snapshot -> it.add(DataSnapshot(snapshot, database)); false /* don't cancel enumeration */ } + js.forEach { snapshot -> + it.add(DataSnapshot(snapshot, database)) + false // don't cancel enumeration + } } } - actual val ref: DatabaseReference + public actual val ref: DatabaseReference get() = DatabaseReference(NativeDatabaseReference(js.ref, database)) - } @PublishedApi internal actual class NativeOnDisconnect internal constructor( val js: JsOnDisconnect, - val database: Database + val database: Database, ) { actual suspend fun removeValue() = rethrow { js.remove().awaitWhileOnline(database) } - actual suspend fun cancel() = rethrow { js.cancel().awaitWhileOnline(database) } + actual suspend fun cancel() = rethrow { js.cancel().awaitWhileOnline(database) } actual suspend fun setValue(encodedValue: Any?) = rethrow { js.set(encodedValue).awaitWhileOnline(database) } actual suspend fun updateEncodedChildren(encodedUpdate: EncodedObject) = rethrow { js.update(encodedUpdate.js).awaitWhileOnline(database) } - } -val OnDisconnect.js get() = native.js -val OnDisconnect.database get() = native.database +public val OnDisconnect.js: dev.gitlive.firebase.database.externals.OnDisconnect get() = native.js +public val OnDisconnect.database: Database get() = native.database -actual class DatabaseException actual constructor(message: String?, cause: Throwable?) : RuntimeException(message, cause) { - constructor(error: dynamic) : this("${error.code ?: "UNKNOWN"}: ${error.message}", error.unsafeCast()) +public actual class DatabaseException actual constructor(message: String?, cause: Throwable?) : RuntimeException(message, cause) { + public constructor(error: dynamic) : this("${error.code ?: "UNKNOWN"}: ${error.message}", error.unsafeCast()) } @PublishedApi @@ -265,16 +267,14 @@ internal inline fun rethrow(function: () -> R): R { @PublishedApi internal suspend fun Promise.awaitWhileOnline(database: Database): T = coroutineScope { - val notConnected = FirebaseDatabase(database) .reference(".info/connected") .valueEvents .filter { !it.value() } .produceIn(this) - select { + select { this@awaitWhileOnline.asDeferred().onAwait { it.also { notConnected.cancel() } } notConnected.onReceive { throw DatabaseException("Database not connected", null) } } - } diff --git a/firebase-database/src/jsMain/kotlin/dev/gitlive/firebase/database/externals/callbacks.kt b/firebase-database/src/jsMain/kotlin/dev/gitlive/firebase/database/externals/callbacks.kt index 86a592432..9d706b15a 100644 --- a/firebase-database/src/jsMain/kotlin/dev/gitlive/firebase/database/externals/callbacks.kt +++ b/firebase-database/src/jsMain/kotlin/dev/gitlive/firebase/database/externals/callbacks.kt @@ -4,6 +4,6 @@ package dev.gitlive.firebase.database.externals -typealias ChangeSnapshotCallback = (data: DataSnapshot, previousChildName: String?) -> Unit -typealias ValueSnapshotCallback = (data: DataSnapshot) -> Unit -typealias CancelCallback = (error: Throwable) -> Unit +public typealias ChangeSnapshotCallback = (data: DataSnapshot, previousChildName: String?) -> Unit +public typealias ValueSnapshotCallback = (data: DataSnapshot) -> Unit +public typealias CancelCallback = (error: Throwable) -> Unit diff --git a/firebase-database/src/jsMain/kotlin/dev/gitlive/firebase/database/externals/database.kt b/firebase-database/src/jsMain/kotlin/dev/gitlive/firebase/database/externals/database.kt index b9390b21b..f8955f400 100644 --- a/firebase-database/src/jsMain/kotlin/dev/gitlive/firebase/database/externals/database.kt +++ b/firebase-database/src/jsMain/kotlin/dev/gitlive/firebase/database/externals/database.kt @@ -7,141 +7,141 @@ import dev.gitlive.firebase.Unsubscribe import dev.gitlive.firebase.externals.FirebaseApp import kotlin.js.Promise -external fun child(parent: DatabaseReference, path: String): DatabaseReference +public external fun child(parent: DatabaseReference, path: String): DatabaseReference -external fun connectDatabaseEmulator( +public external fun connectDatabaseEmulator( db: Database, host: String, port: Int, - options: Any? = definedExternally + options: Any? = definedExternally, ) -external fun enableLogging(enabled: Boolean?, persistent: Boolean? = definedExternally) +public external fun enableLogging(enabled: Boolean?, persistent: Boolean? = definedExternally) -external fun endAt(value: Any?, key: String? = definedExternally): QueryConstraint +public external fun endAt(value: Any?, key: String? = definedExternally): QueryConstraint -external fun endBefore(value: Any?, key: String? = definedExternally): QueryConstraint +public external fun endBefore(value: Any?, key: String? = definedExternally): QueryConstraint -external fun equalTo(value: Any?, key: String? = definedExternally): QueryConstraint +public external fun equalTo(value: Any?, key: String? = definedExternally): QueryConstraint -external fun get(query: Query): Promise +public external fun get(query: Query): Promise -external fun getDatabase( +public external fun getDatabase( app: FirebaseApp? = definedExternally, - url: String? = definedExternally + url: String? = definedExternally, ): Database -external fun increment(delta: Double): Any +public external fun increment(delta: Double): Any -external fun limitToFirst(limit: Int): QueryConstraint +public external fun limitToFirst(limit: Int): QueryConstraint -external fun limitToLast(limit: Int): QueryConstraint +public external fun limitToLast(limit: Int): QueryConstraint -external fun off(query: Query, eventType: String?, callback: Any?) +public external fun off(query: Query, eventType: String?, callback: Any?) -external fun goOffline(db: Database) +public external fun goOffline(db: Database) -external fun goOnline(db: Database) +public external fun goOnline(db: Database) -external fun onChildAdded( +public external fun onChildAdded( query: Query, callback: ChangeSnapshotCallback, cancelCallback: CancelCallback? = definedExternally, ): Unsubscribe -external fun onChildChanged( +public external fun onChildChanged( query: Query, callback: ChangeSnapshotCallback, cancelCallback: CancelCallback? = definedExternally, ): Unsubscribe -external fun onChildMoved( +public external fun onChildMoved( query: Query, callback: ChangeSnapshotCallback, cancelCallback: CancelCallback? = definedExternally, ): Unsubscribe -external fun onChildRemoved( +public external fun onChildRemoved( query: Query, callback: ChangeSnapshotCallback, cancelCallback: CancelCallback? = definedExternally, ): Unsubscribe -external fun onValue( +public external fun onValue( query: Query, callback: ValueSnapshotCallback, cancelCallback: CancelCallback? = definedExternally, ): Unsubscribe -external fun onDisconnect(ref: DatabaseReference): OnDisconnect +public external fun onDisconnect(ref: DatabaseReference): OnDisconnect -external fun orderByChild(path: String): QueryConstraint +public external fun orderByChild(path: String): QueryConstraint -external fun orderByKey(): QueryConstraint +public external fun orderByKey(): QueryConstraint -external fun orderByValue(): QueryConstraint +public external fun orderByValue(): QueryConstraint -external fun push(parent: DatabaseReference, value: Any? = definedExternally): ThenableReference +public external fun push(parent: DatabaseReference, value: Any? = definedExternally): ThenableReference -external fun query(query: Query, vararg queryConstraints: QueryConstraint): Query +public external fun query(query: Query, vararg queryConstraints: QueryConstraint): Query -external fun ref(db: Database, path: String? = definedExternally): DatabaseReference +public external fun ref(db: Database, path: String? = definedExternally): DatabaseReference -external fun remove(ref: DatabaseReference): Promise +public external fun remove(ref: DatabaseReference): Promise -external fun serverTimestamp(): Any +public external fun serverTimestamp(): Any -external fun set(ref: DatabaseReference, value: Any?): Promise +public external fun set(ref: DatabaseReference, value: Any?): Promise -external fun startAfter(value: Any?, key: String? = definedExternally): QueryConstraint +public external fun startAfter(value: Any?, key: String? = definedExternally): QueryConstraint -external fun startAt(value: Any?, key: String? = definedExternally): QueryConstraint +public external fun startAt(value: Any?, key: String? = definedExternally): QueryConstraint -external fun update(ref: DatabaseReference, values: Any): Promise +public external fun update(ref: DatabaseReference, values: Any): Promise -external fun runTransaction( +public external fun runTransaction( ref: DatabaseReference, transactionUpdate: (currentData: T) -> T, - options: Any? = definedExternally + options: Any? = definedExternally, ): Promise -external interface Database { - val app: FirebaseApp +public external interface Database { + public val app: FirebaseApp } -external interface Query { - val ref: DatabaseReference +public external interface Query { + public val ref: DatabaseReference } -external interface QueryConstraint +public external interface QueryConstraint -external interface DatabaseReference : Query { - val key: String? - val parent: DatabaseReference? - val root: DatabaseReference +public external interface DatabaseReference : Query { + public val key: String? + public val parent: DatabaseReference? + public val root: DatabaseReference } -external interface ThenableReference : DatabaseReference - -external interface DataSnapshot { - val key: String? - val size: Int - val ref: DatabaseReference - fun `val`(): Any - fun exists(): Boolean - fun forEach(action: (a: DataSnapshot) -> Boolean): Boolean - fun child(path: String): DataSnapshot - fun hasChildren(): Boolean; +public external interface ThenableReference : DatabaseReference + +public external interface DataSnapshot { + public val key: String? + public val size: Int + public val ref: DatabaseReference + public fun `val`(): Any + public fun exists(): Boolean + public fun forEach(action: (a: DataSnapshot) -> Boolean): Boolean + public fun child(path: String): DataSnapshot + public fun hasChildren(): Boolean } -external interface OnDisconnect { - fun cancel(): Promise - fun remove(): Promise - fun set(value: Any?): Promise - fun update(value: Any): Promise +public external interface OnDisconnect { + public fun cancel(): Promise + public fun remove(): Promise + public fun set(value: Any?): Promise + public fun update(value: Any): Promise } -external interface TransactionResult { - val committed: Boolean - val snapshot: DataSnapshot +public external interface TransactionResult { + public val committed: Boolean + public val snapshot: DataSnapshot } diff --git a/firebase-database/src/jsTest/kotlin/dev/gitlive/firebase/database/database.kt b/firebase-database/src/jsTest/kotlin/dev/gitlive/firebase/database/database.kt index f1821d3c3..e16889d97 100644 --- a/firebase-database/src/jsTest/kotlin/dev/gitlive/firebase/database/database.kt +++ b/firebase-database/src/jsTest/kotlin/dev/gitlive/firebase/database/database.kt @@ -6,5 +6,6 @@ actual val context: Any = Unit @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) actual annotation class IgnoreForAndroidUnitTest + @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) actual annotation class IgnoreForAndroidTest diff --git a/firebase-database/src/jvmTest/kotlin/dev/gitlive/firebase/database/database.kt b/firebase-database/src/jvmTest/kotlin/dev/gitlive/firebase/database/database.kt index 467e76ad4..2ba970b4e 100644 --- a/firebase-database/src/jvmTest/kotlin/dev/gitlive/firebase/database/database.kt +++ b/firebase-database/src/jvmTest/kotlin/dev/gitlive/firebase/database/database.kt @@ -3,6 +3,7 @@ */ @file:JvmName("tests") + package dev.gitlive.firebase.database import dev.gitlive.firebase.testContext @@ -13,5 +14,6 @@ actual val context: Any = testContext @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) actual annotation class IgnoreForAndroidUnitTest + @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) actual annotation class IgnoreForAndroidTest diff --git a/firebase-firestore/api/android/firebase-firestore.api b/firebase-firestore/api/android/firebase-firestore.api new file mode 100644 index 000000000..a17f631c3 --- /dev/null +++ b/firebase-firestore/api/android/firebase-firestore.api @@ -0,0 +1,915 @@ +public abstract class dev/gitlive/firebase/firestore/BaseTimestamp { + public static final field Companion Ldev/gitlive/firebase/firestore/BaseTimestamp$Companion; +} + +public final class dev/gitlive/firebase/firestore/BaseTimestamp$Companion { + public final fun serializer ()Lkotlinx/serialization/KSerializer; +} + +public final class dev/gitlive/firebase/firestore/BaseTimestampSerializer : kotlinx/serialization/KSerializer { + public static final field INSTANCE Ldev/gitlive/firebase/firestore/BaseTimestampSerializer; + public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ldev/gitlive/firebase/firestore/BaseTimestamp; + public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; + public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; + public fun serialize (Lkotlinx/serialization/encoding/Encoder;Ldev/gitlive/firebase/firestore/BaseTimestamp;)V + public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V +} + +public final class dev/gitlive/firebase/firestore/CollectionReference : dev/gitlive/firebase/firestore/Query { + public fun (Lcom/google/firebase/firestore/CollectionReference;)V + public final fun add (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun add (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static synthetic fun add$default (Ldev/gitlive/firebase/firestore/CollectionReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; + public final fun addEncoded (Ldev/gitlive/firebase/internal/EncodedObject;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun copy (Ldev/gitlive/firebase/firestore/internal/NativeCollectionReferenceWrapper;)Ldev/gitlive/firebase/firestore/CollectionReference; + public static synthetic fun copy$default (Ldev/gitlive/firebase/firestore/CollectionReference;Ldev/gitlive/firebase/firestore/internal/NativeCollectionReferenceWrapper;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/CollectionReference; + public final fun document (Ljava/lang/String;)Ldev/gitlive/firebase/firestore/DocumentReference; + public fun equals (Ljava/lang/Object;)Z + public final fun getDocument ()Ldev/gitlive/firebase/firestore/DocumentReference; + public fun getNative ()Lcom/google/firebase/firestore/CollectionReference; + public synthetic fun getNative ()Lcom/google/firebase/firestore/Query; + public final fun getNativeWrapper ()Ldev/gitlive/firebase/firestore/internal/NativeCollectionReferenceWrapper; + public final fun getParent ()Ldev/gitlive/firebase/firestore/DocumentReference; + public final fun getPath ()Ljava/lang/String; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/firestore/DocumentChange { + public fun (Lcom/google/firebase/firestore/DocumentChange;)V + public final fun getAndroid ()Lcom/google/firebase/firestore/DocumentChange; + public final fun getDocument ()Ldev/gitlive/firebase/firestore/DocumentSnapshot; + public final fun getNewIndex ()I + public final fun getOldIndex ()I + public final fun getType ()Lcom/google/firebase/firestore/DocumentChange$Type; +} + +public final class dev/gitlive/firebase/firestore/DocumentReference { + public static final field Companion Ldev/gitlive/firebase/firestore/DocumentReference$Companion; + public final fun collection (Ljava/lang/String;)Ldev/gitlive/firebase/firestore/CollectionReference; + public final fun copy (Ldev/gitlive/firebase/firestore/internal/NativeDocumentReference;)Ldev/gitlive/firebase/firestore/DocumentReference; + public static synthetic fun copy$default (Ldev/gitlive/firebase/firestore/DocumentReference;Ldev/gitlive/firebase/firestore/internal/NativeDocumentReference;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/DocumentReference; + public final fun delete (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public fun equals (Ljava/lang/Object;)Z + public final fun get (Ldev/gitlive/firebase/firestore/Source;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static synthetic fun get$default (Ldev/gitlive/firebase/firestore/DocumentReference;Ldev/gitlive/firebase/firestore/Source;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; + public final fun getId ()Ljava/lang/String; + public final fun getNative ()Ldev/gitlive/firebase/firestore/internal/NativeDocumentReference; + public final fun getParent ()Ldev/gitlive/firebase/firestore/CollectionReference; + public final fun getPath ()Ljava/lang/String; + public final fun getSnapshots ()Lkotlinx/coroutines/flow/Flow; + public fun hashCode ()I + public final fun set (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;ZLkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun set (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;ZZLkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun set (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Z[Ldev/gitlive/firebase/firestore/FieldPath;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun set (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Z[Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun set (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;[Ldev/gitlive/firebase/firestore/FieldPath;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun set (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;[Ljava/lang/String;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static synthetic fun set$default (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;ZLkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; + public static synthetic fun set$default (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;ZZLkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; + public static synthetic fun set$default (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;[Ldev/gitlive/firebase/firestore/FieldPath;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; + public static synthetic fun set$default (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;[Ljava/lang/String;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; + public final fun snapshots (Z)Lkotlinx/coroutines/flow/Flow; + public static synthetic fun snapshots$default (Ldev/gitlive/firebase/firestore/DocumentReference;ZILjava/lang/Object;)Lkotlinx/coroutines/flow/Flow; + public fun toString ()Ljava/lang/String; + public final fun update (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun update (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static synthetic fun update$default (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; + public final fun updateFieldPaths ([Lkotlin/Pair;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static synthetic fun updateFieldPaths$default (Ldev/gitlive/firebase/firestore/DocumentReference;[Lkotlin/Pair;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; + public final fun updateFields ([Lkotlin/Pair;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static synthetic fun updateFields$default (Ldev/gitlive/firebase/firestore/DocumentReference;[Lkotlin/Pair;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; +} + +public final class dev/gitlive/firebase/firestore/DocumentReference$Companion { + public final fun serializer ()Lkotlinx/serialization/KSerializer; +} + +public final class dev/gitlive/firebase/firestore/DocumentReferenceSerializer : kotlinx/serialization/KSerializer { + public static final field INSTANCE Ldev/gitlive/firebase/firestore/DocumentReferenceSerializer; + public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ldev/gitlive/firebase/firestore/DocumentReference; + public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; + public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; + public fun serialize (Lkotlinx/serialization/encoding/Encoder;Ldev/gitlive/firebase/firestore/DocumentReference;)V + public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V +} + +public final class dev/gitlive/firebase/firestore/DocumentSnapshot { + public fun (Lcom/google/firebase/firestore/DocumentSnapshot;)V + public final fun contains (Ldev/gitlive/firebase/firestore/FieldPath;)Z + public final fun contains (Ljava/lang/String;)Z + public final fun copy (Ldev/gitlive/firebase/firestore/internal/NativeDocumentSnapshotWrapper;)Ldev/gitlive/firebase/firestore/DocumentSnapshot; + public static synthetic fun copy$default (Ldev/gitlive/firebase/firestore/DocumentSnapshot;Ldev/gitlive/firebase/firestore/internal/NativeDocumentSnapshotWrapper;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/DocumentSnapshot; + public final fun data (Lkotlinx/serialization/DeserializationStrategy;Ldev/gitlive/firebase/firestore/ServerTimestampBehavior;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; + public static synthetic fun data$default (Ldev/gitlive/firebase/firestore/DocumentSnapshot;Lkotlinx/serialization/DeserializationStrategy;Ldev/gitlive/firebase/firestore/ServerTimestampBehavior;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/lang/Object; + public final fun encodedData (Ldev/gitlive/firebase/firestore/ServerTimestampBehavior;)Ljava/lang/Object; + public static synthetic fun encodedData$default (Ldev/gitlive/firebase/firestore/DocumentSnapshot;Ldev/gitlive/firebase/firestore/ServerTimestampBehavior;ILjava/lang/Object;)Ljava/lang/Object; + public fun equals (Ljava/lang/Object;)Z + public final fun get (Ldev/gitlive/firebase/firestore/FieldPath;Lkotlinx/serialization/DeserializationStrategy;Ldev/gitlive/firebase/firestore/ServerTimestampBehavior;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; + public final fun get (Ljava/lang/String;Lkotlinx/serialization/DeserializationStrategy;Ldev/gitlive/firebase/firestore/ServerTimestampBehavior;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; + public static synthetic fun get$default (Ldev/gitlive/firebase/firestore/DocumentSnapshot;Ldev/gitlive/firebase/firestore/FieldPath;Lkotlinx/serialization/DeserializationStrategy;Ldev/gitlive/firebase/firestore/ServerTimestampBehavior;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/lang/Object; + public static synthetic fun get$default (Ldev/gitlive/firebase/firestore/DocumentSnapshot;Ljava/lang/String;Lkotlinx/serialization/DeserializationStrategy;Ldev/gitlive/firebase/firestore/ServerTimestampBehavior;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/lang/Object; + public final fun getEncoded (Ldev/gitlive/firebase/firestore/FieldPath;Ldev/gitlive/firebase/firestore/ServerTimestampBehavior;)Ljava/lang/Object; + public final fun getEncoded (Ljava/lang/String;Ldev/gitlive/firebase/firestore/ServerTimestampBehavior;)Ljava/lang/Object; + public static synthetic fun getEncoded$default (Ldev/gitlive/firebase/firestore/DocumentSnapshot;Ldev/gitlive/firebase/firestore/FieldPath;Ldev/gitlive/firebase/firestore/ServerTimestampBehavior;ILjava/lang/Object;)Ljava/lang/Object; + public static synthetic fun getEncoded$default (Ldev/gitlive/firebase/firestore/DocumentSnapshot;Ljava/lang/String;Ldev/gitlive/firebase/firestore/ServerTimestampBehavior;ILjava/lang/Object;)Ljava/lang/Object; + public final fun getExists ()Z + public final fun getId ()Ljava/lang/String; + public final fun getMetadata ()Ldev/gitlive/firebase/firestore/SnapshotMetadata; + public final fun getNative ()Lcom/google/firebase/firestore/DocumentSnapshot; + public final fun getNativeWrapper ()Ldev/gitlive/firebase/firestore/internal/NativeDocumentSnapshotWrapper; + public final fun getReference ()Ldev/gitlive/firebase/firestore/DocumentReference; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/firestore/DoubleAsTimestampSerializer : kotlinx/serialization/KSerializer { + public static final field INSTANCE Ldev/gitlive/firebase/firestore/DoubleAsTimestampSerializer; + public static final field SERVER_TIMESTAMP D + public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Double; + public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; + public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; + public fun serialize (Lkotlinx/serialization/encoding/Encoder;D)V + public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V +} + +public final class dev/gitlive/firebase/firestore/FieldPath { + public static final field Companion Ldev/gitlive/firebase/firestore/FieldPath$Companion; + public fun ([Ljava/lang/String;)V + public fun equals (Ljava/lang/Object;)Z + public final fun getAndroid ()Lcom/google/firebase/firestore/FieldPath; + public final fun getDocumentId ()Ldev/gitlive/firebase/firestore/FieldPath; + public final fun getEncoded ()Lcom/google/firebase/firestore/FieldPath; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/firestore/FieldPath$Companion { + public final fun getDocumentId ()Ldev/gitlive/firebase/firestore/FieldPath; +} + +public final class dev/gitlive/firebase/firestore/FieldValue { + public static final field Companion Ldev/gitlive/firebase/firestore/FieldValue$Companion; + public fun equals (Ljava/lang/Object;)Z + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/firestore/FieldValue$Companion { + public final fun arrayRemove ([Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/FieldValue; + public final fun arrayUnion ([Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/FieldValue; + public final fun getDelete ()Ldev/gitlive/firebase/firestore/FieldValue; + public final fun getServerTimestamp ()Ldev/gitlive/firebase/firestore/FieldValue; + public final fun increment (I)Ldev/gitlive/firebase/firestore/FieldValue; + public final fun serializer ()Lkotlinx/serialization/KSerializer; +} + +public final class dev/gitlive/firebase/firestore/FieldValueSerializer : kotlinx/serialization/KSerializer { + public static final field INSTANCE Ldev/gitlive/firebase/firestore/FieldValueSerializer; + public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ldev/gitlive/firebase/firestore/FieldValue; + public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; + public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; + public fun serialize (Lkotlinx/serialization/encoding/Encoder;Ldev/gitlive/firebase/firestore/FieldValue;)V + public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V +} + +public abstract class dev/gitlive/firebase/firestore/Filter { +} + +public final class dev/gitlive/firebase/firestore/Filter$And : dev/gitlive/firebase/firestore/Filter { + public final fun component1 ()Ljava/util/List; + public final fun copy (Ljava/util/List;)Ldev/gitlive/firebase/firestore/Filter$And; + public static synthetic fun copy$default (Ldev/gitlive/firebase/firestore/Filter$And;Ljava/util/List;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/Filter$And; + public fun equals (Ljava/lang/Object;)Z + public final fun getFilters ()Ljava/util/List; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/firestore/Filter$Field : dev/gitlive/firebase/firestore/Filter$WithConstraint { + public final fun component1 ()Ljava/lang/String; + public final fun component2 ()Ldev/gitlive/firebase/firestore/WhereConstraint; + public final fun copy (Ljava/lang/String;Ldev/gitlive/firebase/firestore/WhereConstraint;)Ldev/gitlive/firebase/firestore/Filter$Field; + public static synthetic fun copy$default (Ldev/gitlive/firebase/firestore/Filter$Field;Ljava/lang/String;Ldev/gitlive/firebase/firestore/WhereConstraint;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/Filter$Field; + public fun equals (Ljava/lang/Object;)Z + public fun getConstraint ()Ldev/gitlive/firebase/firestore/WhereConstraint; + public final fun getField ()Ljava/lang/String; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/firestore/Filter$Or : dev/gitlive/firebase/firestore/Filter { + public final fun component1 ()Ljava/util/List; + public final fun copy (Ljava/util/List;)Ldev/gitlive/firebase/firestore/Filter$Or; + public static synthetic fun copy$default (Ldev/gitlive/firebase/firestore/Filter$Or;Ljava/util/List;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/Filter$Or; + public fun equals (Ljava/lang/Object;)Z + public final fun getFilters ()Ljava/util/List; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/firestore/Filter$Path : dev/gitlive/firebase/firestore/Filter$WithConstraint { + public final fun component1 ()Ldev/gitlive/firebase/firestore/FieldPath; + public final fun component2 ()Ldev/gitlive/firebase/firestore/WhereConstraint; + public final fun copy (Ldev/gitlive/firebase/firestore/FieldPath;Ldev/gitlive/firebase/firestore/WhereConstraint;)Ldev/gitlive/firebase/firestore/Filter$Path; + public static synthetic fun copy$default (Ldev/gitlive/firebase/firestore/Filter$Path;Ldev/gitlive/firebase/firestore/FieldPath;Ldev/gitlive/firebase/firestore/WhereConstraint;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/Filter$Path; + public fun equals (Ljava/lang/Object;)Z + public fun getConstraint ()Ldev/gitlive/firebase/firestore/WhereConstraint; + public final fun getPath ()Ldev/gitlive/firebase/firestore/FieldPath; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public abstract class dev/gitlive/firebase/firestore/Filter$WithConstraint : dev/gitlive/firebase/firestore/Filter { + public abstract fun getConstraint ()Ldev/gitlive/firebase/firestore/WhereConstraint; +} + +public final class dev/gitlive/firebase/firestore/FilterBuilder { + public final fun all ([Ldev/gitlive/firebase/firestore/Filter;)Ldev/gitlive/firebase/firestore/Filter; + public final fun and (Ldev/gitlive/firebase/firestore/Filter;Ldev/gitlive/firebase/firestore/Filter;)Ldev/gitlive/firebase/firestore/Filter$And; + public final fun any ([Ldev/gitlive/firebase/firestore/Filter;)Ldev/gitlive/firebase/firestore/Filter; + public final fun contains (Ldev/gitlive/firebase/firestore/FieldPath;Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/Filter$WithConstraint; + public final fun contains (Ljava/lang/String;Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/Filter$WithConstraint; + public final fun containsAny (Ldev/gitlive/firebase/firestore/FieldPath;Ljava/util/List;)Ldev/gitlive/firebase/firestore/Filter$WithConstraint; + public final fun containsAny (Ljava/lang/String;Ljava/util/List;)Ldev/gitlive/firebase/firestore/Filter$WithConstraint; + public final fun equalTo (Ldev/gitlive/firebase/firestore/FieldPath;Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/Filter$WithConstraint; + public final fun equalTo (Ljava/lang/String;Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/Filter$WithConstraint; + public final fun greaterThan (Ldev/gitlive/firebase/firestore/FieldPath;Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/Filter$WithConstraint; + public final fun greaterThan (Ljava/lang/String;Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/Filter$WithConstraint; + public final fun greaterThanOrEqualTo (Ldev/gitlive/firebase/firestore/FieldPath;Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/Filter$WithConstraint; + public final fun greaterThanOrEqualTo (Ljava/lang/String;Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/Filter$WithConstraint; + public final fun inArray (Ldev/gitlive/firebase/firestore/FieldPath;Ljava/util/List;)Ldev/gitlive/firebase/firestore/Filter$WithConstraint; + public final fun inArray (Ljava/lang/String;Ljava/util/List;)Ldev/gitlive/firebase/firestore/Filter$WithConstraint; + public final fun lessThan (Ldev/gitlive/firebase/firestore/FieldPath;Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/Filter$WithConstraint; + public final fun lessThan (Ljava/lang/String;Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/Filter$WithConstraint; + public final fun lessThanOrEqualTo (Ldev/gitlive/firebase/firestore/FieldPath;Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/Filter$WithConstraint; + public final fun lessThanOrEqualTo (Ljava/lang/String;Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/Filter$WithConstraint; + public final fun notEqualTo (Ldev/gitlive/firebase/firestore/FieldPath;Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/Filter$WithConstraint; + public final fun notEqualTo (Ljava/lang/String;Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/Filter$WithConstraint; + public final fun notInArray (Ldev/gitlive/firebase/firestore/FieldPath;Ljava/util/List;)Ldev/gitlive/firebase/firestore/Filter$WithConstraint; + public final fun notInArray (Ljava/lang/String;Ljava/util/List;)Ldev/gitlive/firebase/firestore/Filter$WithConstraint; + public final fun or (Ldev/gitlive/firebase/firestore/Filter;Ldev/gitlive/firebase/firestore/Filter;)Ldev/gitlive/firebase/firestore/Filter$Or; +} + +public final class dev/gitlive/firebase/firestore/FirebaseFirestore { + public fun (Lcom/google/firebase/firestore/FirebaseFirestore;)V + public final fun batch ()Ldev/gitlive/firebase/firestore/WriteBatch; + public final fun clearPersistence (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun collection (Ljava/lang/String;)Ldev/gitlive/firebase/firestore/CollectionReference; + public final fun collectionGroup (Ljava/lang/String;)Ldev/gitlive/firebase/firestore/Query; + public final fun disableNetwork (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun document (Ljava/lang/String;)Ldev/gitlive/firebase/firestore/DocumentReference; + public final fun enableNetwork (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun getNative ()Lcom/google/firebase/firestore/FirebaseFirestore; + public final fun getSettings ()Ldev/gitlive/firebase/firestore/FirebaseFirestoreSettings; + public final fun runTransaction (Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun setLoggingEnabled (Z)V + public final fun setSettings (Ldev/gitlive/firebase/firestore/FirebaseFirestoreSettings;)V + public final fun setSettings (Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/String;Ljava/lang/Long;)V + public static synthetic fun setSettings$default (Ldev/gitlive/firebase/firestore/FirebaseFirestore;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/String;Ljava/lang/Long;ILjava/lang/Object;)V + public final fun useEmulator (Ljava/lang/String;I)V +} + +public final class dev/gitlive/firebase/firestore/FirebaseFirestoreSettings { + public static final field Companion Ldev/gitlive/firebase/firestore/FirebaseFirestoreSettings$Companion; + public fun (ZLjava/lang/String;Ldev/gitlive/firebase/firestore/LocalCacheSettings;Ljava/util/concurrent/Executor;)V + public final fun component1 ()Z + public final fun component2 ()Ljava/lang/String; + public final fun component3 ()Ldev/gitlive/firebase/firestore/LocalCacheSettings; + public final fun component4 ()Ljava/util/concurrent/Executor; + public final fun copy (ZLjava/lang/String;Ldev/gitlive/firebase/firestore/LocalCacheSettings;Ljava/util/concurrent/Executor;)Ldev/gitlive/firebase/firestore/FirebaseFirestoreSettings; + public static synthetic fun copy$default (Ldev/gitlive/firebase/firestore/FirebaseFirestoreSettings;ZLjava/lang/String;Ldev/gitlive/firebase/firestore/LocalCacheSettings;Ljava/util/concurrent/Executor;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/FirebaseFirestoreSettings; + public fun equals (Ljava/lang/Object;)Z + public final fun getCacheSettings ()Ldev/gitlive/firebase/firestore/LocalCacheSettings; + public final fun getCallbackExecutor ()Ljava/util/concurrent/Executor; + public final fun getHost ()Ljava/lang/String; + public final fun getSslEnabled ()Z + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/firestore/FirebaseFirestoreSettings$Builder { + public fun ()V + public fun (Ldev/gitlive/firebase/firestore/FirebaseFirestoreSettings;)V + public final fun build ()Ldev/gitlive/firebase/firestore/FirebaseFirestoreSettings; + public final fun getCacheSettings ()Ldev/gitlive/firebase/firestore/LocalCacheSettings; + public final fun getCallbackExecutor ()Ljava/util/concurrent/Executor; + public final fun getHost ()Ljava/lang/String; + public final fun getSslEnabled ()Z + public final fun setCacheSettings (Ldev/gitlive/firebase/firestore/LocalCacheSettings;)V + public final fun setCallbackExecutor (Ljava/util/concurrent/Executor;)V + public final fun setHost (Ljava/lang/String;)V + public final fun setSslEnabled (Z)V +} + +public final class dev/gitlive/firebase/firestore/FirebaseFirestoreSettings$Companion { + public final fun getCACHE_SIZE_UNLIMITED ()J +} + +public final class dev/gitlive/firebase/firestore/FirestoreKt { + public static final fun where (Ldev/gitlive/firebase/firestore/Query;Ldev/gitlive/firebase/firestore/FieldPath;Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/Query; + public static final fun where (Ldev/gitlive/firebase/firestore/Query;Ldev/gitlive/firebase/firestore/FieldPath;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/Query; + public static final fun where (Ldev/gitlive/firebase/firestore/Query;Ldev/gitlive/firebase/firestore/FieldPath;Ljava/util/List;Ljava/util/List;)Ldev/gitlive/firebase/firestore/Query; + public static final fun where (Ldev/gitlive/firebase/firestore/Query;Ljava/lang/String;Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/Query; + public static final fun where (Ldev/gitlive/firebase/firestore/Query;Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/Query; + public static final fun where (Ldev/gitlive/firebase/firestore/Query;Ljava/lang/String;Ljava/util/List;Ljava/util/List;)Ldev/gitlive/firebase/firestore/Query; + public static synthetic fun where$default (Ldev/gitlive/firebase/firestore/Query;Ldev/gitlive/firebase/firestore/FieldPath;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/Query; + public static synthetic fun where$default (Ldev/gitlive/firebase/firestore/Query;Ldev/gitlive/firebase/firestore/FieldPath;Ljava/util/List;Ljava/util/List;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/Query; + public static synthetic fun where$default (Ldev/gitlive/firebase/firestore/Query;Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/Query; + public static synthetic fun where$default (Ldev/gitlive/firebase/firestore/Query;Ljava/lang/String;Ljava/util/List;Ljava/util/List;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/Query; +} + +public final class dev/gitlive/firebase/firestore/GeoPoint { + public static final field Companion Ldev/gitlive/firebase/firestore/GeoPoint$Companion; + public fun (DD)V + public fun equals (Ljava/lang/Object;)Z + public final fun getLatitude ()D + public final fun getLongitude ()D + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/firestore/GeoPoint$Companion { + public final fun serializer ()Lkotlinx/serialization/KSerializer; +} + +public final class dev/gitlive/firebase/firestore/GeoPointSerializer : kotlinx/serialization/KSerializer { + public static final field INSTANCE Ldev/gitlive/firebase/firestore/GeoPointSerializer; + public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ldev/gitlive/firebase/firestore/GeoPoint; + public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; + public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; + public fun serialize (Lkotlinx/serialization/encoding/Encoder;Ldev/gitlive/firebase/firestore/GeoPoint;)V + public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V +} + +public final class dev/gitlive/firebase/firestore/HelpersKt { + public static final fun encodeFieldAndValue ([Lkotlin/Pair;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;)Ljava/util/List; + public static final fun performUpdateFieldPaths ([Lkotlin/Pair;Lkotlin/jvm/functions/Function1;)Ljava/util/List; + public static final fun performUpdateFields ([Lkotlin/Pair;Lkotlin/jvm/functions/Function1;)Ljava/util/List; +} + +public abstract interface class dev/gitlive/firebase/firestore/LocalCacheSettings { +} + +public final class dev/gitlive/firebase/firestore/LocalCacheSettings$Memory : dev/gitlive/firebase/firestore/LocalCacheSettings { + public static final field Companion Ldev/gitlive/firebase/firestore/LocalCacheSettings$Memory$Companion; + public final fun component1 ()Ldev/gitlive/firebase/firestore/MemoryGarbageCollectorSettings; + public final fun copy (Ldev/gitlive/firebase/firestore/MemoryGarbageCollectorSettings;)Ldev/gitlive/firebase/firestore/LocalCacheSettings$Memory; + public static synthetic fun copy$default (Ldev/gitlive/firebase/firestore/LocalCacheSettings$Memory;Ldev/gitlive/firebase/firestore/MemoryGarbageCollectorSettings;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/LocalCacheSettings$Memory; + public fun equals (Ljava/lang/Object;)Z + public final fun getGarbaseCollectorSettings ()Ldev/gitlive/firebase/firestore/MemoryGarbageCollectorSettings; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/firestore/LocalCacheSettings$Memory$Builder { + public final fun build ()Ldev/gitlive/firebase/firestore/LocalCacheSettings$Memory; + public final fun getGcSettings ()Ldev/gitlive/firebase/firestore/MemoryGarbageCollectorSettings; + public final fun setGcSettings (Ldev/gitlive/firebase/firestore/MemoryGarbageCollectorSettings;)V +} + +public final class dev/gitlive/firebase/firestore/LocalCacheSettings$Memory$Companion { + public final fun newBuilder ()Ldev/gitlive/firebase/firestore/LocalCacheSettings$Memory$Builder; +} + +public final class dev/gitlive/firebase/firestore/LocalCacheSettings$Persistent : dev/gitlive/firebase/firestore/LocalCacheSettings { + public static final field Companion Ldev/gitlive/firebase/firestore/LocalCacheSettings$Persistent$Companion; + public final fun component1 ()J + public final fun copy (J)Ldev/gitlive/firebase/firestore/LocalCacheSettings$Persistent; + public static synthetic fun copy$default (Ldev/gitlive/firebase/firestore/LocalCacheSettings$Persistent;JILjava/lang/Object;)Ldev/gitlive/firebase/firestore/LocalCacheSettings$Persistent; + public fun equals (Ljava/lang/Object;)Z + public final fun getSizeBytes ()J + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/firestore/LocalCacheSettings$Persistent$Builder { + public final fun build ()Ldev/gitlive/firebase/firestore/LocalCacheSettings$Persistent; + public final fun getSizeBytes ()J + public final fun setSizeBytes (J)V +} + +public final class dev/gitlive/firebase/firestore/LocalCacheSettings$Persistent$Companion { + public final fun newBuilder ()Ldev/gitlive/firebase/firestore/LocalCacheSettings$Persistent$Builder; +} + +public final class dev/gitlive/firebase/firestore/LocalCacheSettingsKt { + public static final fun memoryCacheSettings (Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/LocalCacheSettings$Memory; + public static final fun memoryEagerGcSettings (Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/MemoryGarbageCollectorSettings$Eager; + public static final fun memoryLruGcSettings (Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/MemoryGarbageCollectorSettings$LRUGC; + public static final fun persistentCacheSettings (Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/LocalCacheSettings$Persistent; +} + +public abstract interface class dev/gitlive/firebase/firestore/MemoryGarbageCollectorSettings { +} + +public final class dev/gitlive/firebase/firestore/MemoryGarbageCollectorSettings$Eager : dev/gitlive/firebase/firestore/MemoryGarbageCollectorSettings { + public static final field INSTANCE Ldev/gitlive/firebase/firestore/MemoryGarbageCollectorSettings$Eager; + public fun equals (Ljava/lang/Object;)Z + public fun hashCode ()I + public final fun newBuilder ()Ldev/gitlive/firebase/firestore/MemoryGarbageCollectorSettings$Eager$Builder; + public fun toString ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/firestore/MemoryGarbageCollectorSettings$Eager$Builder { + public final fun build ()Ldev/gitlive/firebase/firestore/MemoryGarbageCollectorSettings$Eager; +} + +public final class dev/gitlive/firebase/firestore/MemoryGarbageCollectorSettings$LRUGC : dev/gitlive/firebase/firestore/MemoryGarbageCollectorSettings { + public static final field Companion Ldev/gitlive/firebase/firestore/MemoryGarbageCollectorSettings$LRUGC$Companion; + public final fun component1 ()J + public final fun copy (J)Ldev/gitlive/firebase/firestore/MemoryGarbageCollectorSettings$LRUGC; + public static synthetic fun copy$default (Ldev/gitlive/firebase/firestore/MemoryGarbageCollectorSettings$LRUGC;JILjava/lang/Object;)Ldev/gitlive/firebase/firestore/MemoryGarbageCollectorSettings$LRUGC; + public fun equals (Ljava/lang/Object;)Z + public final fun getSizeBytes ()J + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/firestore/MemoryGarbageCollectorSettings$LRUGC$Builder { + public final fun build ()Ldev/gitlive/firebase/firestore/MemoryGarbageCollectorSettings$LRUGC; + public final fun getSizeBytes ()J + public final fun setSizeBytes (J)V +} + +public final class dev/gitlive/firebase/firestore/MemoryGarbageCollectorSettings$LRUGC$Companion { + public final fun newBuilder ()Ldev/gitlive/firebase/firestore/MemoryGarbageCollectorSettings$LRUGC$Builder; +} + +public class dev/gitlive/firebase/firestore/Query { + public fun (Lcom/google/firebase/firestore/Query;)V + public final fun endAt (Ldev/gitlive/firebase/firestore/DocumentSnapshot;)Ldev/gitlive/firebase/firestore/Query; + public final fun endAt ([Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/Query; + public final fun endBefore (Ldev/gitlive/firebase/firestore/DocumentSnapshot;)Ldev/gitlive/firebase/firestore/Query; + public final fun endBefore ([Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/Query; + public final fun get (Ldev/gitlive/firebase/firestore/Source;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static synthetic fun get$default (Ldev/gitlive/firebase/firestore/Query;Ldev/gitlive/firebase/firestore/Source;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; + public fun getNative ()Lcom/google/firebase/firestore/Query; + public final fun getSnapshots ()Lkotlinx/coroutines/flow/Flow; + public final fun limit (Ljava/lang/Number;)Ldev/gitlive/firebase/firestore/Query; + public final fun orderBy (Ldev/gitlive/firebase/firestore/FieldPath;Lcom/google/firebase/firestore/Query$Direction;)Ldev/gitlive/firebase/firestore/Query; + public final fun orderBy (Ljava/lang/String;Lcom/google/firebase/firestore/Query$Direction;)Ldev/gitlive/firebase/firestore/Query; + public static synthetic fun orderBy$default (Ldev/gitlive/firebase/firestore/Query;Ldev/gitlive/firebase/firestore/FieldPath;Lcom/google/firebase/firestore/Query$Direction;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/Query; + public static synthetic fun orderBy$default (Ldev/gitlive/firebase/firestore/Query;Ljava/lang/String;Lcom/google/firebase/firestore/Query$Direction;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/Query; + public final fun snapshots (Z)Lkotlinx/coroutines/flow/Flow; + public static synthetic fun snapshots$default (Ldev/gitlive/firebase/firestore/Query;ZILjava/lang/Object;)Lkotlinx/coroutines/flow/Flow; + public final fun startAfter (Ldev/gitlive/firebase/firestore/DocumentSnapshot;)Ldev/gitlive/firebase/firestore/Query; + public final fun startAfter ([Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/Query; + public final fun startAt (Ldev/gitlive/firebase/firestore/DocumentSnapshot;)Ldev/gitlive/firebase/firestore/Query; + public final fun startAt ([Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/Query; + public final fun where (Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Query; +} + +public final class dev/gitlive/firebase/firestore/QuerySnapshot { + public fun (Lcom/google/firebase/firestore/QuerySnapshot;)V + public final fun getAndroid ()Lcom/google/firebase/firestore/QuerySnapshot; + public final fun getDocumentChanges ()Ljava/util/List; + public final fun getDocuments ()Ljava/util/List; + public final fun getMetadata ()Ldev/gitlive/firebase/firestore/SnapshotMetadata; +} + +public final class dev/gitlive/firebase/firestore/ServerTimestampBehavior : java/lang/Enum { + public static final field ESTIMATE Ldev/gitlive/firebase/firestore/ServerTimestampBehavior; + public static final field NONE Ldev/gitlive/firebase/firestore/ServerTimestampBehavior; + public static final field PREVIOUS Ldev/gitlive/firebase/firestore/ServerTimestampBehavior; + public static fun getEntries ()Lkotlin/enums/EnumEntries; + public static fun valueOf (Ljava/lang/String;)Ldev/gitlive/firebase/firestore/ServerTimestampBehavior; + public static fun values ()[Ldev/gitlive/firebase/firestore/ServerTimestampBehavior; +} + +public final class dev/gitlive/firebase/firestore/ServerTimestampSerializer : kotlinx/serialization/KSerializer { + public static final field INSTANCE Ldev/gitlive/firebase/firestore/ServerTimestampSerializer; + public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ldev/gitlive/firebase/firestore/Timestamp$ServerTimestamp; + public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; + public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; + public fun serialize (Lkotlinx/serialization/encoding/Encoder;Ldev/gitlive/firebase/firestore/Timestamp$ServerTimestamp;)V + public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V +} + +public final class dev/gitlive/firebase/firestore/SnapshotMetadata { + public fun (Lcom/google/firebase/firestore/SnapshotMetadata;)V + public final fun getAndroid ()Lcom/google/firebase/firestore/SnapshotMetadata; + public final fun getHasPendingWrites ()Z + public final fun isFromCache ()Z +} + +public final class dev/gitlive/firebase/firestore/Source : java/lang/Enum { + public static final field CACHE Ldev/gitlive/firebase/firestore/Source; + public static final field DEFAULT Ldev/gitlive/firebase/firestore/Source; + public static final field SERVER Ldev/gitlive/firebase/firestore/Source; + public static fun getEntries ()Lkotlin/enums/EnumEntries; + public static fun valueOf (Ljava/lang/String;)Ldev/gitlive/firebase/firestore/Source; + public static fun values ()[Ldev/gitlive/firebase/firestore/Source; +} + +public final class dev/gitlive/firebase/firestore/Timestamp : dev/gitlive/firebase/firestore/BaseTimestamp { + public static final field Companion Ldev/gitlive/firebase/firestore/Timestamp$Companion; + public fun (JI)V + public fun equals (Ljava/lang/Object;)Z + public final fun getNanoseconds ()I + public final fun getSeconds ()J + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/firestore/Timestamp$Companion { + public final fun now ()Ldev/gitlive/firebase/firestore/Timestamp; + public final fun serializer ()Lkotlinx/serialization/KSerializer; +} + +public final class dev/gitlive/firebase/firestore/Timestamp$ServerTimestamp : dev/gitlive/firebase/firestore/BaseTimestamp { + public static final field INSTANCE Ldev/gitlive/firebase/firestore/Timestamp$ServerTimestamp; + public fun equals (Ljava/lang/Object;)Z + public fun hashCode ()I + public final fun serializer ()Lkotlinx/serialization/KSerializer; + public fun toString ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/firestore/TimestampKt { + public static final fun fromDuration-HG0u8IE (Ldev/gitlive/firebase/firestore/Timestamp$Companion;J)Ldev/gitlive/firebase/firestore/Timestamp; + public static final fun fromMilliseconds (Ldev/gitlive/firebase/firestore/Timestamp$Companion;D)Ldev/gitlive/firebase/firestore/Timestamp; + public static final fun toDuration (Ldev/gitlive/firebase/firestore/Timestamp;)J + public static final fun toMilliseconds (Ldev/gitlive/firebase/firestore/Timestamp;)D +} + +public final class dev/gitlive/firebase/firestore/TimestampSerializer : kotlinx/serialization/KSerializer { + public static final field INSTANCE Ldev/gitlive/firebase/firestore/TimestampSerializer; + public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ldev/gitlive/firebase/firestore/Timestamp; + public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; + public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; + public fun serialize (Lkotlinx/serialization/encoding/Encoder;Ldev/gitlive/firebase/firestore/Timestamp;)V + public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V +} + +public final class dev/gitlive/firebase/firestore/Transaction { + public fun (Lcom/google/firebase/firestore/Transaction;)V + public final fun copy (Ldev/gitlive/firebase/firestore/internal/NativeTransactionWrapper;)Ldev/gitlive/firebase/firestore/Transaction; + public static synthetic fun copy$default (Ldev/gitlive/firebase/firestore/Transaction;Ldev/gitlive/firebase/firestore/internal/NativeTransactionWrapper;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/Transaction; + public final fun delete (Ldev/gitlive/firebase/firestore/DocumentReference;)Ldev/gitlive/firebase/firestore/Transaction; + public fun equals (Ljava/lang/Object;)Z + public final fun get (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun getNative ()Lcom/google/firebase/firestore/Transaction; + public final fun getNativeWrapper ()Ldev/gitlive/firebase/firestore/internal/NativeTransactionWrapper; + public fun hashCode ()I + public final fun set (Ldev/gitlive/firebase/firestore/DocumentReference;Ljava/lang/Object;ZLkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Transaction; + public final fun set (Ldev/gitlive/firebase/firestore/DocumentReference;Ljava/lang/Object;ZZ)Ldev/gitlive/firebase/firestore/Transaction; + public final fun set (Ldev/gitlive/firebase/firestore/DocumentReference;Ljava/lang/Object;Z[Ldev/gitlive/firebase/firestore/FieldPath;)Ldev/gitlive/firebase/firestore/Transaction; + public final fun set (Ldev/gitlive/firebase/firestore/DocumentReference;Ljava/lang/Object;Z[Ljava/lang/String;)Ldev/gitlive/firebase/firestore/Transaction; + public final fun set (Ldev/gitlive/firebase/firestore/DocumentReference;Ljava/lang/Object;[Ldev/gitlive/firebase/firestore/FieldPath;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Transaction; + public final fun set (Ldev/gitlive/firebase/firestore/DocumentReference;Ljava/lang/Object;[Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Transaction; + public final fun set (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;ZLkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Transaction; + public final fun set (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;ZZ)Ldev/gitlive/firebase/firestore/Transaction; + public final fun set (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Z[Ldev/gitlive/firebase/firestore/FieldPath;)Ldev/gitlive/firebase/firestore/Transaction; + public final fun set (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Z[Ljava/lang/String;)Ldev/gitlive/firebase/firestore/Transaction; + public final fun set (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;[Ldev/gitlive/firebase/firestore/FieldPath;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Transaction; + public final fun set (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;[Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Transaction; + public static synthetic fun set$default (Ldev/gitlive/firebase/firestore/Transaction;Ldev/gitlive/firebase/firestore/DocumentReference;Ljava/lang/Object;ZLkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/Transaction; + public static synthetic fun set$default (Ldev/gitlive/firebase/firestore/Transaction;Ldev/gitlive/firebase/firestore/DocumentReference;Ljava/lang/Object;ZZILjava/lang/Object;)Ldev/gitlive/firebase/firestore/Transaction; + public static synthetic fun set$default (Ldev/gitlive/firebase/firestore/Transaction;Ldev/gitlive/firebase/firestore/DocumentReference;Ljava/lang/Object;[Ldev/gitlive/firebase/firestore/FieldPath;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/Transaction; + public static synthetic fun set$default (Ldev/gitlive/firebase/firestore/Transaction;Ldev/gitlive/firebase/firestore/DocumentReference;Ljava/lang/Object;[Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/Transaction; + public static synthetic fun set$default (Ldev/gitlive/firebase/firestore/Transaction;Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;ZLkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/Transaction; + public static synthetic fun set$default (Ldev/gitlive/firebase/firestore/Transaction;Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;ZZILjava/lang/Object;)Ldev/gitlive/firebase/firestore/Transaction; + public static synthetic fun set$default (Ldev/gitlive/firebase/firestore/Transaction;Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;[Ldev/gitlive/firebase/firestore/FieldPath;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/Transaction; + public static synthetic fun set$default (Ldev/gitlive/firebase/firestore/Transaction;Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;[Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/Transaction; + public final fun setEncoded (Ldev/gitlive/firebase/firestore/DocumentReference;Ldev/gitlive/firebase/internal/EncodedObject;Ldev/gitlive/firebase/firestore/internal/SetOptions;)Ldev/gitlive/firebase/firestore/Transaction; + public fun toString ()Ljava/lang/String; + public final fun update (Ldev/gitlive/firebase/firestore/DocumentReference;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Transaction; + public final fun update (Ldev/gitlive/firebase/firestore/DocumentReference;Ljava/lang/Object;Z)Ldev/gitlive/firebase/firestore/Transaction; + public final fun update (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Transaction; + public final fun update (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Z)Ldev/gitlive/firebase/firestore/Transaction; + public static synthetic fun update$default (Ldev/gitlive/firebase/firestore/Transaction;Ldev/gitlive/firebase/firestore/DocumentReference;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/Transaction; + public static synthetic fun update$default (Ldev/gitlive/firebase/firestore/Transaction;Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/Transaction; + public final fun updateEncoded (Ldev/gitlive/firebase/firestore/DocumentReference;Ldev/gitlive/firebase/internal/EncodedObject;)Ldev/gitlive/firebase/firestore/Transaction; + public final fun updateEncodedFieldPathsAndValues (Ldev/gitlive/firebase/firestore/DocumentReference;Ljava/util/List;)Ldev/gitlive/firebase/firestore/Transaction; + public final fun updateEncodedFieldsAndValues (Ldev/gitlive/firebase/firestore/DocumentReference;Ljava/util/List;)Ldev/gitlive/firebase/firestore/Transaction; + public final fun updateFieldPaths (Ldev/gitlive/firebase/firestore/DocumentReference;[Lkotlin/Pair;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Transaction; + public static synthetic fun updateFieldPaths$default (Ldev/gitlive/firebase/firestore/Transaction;Ldev/gitlive/firebase/firestore/DocumentReference;[Lkotlin/Pair;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/Transaction; + public final fun updateFields (Ldev/gitlive/firebase/firestore/DocumentReference;[Lkotlin/Pair;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Transaction; + public static synthetic fun updateFields$default (Ldev/gitlive/firebase/firestore/Transaction;Ldev/gitlive/firebase/firestore/DocumentReference;[Lkotlin/Pair;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/Transaction; +} + +public abstract interface class dev/gitlive/firebase/firestore/WhereConstraint { +} + +public final class dev/gitlive/firebase/firestore/WhereConstraint$ArrayContains : dev/gitlive/firebase/firestore/WhereConstraint$ForObject { + public final fun component1 ()Ljava/lang/Object; + public final fun copy (Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/WhereConstraint$ArrayContains; + public static synthetic fun copy$default (Ldev/gitlive/firebase/firestore/WhereConstraint$ArrayContains;Ljava/lang/Object;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/WhereConstraint$ArrayContains; + public fun equals (Ljava/lang/Object;)Z + public fun getSafeValue ()Ljava/lang/Object; + public fun getValue ()Ljava/lang/Object; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/firestore/WhereConstraint$ArrayContainsAny : dev/gitlive/firebase/firestore/WhereConstraint$ForArray { + public final fun component1 ()Ljava/util/List; + public final fun copy (Ljava/util/List;)Ldev/gitlive/firebase/firestore/WhereConstraint$ArrayContainsAny; + public static synthetic fun copy$default (Ldev/gitlive/firebase/firestore/WhereConstraint$ArrayContainsAny;Ljava/util/List;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/WhereConstraint$ArrayContainsAny; + public fun equals (Ljava/lang/Object;)Z + public fun getSafeValues ()Ljava/util/List; + public fun getValues ()Ljava/util/List; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/firestore/WhereConstraint$EqualTo : dev/gitlive/firebase/firestore/WhereConstraint$ForNullableObject { + public final fun component1 ()Ljava/lang/Object; + public final fun copy (Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/WhereConstraint$EqualTo; + public static synthetic fun copy$default (Ldev/gitlive/firebase/firestore/WhereConstraint$EqualTo;Ljava/lang/Object;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/WhereConstraint$EqualTo; + public fun equals (Ljava/lang/Object;)Z + public fun getSafeValue ()Ljava/lang/Object; + public fun getValue ()Ljava/lang/Object; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public abstract interface class dev/gitlive/firebase/firestore/WhereConstraint$ForArray : dev/gitlive/firebase/firestore/WhereConstraint { + public abstract fun getSafeValues ()Ljava/util/List; + public abstract fun getValues ()Ljava/util/List; +} + +public final class dev/gitlive/firebase/firestore/WhereConstraint$ForArray$DefaultImpls { + public static fun getSafeValues (Ldev/gitlive/firebase/firestore/WhereConstraint$ForArray;)Ljava/util/List; +} + +public abstract interface class dev/gitlive/firebase/firestore/WhereConstraint$ForNullableObject : dev/gitlive/firebase/firestore/WhereConstraint { + public abstract fun getSafeValue ()Ljava/lang/Object; + public abstract fun getValue ()Ljava/lang/Object; +} + +public final class dev/gitlive/firebase/firestore/WhereConstraint$ForNullableObject$DefaultImpls { + public static fun getSafeValue (Ldev/gitlive/firebase/firestore/WhereConstraint$ForNullableObject;)Ljava/lang/Object; +} + +public abstract interface class dev/gitlive/firebase/firestore/WhereConstraint$ForObject : dev/gitlive/firebase/firestore/WhereConstraint { + public abstract fun getSafeValue ()Ljava/lang/Object; + public abstract fun getValue ()Ljava/lang/Object; +} + +public final class dev/gitlive/firebase/firestore/WhereConstraint$ForObject$DefaultImpls { + public static fun getSafeValue (Ldev/gitlive/firebase/firestore/WhereConstraint$ForObject;)Ljava/lang/Object; +} + +public final class dev/gitlive/firebase/firestore/WhereConstraint$GreaterThan : dev/gitlive/firebase/firestore/WhereConstraint$ForObject { + public final fun component1 ()Ljava/lang/Object; + public final fun copy (Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/WhereConstraint$GreaterThan; + public static synthetic fun copy$default (Ldev/gitlive/firebase/firestore/WhereConstraint$GreaterThan;Ljava/lang/Object;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/WhereConstraint$GreaterThan; + public fun equals (Ljava/lang/Object;)Z + public fun getSafeValue ()Ljava/lang/Object; + public fun getValue ()Ljava/lang/Object; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/firestore/WhereConstraint$GreaterThanOrEqualTo : dev/gitlive/firebase/firestore/WhereConstraint$ForObject { + public final fun component1 ()Ljava/lang/Object; + public final fun copy (Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/WhereConstraint$GreaterThanOrEqualTo; + public static synthetic fun copy$default (Ldev/gitlive/firebase/firestore/WhereConstraint$GreaterThanOrEqualTo;Ljava/lang/Object;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/WhereConstraint$GreaterThanOrEqualTo; + public fun equals (Ljava/lang/Object;)Z + public fun getSafeValue ()Ljava/lang/Object; + public fun getValue ()Ljava/lang/Object; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/firestore/WhereConstraint$InArray : dev/gitlive/firebase/firestore/WhereConstraint$ForArray { + public final fun component1 ()Ljava/util/List; + public final fun copy (Ljava/util/List;)Ldev/gitlive/firebase/firestore/WhereConstraint$InArray; + public static synthetic fun copy$default (Ldev/gitlive/firebase/firestore/WhereConstraint$InArray;Ljava/util/List;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/WhereConstraint$InArray; + public fun equals (Ljava/lang/Object;)Z + public fun getSafeValues ()Ljava/util/List; + public fun getValues ()Ljava/util/List; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/firestore/WhereConstraint$LessThan : dev/gitlive/firebase/firestore/WhereConstraint$ForObject { + public final fun component1 ()Ljava/lang/Object; + public final fun copy (Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/WhereConstraint$LessThan; + public static synthetic fun copy$default (Ldev/gitlive/firebase/firestore/WhereConstraint$LessThan;Ljava/lang/Object;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/WhereConstraint$LessThan; + public fun equals (Ljava/lang/Object;)Z + public fun getSafeValue ()Ljava/lang/Object; + public fun getValue ()Ljava/lang/Object; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/firestore/WhereConstraint$LessThanOrEqualTo : dev/gitlive/firebase/firestore/WhereConstraint$ForObject { + public final fun component1 ()Ljava/lang/Object; + public final fun copy (Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/WhereConstraint$LessThanOrEqualTo; + public static synthetic fun copy$default (Ldev/gitlive/firebase/firestore/WhereConstraint$LessThanOrEqualTo;Ljava/lang/Object;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/WhereConstraint$LessThanOrEqualTo; + public fun equals (Ljava/lang/Object;)Z + public fun getSafeValue ()Ljava/lang/Object; + public fun getValue ()Ljava/lang/Object; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/firestore/WhereConstraint$NotEqualTo : dev/gitlive/firebase/firestore/WhereConstraint$ForNullableObject { + public final fun component1 ()Ljava/lang/Object; + public final fun copy (Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/WhereConstraint$NotEqualTo; + public static synthetic fun copy$default (Ldev/gitlive/firebase/firestore/WhereConstraint$NotEqualTo;Ljava/lang/Object;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/WhereConstraint$NotEqualTo; + public fun equals (Ljava/lang/Object;)Z + public fun getSafeValue ()Ljava/lang/Object; + public fun getValue ()Ljava/lang/Object; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/firestore/WhereConstraint$NotInArray : dev/gitlive/firebase/firestore/WhereConstraint$ForArray { + public final fun component1 ()Ljava/util/List; + public final fun copy (Ljava/util/List;)Ldev/gitlive/firebase/firestore/WhereConstraint$NotInArray; + public static synthetic fun copy$default (Ldev/gitlive/firebase/firestore/WhereConstraint$NotInArray;Ljava/util/List;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/WhereConstraint$NotInArray; + public fun equals (Ljava/lang/Object;)Z + public fun getSafeValues ()Ljava/util/List; + public fun getValues ()Ljava/util/List; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/firestore/WriteBatch { + public fun (Lcom/google/firebase/firestore/WriteBatch;)V + public final fun commit (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun copy (Ldev/gitlive/firebase/firestore/internal/NativeWriteBatchWrapper;)Ldev/gitlive/firebase/firestore/WriteBatch; + public static synthetic fun copy$default (Ldev/gitlive/firebase/firestore/WriteBatch;Ldev/gitlive/firebase/firestore/internal/NativeWriteBatchWrapper;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/WriteBatch; + public final fun delete (Ldev/gitlive/firebase/firestore/DocumentReference;)Ldev/gitlive/firebase/firestore/WriteBatch; + public fun equals (Ljava/lang/Object;)Z + public final fun getNative ()Lcom/google/firebase/firestore/WriteBatch; + public final fun getNativeWrapper ()Ldev/gitlive/firebase/firestore/internal/NativeWriteBatchWrapper; + public fun hashCode ()I + public final fun set (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;ZLkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/WriteBatch; + public final fun set (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;ZZ)Ldev/gitlive/firebase/firestore/WriteBatch; + public final fun set (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Z[Ldev/gitlive/firebase/firestore/FieldPath;)Ldev/gitlive/firebase/firestore/WriteBatch; + public final fun set (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Z[Ljava/lang/String;)Ldev/gitlive/firebase/firestore/WriteBatch; + public final fun set (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;[Ldev/gitlive/firebase/firestore/FieldPath;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/WriteBatch; + public final fun set (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;[Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/WriteBatch; + public static synthetic fun set$default (Ldev/gitlive/firebase/firestore/WriteBatch;Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;ZLkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/WriteBatch; + public static synthetic fun set$default (Ldev/gitlive/firebase/firestore/WriteBatch;Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;ZZILjava/lang/Object;)Ldev/gitlive/firebase/firestore/WriteBatch; + public static synthetic fun set$default (Ldev/gitlive/firebase/firestore/WriteBatch;Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;[Ldev/gitlive/firebase/firestore/FieldPath;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/WriteBatch; + public static synthetic fun set$default (Ldev/gitlive/firebase/firestore/WriteBatch;Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;[Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/WriteBatch; + public final fun setEncoded (Ldev/gitlive/firebase/firestore/DocumentReference;Ldev/gitlive/firebase/internal/EncodedObject;Ldev/gitlive/firebase/firestore/internal/SetOptions;)Ldev/gitlive/firebase/firestore/WriteBatch; + public fun toString ()Ljava/lang/String; + public final fun update (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/WriteBatch; + public final fun update (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Z)Ldev/gitlive/firebase/firestore/WriteBatch; + public static synthetic fun update$default (Ldev/gitlive/firebase/firestore/WriteBatch;Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/WriteBatch; + public final fun updateEncoded (Ldev/gitlive/firebase/firestore/DocumentReference;Ldev/gitlive/firebase/internal/EncodedObject;)Ldev/gitlive/firebase/firestore/WriteBatch; + public final fun updateEncodedFieldPathsAndValues (Ldev/gitlive/firebase/firestore/DocumentReference;Ljava/util/List;)Ldev/gitlive/firebase/firestore/WriteBatch; + public final fun updateEncodedFieldsAndValues (Ldev/gitlive/firebase/firestore/DocumentReference;Ljava/util/List;)Ldev/gitlive/firebase/firestore/WriteBatch; + public final fun updateField (Ldev/gitlive/firebase/firestore/DocumentReference;[Lkotlin/Pair;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/WriteBatch; + public static synthetic fun updateField$default (Ldev/gitlive/firebase/firestore/WriteBatch;Ldev/gitlive/firebase/firestore/DocumentReference;[Lkotlin/Pair;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/WriteBatch; + public final fun updateFieldPath (Ldev/gitlive/firebase/firestore/DocumentReference;[Lkotlin/Pair;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/WriteBatch; + public static synthetic fun updateFieldPath$default (Ldev/gitlive/firebase/firestore/WriteBatch;Ldev/gitlive/firebase/firestore/DocumentReference;[Lkotlin/Pair;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/WriteBatch; +} + +public final class dev/gitlive/firebase/firestore/_encodersKt { + public static final fun isSpecialValue (Ljava/lang/Object;)Z +} + +public final class dev/gitlive/firebase/firestore/android { + public static final fun firestore (Ldev/gitlive/firebase/Firebase;Ldev/gitlive/firebase/FirebaseApp;)Ldev/gitlive/firebase/firestore/FirebaseFirestore; + public static final fun firestoreSettings (Ldev/gitlive/firebase/firestore/FirebaseFirestoreSettings;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/FirebaseFirestoreSettings; + public static synthetic fun firestoreSettings$default (Ldev/gitlive/firebase/firestore/FirebaseFirestoreSettings;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/FirebaseFirestoreSettings; + public static final fun getAndroid (Ldev/gitlive/firebase/firestore/CollectionReference;)Lcom/google/firebase/firestore/CollectionReference; + public static final fun getAndroid (Ldev/gitlive/firebase/firestore/DocumentReference;)Lcom/google/firebase/firestore/DocumentReference; + public static final fun getAndroid (Ldev/gitlive/firebase/firestore/DocumentSnapshot;)Lcom/google/firebase/firestore/DocumentSnapshot; + public static final fun getAndroid (Ldev/gitlive/firebase/firestore/FirebaseFirestore;)Lcom/google/firebase/firestore/FirebaseFirestore; + public static final fun getAndroid (Ldev/gitlive/firebase/firestore/LocalCacheSettings;)Lcom/google/firebase/firestore/LocalCacheSettings; + public static final fun getAndroid (Ldev/gitlive/firebase/firestore/Query;)Lcom/google/firebase/firestore/Query; + public static final fun getAndroid (Ldev/gitlive/firebase/firestore/Transaction;)Lcom/google/firebase/firestore/Transaction; + public static final fun getAndroid (Ldev/gitlive/firebase/firestore/WriteBatch;)Lcom/google/firebase/firestore/WriteBatch; + public static final fun getCode (Lcom/google/firebase/firestore/FirebaseFirestoreException;)Lcom/google/firebase/firestore/FirebaseFirestoreException$Code; + public static final fun getFirestore (Ldev/gitlive/firebase/Firebase;)Ldev/gitlive/firebase/firestore/FirebaseFirestore; +} + +public final class dev/gitlive/firebase/firestore/internal/NativeCollectionReferenceWrapper : dev/gitlive/firebase/firestore/internal/NativeQueryWrapper { + public final fun addEncoded (Ldev/gitlive/firebase/internal/EncodedObject;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun document (Ljava/lang/String;)Ldev/gitlive/firebase/firestore/internal/NativeDocumentReference; + public final fun getDocument ()Ldev/gitlive/firebase/firestore/internal/NativeDocumentReference; + public fun getNative ()Lcom/google/firebase/firestore/CollectionReference; + public synthetic fun getNative ()Lcom/google/firebase/firestore/Query; + public final fun getParent ()Ldev/gitlive/firebase/firestore/internal/NativeDocumentReference; + public final fun getPath ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/firestore/internal/NativeDocumentReference { + public fun (Lcom/google/firebase/firestore/DocumentReference;)V + public final fun collection (Ljava/lang/String;)Lcom/google/firebase/firestore/CollectionReference; + public final fun delete (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public fun equals (Ljava/lang/Object;)Z + public final fun get (Ldev/gitlive/firebase/firestore/Source;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static synthetic fun get$default (Ldev/gitlive/firebase/firestore/internal/NativeDocumentReference;Ldev/gitlive/firebase/firestore/Source;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; + public final fun getAndroid ()Lcom/google/firebase/firestore/DocumentReference; + public final fun getId ()Ljava/lang/String; + public final fun getNativeValue ()Lcom/google/firebase/firestore/DocumentReference; + public final fun getParent ()Ldev/gitlive/firebase/firestore/internal/NativeCollectionReferenceWrapper; + public final fun getPath ()Ljava/lang/String; + public final fun getSnapshots ()Lkotlinx/coroutines/flow/Flow; + public fun hashCode ()I + public final fun setEncoded (Ldev/gitlive/firebase/internal/EncodedObject;Ldev/gitlive/firebase/firestore/internal/SetOptions;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun snapshots (Z)Lkotlinx/coroutines/flow/Flow; + public static synthetic fun snapshots$default (Ldev/gitlive/firebase/firestore/internal/NativeDocumentReference;ZILjava/lang/Object;)Lkotlinx/coroutines/flow/Flow; + public fun toString ()Ljava/lang/String; + public final fun updateEncoded (Ldev/gitlive/firebase/internal/EncodedObject;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun updateEncodedFieldPathsAndValues (Ljava/util/List;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun updateEncodedFieldsAndValues (Ljava/util/List;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; +} + +public final class dev/gitlive/firebase/firestore/internal/NativeDocumentSnapshotWrapper { + public final fun contains (Lcom/google/firebase/firestore/FieldPath;)Z + public final fun contains (Ljava/lang/String;)Z + public final fun encodedData (Ldev/gitlive/firebase/firestore/ServerTimestampBehavior;)Ljava/lang/Object; + public static synthetic fun encodedData$default (Ldev/gitlive/firebase/firestore/internal/NativeDocumentSnapshotWrapper;Ldev/gitlive/firebase/firestore/ServerTimestampBehavior;ILjava/lang/Object;)Ljava/lang/Object; + public final fun getEncoded (Lcom/google/firebase/firestore/FieldPath;Ldev/gitlive/firebase/firestore/ServerTimestampBehavior;)Ljava/lang/Object; + public final fun getEncoded (Ljava/lang/String;Ldev/gitlive/firebase/firestore/ServerTimestampBehavior;)Ljava/lang/Object; + public static synthetic fun getEncoded$default (Ldev/gitlive/firebase/firestore/internal/NativeDocumentSnapshotWrapper;Lcom/google/firebase/firestore/FieldPath;Ldev/gitlive/firebase/firestore/ServerTimestampBehavior;ILjava/lang/Object;)Ljava/lang/Object; + public static synthetic fun getEncoded$default (Ldev/gitlive/firebase/firestore/internal/NativeDocumentSnapshotWrapper;Ljava/lang/String;Ldev/gitlive/firebase/firestore/ServerTimestampBehavior;ILjava/lang/Object;)Ljava/lang/Object; + public final fun getExists ()Z + public final fun getId ()Ljava/lang/String; + public final fun getMetadata ()Ldev/gitlive/firebase/firestore/SnapshotMetadata; + public final fun getNative ()Lcom/google/firebase/firestore/DocumentSnapshot; + public final fun getReference ()Ldev/gitlive/firebase/firestore/internal/NativeDocumentReference; + public final fun toAndroid (Ldev/gitlive/firebase/firestore/ServerTimestampBehavior;)Lcom/google/firebase/firestore/DocumentSnapshot$ServerTimestampBehavior; +} + +public class dev/gitlive/firebase/firestore/internal/NativeQueryWrapper { + public final fun endAt (Lcom/google/firebase/firestore/DocumentSnapshot;)Lcom/google/firebase/firestore/Query; + public final fun endAt ([Ljava/lang/Object;)Lcom/google/firebase/firestore/Query; + public final fun endBefore (Lcom/google/firebase/firestore/DocumentSnapshot;)Lcom/google/firebase/firestore/Query; + public final fun endBefore ([Ljava/lang/Object;)Lcom/google/firebase/firestore/Query; + public final fun get (Ldev/gitlive/firebase/firestore/Source;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static synthetic fun get$default (Ldev/gitlive/firebase/firestore/internal/NativeQueryWrapper;Ldev/gitlive/firebase/firestore/Source;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; + public fun getNative ()Lcom/google/firebase/firestore/Query; + public final fun getSnapshots ()Lkotlinx/coroutines/flow/Flow; + public final fun limit (Ljava/lang/Number;)Lcom/google/firebase/firestore/Query; + public final fun orderBy (Lcom/google/firebase/firestore/FieldPath;Lcom/google/firebase/firestore/Query$Direction;)Lcom/google/firebase/firestore/Query; + public final fun orderBy (Ljava/lang/String;Lcom/google/firebase/firestore/Query$Direction;)Lcom/google/firebase/firestore/Query; + public final fun snapshots (Z)Lkotlinx/coroutines/flow/Flow; + public static synthetic fun snapshots$default (Ldev/gitlive/firebase/firestore/internal/NativeQueryWrapper;ZILjava/lang/Object;)Lkotlinx/coroutines/flow/Flow; + public final fun startAfter (Lcom/google/firebase/firestore/DocumentSnapshot;)Lcom/google/firebase/firestore/Query; + public final fun startAfter ([Ljava/lang/Object;)Lcom/google/firebase/firestore/Query; + public final fun startAt (Lcom/google/firebase/firestore/DocumentSnapshot;)Lcom/google/firebase/firestore/Query; + public final fun startAt ([Ljava/lang/Object;)Lcom/google/firebase/firestore/Query; + public final fun where (Ldev/gitlive/firebase/firestore/Filter;)Lcom/google/firebase/firestore/Query; +} + +public final class dev/gitlive/firebase/firestore/internal/NativeTransactionWrapper { + public final fun delete (Ldev/gitlive/firebase/firestore/DocumentReference;)Ldev/gitlive/firebase/firestore/internal/NativeTransactionWrapper; + public final fun get (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun getNative ()Lcom/google/firebase/firestore/Transaction; + public final fun setEncoded (Ldev/gitlive/firebase/firestore/DocumentReference;Ldev/gitlive/firebase/internal/EncodedObject;Ldev/gitlive/firebase/firestore/internal/SetOptions;)Ldev/gitlive/firebase/firestore/internal/NativeTransactionWrapper; + public final fun updateEncoded (Ldev/gitlive/firebase/firestore/DocumentReference;Ldev/gitlive/firebase/internal/EncodedObject;)Ldev/gitlive/firebase/firestore/internal/NativeTransactionWrapper; + public final fun updateEncodedFieldPathsAndValues (Ldev/gitlive/firebase/firestore/DocumentReference;Ljava/util/List;)Ldev/gitlive/firebase/firestore/internal/NativeTransactionWrapper; + public final fun updateEncodedFieldsAndValues (Ldev/gitlive/firebase/firestore/DocumentReference;Ljava/util/List;)Ldev/gitlive/firebase/firestore/internal/NativeTransactionWrapper; +} + +public final class dev/gitlive/firebase/firestore/internal/NativeWriteBatchWrapper { + public final fun commit (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun delete (Ldev/gitlive/firebase/firestore/DocumentReference;)Ldev/gitlive/firebase/firestore/internal/NativeWriteBatchWrapper; + public final fun getNative ()Lcom/google/firebase/firestore/WriteBatch; + public final fun setEncoded (Ldev/gitlive/firebase/firestore/DocumentReference;Ldev/gitlive/firebase/internal/EncodedObject;Ldev/gitlive/firebase/firestore/internal/SetOptions;)Ldev/gitlive/firebase/firestore/internal/NativeWriteBatchWrapper; + public final fun updateEncoded (Ldev/gitlive/firebase/firestore/DocumentReference;Ldev/gitlive/firebase/internal/EncodedObject;)Ldev/gitlive/firebase/firestore/internal/NativeWriteBatchWrapper; + public final fun updateEncodedFieldPathsAndValues (Ldev/gitlive/firebase/firestore/DocumentReference;Ljava/util/List;)Ldev/gitlive/firebase/firestore/internal/NativeWriteBatchWrapper; + public final fun updateEncodedFieldsAndValues (Ldev/gitlive/firebase/firestore/DocumentReference;Ljava/util/List;)Ldev/gitlive/firebase/firestore/internal/NativeWriteBatchWrapper; +} + +public abstract class dev/gitlive/firebase/firestore/internal/SetOptions { +} + +public final class dev/gitlive/firebase/firestore/internal/SetOptions$Merge : dev/gitlive/firebase/firestore/internal/SetOptions { + public static final field INSTANCE Ldev/gitlive/firebase/firestore/internal/SetOptions$Merge; + public fun equals (Ljava/lang/Object;)Z + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/firestore/internal/SetOptions$MergeFieldPaths : dev/gitlive/firebase/firestore/internal/SetOptions { + public fun (Ljava/util/List;)V + public final fun component1 ()Ljava/util/List; + public final fun copy (Ljava/util/List;)Ldev/gitlive/firebase/firestore/internal/SetOptions$MergeFieldPaths; + public static synthetic fun copy$default (Ldev/gitlive/firebase/firestore/internal/SetOptions$MergeFieldPaths;Ljava/util/List;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/internal/SetOptions$MergeFieldPaths; + public fun equals (Ljava/lang/Object;)Z + public final fun getEncodedFieldPaths ()Ljava/util/List; + public final fun getFieldPaths ()Ljava/util/List; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/firestore/internal/SetOptions$MergeFields : dev/gitlive/firebase/firestore/internal/SetOptions { + public fun (Ljava/util/List;)V + public final fun component1 ()Ljava/util/List; + public final fun copy (Ljava/util/List;)Ldev/gitlive/firebase/firestore/internal/SetOptions$MergeFields; + public static synthetic fun copy$default (Ldev/gitlive/firebase/firestore/internal/SetOptions$MergeFields;Ljava/util/List;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/internal/SetOptions$MergeFields; + public fun equals (Ljava/lang/Object;)Z + public final fun getFields ()Ljava/util/List; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/firestore/internal/SetOptions$Overwrite : dev/gitlive/firebase/firestore/internal/SetOptions { + public static final field INSTANCE Ldev/gitlive/firebase/firestore/internal/SetOptions$Overwrite; + public fun equals (Ljava/lang/Object;)Z + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + diff --git a/firebase-firestore/api/jvm/firebase-firestore.api b/firebase-firestore/api/jvm/firebase-firestore.api new file mode 100644 index 000000000..a17f631c3 --- /dev/null +++ b/firebase-firestore/api/jvm/firebase-firestore.api @@ -0,0 +1,915 @@ +public abstract class dev/gitlive/firebase/firestore/BaseTimestamp { + public static final field Companion Ldev/gitlive/firebase/firestore/BaseTimestamp$Companion; +} + +public final class dev/gitlive/firebase/firestore/BaseTimestamp$Companion { + public final fun serializer ()Lkotlinx/serialization/KSerializer; +} + +public final class dev/gitlive/firebase/firestore/BaseTimestampSerializer : kotlinx/serialization/KSerializer { + public static final field INSTANCE Ldev/gitlive/firebase/firestore/BaseTimestampSerializer; + public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ldev/gitlive/firebase/firestore/BaseTimestamp; + public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; + public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; + public fun serialize (Lkotlinx/serialization/encoding/Encoder;Ldev/gitlive/firebase/firestore/BaseTimestamp;)V + public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V +} + +public final class dev/gitlive/firebase/firestore/CollectionReference : dev/gitlive/firebase/firestore/Query { + public fun (Lcom/google/firebase/firestore/CollectionReference;)V + public final fun add (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun add (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static synthetic fun add$default (Ldev/gitlive/firebase/firestore/CollectionReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; + public final fun addEncoded (Ldev/gitlive/firebase/internal/EncodedObject;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun copy (Ldev/gitlive/firebase/firestore/internal/NativeCollectionReferenceWrapper;)Ldev/gitlive/firebase/firestore/CollectionReference; + public static synthetic fun copy$default (Ldev/gitlive/firebase/firestore/CollectionReference;Ldev/gitlive/firebase/firestore/internal/NativeCollectionReferenceWrapper;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/CollectionReference; + public final fun document (Ljava/lang/String;)Ldev/gitlive/firebase/firestore/DocumentReference; + public fun equals (Ljava/lang/Object;)Z + public final fun getDocument ()Ldev/gitlive/firebase/firestore/DocumentReference; + public fun getNative ()Lcom/google/firebase/firestore/CollectionReference; + public synthetic fun getNative ()Lcom/google/firebase/firestore/Query; + public final fun getNativeWrapper ()Ldev/gitlive/firebase/firestore/internal/NativeCollectionReferenceWrapper; + public final fun getParent ()Ldev/gitlive/firebase/firestore/DocumentReference; + public final fun getPath ()Ljava/lang/String; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/firestore/DocumentChange { + public fun (Lcom/google/firebase/firestore/DocumentChange;)V + public final fun getAndroid ()Lcom/google/firebase/firestore/DocumentChange; + public final fun getDocument ()Ldev/gitlive/firebase/firestore/DocumentSnapshot; + public final fun getNewIndex ()I + public final fun getOldIndex ()I + public final fun getType ()Lcom/google/firebase/firestore/DocumentChange$Type; +} + +public final class dev/gitlive/firebase/firestore/DocumentReference { + public static final field Companion Ldev/gitlive/firebase/firestore/DocumentReference$Companion; + public final fun collection (Ljava/lang/String;)Ldev/gitlive/firebase/firestore/CollectionReference; + public final fun copy (Ldev/gitlive/firebase/firestore/internal/NativeDocumentReference;)Ldev/gitlive/firebase/firestore/DocumentReference; + public static synthetic fun copy$default (Ldev/gitlive/firebase/firestore/DocumentReference;Ldev/gitlive/firebase/firestore/internal/NativeDocumentReference;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/DocumentReference; + public final fun delete (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public fun equals (Ljava/lang/Object;)Z + public final fun get (Ldev/gitlive/firebase/firestore/Source;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static synthetic fun get$default (Ldev/gitlive/firebase/firestore/DocumentReference;Ldev/gitlive/firebase/firestore/Source;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; + public final fun getId ()Ljava/lang/String; + public final fun getNative ()Ldev/gitlive/firebase/firestore/internal/NativeDocumentReference; + public final fun getParent ()Ldev/gitlive/firebase/firestore/CollectionReference; + public final fun getPath ()Ljava/lang/String; + public final fun getSnapshots ()Lkotlinx/coroutines/flow/Flow; + public fun hashCode ()I + public final fun set (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;ZLkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun set (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;ZZLkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun set (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Z[Ldev/gitlive/firebase/firestore/FieldPath;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun set (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Z[Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun set (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;[Ldev/gitlive/firebase/firestore/FieldPath;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun set (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;[Ljava/lang/String;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static synthetic fun set$default (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;ZLkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; + public static synthetic fun set$default (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;ZZLkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; + public static synthetic fun set$default (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;[Ldev/gitlive/firebase/firestore/FieldPath;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; + public static synthetic fun set$default (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;[Ljava/lang/String;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; + public final fun snapshots (Z)Lkotlinx/coroutines/flow/Flow; + public static synthetic fun snapshots$default (Ldev/gitlive/firebase/firestore/DocumentReference;ZILjava/lang/Object;)Lkotlinx/coroutines/flow/Flow; + public fun toString ()Ljava/lang/String; + public final fun update (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun update (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static synthetic fun update$default (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; + public final fun updateFieldPaths ([Lkotlin/Pair;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static synthetic fun updateFieldPaths$default (Ldev/gitlive/firebase/firestore/DocumentReference;[Lkotlin/Pair;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; + public final fun updateFields ([Lkotlin/Pair;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static synthetic fun updateFields$default (Ldev/gitlive/firebase/firestore/DocumentReference;[Lkotlin/Pair;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; +} + +public final class dev/gitlive/firebase/firestore/DocumentReference$Companion { + public final fun serializer ()Lkotlinx/serialization/KSerializer; +} + +public final class dev/gitlive/firebase/firestore/DocumentReferenceSerializer : kotlinx/serialization/KSerializer { + public static final field INSTANCE Ldev/gitlive/firebase/firestore/DocumentReferenceSerializer; + public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ldev/gitlive/firebase/firestore/DocumentReference; + public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; + public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; + public fun serialize (Lkotlinx/serialization/encoding/Encoder;Ldev/gitlive/firebase/firestore/DocumentReference;)V + public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V +} + +public final class dev/gitlive/firebase/firestore/DocumentSnapshot { + public fun (Lcom/google/firebase/firestore/DocumentSnapshot;)V + public final fun contains (Ldev/gitlive/firebase/firestore/FieldPath;)Z + public final fun contains (Ljava/lang/String;)Z + public final fun copy (Ldev/gitlive/firebase/firestore/internal/NativeDocumentSnapshotWrapper;)Ldev/gitlive/firebase/firestore/DocumentSnapshot; + public static synthetic fun copy$default (Ldev/gitlive/firebase/firestore/DocumentSnapshot;Ldev/gitlive/firebase/firestore/internal/NativeDocumentSnapshotWrapper;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/DocumentSnapshot; + public final fun data (Lkotlinx/serialization/DeserializationStrategy;Ldev/gitlive/firebase/firestore/ServerTimestampBehavior;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; + public static synthetic fun data$default (Ldev/gitlive/firebase/firestore/DocumentSnapshot;Lkotlinx/serialization/DeserializationStrategy;Ldev/gitlive/firebase/firestore/ServerTimestampBehavior;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/lang/Object; + public final fun encodedData (Ldev/gitlive/firebase/firestore/ServerTimestampBehavior;)Ljava/lang/Object; + public static synthetic fun encodedData$default (Ldev/gitlive/firebase/firestore/DocumentSnapshot;Ldev/gitlive/firebase/firestore/ServerTimestampBehavior;ILjava/lang/Object;)Ljava/lang/Object; + public fun equals (Ljava/lang/Object;)Z + public final fun get (Ldev/gitlive/firebase/firestore/FieldPath;Lkotlinx/serialization/DeserializationStrategy;Ldev/gitlive/firebase/firestore/ServerTimestampBehavior;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; + public final fun get (Ljava/lang/String;Lkotlinx/serialization/DeserializationStrategy;Ldev/gitlive/firebase/firestore/ServerTimestampBehavior;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; + public static synthetic fun get$default (Ldev/gitlive/firebase/firestore/DocumentSnapshot;Ldev/gitlive/firebase/firestore/FieldPath;Lkotlinx/serialization/DeserializationStrategy;Ldev/gitlive/firebase/firestore/ServerTimestampBehavior;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/lang/Object; + public static synthetic fun get$default (Ldev/gitlive/firebase/firestore/DocumentSnapshot;Ljava/lang/String;Lkotlinx/serialization/DeserializationStrategy;Ldev/gitlive/firebase/firestore/ServerTimestampBehavior;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/lang/Object; + public final fun getEncoded (Ldev/gitlive/firebase/firestore/FieldPath;Ldev/gitlive/firebase/firestore/ServerTimestampBehavior;)Ljava/lang/Object; + public final fun getEncoded (Ljava/lang/String;Ldev/gitlive/firebase/firestore/ServerTimestampBehavior;)Ljava/lang/Object; + public static synthetic fun getEncoded$default (Ldev/gitlive/firebase/firestore/DocumentSnapshot;Ldev/gitlive/firebase/firestore/FieldPath;Ldev/gitlive/firebase/firestore/ServerTimestampBehavior;ILjava/lang/Object;)Ljava/lang/Object; + public static synthetic fun getEncoded$default (Ldev/gitlive/firebase/firestore/DocumentSnapshot;Ljava/lang/String;Ldev/gitlive/firebase/firestore/ServerTimestampBehavior;ILjava/lang/Object;)Ljava/lang/Object; + public final fun getExists ()Z + public final fun getId ()Ljava/lang/String; + public final fun getMetadata ()Ldev/gitlive/firebase/firestore/SnapshotMetadata; + public final fun getNative ()Lcom/google/firebase/firestore/DocumentSnapshot; + public final fun getNativeWrapper ()Ldev/gitlive/firebase/firestore/internal/NativeDocumentSnapshotWrapper; + public final fun getReference ()Ldev/gitlive/firebase/firestore/DocumentReference; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/firestore/DoubleAsTimestampSerializer : kotlinx/serialization/KSerializer { + public static final field INSTANCE Ldev/gitlive/firebase/firestore/DoubleAsTimestampSerializer; + public static final field SERVER_TIMESTAMP D + public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Double; + public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; + public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; + public fun serialize (Lkotlinx/serialization/encoding/Encoder;D)V + public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V +} + +public final class dev/gitlive/firebase/firestore/FieldPath { + public static final field Companion Ldev/gitlive/firebase/firestore/FieldPath$Companion; + public fun ([Ljava/lang/String;)V + public fun equals (Ljava/lang/Object;)Z + public final fun getAndroid ()Lcom/google/firebase/firestore/FieldPath; + public final fun getDocumentId ()Ldev/gitlive/firebase/firestore/FieldPath; + public final fun getEncoded ()Lcom/google/firebase/firestore/FieldPath; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/firestore/FieldPath$Companion { + public final fun getDocumentId ()Ldev/gitlive/firebase/firestore/FieldPath; +} + +public final class dev/gitlive/firebase/firestore/FieldValue { + public static final field Companion Ldev/gitlive/firebase/firestore/FieldValue$Companion; + public fun equals (Ljava/lang/Object;)Z + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/firestore/FieldValue$Companion { + public final fun arrayRemove ([Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/FieldValue; + public final fun arrayUnion ([Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/FieldValue; + public final fun getDelete ()Ldev/gitlive/firebase/firestore/FieldValue; + public final fun getServerTimestamp ()Ldev/gitlive/firebase/firestore/FieldValue; + public final fun increment (I)Ldev/gitlive/firebase/firestore/FieldValue; + public final fun serializer ()Lkotlinx/serialization/KSerializer; +} + +public final class dev/gitlive/firebase/firestore/FieldValueSerializer : kotlinx/serialization/KSerializer { + public static final field INSTANCE Ldev/gitlive/firebase/firestore/FieldValueSerializer; + public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ldev/gitlive/firebase/firestore/FieldValue; + public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; + public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; + public fun serialize (Lkotlinx/serialization/encoding/Encoder;Ldev/gitlive/firebase/firestore/FieldValue;)V + public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V +} + +public abstract class dev/gitlive/firebase/firestore/Filter { +} + +public final class dev/gitlive/firebase/firestore/Filter$And : dev/gitlive/firebase/firestore/Filter { + public final fun component1 ()Ljava/util/List; + public final fun copy (Ljava/util/List;)Ldev/gitlive/firebase/firestore/Filter$And; + public static synthetic fun copy$default (Ldev/gitlive/firebase/firestore/Filter$And;Ljava/util/List;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/Filter$And; + public fun equals (Ljava/lang/Object;)Z + public final fun getFilters ()Ljava/util/List; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/firestore/Filter$Field : dev/gitlive/firebase/firestore/Filter$WithConstraint { + public final fun component1 ()Ljava/lang/String; + public final fun component2 ()Ldev/gitlive/firebase/firestore/WhereConstraint; + public final fun copy (Ljava/lang/String;Ldev/gitlive/firebase/firestore/WhereConstraint;)Ldev/gitlive/firebase/firestore/Filter$Field; + public static synthetic fun copy$default (Ldev/gitlive/firebase/firestore/Filter$Field;Ljava/lang/String;Ldev/gitlive/firebase/firestore/WhereConstraint;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/Filter$Field; + public fun equals (Ljava/lang/Object;)Z + public fun getConstraint ()Ldev/gitlive/firebase/firestore/WhereConstraint; + public final fun getField ()Ljava/lang/String; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/firestore/Filter$Or : dev/gitlive/firebase/firestore/Filter { + public final fun component1 ()Ljava/util/List; + public final fun copy (Ljava/util/List;)Ldev/gitlive/firebase/firestore/Filter$Or; + public static synthetic fun copy$default (Ldev/gitlive/firebase/firestore/Filter$Or;Ljava/util/List;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/Filter$Or; + public fun equals (Ljava/lang/Object;)Z + public final fun getFilters ()Ljava/util/List; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/firestore/Filter$Path : dev/gitlive/firebase/firestore/Filter$WithConstraint { + public final fun component1 ()Ldev/gitlive/firebase/firestore/FieldPath; + public final fun component2 ()Ldev/gitlive/firebase/firestore/WhereConstraint; + public final fun copy (Ldev/gitlive/firebase/firestore/FieldPath;Ldev/gitlive/firebase/firestore/WhereConstraint;)Ldev/gitlive/firebase/firestore/Filter$Path; + public static synthetic fun copy$default (Ldev/gitlive/firebase/firestore/Filter$Path;Ldev/gitlive/firebase/firestore/FieldPath;Ldev/gitlive/firebase/firestore/WhereConstraint;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/Filter$Path; + public fun equals (Ljava/lang/Object;)Z + public fun getConstraint ()Ldev/gitlive/firebase/firestore/WhereConstraint; + public final fun getPath ()Ldev/gitlive/firebase/firestore/FieldPath; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public abstract class dev/gitlive/firebase/firestore/Filter$WithConstraint : dev/gitlive/firebase/firestore/Filter { + public abstract fun getConstraint ()Ldev/gitlive/firebase/firestore/WhereConstraint; +} + +public final class dev/gitlive/firebase/firestore/FilterBuilder { + public final fun all ([Ldev/gitlive/firebase/firestore/Filter;)Ldev/gitlive/firebase/firestore/Filter; + public final fun and (Ldev/gitlive/firebase/firestore/Filter;Ldev/gitlive/firebase/firestore/Filter;)Ldev/gitlive/firebase/firestore/Filter$And; + public final fun any ([Ldev/gitlive/firebase/firestore/Filter;)Ldev/gitlive/firebase/firestore/Filter; + public final fun contains (Ldev/gitlive/firebase/firestore/FieldPath;Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/Filter$WithConstraint; + public final fun contains (Ljava/lang/String;Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/Filter$WithConstraint; + public final fun containsAny (Ldev/gitlive/firebase/firestore/FieldPath;Ljava/util/List;)Ldev/gitlive/firebase/firestore/Filter$WithConstraint; + public final fun containsAny (Ljava/lang/String;Ljava/util/List;)Ldev/gitlive/firebase/firestore/Filter$WithConstraint; + public final fun equalTo (Ldev/gitlive/firebase/firestore/FieldPath;Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/Filter$WithConstraint; + public final fun equalTo (Ljava/lang/String;Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/Filter$WithConstraint; + public final fun greaterThan (Ldev/gitlive/firebase/firestore/FieldPath;Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/Filter$WithConstraint; + public final fun greaterThan (Ljava/lang/String;Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/Filter$WithConstraint; + public final fun greaterThanOrEqualTo (Ldev/gitlive/firebase/firestore/FieldPath;Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/Filter$WithConstraint; + public final fun greaterThanOrEqualTo (Ljava/lang/String;Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/Filter$WithConstraint; + public final fun inArray (Ldev/gitlive/firebase/firestore/FieldPath;Ljava/util/List;)Ldev/gitlive/firebase/firestore/Filter$WithConstraint; + public final fun inArray (Ljava/lang/String;Ljava/util/List;)Ldev/gitlive/firebase/firestore/Filter$WithConstraint; + public final fun lessThan (Ldev/gitlive/firebase/firestore/FieldPath;Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/Filter$WithConstraint; + public final fun lessThan (Ljava/lang/String;Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/Filter$WithConstraint; + public final fun lessThanOrEqualTo (Ldev/gitlive/firebase/firestore/FieldPath;Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/Filter$WithConstraint; + public final fun lessThanOrEqualTo (Ljava/lang/String;Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/Filter$WithConstraint; + public final fun notEqualTo (Ldev/gitlive/firebase/firestore/FieldPath;Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/Filter$WithConstraint; + public final fun notEqualTo (Ljava/lang/String;Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/Filter$WithConstraint; + public final fun notInArray (Ldev/gitlive/firebase/firestore/FieldPath;Ljava/util/List;)Ldev/gitlive/firebase/firestore/Filter$WithConstraint; + public final fun notInArray (Ljava/lang/String;Ljava/util/List;)Ldev/gitlive/firebase/firestore/Filter$WithConstraint; + public final fun or (Ldev/gitlive/firebase/firestore/Filter;Ldev/gitlive/firebase/firestore/Filter;)Ldev/gitlive/firebase/firestore/Filter$Or; +} + +public final class dev/gitlive/firebase/firestore/FirebaseFirestore { + public fun (Lcom/google/firebase/firestore/FirebaseFirestore;)V + public final fun batch ()Ldev/gitlive/firebase/firestore/WriteBatch; + public final fun clearPersistence (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun collection (Ljava/lang/String;)Ldev/gitlive/firebase/firestore/CollectionReference; + public final fun collectionGroup (Ljava/lang/String;)Ldev/gitlive/firebase/firestore/Query; + public final fun disableNetwork (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun document (Ljava/lang/String;)Ldev/gitlive/firebase/firestore/DocumentReference; + public final fun enableNetwork (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun getNative ()Lcom/google/firebase/firestore/FirebaseFirestore; + public final fun getSettings ()Ldev/gitlive/firebase/firestore/FirebaseFirestoreSettings; + public final fun runTransaction (Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun setLoggingEnabled (Z)V + public final fun setSettings (Ldev/gitlive/firebase/firestore/FirebaseFirestoreSettings;)V + public final fun setSettings (Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/String;Ljava/lang/Long;)V + public static synthetic fun setSettings$default (Ldev/gitlive/firebase/firestore/FirebaseFirestore;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/String;Ljava/lang/Long;ILjava/lang/Object;)V + public final fun useEmulator (Ljava/lang/String;I)V +} + +public final class dev/gitlive/firebase/firestore/FirebaseFirestoreSettings { + public static final field Companion Ldev/gitlive/firebase/firestore/FirebaseFirestoreSettings$Companion; + public fun (ZLjava/lang/String;Ldev/gitlive/firebase/firestore/LocalCacheSettings;Ljava/util/concurrent/Executor;)V + public final fun component1 ()Z + public final fun component2 ()Ljava/lang/String; + public final fun component3 ()Ldev/gitlive/firebase/firestore/LocalCacheSettings; + public final fun component4 ()Ljava/util/concurrent/Executor; + public final fun copy (ZLjava/lang/String;Ldev/gitlive/firebase/firestore/LocalCacheSettings;Ljava/util/concurrent/Executor;)Ldev/gitlive/firebase/firestore/FirebaseFirestoreSettings; + public static synthetic fun copy$default (Ldev/gitlive/firebase/firestore/FirebaseFirestoreSettings;ZLjava/lang/String;Ldev/gitlive/firebase/firestore/LocalCacheSettings;Ljava/util/concurrent/Executor;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/FirebaseFirestoreSettings; + public fun equals (Ljava/lang/Object;)Z + public final fun getCacheSettings ()Ldev/gitlive/firebase/firestore/LocalCacheSettings; + public final fun getCallbackExecutor ()Ljava/util/concurrent/Executor; + public final fun getHost ()Ljava/lang/String; + public final fun getSslEnabled ()Z + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/firestore/FirebaseFirestoreSettings$Builder { + public fun ()V + public fun (Ldev/gitlive/firebase/firestore/FirebaseFirestoreSettings;)V + public final fun build ()Ldev/gitlive/firebase/firestore/FirebaseFirestoreSettings; + public final fun getCacheSettings ()Ldev/gitlive/firebase/firestore/LocalCacheSettings; + public final fun getCallbackExecutor ()Ljava/util/concurrent/Executor; + public final fun getHost ()Ljava/lang/String; + public final fun getSslEnabled ()Z + public final fun setCacheSettings (Ldev/gitlive/firebase/firestore/LocalCacheSettings;)V + public final fun setCallbackExecutor (Ljava/util/concurrent/Executor;)V + public final fun setHost (Ljava/lang/String;)V + public final fun setSslEnabled (Z)V +} + +public final class dev/gitlive/firebase/firestore/FirebaseFirestoreSettings$Companion { + public final fun getCACHE_SIZE_UNLIMITED ()J +} + +public final class dev/gitlive/firebase/firestore/FirestoreKt { + public static final fun where (Ldev/gitlive/firebase/firestore/Query;Ldev/gitlive/firebase/firestore/FieldPath;Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/Query; + public static final fun where (Ldev/gitlive/firebase/firestore/Query;Ldev/gitlive/firebase/firestore/FieldPath;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/Query; + public static final fun where (Ldev/gitlive/firebase/firestore/Query;Ldev/gitlive/firebase/firestore/FieldPath;Ljava/util/List;Ljava/util/List;)Ldev/gitlive/firebase/firestore/Query; + public static final fun where (Ldev/gitlive/firebase/firestore/Query;Ljava/lang/String;Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/Query; + public static final fun where (Ldev/gitlive/firebase/firestore/Query;Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/Query; + public static final fun where (Ldev/gitlive/firebase/firestore/Query;Ljava/lang/String;Ljava/util/List;Ljava/util/List;)Ldev/gitlive/firebase/firestore/Query; + public static synthetic fun where$default (Ldev/gitlive/firebase/firestore/Query;Ldev/gitlive/firebase/firestore/FieldPath;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/Query; + public static synthetic fun where$default (Ldev/gitlive/firebase/firestore/Query;Ldev/gitlive/firebase/firestore/FieldPath;Ljava/util/List;Ljava/util/List;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/Query; + public static synthetic fun where$default (Ldev/gitlive/firebase/firestore/Query;Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/Query; + public static synthetic fun where$default (Ldev/gitlive/firebase/firestore/Query;Ljava/lang/String;Ljava/util/List;Ljava/util/List;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/Query; +} + +public final class dev/gitlive/firebase/firestore/GeoPoint { + public static final field Companion Ldev/gitlive/firebase/firestore/GeoPoint$Companion; + public fun (DD)V + public fun equals (Ljava/lang/Object;)Z + public final fun getLatitude ()D + public final fun getLongitude ()D + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/firestore/GeoPoint$Companion { + public final fun serializer ()Lkotlinx/serialization/KSerializer; +} + +public final class dev/gitlive/firebase/firestore/GeoPointSerializer : kotlinx/serialization/KSerializer { + public static final field INSTANCE Ldev/gitlive/firebase/firestore/GeoPointSerializer; + public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ldev/gitlive/firebase/firestore/GeoPoint; + public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; + public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; + public fun serialize (Lkotlinx/serialization/encoding/Encoder;Ldev/gitlive/firebase/firestore/GeoPoint;)V + public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V +} + +public final class dev/gitlive/firebase/firestore/HelpersKt { + public static final fun encodeFieldAndValue ([Lkotlin/Pair;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;)Ljava/util/List; + public static final fun performUpdateFieldPaths ([Lkotlin/Pair;Lkotlin/jvm/functions/Function1;)Ljava/util/List; + public static final fun performUpdateFields ([Lkotlin/Pair;Lkotlin/jvm/functions/Function1;)Ljava/util/List; +} + +public abstract interface class dev/gitlive/firebase/firestore/LocalCacheSettings { +} + +public final class dev/gitlive/firebase/firestore/LocalCacheSettings$Memory : dev/gitlive/firebase/firestore/LocalCacheSettings { + public static final field Companion Ldev/gitlive/firebase/firestore/LocalCacheSettings$Memory$Companion; + public final fun component1 ()Ldev/gitlive/firebase/firestore/MemoryGarbageCollectorSettings; + public final fun copy (Ldev/gitlive/firebase/firestore/MemoryGarbageCollectorSettings;)Ldev/gitlive/firebase/firestore/LocalCacheSettings$Memory; + public static synthetic fun copy$default (Ldev/gitlive/firebase/firestore/LocalCacheSettings$Memory;Ldev/gitlive/firebase/firestore/MemoryGarbageCollectorSettings;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/LocalCacheSettings$Memory; + public fun equals (Ljava/lang/Object;)Z + public final fun getGarbaseCollectorSettings ()Ldev/gitlive/firebase/firestore/MemoryGarbageCollectorSettings; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/firestore/LocalCacheSettings$Memory$Builder { + public final fun build ()Ldev/gitlive/firebase/firestore/LocalCacheSettings$Memory; + public final fun getGcSettings ()Ldev/gitlive/firebase/firestore/MemoryGarbageCollectorSettings; + public final fun setGcSettings (Ldev/gitlive/firebase/firestore/MemoryGarbageCollectorSettings;)V +} + +public final class dev/gitlive/firebase/firestore/LocalCacheSettings$Memory$Companion { + public final fun newBuilder ()Ldev/gitlive/firebase/firestore/LocalCacheSettings$Memory$Builder; +} + +public final class dev/gitlive/firebase/firestore/LocalCacheSettings$Persistent : dev/gitlive/firebase/firestore/LocalCacheSettings { + public static final field Companion Ldev/gitlive/firebase/firestore/LocalCacheSettings$Persistent$Companion; + public final fun component1 ()J + public final fun copy (J)Ldev/gitlive/firebase/firestore/LocalCacheSettings$Persistent; + public static synthetic fun copy$default (Ldev/gitlive/firebase/firestore/LocalCacheSettings$Persistent;JILjava/lang/Object;)Ldev/gitlive/firebase/firestore/LocalCacheSettings$Persistent; + public fun equals (Ljava/lang/Object;)Z + public final fun getSizeBytes ()J + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/firestore/LocalCacheSettings$Persistent$Builder { + public final fun build ()Ldev/gitlive/firebase/firestore/LocalCacheSettings$Persistent; + public final fun getSizeBytes ()J + public final fun setSizeBytes (J)V +} + +public final class dev/gitlive/firebase/firestore/LocalCacheSettings$Persistent$Companion { + public final fun newBuilder ()Ldev/gitlive/firebase/firestore/LocalCacheSettings$Persistent$Builder; +} + +public final class dev/gitlive/firebase/firestore/LocalCacheSettingsKt { + public static final fun memoryCacheSettings (Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/LocalCacheSettings$Memory; + public static final fun memoryEagerGcSettings (Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/MemoryGarbageCollectorSettings$Eager; + public static final fun memoryLruGcSettings (Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/MemoryGarbageCollectorSettings$LRUGC; + public static final fun persistentCacheSettings (Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/LocalCacheSettings$Persistent; +} + +public abstract interface class dev/gitlive/firebase/firestore/MemoryGarbageCollectorSettings { +} + +public final class dev/gitlive/firebase/firestore/MemoryGarbageCollectorSettings$Eager : dev/gitlive/firebase/firestore/MemoryGarbageCollectorSettings { + public static final field INSTANCE Ldev/gitlive/firebase/firestore/MemoryGarbageCollectorSettings$Eager; + public fun equals (Ljava/lang/Object;)Z + public fun hashCode ()I + public final fun newBuilder ()Ldev/gitlive/firebase/firestore/MemoryGarbageCollectorSettings$Eager$Builder; + public fun toString ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/firestore/MemoryGarbageCollectorSettings$Eager$Builder { + public final fun build ()Ldev/gitlive/firebase/firestore/MemoryGarbageCollectorSettings$Eager; +} + +public final class dev/gitlive/firebase/firestore/MemoryGarbageCollectorSettings$LRUGC : dev/gitlive/firebase/firestore/MemoryGarbageCollectorSettings { + public static final field Companion Ldev/gitlive/firebase/firestore/MemoryGarbageCollectorSettings$LRUGC$Companion; + public final fun component1 ()J + public final fun copy (J)Ldev/gitlive/firebase/firestore/MemoryGarbageCollectorSettings$LRUGC; + public static synthetic fun copy$default (Ldev/gitlive/firebase/firestore/MemoryGarbageCollectorSettings$LRUGC;JILjava/lang/Object;)Ldev/gitlive/firebase/firestore/MemoryGarbageCollectorSettings$LRUGC; + public fun equals (Ljava/lang/Object;)Z + public final fun getSizeBytes ()J + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/firestore/MemoryGarbageCollectorSettings$LRUGC$Builder { + public final fun build ()Ldev/gitlive/firebase/firestore/MemoryGarbageCollectorSettings$LRUGC; + public final fun getSizeBytes ()J + public final fun setSizeBytes (J)V +} + +public final class dev/gitlive/firebase/firestore/MemoryGarbageCollectorSettings$LRUGC$Companion { + public final fun newBuilder ()Ldev/gitlive/firebase/firestore/MemoryGarbageCollectorSettings$LRUGC$Builder; +} + +public class dev/gitlive/firebase/firestore/Query { + public fun (Lcom/google/firebase/firestore/Query;)V + public final fun endAt (Ldev/gitlive/firebase/firestore/DocumentSnapshot;)Ldev/gitlive/firebase/firestore/Query; + public final fun endAt ([Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/Query; + public final fun endBefore (Ldev/gitlive/firebase/firestore/DocumentSnapshot;)Ldev/gitlive/firebase/firestore/Query; + public final fun endBefore ([Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/Query; + public final fun get (Ldev/gitlive/firebase/firestore/Source;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static synthetic fun get$default (Ldev/gitlive/firebase/firestore/Query;Ldev/gitlive/firebase/firestore/Source;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; + public fun getNative ()Lcom/google/firebase/firestore/Query; + public final fun getSnapshots ()Lkotlinx/coroutines/flow/Flow; + public final fun limit (Ljava/lang/Number;)Ldev/gitlive/firebase/firestore/Query; + public final fun orderBy (Ldev/gitlive/firebase/firestore/FieldPath;Lcom/google/firebase/firestore/Query$Direction;)Ldev/gitlive/firebase/firestore/Query; + public final fun orderBy (Ljava/lang/String;Lcom/google/firebase/firestore/Query$Direction;)Ldev/gitlive/firebase/firestore/Query; + public static synthetic fun orderBy$default (Ldev/gitlive/firebase/firestore/Query;Ldev/gitlive/firebase/firestore/FieldPath;Lcom/google/firebase/firestore/Query$Direction;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/Query; + public static synthetic fun orderBy$default (Ldev/gitlive/firebase/firestore/Query;Ljava/lang/String;Lcom/google/firebase/firestore/Query$Direction;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/Query; + public final fun snapshots (Z)Lkotlinx/coroutines/flow/Flow; + public static synthetic fun snapshots$default (Ldev/gitlive/firebase/firestore/Query;ZILjava/lang/Object;)Lkotlinx/coroutines/flow/Flow; + public final fun startAfter (Ldev/gitlive/firebase/firestore/DocumentSnapshot;)Ldev/gitlive/firebase/firestore/Query; + public final fun startAfter ([Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/Query; + public final fun startAt (Ldev/gitlive/firebase/firestore/DocumentSnapshot;)Ldev/gitlive/firebase/firestore/Query; + public final fun startAt ([Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/Query; + public final fun where (Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Query; +} + +public final class dev/gitlive/firebase/firestore/QuerySnapshot { + public fun (Lcom/google/firebase/firestore/QuerySnapshot;)V + public final fun getAndroid ()Lcom/google/firebase/firestore/QuerySnapshot; + public final fun getDocumentChanges ()Ljava/util/List; + public final fun getDocuments ()Ljava/util/List; + public final fun getMetadata ()Ldev/gitlive/firebase/firestore/SnapshotMetadata; +} + +public final class dev/gitlive/firebase/firestore/ServerTimestampBehavior : java/lang/Enum { + public static final field ESTIMATE Ldev/gitlive/firebase/firestore/ServerTimestampBehavior; + public static final field NONE Ldev/gitlive/firebase/firestore/ServerTimestampBehavior; + public static final field PREVIOUS Ldev/gitlive/firebase/firestore/ServerTimestampBehavior; + public static fun getEntries ()Lkotlin/enums/EnumEntries; + public static fun valueOf (Ljava/lang/String;)Ldev/gitlive/firebase/firestore/ServerTimestampBehavior; + public static fun values ()[Ldev/gitlive/firebase/firestore/ServerTimestampBehavior; +} + +public final class dev/gitlive/firebase/firestore/ServerTimestampSerializer : kotlinx/serialization/KSerializer { + public static final field INSTANCE Ldev/gitlive/firebase/firestore/ServerTimestampSerializer; + public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ldev/gitlive/firebase/firestore/Timestamp$ServerTimestamp; + public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; + public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; + public fun serialize (Lkotlinx/serialization/encoding/Encoder;Ldev/gitlive/firebase/firestore/Timestamp$ServerTimestamp;)V + public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V +} + +public final class dev/gitlive/firebase/firestore/SnapshotMetadata { + public fun (Lcom/google/firebase/firestore/SnapshotMetadata;)V + public final fun getAndroid ()Lcom/google/firebase/firestore/SnapshotMetadata; + public final fun getHasPendingWrites ()Z + public final fun isFromCache ()Z +} + +public final class dev/gitlive/firebase/firestore/Source : java/lang/Enum { + public static final field CACHE Ldev/gitlive/firebase/firestore/Source; + public static final field DEFAULT Ldev/gitlive/firebase/firestore/Source; + public static final field SERVER Ldev/gitlive/firebase/firestore/Source; + public static fun getEntries ()Lkotlin/enums/EnumEntries; + public static fun valueOf (Ljava/lang/String;)Ldev/gitlive/firebase/firestore/Source; + public static fun values ()[Ldev/gitlive/firebase/firestore/Source; +} + +public final class dev/gitlive/firebase/firestore/Timestamp : dev/gitlive/firebase/firestore/BaseTimestamp { + public static final field Companion Ldev/gitlive/firebase/firestore/Timestamp$Companion; + public fun (JI)V + public fun equals (Ljava/lang/Object;)Z + public final fun getNanoseconds ()I + public final fun getSeconds ()J + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/firestore/Timestamp$Companion { + public final fun now ()Ldev/gitlive/firebase/firestore/Timestamp; + public final fun serializer ()Lkotlinx/serialization/KSerializer; +} + +public final class dev/gitlive/firebase/firestore/Timestamp$ServerTimestamp : dev/gitlive/firebase/firestore/BaseTimestamp { + public static final field INSTANCE Ldev/gitlive/firebase/firestore/Timestamp$ServerTimestamp; + public fun equals (Ljava/lang/Object;)Z + public fun hashCode ()I + public final fun serializer ()Lkotlinx/serialization/KSerializer; + public fun toString ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/firestore/TimestampKt { + public static final fun fromDuration-HG0u8IE (Ldev/gitlive/firebase/firestore/Timestamp$Companion;J)Ldev/gitlive/firebase/firestore/Timestamp; + public static final fun fromMilliseconds (Ldev/gitlive/firebase/firestore/Timestamp$Companion;D)Ldev/gitlive/firebase/firestore/Timestamp; + public static final fun toDuration (Ldev/gitlive/firebase/firestore/Timestamp;)J + public static final fun toMilliseconds (Ldev/gitlive/firebase/firestore/Timestamp;)D +} + +public final class dev/gitlive/firebase/firestore/TimestampSerializer : kotlinx/serialization/KSerializer { + public static final field INSTANCE Ldev/gitlive/firebase/firestore/TimestampSerializer; + public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ldev/gitlive/firebase/firestore/Timestamp; + public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; + public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; + public fun serialize (Lkotlinx/serialization/encoding/Encoder;Ldev/gitlive/firebase/firestore/Timestamp;)V + public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V +} + +public final class dev/gitlive/firebase/firestore/Transaction { + public fun (Lcom/google/firebase/firestore/Transaction;)V + public final fun copy (Ldev/gitlive/firebase/firestore/internal/NativeTransactionWrapper;)Ldev/gitlive/firebase/firestore/Transaction; + public static synthetic fun copy$default (Ldev/gitlive/firebase/firestore/Transaction;Ldev/gitlive/firebase/firestore/internal/NativeTransactionWrapper;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/Transaction; + public final fun delete (Ldev/gitlive/firebase/firestore/DocumentReference;)Ldev/gitlive/firebase/firestore/Transaction; + public fun equals (Ljava/lang/Object;)Z + public final fun get (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun getNative ()Lcom/google/firebase/firestore/Transaction; + public final fun getNativeWrapper ()Ldev/gitlive/firebase/firestore/internal/NativeTransactionWrapper; + public fun hashCode ()I + public final fun set (Ldev/gitlive/firebase/firestore/DocumentReference;Ljava/lang/Object;ZLkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Transaction; + public final fun set (Ldev/gitlive/firebase/firestore/DocumentReference;Ljava/lang/Object;ZZ)Ldev/gitlive/firebase/firestore/Transaction; + public final fun set (Ldev/gitlive/firebase/firestore/DocumentReference;Ljava/lang/Object;Z[Ldev/gitlive/firebase/firestore/FieldPath;)Ldev/gitlive/firebase/firestore/Transaction; + public final fun set (Ldev/gitlive/firebase/firestore/DocumentReference;Ljava/lang/Object;Z[Ljava/lang/String;)Ldev/gitlive/firebase/firestore/Transaction; + public final fun set (Ldev/gitlive/firebase/firestore/DocumentReference;Ljava/lang/Object;[Ldev/gitlive/firebase/firestore/FieldPath;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Transaction; + public final fun set (Ldev/gitlive/firebase/firestore/DocumentReference;Ljava/lang/Object;[Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Transaction; + public final fun set (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;ZLkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Transaction; + public final fun set (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;ZZ)Ldev/gitlive/firebase/firestore/Transaction; + public final fun set (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Z[Ldev/gitlive/firebase/firestore/FieldPath;)Ldev/gitlive/firebase/firestore/Transaction; + public final fun set (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Z[Ljava/lang/String;)Ldev/gitlive/firebase/firestore/Transaction; + public final fun set (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;[Ldev/gitlive/firebase/firestore/FieldPath;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Transaction; + public final fun set (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;[Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Transaction; + public static synthetic fun set$default (Ldev/gitlive/firebase/firestore/Transaction;Ldev/gitlive/firebase/firestore/DocumentReference;Ljava/lang/Object;ZLkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/Transaction; + public static synthetic fun set$default (Ldev/gitlive/firebase/firestore/Transaction;Ldev/gitlive/firebase/firestore/DocumentReference;Ljava/lang/Object;ZZILjava/lang/Object;)Ldev/gitlive/firebase/firestore/Transaction; + public static synthetic fun set$default (Ldev/gitlive/firebase/firestore/Transaction;Ldev/gitlive/firebase/firestore/DocumentReference;Ljava/lang/Object;[Ldev/gitlive/firebase/firestore/FieldPath;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/Transaction; + public static synthetic fun set$default (Ldev/gitlive/firebase/firestore/Transaction;Ldev/gitlive/firebase/firestore/DocumentReference;Ljava/lang/Object;[Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/Transaction; + public static synthetic fun set$default (Ldev/gitlive/firebase/firestore/Transaction;Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;ZLkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/Transaction; + public static synthetic fun set$default (Ldev/gitlive/firebase/firestore/Transaction;Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;ZZILjava/lang/Object;)Ldev/gitlive/firebase/firestore/Transaction; + public static synthetic fun set$default (Ldev/gitlive/firebase/firestore/Transaction;Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;[Ldev/gitlive/firebase/firestore/FieldPath;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/Transaction; + public static synthetic fun set$default (Ldev/gitlive/firebase/firestore/Transaction;Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;[Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/Transaction; + public final fun setEncoded (Ldev/gitlive/firebase/firestore/DocumentReference;Ldev/gitlive/firebase/internal/EncodedObject;Ldev/gitlive/firebase/firestore/internal/SetOptions;)Ldev/gitlive/firebase/firestore/Transaction; + public fun toString ()Ljava/lang/String; + public final fun update (Ldev/gitlive/firebase/firestore/DocumentReference;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Transaction; + public final fun update (Ldev/gitlive/firebase/firestore/DocumentReference;Ljava/lang/Object;Z)Ldev/gitlive/firebase/firestore/Transaction; + public final fun update (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Transaction; + public final fun update (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Z)Ldev/gitlive/firebase/firestore/Transaction; + public static synthetic fun update$default (Ldev/gitlive/firebase/firestore/Transaction;Ldev/gitlive/firebase/firestore/DocumentReference;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/Transaction; + public static synthetic fun update$default (Ldev/gitlive/firebase/firestore/Transaction;Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/Transaction; + public final fun updateEncoded (Ldev/gitlive/firebase/firestore/DocumentReference;Ldev/gitlive/firebase/internal/EncodedObject;)Ldev/gitlive/firebase/firestore/Transaction; + public final fun updateEncodedFieldPathsAndValues (Ldev/gitlive/firebase/firestore/DocumentReference;Ljava/util/List;)Ldev/gitlive/firebase/firestore/Transaction; + public final fun updateEncodedFieldsAndValues (Ldev/gitlive/firebase/firestore/DocumentReference;Ljava/util/List;)Ldev/gitlive/firebase/firestore/Transaction; + public final fun updateFieldPaths (Ldev/gitlive/firebase/firestore/DocumentReference;[Lkotlin/Pair;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Transaction; + public static synthetic fun updateFieldPaths$default (Ldev/gitlive/firebase/firestore/Transaction;Ldev/gitlive/firebase/firestore/DocumentReference;[Lkotlin/Pair;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/Transaction; + public final fun updateFields (Ldev/gitlive/firebase/firestore/DocumentReference;[Lkotlin/Pair;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Transaction; + public static synthetic fun updateFields$default (Ldev/gitlive/firebase/firestore/Transaction;Ldev/gitlive/firebase/firestore/DocumentReference;[Lkotlin/Pair;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/Transaction; +} + +public abstract interface class dev/gitlive/firebase/firestore/WhereConstraint { +} + +public final class dev/gitlive/firebase/firestore/WhereConstraint$ArrayContains : dev/gitlive/firebase/firestore/WhereConstraint$ForObject { + public final fun component1 ()Ljava/lang/Object; + public final fun copy (Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/WhereConstraint$ArrayContains; + public static synthetic fun copy$default (Ldev/gitlive/firebase/firestore/WhereConstraint$ArrayContains;Ljava/lang/Object;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/WhereConstraint$ArrayContains; + public fun equals (Ljava/lang/Object;)Z + public fun getSafeValue ()Ljava/lang/Object; + public fun getValue ()Ljava/lang/Object; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/firestore/WhereConstraint$ArrayContainsAny : dev/gitlive/firebase/firestore/WhereConstraint$ForArray { + public final fun component1 ()Ljava/util/List; + public final fun copy (Ljava/util/List;)Ldev/gitlive/firebase/firestore/WhereConstraint$ArrayContainsAny; + public static synthetic fun copy$default (Ldev/gitlive/firebase/firestore/WhereConstraint$ArrayContainsAny;Ljava/util/List;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/WhereConstraint$ArrayContainsAny; + public fun equals (Ljava/lang/Object;)Z + public fun getSafeValues ()Ljava/util/List; + public fun getValues ()Ljava/util/List; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/firestore/WhereConstraint$EqualTo : dev/gitlive/firebase/firestore/WhereConstraint$ForNullableObject { + public final fun component1 ()Ljava/lang/Object; + public final fun copy (Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/WhereConstraint$EqualTo; + public static synthetic fun copy$default (Ldev/gitlive/firebase/firestore/WhereConstraint$EqualTo;Ljava/lang/Object;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/WhereConstraint$EqualTo; + public fun equals (Ljava/lang/Object;)Z + public fun getSafeValue ()Ljava/lang/Object; + public fun getValue ()Ljava/lang/Object; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public abstract interface class dev/gitlive/firebase/firestore/WhereConstraint$ForArray : dev/gitlive/firebase/firestore/WhereConstraint { + public abstract fun getSafeValues ()Ljava/util/List; + public abstract fun getValues ()Ljava/util/List; +} + +public final class dev/gitlive/firebase/firestore/WhereConstraint$ForArray$DefaultImpls { + public static fun getSafeValues (Ldev/gitlive/firebase/firestore/WhereConstraint$ForArray;)Ljava/util/List; +} + +public abstract interface class dev/gitlive/firebase/firestore/WhereConstraint$ForNullableObject : dev/gitlive/firebase/firestore/WhereConstraint { + public abstract fun getSafeValue ()Ljava/lang/Object; + public abstract fun getValue ()Ljava/lang/Object; +} + +public final class dev/gitlive/firebase/firestore/WhereConstraint$ForNullableObject$DefaultImpls { + public static fun getSafeValue (Ldev/gitlive/firebase/firestore/WhereConstraint$ForNullableObject;)Ljava/lang/Object; +} + +public abstract interface class dev/gitlive/firebase/firestore/WhereConstraint$ForObject : dev/gitlive/firebase/firestore/WhereConstraint { + public abstract fun getSafeValue ()Ljava/lang/Object; + public abstract fun getValue ()Ljava/lang/Object; +} + +public final class dev/gitlive/firebase/firestore/WhereConstraint$ForObject$DefaultImpls { + public static fun getSafeValue (Ldev/gitlive/firebase/firestore/WhereConstraint$ForObject;)Ljava/lang/Object; +} + +public final class dev/gitlive/firebase/firestore/WhereConstraint$GreaterThan : dev/gitlive/firebase/firestore/WhereConstraint$ForObject { + public final fun component1 ()Ljava/lang/Object; + public final fun copy (Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/WhereConstraint$GreaterThan; + public static synthetic fun copy$default (Ldev/gitlive/firebase/firestore/WhereConstraint$GreaterThan;Ljava/lang/Object;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/WhereConstraint$GreaterThan; + public fun equals (Ljava/lang/Object;)Z + public fun getSafeValue ()Ljava/lang/Object; + public fun getValue ()Ljava/lang/Object; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/firestore/WhereConstraint$GreaterThanOrEqualTo : dev/gitlive/firebase/firestore/WhereConstraint$ForObject { + public final fun component1 ()Ljava/lang/Object; + public final fun copy (Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/WhereConstraint$GreaterThanOrEqualTo; + public static synthetic fun copy$default (Ldev/gitlive/firebase/firestore/WhereConstraint$GreaterThanOrEqualTo;Ljava/lang/Object;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/WhereConstraint$GreaterThanOrEqualTo; + public fun equals (Ljava/lang/Object;)Z + public fun getSafeValue ()Ljava/lang/Object; + public fun getValue ()Ljava/lang/Object; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/firestore/WhereConstraint$InArray : dev/gitlive/firebase/firestore/WhereConstraint$ForArray { + public final fun component1 ()Ljava/util/List; + public final fun copy (Ljava/util/List;)Ldev/gitlive/firebase/firestore/WhereConstraint$InArray; + public static synthetic fun copy$default (Ldev/gitlive/firebase/firestore/WhereConstraint$InArray;Ljava/util/List;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/WhereConstraint$InArray; + public fun equals (Ljava/lang/Object;)Z + public fun getSafeValues ()Ljava/util/List; + public fun getValues ()Ljava/util/List; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/firestore/WhereConstraint$LessThan : dev/gitlive/firebase/firestore/WhereConstraint$ForObject { + public final fun component1 ()Ljava/lang/Object; + public final fun copy (Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/WhereConstraint$LessThan; + public static synthetic fun copy$default (Ldev/gitlive/firebase/firestore/WhereConstraint$LessThan;Ljava/lang/Object;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/WhereConstraint$LessThan; + public fun equals (Ljava/lang/Object;)Z + public fun getSafeValue ()Ljava/lang/Object; + public fun getValue ()Ljava/lang/Object; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/firestore/WhereConstraint$LessThanOrEqualTo : dev/gitlive/firebase/firestore/WhereConstraint$ForObject { + public final fun component1 ()Ljava/lang/Object; + public final fun copy (Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/WhereConstraint$LessThanOrEqualTo; + public static synthetic fun copy$default (Ldev/gitlive/firebase/firestore/WhereConstraint$LessThanOrEqualTo;Ljava/lang/Object;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/WhereConstraint$LessThanOrEqualTo; + public fun equals (Ljava/lang/Object;)Z + public fun getSafeValue ()Ljava/lang/Object; + public fun getValue ()Ljava/lang/Object; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/firestore/WhereConstraint$NotEqualTo : dev/gitlive/firebase/firestore/WhereConstraint$ForNullableObject { + public final fun component1 ()Ljava/lang/Object; + public final fun copy (Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/WhereConstraint$NotEqualTo; + public static synthetic fun copy$default (Ldev/gitlive/firebase/firestore/WhereConstraint$NotEqualTo;Ljava/lang/Object;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/WhereConstraint$NotEqualTo; + public fun equals (Ljava/lang/Object;)Z + public fun getSafeValue ()Ljava/lang/Object; + public fun getValue ()Ljava/lang/Object; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/firestore/WhereConstraint$NotInArray : dev/gitlive/firebase/firestore/WhereConstraint$ForArray { + public final fun component1 ()Ljava/util/List; + public final fun copy (Ljava/util/List;)Ldev/gitlive/firebase/firestore/WhereConstraint$NotInArray; + public static synthetic fun copy$default (Ldev/gitlive/firebase/firestore/WhereConstraint$NotInArray;Ljava/util/List;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/WhereConstraint$NotInArray; + public fun equals (Ljava/lang/Object;)Z + public fun getSafeValues ()Ljava/util/List; + public fun getValues ()Ljava/util/List; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/firestore/WriteBatch { + public fun (Lcom/google/firebase/firestore/WriteBatch;)V + public final fun commit (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun copy (Ldev/gitlive/firebase/firestore/internal/NativeWriteBatchWrapper;)Ldev/gitlive/firebase/firestore/WriteBatch; + public static synthetic fun copy$default (Ldev/gitlive/firebase/firestore/WriteBatch;Ldev/gitlive/firebase/firestore/internal/NativeWriteBatchWrapper;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/WriteBatch; + public final fun delete (Ldev/gitlive/firebase/firestore/DocumentReference;)Ldev/gitlive/firebase/firestore/WriteBatch; + public fun equals (Ljava/lang/Object;)Z + public final fun getNative ()Lcom/google/firebase/firestore/WriteBatch; + public final fun getNativeWrapper ()Ldev/gitlive/firebase/firestore/internal/NativeWriteBatchWrapper; + public fun hashCode ()I + public final fun set (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;ZLkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/WriteBatch; + public final fun set (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;ZZ)Ldev/gitlive/firebase/firestore/WriteBatch; + public final fun set (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Z[Ldev/gitlive/firebase/firestore/FieldPath;)Ldev/gitlive/firebase/firestore/WriteBatch; + public final fun set (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Z[Ljava/lang/String;)Ldev/gitlive/firebase/firestore/WriteBatch; + public final fun set (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;[Ldev/gitlive/firebase/firestore/FieldPath;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/WriteBatch; + public final fun set (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;[Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/WriteBatch; + public static synthetic fun set$default (Ldev/gitlive/firebase/firestore/WriteBatch;Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;ZLkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/WriteBatch; + public static synthetic fun set$default (Ldev/gitlive/firebase/firestore/WriteBatch;Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;ZZILjava/lang/Object;)Ldev/gitlive/firebase/firestore/WriteBatch; + public static synthetic fun set$default (Ldev/gitlive/firebase/firestore/WriteBatch;Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;[Ldev/gitlive/firebase/firestore/FieldPath;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/WriteBatch; + public static synthetic fun set$default (Ldev/gitlive/firebase/firestore/WriteBatch;Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;[Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/WriteBatch; + public final fun setEncoded (Ldev/gitlive/firebase/firestore/DocumentReference;Ldev/gitlive/firebase/internal/EncodedObject;Ldev/gitlive/firebase/firestore/internal/SetOptions;)Ldev/gitlive/firebase/firestore/WriteBatch; + public fun toString ()Ljava/lang/String; + public final fun update (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/WriteBatch; + public final fun update (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Z)Ldev/gitlive/firebase/firestore/WriteBatch; + public static synthetic fun update$default (Ldev/gitlive/firebase/firestore/WriteBatch;Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/WriteBatch; + public final fun updateEncoded (Ldev/gitlive/firebase/firestore/DocumentReference;Ldev/gitlive/firebase/internal/EncodedObject;)Ldev/gitlive/firebase/firestore/WriteBatch; + public final fun updateEncodedFieldPathsAndValues (Ldev/gitlive/firebase/firestore/DocumentReference;Ljava/util/List;)Ldev/gitlive/firebase/firestore/WriteBatch; + public final fun updateEncodedFieldsAndValues (Ldev/gitlive/firebase/firestore/DocumentReference;Ljava/util/List;)Ldev/gitlive/firebase/firestore/WriteBatch; + public final fun updateField (Ldev/gitlive/firebase/firestore/DocumentReference;[Lkotlin/Pair;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/WriteBatch; + public static synthetic fun updateField$default (Ldev/gitlive/firebase/firestore/WriteBatch;Ldev/gitlive/firebase/firestore/DocumentReference;[Lkotlin/Pair;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/WriteBatch; + public final fun updateFieldPath (Ldev/gitlive/firebase/firestore/DocumentReference;[Lkotlin/Pair;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/WriteBatch; + public static synthetic fun updateFieldPath$default (Ldev/gitlive/firebase/firestore/WriteBatch;Ldev/gitlive/firebase/firestore/DocumentReference;[Lkotlin/Pair;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/WriteBatch; +} + +public final class dev/gitlive/firebase/firestore/_encodersKt { + public static final fun isSpecialValue (Ljava/lang/Object;)Z +} + +public final class dev/gitlive/firebase/firestore/android { + public static final fun firestore (Ldev/gitlive/firebase/Firebase;Ldev/gitlive/firebase/FirebaseApp;)Ldev/gitlive/firebase/firestore/FirebaseFirestore; + public static final fun firestoreSettings (Ldev/gitlive/firebase/firestore/FirebaseFirestoreSettings;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/FirebaseFirestoreSettings; + public static synthetic fun firestoreSettings$default (Ldev/gitlive/firebase/firestore/FirebaseFirestoreSettings;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/FirebaseFirestoreSettings; + public static final fun getAndroid (Ldev/gitlive/firebase/firestore/CollectionReference;)Lcom/google/firebase/firestore/CollectionReference; + public static final fun getAndroid (Ldev/gitlive/firebase/firestore/DocumentReference;)Lcom/google/firebase/firestore/DocumentReference; + public static final fun getAndroid (Ldev/gitlive/firebase/firestore/DocumentSnapshot;)Lcom/google/firebase/firestore/DocumentSnapshot; + public static final fun getAndroid (Ldev/gitlive/firebase/firestore/FirebaseFirestore;)Lcom/google/firebase/firestore/FirebaseFirestore; + public static final fun getAndroid (Ldev/gitlive/firebase/firestore/LocalCacheSettings;)Lcom/google/firebase/firestore/LocalCacheSettings; + public static final fun getAndroid (Ldev/gitlive/firebase/firestore/Query;)Lcom/google/firebase/firestore/Query; + public static final fun getAndroid (Ldev/gitlive/firebase/firestore/Transaction;)Lcom/google/firebase/firestore/Transaction; + public static final fun getAndroid (Ldev/gitlive/firebase/firestore/WriteBatch;)Lcom/google/firebase/firestore/WriteBatch; + public static final fun getCode (Lcom/google/firebase/firestore/FirebaseFirestoreException;)Lcom/google/firebase/firestore/FirebaseFirestoreException$Code; + public static final fun getFirestore (Ldev/gitlive/firebase/Firebase;)Ldev/gitlive/firebase/firestore/FirebaseFirestore; +} + +public final class dev/gitlive/firebase/firestore/internal/NativeCollectionReferenceWrapper : dev/gitlive/firebase/firestore/internal/NativeQueryWrapper { + public final fun addEncoded (Ldev/gitlive/firebase/internal/EncodedObject;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun document (Ljava/lang/String;)Ldev/gitlive/firebase/firestore/internal/NativeDocumentReference; + public final fun getDocument ()Ldev/gitlive/firebase/firestore/internal/NativeDocumentReference; + public fun getNative ()Lcom/google/firebase/firestore/CollectionReference; + public synthetic fun getNative ()Lcom/google/firebase/firestore/Query; + public final fun getParent ()Ldev/gitlive/firebase/firestore/internal/NativeDocumentReference; + public final fun getPath ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/firestore/internal/NativeDocumentReference { + public fun (Lcom/google/firebase/firestore/DocumentReference;)V + public final fun collection (Ljava/lang/String;)Lcom/google/firebase/firestore/CollectionReference; + public final fun delete (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public fun equals (Ljava/lang/Object;)Z + public final fun get (Ldev/gitlive/firebase/firestore/Source;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static synthetic fun get$default (Ldev/gitlive/firebase/firestore/internal/NativeDocumentReference;Ldev/gitlive/firebase/firestore/Source;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; + public final fun getAndroid ()Lcom/google/firebase/firestore/DocumentReference; + public final fun getId ()Ljava/lang/String; + public final fun getNativeValue ()Lcom/google/firebase/firestore/DocumentReference; + public final fun getParent ()Ldev/gitlive/firebase/firestore/internal/NativeCollectionReferenceWrapper; + public final fun getPath ()Ljava/lang/String; + public final fun getSnapshots ()Lkotlinx/coroutines/flow/Flow; + public fun hashCode ()I + public final fun setEncoded (Ldev/gitlive/firebase/internal/EncodedObject;Ldev/gitlive/firebase/firestore/internal/SetOptions;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun snapshots (Z)Lkotlinx/coroutines/flow/Flow; + public static synthetic fun snapshots$default (Ldev/gitlive/firebase/firestore/internal/NativeDocumentReference;ZILjava/lang/Object;)Lkotlinx/coroutines/flow/Flow; + public fun toString ()Ljava/lang/String; + public final fun updateEncoded (Ldev/gitlive/firebase/internal/EncodedObject;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun updateEncodedFieldPathsAndValues (Ljava/util/List;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun updateEncodedFieldsAndValues (Ljava/util/List;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; +} + +public final class dev/gitlive/firebase/firestore/internal/NativeDocumentSnapshotWrapper { + public final fun contains (Lcom/google/firebase/firestore/FieldPath;)Z + public final fun contains (Ljava/lang/String;)Z + public final fun encodedData (Ldev/gitlive/firebase/firestore/ServerTimestampBehavior;)Ljava/lang/Object; + public static synthetic fun encodedData$default (Ldev/gitlive/firebase/firestore/internal/NativeDocumentSnapshotWrapper;Ldev/gitlive/firebase/firestore/ServerTimestampBehavior;ILjava/lang/Object;)Ljava/lang/Object; + public final fun getEncoded (Lcom/google/firebase/firestore/FieldPath;Ldev/gitlive/firebase/firestore/ServerTimestampBehavior;)Ljava/lang/Object; + public final fun getEncoded (Ljava/lang/String;Ldev/gitlive/firebase/firestore/ServerTimestampBehavior;)Ljava/lang/Object; + public static synthetic fun getEncoded$default (Ldev/gitlive/firebase/firestore/internal/NativeDocumentSnapshotWrapper;Lcom/google/firebase/firestore/FieldPath;Ldev/gitlive/firebase/firestore/ServerTimestampBehavior;ILjava/lang/Object;)Ljava/lang/Object; + public static synthetic fun getEncoded$default (Ldev/gitlive/firebase/firestore/internal/NativeDocumentSnapshotWrapper;Ljava/lang/String;Ldev/gitlive/firebase/firestore/ServerTimestampBehavior;ILjava/lang/Object;)Ljava/lang/Object; + public final fun getExists ()Z + public final fun getId ()Ljava/lang/String; + public final fun getMetadata ()Ldev/gitlive/firebase/firestore/SnapshotMetadata; + public final fun getNative ()Lcom/google/firebase/firestore/DocumentSnapshot; + public final fun getReference ()Ldev/gitlive/firebase/firestore/internal/NativeDocumentReference; + public final fun toAndroid (Ldev/gitlive/firebase/firestore/ServerTimestampBehavior;)Lcom/google/firebase/firestore/DocumentSnapshot$ServerTimestampBehavior; +} + +public class dev/gitlive/firebase/firestore/internal/NativeQueryWrapper { + public final fun endAt (Lcom/google/firebase/firestore/DocumentSnapshot;)Lcom/google/firebase/firestore/Query; + public final fun endAt ([Ljava/lang/Object;)Lcom/google/firebase/firestore/Query; + public final fun endBefore (Lcom/google/firebase/firestore/DocumentSnapshot;)Lcom/google/firebase/firestore/Query; + public final fun endBefore ([Ljava/lang/Object;)Lcom/google/firebase/firestore/Query; + public final fun get (Ldev/gitlive/firebase/firestore/Source;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static synthetic fun get$default (Ldev/gitlive/firebase/firestore/internal/NativeQueryWrapper;Ldev/gitlive/firebase/firestore/Source;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; + public fun getNative ()Lcom/google/firebase/firestore/Query; + public final fun getSnapshots ()Lkotlinx/coroutines/flow/Flow; + public final fun limit (Ljava/lang/Number;)Lcom/google/firebase/firestore/Query; + public final fun orderBy (Lcom/google/firebase/firestore/FieldPath;Lcom/google/firebase/firestore/Query$Direction;)Lcom/google/firebase/firestore/Query; + public final fun orderBy (Ljava/lang/String;Lcom/google/firebase/firestore/Query$Direction;)Lcom/google/firebase/firestore/Query; + public final fun snapshots (Z)Lkotlinx/coroutines/flow/Flow; + public static synthetic fun snapshots$default (Ldev/gitlive/firebase/firestore/internal/NativeQueryWrapper;ZILjava/lang/Object;)Lkotlinx/coroutines/flow/Flow; + public final fun startAfter (Lcom/google/firebase/firestore/DocumentSnapshot;)Lcom/google/firebase/firestore/Query; + public final fun startAfter ([Ljava/lang/Object;)Lcom/google/firebase/firestore/Query; + public final fun startAt (Lcom/google/firebase/firestore/DocumentSnapshot;)Lcom/google/firebase/firestore/Query; + public final fun startAt ([Ljava/lang/Object;)Lcom/google/firebase/firestore/Query; + public final fun where (Ldev/gitlive/firebase/firestore/Filter;)Lcom/google/firebase/firestore/Query; +} + +public final class dev/gitlive/firebase/firestore/internal/NativeTransactionWrapper { + public final fun delete (Ldev/gitlive/firebase/firestore/DocumentReference;)Ldev/gitlive/firebase/firestore/internal/NativeTransactionWrapper; + public final fun get (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun getNative ()Lcom/google/firebase/firestore/Transaction; + public final fun setEncoded (Ldev/gitlive/firebase/firestore/DocumentReference;Ldev/gitlive/firebase/internal/EncodedObject;Ldev/gitlive/firebase/firestore/internal/SetOptions;)Ldev/gitlive/firebase/firestore/internal/NativeTransactionWrapper; + public final fun updateEncoded (Ldev/gitlive/firebase/firestore/DocumentReference;Ldev/gitlive/firebase/internal/EncodedObject;)Ldev/gitlive/firebase/firestore/internal/NativeTransactionWrapper; + public final fun updateEncodedFieldPathsAndValues (Ldev/gitlive/firebase/firestore/DocumentReference;Ljava/util/List;)Ldev/gitlive/firebase/firestore/internal/NativeTransactionWrapper; + public final fun updateEncodedFieldsAndValues (Ldev/gitlive/firebase/firestore/DocumentReference;Ljava/util/List;)Ldev/gitlive/firebase/firestore/internal/NativeTransactionWrapper; +} + +public final class dev/gitlive/firebase/firestore/internal/NativeWriteBatchWrapper { + public final fun commit (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun delete (Ldev/gitlive/firebase/firestore/DocumentReference;)Ldev/gitlive/firebase/firestore/internal/NativeWriteBatchWrapper; + public final fun getNative ()Lcom/google/firebase/firestore/WriteBatch; + public final fun setEncoded (Ldev/gitlive/firebase/firestore/DocumentReference;Ldev/gitlive/firebase/internal/EncodedObject;Ldev/gitlive/firebase/firestore/internal/SetOptions;)Ldev/gitlive/firebase/firestore/internal/NativeWriteBatchWrapper; + public final fun updateEncoded (Ldev/gitlive/firebase/firestore/DocumentReference;Ldev/gitlive/firebase/internal/EncodedObject;)Ldev/gitlive/firebase/firestore/internal/NativeWriteBatchWrapper; + public final fun updateEncodedFieldPathsAndValues (Ldev/gitlive/firebase/firestore/DocumentReference;Ljava/util/List;)Ldev/gitlive/firebase/firestore/internal/NativeWriteBatchWrapper; + public final fun updateEncodedFieldsAndValues (Ldev/gitlive/firebase/firestore/DocumentReference;Ljava/util/List;)Ldev/gitlive/firebase/firestore/internal/NativeWriteBatchWrapper; +} + +public abstract class dev/gitlive/firebase/firestore/internal/SetOptions { +} + +public final class dev/gitlive/firebase/firestore/internal/SetOptions$Merge : dev/gitlive/firebase/firestore/internal/SetOptions { + public static final field INSTANCE Ldev/gitlive/firebase/firestore/internal/SetOptions$Merge; + public fun equals (Ljava/lang/Object;)Z + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/firestore/internal/SetOptions$MergeFieldPaths : dev/gitlive/firebase/firestore/internal/SetOptions { + public fun (Ljava/util/List;)V + public final fun component1 ()Ljava/util/List; + public final fun copy (Ljava/util/List;)Ldev/gitlive/firebase/firestore/internal/SetOptions$MergeFieldPaths; + public static synthetic fun copy$default (Ldev/gitlive/firebase/firestore/internal/SetOptions$MergeFieldPaths;Ljava/util/List;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/internal/SetOptions$MergeFieldPaths; + public fun equals (Ljava/lang/Object;)Z + public final fun getEncodedFieldPaths ()Ljava/util/List; + public final fun getFieldPaths ()Ljava/util/List; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/firestore/internal/SetOptions$MergeFields : dev/gitlive/firebase/firestore/internal/SetOptions { + public fun (Ljava/util/List;)V + public final fun component1 ()Ljava/util/List; + public final fun copy (Ljava/util/List;)Ldev/gitlive/firebase/firestore/internal/SetOptions$MergeFields; + public static synthetic fun copy$default (Ldev/gitlive/firebase/firestore/internal/SetOptions$MergeFields;Ljava/util/List;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/internal/SetOptions$MergeFields; + public fun equals (Ljava/lang/Object;)Z + public final fun getFields ()Ljava/util/List; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/firestore/internal/SetOptions$Overwrite : dev/gitlive/firebase/firestore/internal/SetOptions { + public static final field INSTANCE Ldev/gitlive/firebase/firestore/internal/SetOptions$Overwrite; + public fun equals (Ljava/lang/Object;)Z + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + diff --git a/firebase-firestore/build.gradle.kts b/firebase-firestore/build.gradle.kts index 5d7c5a714..3cf3d1c71 100644 --- a/firebase-firestore/build.gradle.kts +++ b/firebase-firestore/build.gradle.kts @@ -50,6 +50,8 @@ android { val supportIosTarget = project.property("skipIosTarget") != "true" kotlin { + explicitApi() + @OptIn(ExperimentalKotlinGradlePluginApi::class) compilerOptions { freeCompilerArgs.add("-Xexpect-actual-classes") diff --git a/firebase-firestore/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/firestore/Ignore.kt b/firebase-firestore/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/firestore/Ignore.kt index 1f70d3731..e484ad9f6 100644 --- a/firebase-firestore/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/firestore/Ignore.kt +++ b/firebase-firestore/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/firestore/Ignore.kt @@ -2,5 +2,6 @@ package dev.gitlive.firebase.firestore @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) actual annotation class IgnoreJs + @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) actual annotation class IgnoreForAndroidUnitTest diff --git a/firebase-firestore/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt b/firebase-firestore/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt index 143c1f350..ca3a160c8 100644 --- a/firebase-firestore/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt +++ b/firebase-firestore/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt @@ -3,6 +3,7 @@ */ @file:JvmName("tests") + package dev.gitlive.firebase.firestore import androidx.test.platform.app.InstrumentationRegistry diff --git a/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/FieldValue.kt b/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/FieldValue.kt index f5f2cee34..2c324b45f 100644 --- a/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/FieldValue.kt +++ b/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/FieldValue.kt @@ -3,11 +3,11 @@ package dev.gitlive.firebase.firestore import kotlinx.serialization.Serializable /** Represents a platform specific Firebase FieldValue. */ -typealias NativeFieldValue = com.google.firebase.firestore.FieldValue +public typealias NativeFieldValue = com.google.firebase.firestore.FieldValue /** Represents a Firebase FieldValue. */ @Serializable(with = FieldValueSerializer::class) -actual class FieldValue internal actual constructor(internal actual val nativeValue: Any) { +public actual class FieldValue internal actual constructor(internal actual val nativeValue: Any) { init { require(nativeValue is NativeFieldValue) } @@ -16,11 +16,11 @@ actual class FieldValue internal actual constructor(internal actual val nativeVa override fun hashCode(): Int = nativeValue.hashCode() override fun toString(): String = nativeValue.toString() - actual companion object { - actual val serverTimestamp: FieldValue get() = FieldValue(NativeFieldValue.serverTimestamp()) - actual val delete: FieldValue get() = FieldValue(NativeFieldValue.delete()) - actual fun increment(value: Int): FieldValue = FieldValue(NativeFieldValue.increment(value.toDouble())) - actual fun arrayUnion(vararg elements: Any): FieldValue = FieldValue(NativeFieldValue.arrayUnion(*elements)) - actual fun arrayRemove(vararg elements: Any): FieldValue = FieldValue(NativeFieldValue.arrayRemove(*elements)) + public actual companion object { + public actual val serverTimestamp: FieldValue get() = FieldValue(NativeFieldValue.serverTimestamp()) + public actual val delete: FieldValue get() = FieldValue(NativeFieldValue.delete()) + public actual fun increment(value: Int): FieldValue = FieldValue(NativeFieldValue.increment(value.toDouble())) + public actual fun arrayUnion(vararg elements: Any): FieldValue = FieldValue(NativeFieldValue.arrayUnion(*elements)) + public actual fun arrayRemove(vararg elements: Any): FieldValue = FieldValue(NativeFieldValue.arrayRemove(*elements)) } } diff --git a/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/GeoPoint.kt b/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/GeoPoint.kt index 7523619f5..dcf73b20d 100644 --- a/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/GeoPoint.kt +++ b/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/GeoPoint.kt @@ -3,14 +3,14 @@ package dev.gitlive.firebase.firestore import kotlinx.serialization.Serializable /** A class representing a platform specific Firebase GeoPoint. */ -actual typealias NativeGeoPoint = com.google.firebase.firestore.GeoPoint +public actual typealias NativeGeoPoint = com.google.firebase.firestore.GeoPoint /** A class representing a Firebase GeoPoint. */ @Serializable(with = GeoPointSerializer::class) -actual class GeoPoint internal actual constructor(internal actual val nativeValue: NativeGeoPoint) { - actual constructor(latitude: Double, longitude: Double) : this(NativeGeoPoint(latitude, longitude)) - actual val latitude: Double = nativeValue.latitude - actual val longitude: Double = nativeValue.longitude +public actual class GeoPoint internal actual constructor(internal actual val nativeValue: NativeGeoPoint) { + public actual constructor(latitude: Double, longitude: Double) : this(NativeGeoPoint(latitude, longitude)) + public actual val latitude: Double = nativeValue.latitude + public actual val longitude: Double = nativeValue.longitude override fun equals(other: Any?): Boolean = this === other || other is GeoPoint && nativeValue == other.nativeValue diff --git a/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/Timestamp.kt b/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/Timestamp.kt index cc9a2ddb9..61388745b 100644 --- a/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/Timestamp.kt +++ b/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/Timestamp.kt @@ -1,35 +1,36 @@ @file:JvmName("androidTimestamp") + package dev.gitlive.firebase.firestore import kotlinx.serialization.Serializable /** A class representing a platform specific Firebase Timestamp. */ -actual typealias NativeTimestamp = com.google.firebase.Timestamp +public actual typealias NativeTimestamp = com.google.firebase.Timestamp /** A base class that could be used to combine [Timestamp] and [Timestamp.ServerTimestamp] in the same field. */ @Serializable(with = BaseTimestampSerializer::class) -actual sealed class BaseTimestamp +public actual sealed class BaseTimestamp /** A class representing a Firebase Timestamp. */ @Serializable(with = TimestampSerializer::class) -actual class Timestamp internal actual constructor( - internal actual val nativeValue: NativeTimestamp -): BaseTimestamp() { - actual constructor(seconds: Long, nanoseconds: Int) : this(NativeTimestamp(seconds, nanoseconds)) +public actual class Timestamp internal actual constructor( + internal actual val nativeValue: NativeTimestamp, +) : BaseTimestamp() { + public actual constructor(seconds: Long, nanoseconds: Int) : this(NativeTimestamp(seconds, nanoseconds)) - actual val seconds: Long = nativeValue.seconds - actual val nanoseconds: Int = nativeValue.nanoseconds + public actual val seconds: Long = nativeValue.seconds + public actual val nanoseconds: Int = nativeValue.nanoseconds override fun equals(other: Any?): Boolean = this === other || other is Timestamp && nativeValue == other.nativeValue override fun hashCode(): Int = nativeValue.hashCode() override fun toString(): String = nativeValue.toString() - actual companion object { - actual fun now(): Timestamp = Timestamp(NativeTimestamp.now()) + public actual companion object { + public actual fun now(): Timestamp = Timestamp(NativeTimestamp.now()) } /** A server time timestamp. */ @Serializable(with = ServerTimestampSerializer::class) - actual object ServerTimestamp: BaseTimestamp() + public actual data object ServerTimestamp : BaseTimestamp() } diff --git a/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/_encoders.kt b/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/_encoders.kt index 84445fb4d..a1e313dd6 100644 --- a/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/_encoders.kt +++ b/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/_encoders.kt @@ -1,10 +1,11 @@ package dev.gitlive.firebase.firestore @PublishedApi -internal actual fun isSpecialValue(value: Any) = when(value) { +internal actual fun isSpecialValue(value: Any): Boolean = when (value) { is NativeFieldValue, is NativeGeoPoint, is NativeTimestamp, - is NativeDocumentReferenceType -> true + is NativeDocumentReferenceType, + -> true else -> false } diff --git a/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt b/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt index e190cd5a6..d5650382f 100644 --- a/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt +++ b/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt @@ -3,6 +3,7 @@ */ @file:JvmName("android") + package dev.gitlive.firebase.firestore import com.google.android.gms.tasks.TaskExecutors @@ -16,154 +17,155 @@ import com.google.firebase.firestore.memoryEagerGcSettings as androidMemoryEager import com.google.firebase.firestore.memoryLruGcSettings as androidMemoryLruGcSettings import com.google.firebase.firestore.persistentCacheSettings as androidPersistentCacheSettings -actual val Firebase.firestore get() = +public actual val Firebase.firestore: FirebaseFirestore get() = FirebaseFirestore(com.google.firebase.firestore.FirebaseFirestore.getInstance()) -actual fun Firebase.firestore(app: FirebaseApp) = +public actual fun Firebase.firestore(app: FirebaseApp): FirebaseFirestore = FirebaseFirestore(com.google.firebase.firestore.FirebaseFirestore.getInstance(app.android)) -val LocalCacheSettings.android: com.google.firebase.firestore.LocalCacheSettings get() = when (this) { +public val LocalCacheSettings.android: com.google.firebase.firestore.LocalCacheSettings get() = when (this) { is LocalCacheSettings.Persistent -> androidPersistentCacheSettings { setSizeBytes(sizeBytes) } is LocalCacheSettings.Memory -> androidMemoryCacheSettings { setGcSettings( when (garbaseCollectorSettings) { - is MemoryGarbageCollectorSettings.Eager -> androidMemoryEagerGcSettings { } + is MemoryGarbageCollectorSettings.Eager -> androidMemoryEagerGcSettings { } is MemoryGarbageCollectorSettings.LRUGC -> androidMemoryLruGcSettings { setSizeBytes(garbaseCollectorSettings.sizeBytes) } - } + }, ) } } -actual typealias NativeFirebaseFirestore = com.google.firebase.firestore.FirebaseFirestore +public actual typealias NativeFirebaseFirestore = com.google.firebase.firestore.FirebaseFirestore -val FirebaseFirestore.android get() = native +public val FirebaseFirestore.android: NativeFirebaseFirestore get() = native -actual data class FirebaseFirestoreSettings( +public actual data class FirebaseFirestoreSettings( actual val sslEnabled: Boolean, actual val host: String, actual val cacheSettings: LocalCacheSettings, val callbackExecutor: Executor, ) { - actual companion object { - actual val CACHE_SIZE_UNLIMITED: Long = -1L + public actual companion object { + public actual val CACHE_SIZE_UNLIMITED: Long = -1L internal actual val DEFAULT_HOST: String = "firestore.googleapis.com" internal actual val MINIMUM_CACHE_BYTES: Long = 1 * 1024 * 1024 internal actual val DEFAULT_CACHE_SIZE_BYTES: Long = 100 * 1024 * 1024 } - actual class Builder internal constructor( - actual var sslEnabled: Boolean, - actual var host: String, - actual var cacheSettings: LocalCacheSettings, - var callbackExecutor: Executor, + public actual class Builder internal constructor( + public actual var sslEnabled: Boolean, + public actual var host: String, + public actual var cacheSettings: LocalCacheSettings, + public var callbackExecutor: Executor, ) { - actual constructor() : this( + public actual constructor() : this( true, DEFAULT_HOST, - persistentCacheSettings { }, - TaskExecutors.MAIN_THREAD + persistentCacheSettings { }, + TaskExecutors.MAIN_THREAD, ) - actual constructor(settings: FirebaseFirestoreSettings) : this(settings.sslEnabled, settings.host, settings.cacheSettings, settings.callbackExecutor) + public actual constructor(settings: FirebaseFirestoreSettings) : this(settings.sslEnabled, settings.host, settings.cacheSettings, settings.callbackExecutor) - actual fun build(): FirebaseFirestoreSettings = FirebaseFirestoreSettings(sslEnabled, host, cacheSettings, callbackExecutor) + public actual fun build(): FirebaseFirestoreSettings = FirebaseFirestoreSettings(sslEnabled, host, cacheSettings, callbackExecutor) } } -actual fun firestoreSettings( +public actual fun firestoreSettings( settings: FirebaseFirestoreSettings?, - builder: FirebaseFirestoreSettings.Builder.() -> Unit + builder: FirebaseFirestoreSettings.Builder.() -> Unit, ): FirebaseFirestoreSettings = FirebaseFirestoreSettings.Builder().apply { - settings?.let { - sslEnabled = it.sslEnabled - host = it.host - cacheSettings = it.cacheSettings - callbackExecutor = it.callbackExecutor - } - }.apply(builder).build() + settings?.let { + sslEnabled = it.sslEnabled + host = it.host + cacheSettings = it.cacheSettings + callbackExecutor = it.callbackExecutor + } +}.apply(builder).build() -actual typealias NativeWriteBatch = com.google.firebase.firestore.WriteBatch +public actual typealias NativeWriteBatch = com.google.firebase.firestore.WriteBatch -val WriteBatch.android get() = native +public val WriteBatch.android: NativeWriteBatch get() = native -actual typealias NativeTransaction = com.google.firebase.firestore.Transaction +public actual typealias NativeTransaction = com.google.firebase.firestore.Transaction -val Transaction.android get() = native +public val Transaction.android: NativeTransaction get() = native /** A class representing a platform specific Firebase DocumentReference. */ -actual typealias NativeDocumentReferenceType = com.google.firebase.firestore.DocumentReference +public actual typealias NativeDocumentReferenceType = com.google.firebase.firestore.DocumentReference -val DocumentReference.android get() = native.android +public val DocumentReference.android: NativeDocumentReferenceType get() = native.android -actual typealias NativeQuery = AndroidQuery +public actual typealias NativeQuery = AndroidQuery -val Query.android get() = native +public val Query.android: NativeQuery get() = native -actual typealias Direction = com.google.firebase.firestore.Query.Direction -actual typealias ChangeType = com.google.firebase.firestore.DocumentChange.Type +public actual typealias Direction = com.google.firebase.firestore.Query.Direction +public actual typealias ChangeType = com.google.firebase.firestore.DocumentChange.Type -actual typealias NativeCollectionReference = com.google.firebase.firestore.CollectionReference +public actual typealias NativeCollectionReference = com.google.firebase.firestore.CollectionReference -val CollectionReference.android get() = native +public val CollectionReference.android: NativeCollectionReference get() = native -actual typealias FirebaseFirestoreException = com.google.firebase.firestore.FirebaseFirestoreException +public actual typealias FirebaseFirestoreException = com.google.firebase.firestore.FirebaseFirestoreException -actual val FirebaseFirestoreException.code: FirestoreExceptionCode get() = code +@Suppress("ConflictingExtensionProperty") +public actual val FirebaseFirestoreException.code: FirestoreExceptionCode get() = code -actual typealias FirestoreExceptionCode = com.google.firebase.firestore.FirebaseFirestoreException.Code +public actual typealias FirestoreExceptionCode = com.google.firebase.firestore.FirebaseFirestoreException.Code -actual class QuerySnapshot(val android: com.google.firebase.firestore.QuerySnapshot) { - actual val documents +public actual class QuerySnapshot(public val android: com.google.firebase.firestore.QuerySnapshot) { + public actual val documents: List get() = android.documents.map { DocumentSnapshot(NativeDocumentSnapshotWrapper(it)) } - actual val documentChanges + public actual val documentChanges: List get() = android.documentChanges.map { DocumentChange(it) } - actual val metadata: SnapshotMetadata get() = SnapshotMetadata(android.metadata) + public actual val metadata: SnapshotMetadata get() = SnapshotMetadata(android.metadata) } -actual class DocumentChange(val android: com.google.firebase.firestore.DocumentChange) { - actual val document: DocumentSnapshot +public actual class DocumentChange(public val android: com.google.firebase.firestore.DocumentChange) { + public actual val document: DocumentSnapshot get() = DocumentSnapshot(NativeDocumentSnapshotWrapper(android.document)) - actual val newIndex: Int + public actual val newIndex: Int get() = android.newIndex - actual val oldIndex: Int + public actual val oldIndex: Int get() = android.oldIndex - actual val type: ChangeType + public actual val type: ChangeType get() = android.type } -actual typealias NativeDocumentSnapshot = com.google.firebase.firestore.DocumentSnapshot +public actual typealias NativeDocumentSnapshot = com.google.firebase.firestore.DocumentSnapshot -val DocumentSnapshot.android get() = native +public val DocumentSnapshot.android: NativeDocumentSnapshot get() = native -actual class SnapshotMetadata(val android: com.google.firebase.firestore.SnapshotMetadata) { - actual val hasPendingWrites: Boolean get() = android.hasPendingWrites() - actual val isFromCache: Boolean get() = android.isFromCache +public actual class SnapshotMetadata(public val android: com.google.firebase.firestore.SnapshotMetadata) { + public actual val hasPendingWrites: Boolean get() = android.hasPendingWrites() + public actual val isFromCache: Boolean get() = android.isFromCache } -actual class FieldPath private constructor(val android: com.google.firebase.firestore.FieldPath) { +public actual class FieldPath private constructor(public val android: com.google.firebase.firestore.FieldPath) { - actual companion object { - actual val documentId = FieldPath(com.google.firebase.firestore.FieldPath.documentId()) + public actual companion object { + public actual val documentId: FieldPath = FieldPath(com.google.firebase.firestore.FieldPath.documentId()) } - actual constructor(vararg fieldNames: String) : this( + public actual constructor(vararg fieldNames: String) : this( com.google.firebase.firestore.FieldPath.of( - *fieldNames - ) + *fieldNames, + ), ) - actual val documentId: FieldPath get() = FieldPath.documentId - actual val encoded: EncodedFieldPath = android + public actual val documentId: FieldPath get() = FieldPath.documentId + public actual val encoded: EncodedFieldPath = android override fun equals(other: Any?): Boolean = other is FieldPath && android == other.android override fun hashCode(): Int = android.hashCode() override fun toString(): String = android.toString() } -actual typealias EncodedFieldPath = com.google.firebase.firestore.FieldPath +public actual typealias EncodedFieldPath = com.google.firebase.firestore.FieldPath internal typealias NativeSource = com.google.firebase.firestore.Source diff --git a/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeCollectionReferenceWrapper.kt b/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeCollectionReferenceWrapper.kt index 0d41e1e13..ff83740db 100644 --- a/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeCollectionReferenceWrapper.kt +++ b/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeCollectionReferenceWrapper.kt @@ -15,11 +15,11 @@ internal actual class NativeCollectionReferenceWrapper internal actual construct get() = NativeDocumentReference(native.document()) actual val parent: NativeDocumentReference? - get() = native.parent?.let{ NativeDocumentReference(it) } + get() = native.parent?.let { NativeDocumentReference(it) } actual fun document(documentPath: String) = NativeDocumentReference(native.document(documentPath)) actual suspend fun addEncoded(data: EncodedObject) = NativeDocumentReference(native.add(data.android).await()) -} \ No newline at end of file +} diff --git a/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentReference.kt b/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentReference.kt index b0553e921..949d3b821 100644 --- a/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentReference.kt +++ b/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentReference.kt @@ -33,9 +33,11 @@ internal actual class NativeDocumentReference actual constructor(actual val nati android.get(source.toAndroidSource()).await() actual suspend fun setEncoded(encodedData: EncodedObject, setOptions: SetOptions) { - val task = (setOptions.android?.let { - android.set(encodedData.android, it) - } ?: android.set(encodedData.android)) + val task = ( + setOptions.android?.let { + android.set(encodedData.android, it) + } ?: android.set(encodedData.android) + ) task.await() } @@ -74,7 +76,7 @@ internal actual class NativeDocumentReference actual constructor(actual val nati private fun addSnapshotListener( includeMetadataChanges: Boolean = false, - listener: ProducerScope.(com.google.firebase.firestore.DocumentSnapshot?, com.google.firebase.firestore.FirebaseFirestoreException?) -> Unit + listener: ProducerScope.(com.google.firebase.firestore.DocumentSnapshot?, com.google.firebase.firestore.FirebaseFirestoreException?) -> Unit, ) = callbackFlow { val executor = callbackExecutorMap[android.firestore] ?: TaskExecutors.MAIN_THREAD val metadataChanges = @@ -85,4 +87,4 @@ internal actual class NativeDocumentReference actual constructor(actual val nati } awaitClose { registration.remove() } } -} \ No newline at end of file +} diff --git a/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentSnapshotWrapper.kt b/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentSnapshotWrapper.kt index 70ec6128b..825e65f8b 100644 --- a/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentSnapshotWrapper.kt +++ b/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentSnapshotWrapper.kt @@ -5,7 +5,7 @@ import dev.gitlive.firebase.firestore.ServerTimestampBehavior import dev.gitlive.firebase.firestore.SnapshotMetadata @PublishedApi -internal actual class NativeDocumentSnapshotWrapper actual internal constructor(actual val native: com.google.firebase.firestore.DocumentSnapshot) { +internal actual class NativeDocumentSnapshotWrapper internal actual constructor(actual val native: com.google.firebase.firestore.DocumentSnapshot) { actual val id get() = native.id actual val reference get() = NativeDocumentReference(native.reference) @@ -26,4 +26,4 @@ internal actual class NativeDocumentSnapshotWrapper actual internal constructor( ServerTimestampBehavior.NONE -> com.google.firebase.firestore.DocumentSnapshot.ServerTimestampBehavior.NONE ServerTimestampBehavior.PREVIOUS -> com.google.firebase.firestore.DocumentSnapshot.ServerTimestampBehavior.PREVIOUS } -} \ No newline at end of file +} diff --git a/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeFirebaseFirestoreWrapper.kt b/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeFirebaseFirestoreWrapper.kt index 189666ff5..bc2fe2450 100644 --- a/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeFirebaseFirestoreWrapper.kt +++ b/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeFirebaseFirestoreWrapper.kt @@ -29,7 +29,7 @@ internal actual class NativeFirebaseFirestoreWrapper actual constructor(actual v when (val settings = localCacheSettings.garbageCollectorSettings) { is MemoryEagerGcSettings -> MemoryGarbageCollectorSettings.Eager is MemoryLruGcSettings -> MemoryGarbageCollectorSettings.LRUGC( - settings.sizeBytes + settings.sizeBytes, ) else -> throw IllegalArgumentException("Existing settings does not have valid GarbageCollectionSettings") @@ -38,7 +38,7 @@ internal actual class NativeFirebaseFirestoreWrapper actual constructor(actual v } is PersistentCacheSettings -> LocalCacheSettings.Persistent( - localCacheSettings.sizeBytes + localCacheSettings.sizeBytes, ) else -> throw IllegalArgumentException("Existing settings is not of a valid type") @@ -48,17 +48,17 @@ internal actual class NativeFirebaseFirestoreWrapper actual constructor(actual v when { isPersistenceEnabled -> LocalCacheSettings.Persistent(cacheSizeBytes) cacheSizeBytes == FirebaseFirestoreSettings.CACHE_SIZE_UNLIMITED -> LocalCacheSettings.Memory( - MemoryGarbageCollectorSettings.Eager + MemoryGarbageCollectorSettings.Eager, ) else -> LocalCacheSettings.Memory( MemoryGarbageCollectorSettings.LRUGC( - cacheSizeBytes - ) + cacheSizeBytes, + ), ) } }, - callbackExecutorMap[native] ?: TaskExecutors.MAIN_THREAD + callbackExecutorMap[native] ?: TaskExecutors.MAIN_THREAD, ) } set(value) { @@ -97,5 +97,4 @@ internal actual class NativeFirebaseFirestoreWrapper actual constructor(actual v actual suspend fun enableNetwork() = native.enableNetwork().await().run { } - -} \ No newline at end of file +} diff --git a/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeQueryWrapper.kt b/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeQueryWrapper.kt index 349c1fd9f..1f148f607 100644 --- a/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeQueryWrapper.kt +++ b/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeQueryWrapper.kt @@ -17,11 +17,11 @@ import kotlinx.coroutines.flow.callbackFlow import kotlinx.coroutines.tasks.await @PublishedApi -internal actual open class NativeQueryWrapper actual internal constructor(actual open val native: Query) { +internal actual open class NativeQueryWrapper internal actual constructor(actual open val native: Query) { actual fun limit(limit: Number) = native.limit(limit.toLong()) - actual val snapshots get() = callbackFlow { + actual val snapshots get() = callbackFlow { val listener = native.addSnapshotListener { snapshot, exception -> snapshot?.let { trySend(QuerySnapshot(snapshot)) } exception?.let { close(exception) } @@ -29,7 +29,7 @@ internal actual open class NativeQueryWrapper actual internal constructor(actual awaitClose { listener.remove() } } - actual fun snapshots(includeMetadataChanges: Boolean) = callbackFlow { + actual fun snapshots(includeMetadataChanges: Boolean) = callbackFlow { val metadataChanges = if (includeMetadataChanges) MetadataChanges.INCLUDE else MetadataChanges.EXCLUDE val listener = native.addSnapshotListener(metadataChanges) { snapshot, exception -> @@ -45,10 +45,14 @@ internal actual open class NativeQueryWrapper actual internal constructor(actual actual fun where(filter: Filter) = native.where(filter.toAndroidFilter()) private fun Filter.toAndroidFilter(): com.google.firebase.firestore.Filter = when (this) { - is Filter.And -> com.google.firebase.firestore.Filter.and(*filters.map { it.toAndroidFilter() } - .toTypedArray()) - is Filter.Or -> com.google.firebase.firestore.Filter.or(*filters.map { it.toAndroidFilter() } - .toTypedArray()) + is Filter.And -> com.google.firebase.firestore.Filter.and( + *filters.map { it.toAndroidFilter() } + .toTypedArray(), + ) + is Filter.Or -> com.google.firebase.firestore.Filter.or( + *filters.map { it.toAndroidFilter() } + .toTypedArray(), + ) is Filter.Field -> { when (constraint) { is WhereConstraint.ForNullableObject -> { @@ -124,7 +128,7 @@ internal actual open class NativeQueryWrapper actual internal constructor(actual private fun addSnapshotListener( includeMetadataChanges: Boolean = false, - listener: ProducerScope.(com.google.firebase.firestore.QuerySnapshot?, com.google.firebase.firestore.FirebaseFirestoreException?) -> Unit + listener: ProducerScope.(com.google.firebase.firestore.QuerySnapshot?, com.google.firebase.firestore.FirebaseFirestoreException?) -> Unit, ) = callbackFlow { val executor = callbackExecutorMap[native.firestore] ?: TaskExecutors.MAIN_THREAD val metadataChanges = @@ -135,4 +139,4 @@ internal actual open class NativeQueryWrapper actual internal constructor(actual } awaitClose { registration.remove() } } -} \ No newline at end of file +} diff --git a/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeTransactionWrapper.kt b/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeTransactionWrapper.kt index 6db5b7ff3..9440d27a2 100644 --- a/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeTransactionWrapper.kt +++ b/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeTransactionWrapper.kt @@ -9,12 +9,12 @@ import dev.gitlive.firebase.internal.EncodedObject import dev.gitlive.firebase.internal.android @PublishedApi -internal actual class NativeTransactionWrapper actual internal constructor(actual val native: NativeTransaction) { +internal actual class NativeTransactionWrapper internal actual constructor(actual val native: NativeTransaction) { actual fun setEncoded( documentRef: DocumentReference, encodedData: EncodedObject, - setOptions: SetOptions + setOptions: SetOptions, ): NativeTransactionWrapper { setOptions.android?.let { native.set(documentRef.android, encodedData.android, it) @@ -26,14 +26,14 @@ internal actual class NativeTransactionWrapper actual internal constructor(actua actual fun updateEncodedFieldsAndValues( documentRef: DocumentReference, - encodedFieldsAndValues: List> + encodedFieldsAndValues: List>, ) = encodedFieldsAndValues.performUpdate { field, value, moreFieldsAndValues -> native.update(documentRef.android, field, value, *moreFieldsAndValues) }.let { this } actual fun updateEncodedFieldPathsAndValues( documentRef: DocumentReference, - encodedFieldsAndValues: List> + encodedFieldsAndValues: List>, ) = encodedFieldsAndValues.performUpdate { field, value, moreFieldsAndValues -> native.update(documentRef.android, field, value, *moreFieldsAndValues) }.let { this } @@ -43,4 +43,4 @@ internal actual class NativeTransactionWrapper actual internal constructor(actua actual suspend fun get(documentRef: DocumentReference) = NativeDocumentSnapshotWrapper(native.get(documentRef.android)) -} \ No newline at end of file +} diff --git a/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeWriteBatchWrapper.kt b/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeWriteBatchWrapper.kt index 1c6c042b6..ca16c174b 100644 --- a/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeWriteBatchWrapper.kt +++ b/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeWriteBatchWrapper.kt @@ -10,15 +10,17 @@ import dev.gitlive.firebase.internal.android import kotlinx.coroutines.tasks.await @PublishedApi -internal actual class NativeWriteBatchWrapper actual internal constructor(actual val native: NativeWriteBatch) { +internal actual class NativeWriteBatchWrapper internal actual constructor(actual val native: NativeWriteBatch) { actual fun setEncoded( documentRef: DocumentReference, encodedData: EncodedObject, - setOptions: SetOptions - ): NativeWriteBatchWrapper = (setOptions.android?.let { - native.set(documentRef.android, encodedData.android, it) - } ?: native.set(documentRef.android, encodedData.android)).let { + setOptions: SetOptions, + ): NativeWriteBatchWrapper = ( + setOptions.android?.let { + native.set(documentRef.android, encodedData.android, it) + } ?: native.set(documentRef.android, encodedData.android) + ).let { this } @@ -26,14 +28,14 @@ internal actual class NativeWriteBatchWrapper actual internal constructor(actual actual fun updateEncodedFieldsAndValues( documentRef: DocumentReference, - encodedFieldsAndValues: List> + encodedFieldsAndValues: List>, ) = encodedFieldsAndValues.performUpdate { field, value, moreFieldsAndValues -> native.update(documentRef.android, field, value, *moreFieldsAndValues) }.let { this } actual fun updateEncodedFieldPathsAndValues( documentRef: DocumentReference, - encodedFieldsAndValues: List> + encodedFieldsAndValues: List>, ) = encodedFieldsAndValues.performUpdate { field, value, moreFieldsAndValues -> native.update(documentRef.android, field, value, *moreFieldsAndValues) }.let { this } @@ -44,4 +46,4 @@ internal actual class NativeWriteBatchWrapper actual internal constructor(actual actual suspend fun commit() { native.commit().await() } -} \ No newline at end of file +} diff --git a/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/Source.kt b/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/Source.kt index 3b0d71950..4ef12d369 100644 --- a/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/Source.kt +++ b/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/Source.kt @@ -3,8 +3,8 @@ package dev.gitlive.firebase.firestore.internal import dev.gitlive.firebase.firestore.NativeSource import dev.gitlive.firebase.firestore.Source -internal fun Source.toAndroidSource() = when(this) { +internal fun Source.toAndroidSource() = when (this) { Source.CACHE -> NativeSource.CACHE Source.SERVER -> NativeSource.SERVER Source.DEFAULT -> NativeSource.DEFAULT -} \ No newline at end of file +} diff --git a/firebase-firestore/src/androidUnitTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt b/firebase-firestore/src/androidUnitTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt index a7a33ba85..c935a03f4 100644 --- a/firebase-firestore/src/androidUnitTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt +++ b/firebase-firestore/src/androidUnitTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt @@ -3,6 +3,7 @@ */ @file:JvmName("tests") + package dev.gitlive.firebase.firestore actual val emulatorHost: String = "10.0.2.2" diff --git a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/DocumentReferenceSerializer.kt b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/DocumentReferenceSerializer.kt index 4a62715a4..945230bc7 100644 --- a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/DocumentReferenceSerializer.kt +++ b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/DocumentReferenceSerializer.kt @@ -9,7 +9,7 @@ import kotlinx.serialization.SerializationException /** * A serializer for [DocumentReference]. If used with [FirebaseEncoder] performs serialization using native Firebase mechanisms. */ -object DocumentReferenceSerializer : KSerializer by SpecialValueSerializer( +public object DocumentReferenceSerializer : KSerializer by SpecialValueSerializer( serialName = "DocumentReference", toNativeValue = { it.native.nativeValue }, fromNativeValue = { value -> @@ -17,5 +17,5 @@ object DocumentReferenceSerializer : KSerializer by SpecialVa is NativeDocumentReferenceType -> DocumentReference(NativeDocumentReference(value)) else -> throw SerializationException("Cannot deserialize $value") } - } + }, ) diff --git a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/FieldValue.kt b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/FieldValue.kt index a091c4c05..61b5860ad 100644 --- a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/FieldValue.kt +++ b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/FieldValue.kt @@ -4,14 +4,14 @@ import kotlinx.serialization.Serializable /** Represents a Firebase FieldValue. */ @Serializable(with = FieldValueSerializer::class) -expect class FieldValue internal constructor(nativeValue: Any) { +public expect class FieldValue internal constructor(nativeValue: Any) { internal val nativeValue: Any - companion object { - val serverTimestamp: FieldValue - val delete: FieldValue - fun increment(value: Int): FieldValue - fun arrayUnion(vararg elements: Any): FieldValue - fun arrayRemove(vararg elements: Any): FieldValue + public companion object { + public val serverTimestamp: FieldValue + public val delete: FieldValue + public fun increment(value: Int): FieldValue + public fun arrayUnion(vararg elements: Any): FieldValue + public fun arrayRemove(vararg elements: Any): FieldValue } } diff --git a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/FieldValueSerializer.kt b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/FieldValueSerializer.kt index 5b53d2f95..561dcb201 100644 --- a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/FieldValueSerializer.kt +++ b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/FieldValueSerializer.kt @@ -6,10 +6,10 @@ import kotlinx.serialization.KSerializer import kotlinx.serialization.SerializationException /** A serializer for [FieldValue]. Must be used in conjunction with [FirebaseEncoder]. */ -object FieldValueSerializer : KSerializer by SpecialValueSerializer( +public object FieldValueSerializer : KSerializer by SpecialValueSerializer( serialName = "FieldValue", toNativeValue = FieldValue::nativeValue, fromNativeValue = { raw -> raw?.let(::FieldValue) ?: throw SerializationException("Cannot deserialize $raw") - } + }, ) diff --git a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/Filter.kt b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/Filter.kt index 6be86251c..f9e8558e7 100644 --- a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/Filter.kt +++ b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/Filter.kt @@ -2,128 +2,88 @@ package dev.gitlive.firebase.firestore import dev.gitlive.firebase.firestore.internal.safeValue -sealed interface WhereConstraint { +public sealed interface WhereConstraint { - sealed interface ForNullableObject : WhereConstraint { - val value: Any? - val safeValue get() = value?.safeValue + public sealed interface ForNullableObject : WhereConstraint { + public val value: Any? + public val safeValue: Any? get() = value?.safeValue } - sealed interface ForObject : WhereConstraint { - val value: Any - val safeValue get() = value.safeValue + public sealed interface ForObject : WhereConstraint { + public val value: Any + public val safeValue: Any get() = value.safeValue } - sealed interface ForArray : WhereConstraint { - val values: List - val safeValues get() = values.map { it.safeValue } + public sealed interface ForArray : WhereConstraint { + public val values: List + public val safeValues: List get() = values.map { it.safeValue } } - data class EqualTo internal constructor(override val value: Any?) : ForNullableObject - data class NotEqualTo internal constructor(override val value: Any?) : ForNullableObject - data class LessThan internal constructor(override val value: Any) : ForObject - data class GreaterThan internal constructor(override val value: Any) : ForObject - data class LessThanOrEqualTo internal constructor(override val value: Any) : ForObject - data class GreaterThanOrEqualTo internal constructor(override val value: Any) : ForObject - data class ArrayContains internal constructor(override val value: Any) : ForObject - data class ArrayContainsAny internal constructor(override val values: List) : ForArray - data class InArray internal constructor(override val values: List) : ForArray - data class NotInArray internal constructor(override val values: List) : ForArray + public data class EqualTo internal constructor(override val value: Any?) : ForNullableObject + public data class NotEqualTo internal constructor(override val value: Any?) : ForNullableObject + public data class LessThan internal constructor(override val value: Any) : ForObject + public data class GreaterThan internal constructor(override val value: Any) : ForObject + public data class LessThanOrEqualTo internal constructor(override val value: Any) : ForObject + public data class GreaterThanOrEqualTo internal constructor(override val value: Any) : ForObject + public data class ArrayContains internal constructor(override val value: Any) : ForObject + public data class ArrayContainsAny internal constructor(override val values: List) : ForArray + public data class InArray internal constructor(override val values: List) : ForArray + public data class NotInArray internal constructor(override val values: List) : ForArray } -sealed class Filter { - data class And internal constructor(val filters: List) : Filter() - data class Or internal constructor(val filters: List) : Filter() - sealed class WithConstraint : Filter() { - abstract val constraint: WhereConstraint +public sealed class Filter { + public data class And internal constructor(val filters: List) : Filter() + public data class Or internal constructor(val filters: List) : Filter() + public sealed class WithConstraint : Filter() { + public abstract val constraint: WhereConstraint } - data class Field internal constructor(val field: String, override val constraint: WhereConstraint) : WithConstraint() - data class Path internal constructor(val path: FieldPath, override val constraint: WhereConstraint) : WithConstraint() + public data class Field internal constructor(val field: String, override val constraint: WhereConstraint) : WithConstraint() + public data class Path internal constructor(val path: FieldPath, override val constraint: WhereConstraint) : WithConstraint() } -class FilterBuilder internal constructor() { +public class FilterBuilder internal constructor() { - infix fun String.equalTo(value: Any?): Filter.WithConstraint { - return Filter.Field(this, WhereConstraint.EqualTo(value)) - } + public infix fun String.equalTo(value: Any?): Filter.WithConstraint = Filter.Field(this, WhereConstraint.EqualTo(value)) - infix fun FieldPath.equalTo(value: Any?): Filter.WithConstraint { - return Filter.Path(this, WhereConstraint.EqualTo(value)) - } + public infix fun FieldPath.equalTo(value: Any?): Filter.WithConstraint = Filter.Path(this, WhereConstraint.EqualTo(value)) - infix fun String.notEqualTo(value: Any?): Filter.WithConstraint { - return Filter.Field(this, WhereConstraint.NotEqualTo(value)) - } + public infix fun String.notEqualTo(value: Any?): Filter.WithConstraint = Filter.Field(this, WhereConstraint.NotEqualTo(value)) - infix fun FieldPath.notEqualTo(value: Any?): Filter.WithConstraint { - return Filter.Path(this, WhereConstraint.NotEqualTo(value)) - } + public infix fun FieldPath.notEqualTo(value: Any?): Filter.WithConstraint = Filter.Path(this, WhereConstraint.NotEqualTo(value)) - infix fun String.lessThan(value: Any): Filter.WithConstraint { - return Filter.Field(this, WhereConstraint.LessThan(value)) - } + public infix fun String.lessThan(value: Any): Filter.WithConstraint = Filter.Field(this, WhereConstraint.LessThan(value)) - infix fun FieldPath.lessThan(value: Any): Filter.WithConstraint { - return Filter.Path(this, WhereConstraint.LessThan(value)) - } + public infix fun FieldPath.lessThan(value: Any): Filter.WithConstraint = Filter.Path(this, WhereConstraint.LessThan(value)) - infix fun String.greaterThan(value: Any): Filter.WithConstraint { - return Filter.Field(this, WhereConstraint.GreaterThan(value)) - } + public infix fun String.greaterThan(value: Any): Filter.WithConstraint = Filter.Field(this, WhereConstraint.GreaterThan(value)) - infix fun FieldPath.greaterThan(value: Any): Filter.WithConstraint { - return Filter.Path(this, WhereConstraint.GreaterThan(value)) - } + public infix fun FieldPath.greaterThan(value: Any): Filter.WithConstraint = Filter.Path(this, WhereConstraint.GreaterThan(value)) - infix fun String.lessThanOrEqualTo(value: Any): Filter.WithConstraint { - return Filter.Field(this, WhereConstraint.LessThanOrEqualTo(value)) - } + public infix fun String.lessThanOrEqualTo(value: Any): Filter.WithConstraint = Filter.Field(this, WhereConstraint.LessThanOrEqualTo(value)) - infix fun FieldPath.lessThanOrEqualTo(value: Any): Filter.WithConstraint { - return Filter.Path(this, WhereConstraint.LessThanOrEqualTo(value)) - } + public infix fun FieldPath.lessThanOrEqualTo(value: Any): Filter.WithConstraint = Filter.Path(this, WhereConstraint.LessThanOrEqualTo(value)) - infix fun String.greaterThanOrEqualTo(value: Any): Filter.WithConstraint { - return Filter.Field(this, WhereConstraint.GreaterThanOrEqualTo(value)) - } + public infix fun String.greaterThanOrEqualTo(value: Any): Filter.WithConstraint = Filter.Field(this, WhereConstraint.GreaterThanOrEqualTo(value)) - infix fun FieldPath.greaterThanOrEqualTo(value: Any): Filter.WithConstraint { - return Filter.Path(this, WhereConstraint.GreaterThanOrEqualTo(value)) - } + public infix fun FieldPath.greaterThanOrEqualTo(value: Any): Filter.WithConstraint = Filter.Path(this, WhereConstraint.GreaterThanOrEqualTo(value)) - infix fun String.contains(value: Any): Filter.WithConstraint { - return Filter.Field(this, WhereConstraint.ArrayContains(value)) - } + public infix fun String.contains(value: Any): Filter.WithConstraint = Filter.Field(this, WhereConstraint.ArrayContains(value)) - infix fun FieldPath.contains(value: Any): Filter.WithConstraint { - return Filter.Path(this, WhereConstraint.ArrayContains(value)) - } + public infix fun FieldPath.contains(value: Any): Filter.WithConstraint = Filter.Path(this, WhereConstraint.ArrayContains(value)) - infix fun String.containsAny(values: List): Filter.WithConstraint { - return Filter.Field(this, WhereConstraint.ArrayContainsAny(values)) - } + public infix fun String.containsAny(values: List): Filter.WithConstraint = Filter.Field(this, WhereConstraint.ArrayContainsAny(values)) - infix fun FieldPath.containsAny(values: List): Filter.WithConstraint { - return Filter.Path(this, WhereConstraint.ArrayContainsAny(values)) - } + public infix fun FieldPath.containsAny(values: List): Filter.WithConstraint = Filter.Path(this, WhereConstraint.ArrayContainsAny(values)) - infix fun String.inArray(values: List): Filter.WithConstraint { - return Filter.Field(this, WhereConstraint.InArray(values)) - } + public infix fun String.inArray(values: List): Filter.WithConstraint = Filter.Field(this, WhereConstraint.InArray(values)) - infix fun FieldPath.inArray(values: List): Filter.WithConstraint { - return Filter.Path(this, WhereConstraint.InArray(values)) - } + public infix fun FieldPath.inArray(values: List): Filter.WithConstraint = Filter.Path(this, WhereConstraint.InArray(values)) - infix fun String.notInArray(values: List): Filter.WithConstraint { - return Filter.Field(this, WhereConstraint.NotInArray(values)) - } + public infix fun String.notInArray(values: List): Filter.WithConstraint = Filter.Field(this, WhereConstraint.NotInArray(values)) - infix fun FieldPath.notInArray(values: List): Filter.WithConstraint { - return Filter.Path(this, WhereConstraint.NotInArray(values)) - } + public infix fun FieldPath.notInArray(values: List): Filter.WithConstraint = Filter.Path(this, WhereConstraint.NotInArray(values)) - infix fun Filter.and(right: Filter): Filter.And { + public infix fun Filter.and(right: Filter): Filter.And { val leftList = when (this) { is Filter.And -> filters else -> listOf(this) @@ -135,7 +95,7 @@ class FilterBuilder internal constructor() { return Filter.And(leftList + rightList) } - infix fun Filter.or(right: Filter): Filter.Or { + public infix fun Filter.or(right: Filter): Filter.Or { val leftList = when (this) { is Filter.Or -> filters else -> listOf(this) @@ -147,8 +107,8 @@ class FilterBuilder internal constructor() { return Filter.Or(leftList + rightList) } - fun all(vararg filters: Filter): Filter? = filters.toList().combine { left, right -> left and right } - fun any(vararg filters: Filter): Filter? = filters.toList().combine { left, right -> left or right } + public fun all(vararg filters: Filter): Filter? = filters.toList().combine { left, right -> left and right } + public fun any(vararg filters: Filter): Filter? = filters.toList().combine { left, right -> left or right } private fun Collection.combine(over: (Filter, Filter) -> Filter): Filter? = fold(null) { acc, filter -> acc?.let { over(acc, filter) } ?: filter diff --git a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/GeoPoint.kt b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/GeoPoint.kt index 77093b9cb..e5c48d171 100644 --- a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/GeoPoint.kt +++ b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/GeoPoint.kt @@ -3,13 +3,13 @@ package dev.gitlive.firebase.firestore import kotlinx.serialization.Serializable /** A class representing a platform specific Firebase GeoPoint. */ -expect class NativeGeoPoint +public expect class NativeGeoPoint /** A class representing a Firebase GeoPoint. */ @Serializable(with = GeoPointSerializer::class) -expect class GeoPoint internal constructor(nativeValue: NativeGeoPoint) { - constructor(latitude: Double, longitude: Double) - val latitude: Double - val longitude: Double +public expect class GeoPoint internal constructor(nativeValue: NativeGeoPoint) { + public constructor(latitude: Double, longitude: Double) + public val latitude: Double + public val longitude: Double internal val nativeValue: NativeGeoPoint } diff --git a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/GeoPointSerializer.kt b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/GeoPointSerializer.kt index e96308cee..cb46e1792 100644 --- a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/GeoPointSerializer.kt +++ b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/GeoPointSerializer.kt @@ -5,7 +5,7 @@ import kotlinx.serialization.KSerializer import kotlinx.serialization.SerializationException /** Serializer for [GeoPoint]. If used with [FirebaseEncoder] performs serialization using native Firebase mechanisms. */ -object GeoPointSerializer : KSerializer by SpecialValueSerializer( +public object GeoPointSerializer : KSerializer by SpecialValueSerializer( serialName = "GeoPoint", toNativeValue = GeoPoint::nativeValue, fromNativeValue = { value -> @@ -13,5 +13,5 @@ object GeoPointSerializer : KSerializer by SpecialValueSerializer( is NativeGeoPoint -> GeoPoint(value) else -> throw SerializationException("Cannot deserialize $value") } - } -) \ No newline at end of file + }, +) diff --git a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/LocalCacheSettings.kt b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/LocalCacheSettings.kt index a701b8a69..04096c94a 100644 --- a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/LocalCacheSettings.kt +++ b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/LocalCacheSettings.kt @@ -1,69 +1,69 @@ package dev.gitlive.firebase.firestore -sealed interface LocalCacheSettings { +public sealed interface LocalCacheSettings { - data class Persistent internal constructor(val sizeBytes: Long) : LocalCacheSettings { + public data class Persistent internal constructor(public val sizeBytes: Long) : LocalCacheSettings { - companion object { - fun newBuilder(): Builder = Builder() + public companion object { + public fun newBuilder(): Builder = Builder() } - class Builder internal constructor() { - var sizeBytes: Long = FirebaseFirestoreSettings.DEFAULT_CACHE_SIZE_BYTES - fun build(): Persistent = Persistent(sizeBytes) + public class Builder internal constructor() { + public var sizeBytes: Long = FirebaseFirestoreSettings.DEFAULT_CACHE_SIZE_BYTES + public fun build(): Persistent = Persistent(sizeBytes) } } - data class Memory internal constructor(val garbaseCollectorSettings: MemoryGarbageCollectorSettings) : LocalCacheSettings { + public data class Memory internal constructor(val garbaseCollectorSettings: MemoryGarbageCollectorSettings) : LocalCacheSettings { - companion object { - fun newBuilder(): Builder = Builder() + public companion object { + public fun newBuilder(): Builder = Builder() } - class Builder internal constructor() { + public class Builder internal constructor() { - var gcSettings: MemoryGarbageCollectorSettings = MemoryGarbageCollectorSettings.Eager.newBuilder().build() + public var gcSettings: MemoryGarbageCollectorSettings = MemoryGarbageCollectorSettings.Eager.newBuilder().build() - fun build(): Memory = Memory(gcSettings) + public fun build(): Memory = Memory(gcSettings) } } } -typealias PersistentCacheSettings = LocalCacheSettings.Persistent -typealias MemoryCacheSettings = LocalCacheSettings.Memory +public typealias PersistentCacheSettings = LocalCacheSettings.Persistent +public typealias MemoryCacheSettings = LocalCacheSettings.Memory -sealed interface MemoryGarbageCollectorSettings { - data object Eager : MemoryGarbageCollectorSettings { +public sealed interface MemoryGarbageCollectorSettings { + public data object Eager : MemoryGarbageCollectorSettings { - fun newBuilder(): Builder = Builder() + public fun newBuilder(): Builder = Builder() - class Builder internal constructor() { - fun build(): Eager = Eager + public class Builder internal constructor() { + public fun build(): Eager = Eager } } - data class LRUGC internal constructor(val sizeBytes: Long) : MemoryGarbageCollectorSettings { + public data class LRUGC internal constructor(val sizeBytes: Long) : MemoryGarbageCollectorSettings { - companion object { - fun newBuilder(): Builder = Builder() + public companion object { + public fun newBuilder(): Builder = Builder() } - class Builder internal constructor() { - var sizeBytes: Long = FirebaseFirestoreSettings.DEFAULT_CACHE_SIZE_BYTES - fun build(): LRUGC = LRUGC(sizeBytes) + public class Builder internal constructor() { + public var sizeBytes: Long = FirebaseFirestoreSettings.DEFAULT_CACHE_SIZE_BYTES + public fun build(): LRUGC = LRUGC(sizeBytes) } } } -typealias MemoryEagerGcSettings = MemoryGarbageCollectorSettings.Eager -typealias MemoryLruGcSettings = MemoryGarbageCollectorSettings.LRUGC +public typealias MemoryEagerGcSettings = MemoryGarbageCollectorSettings.Eager +public typealias MemoryLruGcSettings = MemoryGarbageCollectorSettings.LRUGC -fun memoryCacheSettings(builder: LocalCacheSettings.Memory.Builder.() -> Unit): LocalCacheSettings.Memory = +public fun memoryCacheSettings(builder: LocalCacheSettings.Memory.Builder.() -> Unit): LocalCacheSettings.Memory = LocalCacheSettings.Memory.newBuilder().apply(builder).build() -fun memoryEagerGcSettings(builder: MemoryGarbageCollectorSettings.Eager.Builder.() -> Unit) = +public fun memoryEagerGcSettings(builder: MemoryGarbageCollectorSettings.Eager.Builder.() -> Unit): MemoryGarbageCollectorSettings.Eager = MemoryGarbageCollectorSettings.Eager.newBuilder().apply(builder).build() -fun memoryLruGcSettings(builder: MemoryGarbageCollectorSettings.LRUGC.Builder.() -> Unit) = +public fun memoryLruGcSettings(builder: MemoryGarbageCollectorSettings.LRUGC.Builder.() -> Unit): MemoryGarbageCollectorSettings.LRUGC = MemoryGarbageCollectorSettings.LRUGC.newBuilder().apply(builder).build() -fun persistentCacheSettings(builder: LocalCacheSettings.Persistent.Builder.() -> Unit) = - LocalCacheSettings.Persistent.newBuilder().apply(builder).build() \ No newline at end of file +public fun persistentCacheSettings(builder: LocalCacheSettings.Persistent.Builder.() -> Unit): LocalCacheSettings.Persistent = + LocalCacheSettings.Persistent.newBuilder().apply(builder).build() diff --git a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/Timestamp.kt b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/Timestamp.kt index c6df088af..13a37a7e7 100644 --- a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/Timestamp.kt +++ b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/Timestamp.kt @@ -8,35 +8,36 @@ import kotlin.time.Duration.Companion.seconds import kotlin.time.DurationUnit /** A class representing a platform specific Firebase Timestamp. */ -expect class NativeTimestamp +public expect class NativeTimestamp /** A base class that could be used to combine [Timestamp] and [Timestamp.ServerTimestamp] in the same field. */ @Serializable(with = BaseTimestampSerializer::class) -expect sealed class BaseTimestamp +public expect sealed class BaseTimestamp /** A class representing a Firebase Timestamp. */ @Serializable(with = TimestampSerializer::class) -expect class Timestamp internal constructor(nativeValue: NativeTimestamp): BaseTimestamp { - constructor(seconds: Long, nanoseconds: Int) - val seconds: Long - val nanoseconds: Int +public expect class Timestamp internal constructor(nativeValue: NativeTimestamp) : BaseTimestamp { + public constructor(seconds: Long, nanoseconds: Int) + public val seconds: Long + public val nanoseconds: Int internal val nativeValue: NativeTimestamp - companion object { + public companion object { /** @return a local time timestamp. */ - fun now(): Timestamp + public fun now(): Timestamp } + /** A server time timestamp. */ @Serializable(with = ServerTimestampSerializer::class) - object ServerTimestamp: BaseTimestamp + public data object ServerTimestamp : BaseTimestamp } -fun Timestamp.Companion.fromDuration(duration: Duration): Timestamp = +public fun Timestamp.Companion.fromDuration(duration: Duration): Timestamp = duration.toComponents { seconds, nanoseconds -> Timestamp(seconds, nanoseconds) } -fun Timestamp.toDuration(): Duration = seconds.seconds + nanoseconds.nanoseconds +public fun Timestamp.toDuration(): Duration = seconds.seconds + nanoseconds.nanoseconds -fun Timestamp.Companion.fromMilliseconds(milliseconds: Double): Timestamp = fromDuration(milliseconds.milliseconds) -fun Timestamp.toMilliseconds(): Double = toDuration().toDouble(DurationUnit.MILLISECONDS) +public fun Timestamp.Companion.fromMilliseconds(milliseconds: Double): Timestamp = fromDuration(milliseconds.milliseconds) +public fun Timestamp.toMilliseconds(): Double = toDuration().toDouble(DurationUnit.MILLISECONDS) diff --git a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/TimestampSerializer.kt b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/TimestampSerializer.kt index 4d126d277..f970b0801 100644 --- a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/TimestampSerializer.kt +++ b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/TimestampSerializer.kt @@ -1,12 +1,12 @@ package dev.gitlive.firebase.firestore import dev.gitlive.firebase.internal.SpecialValueSerializer -import dev.gitlive.firebase.firestore.DoubleAsTimestampSerializer.serverTimestamp +import dev.gitlive.firebase.firestore.DoubleAsTimestampSerializer.SERVER_TIMESTAMP import kotlinx.serialization.KSerializer import kotlinx.serialization.SerializationException /** A serializer for [BaseTimestamp]. Must be used with [FirebaseEncoder]/[FirebaseDecoder]. */ -object BaseTimestampSerializer : KSerializer by SpecialValueSerializer( +public object BaseTimestampSerializer : KSerializer by SpecialValueSerializer( serialName = "Timestamp", toNativeValue = { value -> when (value) { @@ -21,11 +21,11 @@ object BaseTimestampSerializer : KSerializer by SpecialValueSeria FieldValue.serverTimestamp.nativeValue -> Timestamp.ServerTimestamp else -> throw SerializationException("Cannot deserialize $value") } - } + }, ) /** A serializer for [Timestamp]. Must be used with [FirebaseEncoder]/[FirebaseDecoder]. */ -object TimestampSerializer : KSerializer by SpecialValueSerializer( +public object TimestampSerializer : KSerializer by SpecialValueSerializer( serialName = "Timestamp", toNativeValue = Timestamp::nativeValue, fromNativeValue = { value -> @@ -33,11 +33,11 @@ object TimestampSerializer : KSerializer by SpecialValueSerializer( is NativeTimestamp -> Timestamp(value) else -> throw SerializationException("Cannot deserialize $value") } - } + }, ) /** A serializer for [Timestamp.ServerTimestamp]. Must be used with [FirebaseEncoder]/[FirebaseDecoder]. */ -object ServerTimestampSerializer : KSerializer by SpecialValueSerializer( +public object ServerTimestampSerializer : KSerializer by SpecialValueSerializer( serialName = "Timestamp", toNativeValue = { FieldValue.serverTimestamp.nativeValue }, fromNativeValue = { value -> @@ -45,26 +45,26 @@ object ServerTimestampSerializer : KSerializer by Spe FieldValue.serverTimestamp.nativeValue -> Timestamp.ServerTimestamp else -> throw SerializationException("Cannot deserialize $value") } - } + }, ) /** A serializer for a Double field which is stored as a Timestamp. */ -object DoubleAsTimestampSerializer : KSerializer by SpecialValueSerializer( +public object DoubleAsTimestampSerializer : KSerializer by SpecialValueSerializer( serialName = "Timestamp", toNativeValue = { value -> - when(value) { - serverTimestamp -> FieldValue.serverTimestamp.nativeValue + when (value) { + SERVER_TIMESTAMP -> FieldValue.serverTimestamp.nativeValue else -> Timestamp.fromMilliseconds(value).nativeValue } }, fromNativeValue = { value -> - when(value) { - FieldValue.serverTimestamp.nativeValue -> serverTimestamp + when (value) { + FieldValue.serverTimestamp.nativeValue -> SERVER_TIMESTAMP is NativeTimestamp -> Timestamp(value).toMilliseconds() is Double -> value else -> throw SerializationException("Cannot deserialize $value") } - } + }, ) { - const val serverTimestamp = Double.POSITIVE_INFINITY -} \ No newline at end of file + public const val SERVER_TIMESTAMP: Double = Double.POSITIVE_INFINITY +} diff --git a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/encoders.kt b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/encoders.kt index b5f1960dd..54410b4ef 100644 --- a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/encoders.kt +++ b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/encoders.kt @@ -7,7 +7,7 @@ import dev.gitlive.firebase.EncodeSettings internal expect fun isSpecialValue(value: Any): Boolean @PublishedApi -internal inline fun encode(value: T, buildSettings: EncodeSettings.Builder.() -> Unit) = +internal inline fun encode(value: T, buildSettings: EncodeSettings.Builder.() -> Unit): Any? = if (value?.let(::isSpecialValue) == true) { value } else { diff --git a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt index 15a9528b5..caedb1a79 100644 --- a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt +++ b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt @@ -29,35 +29,42 @@ import kotlinx.serialization.SerializationStrategy import kotlin.jvm.JvmName /** Returns the [FirebaseFirestore] instance of the default [FirebaseApp]. */ -expect val Firebase.firestore: FirebaseFirestore +public expect val Firebase.firestore: FirebaseFirestore /** Returns the [FirebaseFirestore] instance of a given [FirebaseApp]. */ -expect fun Firebase.firestore(app: FirebaseApp): FirebaseFirestore +public expect fun Firebase.firestore(app: FirebaseApp): FirebaseFirestore -expect class NativeFirebaseFirestore +public expect class NativeFirebaseFirestore -class FirebaseFirestore internal constructor(private val wrapper: NativeFirebaseFirestoreWrapper) { +public class FirebaseFirestore internal constructor(private val wrapper: NativeFirebaseFirestoreWrapper) { - constructor(native: NativeFirebaseFirestore) : this(NativeFirebaseFirestoreWrapper(native)) + public constructor(native: NativeFirebaseFirestore) : this(NativeFirebaseFirestoreWrapper(native)) // Important to leave this as a get property since on JS it is initialized lazily - val native get() = wrapper.native - var settings: FirebaseFirestoreSettings + public val native: NativeFirebaseFirestore get() = wrapper.native + public var settings: FirebaseFirestoreSettings get() = wrapper.settings set(value) { wrapper.settings = value } - fun collection(collectionPath: String): CollectionReference = CollectionReference(wrapper.collection(collectionPath)) - fun collectionGroup(collectionId: String): Query = Query(wrapper.collectionGroup(collectionId)) - fun document(documentPath: String): DocumentReference = DocumentReference(wrapper.document(documentPath)) - fun batch(): WriteBatch = WriteBatch(wrapper.batch()) - fun setLoggingEnabled(loggingEnabled: Boolean) = wrapper.setLoggingEnabled(loggingEnabled) - suspend fun clearPersistence() = wrapper.clearPersistence() - suspend fun runTransaction(func: suspend Transaction.() -> T): T = wrapper.runTransaction { func(Transaction(this)) } - fun useEmulator(host: String, port: Int) = wrapper.useEmulator(host, port) + public fun collection(collectionPath: String): CollectionReference = CollectionReference(wrapper.collection(collectionPath)) + public fun collectionGroup(collectionId: String): Query = Query(wrapper.collectionGroup(collectionId)) + public fun document(documentPath: String): DocumentReference = DocumentReference(wrapper.document(documentPath)) + public fun batch(): WriteBatch = WriteBatch(wrapper.batch()) + public fun setLoggingEnabled(loggingEnabled: Boolean) { + wrapper.setLoggingEnabled(loggingEnabled) + } + public suspend fun clearPersistence() { + wrapper.clearPersistence() + } + public suspend fun runTransaction(func: suspend Transaction.() -> T): T = wrapper.runTransaction { func(Transaction(this)) } + public fun useEmulator(host: String, port: Int) { + wrapper.useEmulator(host, port) + } + @Deprecated("Use settings instead", replaceWith = ReplaceWith("settings = firestoreSettings{}")) - fun setSettings( + public fun setSettings( persistenceEnabled: Boolean? = null, sslEnabled: Boolean? = null, host: String? = null, @@ -79,101 +86,105 @@ class FirebaseFirestore internal constructor(private val wrapper: NativeFirebase } } } - suspend fun disableNetwork() = wrapper.disableNetwork() - suspend fun enableNetwork() = wrapper.enableNetwork() + public suspend fun disableNetwork() { + wrapper.disableNetwork() + } + public suspend fun enableNetwork() { + wrapper.enableNetwork() + } } -expect class FirebaseFirestoreSettings { +public expect class FirebaseFirestoreSettings { - companion object { - val CACHE_SIZE_UNLIMITED: Long + public companion object { + public val CACHE_SIZE_UNLIMITED: Long internal val DEFAULT_HOST: String internal val MINIMUM_CACHE_BYTES: Long internal val DEFAULT_CACHE_SIZE_BYTES: Long } - class Builder constructor() { + public class Builder { + public constructor() + public constructor(settings: FirebaseFirestoreSettings) - constructor(settings: FirebaseFirestoreSettings) + public var sslEnabled: Boolean + public var host: String + public var cacheSettings: LocalCacheSettings - var sslEnabled: Boolean - var host: String - var cacheSettings: LocalCacheSettings - - fun build(): FirebaseFirestoreSettings + public fun build(): FirebaseFirestoreSettings } - val sslEnabled: Boolean - val host: String - val cacheSettings: LocalCacheSettings + public val sslEnabled: Boolean + public val host: String + public val cacheSettings: LocalCacheSettings } -expect fun firestoreSettings(settings: FirebaseFirestoreSettings? = null, builder: FirebaseFirestoreSettings.Builder.() -> Unit): FirebaseFirestoreSettings +public expect fun firestoreSettings(settings: FirebaseFirestoreSettings? = null, builder: FirebaseFirestoreSettings.Builder.() -> Unit): FirebaseFirestoreSettings -expect class NativeTransaction +public expect class NativeTransaction -data class Transaction internal constructor(@PublishedApi internal val nativeWrapper: NativeTransactionWrapper) { +public data class Transaction internal constructor(@PublishedApi internal val nativeWrapper: NativeTransactionWrapper) { - constructor(native: NativeTransaction) : this(NativeTransactionWrapper(native)) + public constructor(native: NativeTransaction) : this(NativeTransactionWrapper(native)) - val native = nativeWrapper.native + public val native: NativeTransaction = nativeWrapper.native @Deprecated("Deprecated. Use builder instead", replaceWith = ReplaceWith("set(documentRef, data, merge) { this.encodeDefaults = encodeDefaults }")) - fun set(documentRef: DocumentReference, data: Any, encodeDefaults: Boolean, merge: Boolean = false): Transaction = set(documentRef, data, merge) { + public fun set(documentRef: DocumentReference, data: Any, encodeDefaults: Boolean, merge: Boolean = false): Transaction = set(documentRef, data, merge) { this.encodeDefaults = encodeDefaults } - inline fun set(documentRef: DocumentReference, data: Any, merge: Boolean = false, buildSettings: EncodeSettings.Builder.() -> Unit = {}): Transaction = setEncoded(documentRef, encodeAsObject(data, buildSettings), if (merge) SetOptions.Merge else SetOptions.Overwrite) - + public inline fun set(documentRef: DocumentReference, data: Any, merge: Boolean = false, buildSettings: EncodeSettings.Builder.() -> Unit = {}): Transaction = setEncoded(documentRef, encodeAsObject(data, buildSettings), if (merge) SetOptions.Merge else SetOptions.Overwrite) @Deprecated("Deprecated. Use builder instead", replaceWith = ReplaceWith("set(documentRef, data, mergeFields) { this.encodeDefaults = encodeDefaults }")) - fun set(documentRef: DocumentReference, data: Any, encodeDefaults: Boolean, vararg mergeFields: String) = set(documentRef, data, *mergeFields) { + public fun set(documentRef: DocumentReference, data: Any, encodeDefaults: Boolean, vararg mergeFields: String): Transaction = set(documentRef, data, *mergeFields) { this.encodeDefaults = encodeDefaults } - inline fun set(documentRef: DocumentReference, data: Any, vararg mergeFields: String, buildSettings: EncodeSettings.Builder.() -> Unit = {}): Transaction = setEncoded(documentRef, encodeAsObject(data, buildSettings), SetOptions.MergeFields(mergeFields.asList())) + public inline fun set(documentRef: DocumentReference, data: Any, vararg mergeFields: String, buildSettings: EncodeSettings.Builder.() -> Unit = {}): Transaction = setEncoded(documentRef, encodeAsObject(data, buildSettings), SetOptions.MergeFields(mergeFields.asList())) @Deprecated("Deprecated. Use builder instead", replaceWith = ReplaceWith("set(documentRef, data, mergeFieldPaths) { this.encodeDefaults = encodeDefaults }")) - fun set(documentRef: DocumentReference, data: Any, encodeDefaults: Boolean, vararg mergeFieldPaths: FieldPath) = set(documentRef, data, *mergeFieldPaths) { + public fun set(documentRef: DocumentReference, data: Any, encodeDefaults: Boolean, vararg mergeFieldPaths: FieldPath): Transaction = set(documentRef, data, *mergeFieldPaths) { this.encodeDefaults = encodeDefaults } - inline fun set(documentRef: DocumentReference, data: Any, vararg mergeFieldPaths: FieldPath, buildSettings: EncodeSettings.Builder.() -> Unit = {}): Transaction = setEncoded(documentRef, encodeAsObject(data, buildSettings), SetOptions.MergeFieldPaths(mergeFieldPaths.asList())) + public inline fun set(documentRef: DocumentReference, data: Any, vararg mergeFieldPaths: FieldPath, buildSettings: EncodeSettings.Builder.() -> Unit = {}): Transaction = setEncoded(documentRef, encodeAsObject(data, buildSettings), SetOptions.MergeFieldPaths(mergeFieldPaths.asList())) @Deprecated("Deprecated. Use builder instead", replaceWith = ReplaceWith("set(documentRef, strategy, data, merge) { this.encodeDefaults = encodeDefaults }")) - fun set(documentRef: DocumentReference, strategy: SerializationStrategy, data: T, encodeDefaults: Boolean, merge: Boolean = false) = set(documentRef, strategy, data, merge) { + public fun set(documentRef: DocumentReference, strategy: SerializationStrategy, data: T, encodeDefaults: Boolean, merge: Boolean = false): Transaction = set(documentRef, strategy, data, merge) { this.encodeDefaults = encodeDefaults } - inline fun set(documentRef: DocumentReference, strategy: SerializationStrategy, data: T, merge: Boolean = false, buildSettings: EncodeSettings.Builder.() -> Unit = {}): Transaction = setEncoded(documentRef, encodeAsObject(strategy, data, buildSettings), if (merge) SetOptions.Merge else SetOptions.Overwrite) + public inline fun set(documentRef: DocumentReference, strategy: SerializationStrategy, data: T, merge: Boolean = false, buildSettings: EncodeSettings.Builder.() -> Unit = {}): Transaction = setEncoded(documentRef, encodeAsObject(strategy, data, buildSettings), if (merge) SetOptions.Merge else SetOptions.Overwrite) @Deprecated("Deprecated. Use builder instead", replaceWith = ReplaceWith("set(documentRef, strategy, data, mergeFields) { this.encodeDefaults = encodeDefaults }")) - fun set(documentRef: DocumentReference, strategy: SerializationStrategy, data: T, encodeDefaults: Boolean, vararg mergeFields: String) = set(documentRef, strategy, data, *mergeFields) { + public fun set(documentRef: DocumentReference, strategy: SerializationStrategy, data: T, encodeDefaults: Boolean, vararg mergeFields: String): Transaction = set(documentRef, strategy, data, *mergeFields) { this.encodeDefaults = encodeDefaults } - inline fun set(documentRef: DocumentReference, strategy: SerializationStrategy, data: T, vararg mergeFields: String, buildSettings: EncodeSettings.Builder.() -> Unit = {}): Transaction = setEncoded(documentRef, encodeAsObject(strategy, data, buildSettings), SetOptions.MergeFields(mergeFields.asList())) + public inline fun set(documentRef: DocumentReference, strategy: SerializationStrategy, data: T, vararg mergeFields: String, buildSettings: EncodeSettings.Builder.() -> Unit = {}): Transaction = setEncoded(documentRef, encodeAsObject(strategy, data, buildSettings), SetOptions.MergeFields(mergeFields.asList())) @Deprecated("Deprecated. Use builder instead", replaceWith = ReplaceWith("set(documentRef, strategy, data, mergeFieldPaths) { this.encodeDefaults = encodeDefaults }")) - fun set(documentRef: DocumentReference, strategy: SerializationStrategy, data: T, encodeDefaults: Boolean, vararg mergeFieldPaths: FieldPath) = set(documentRef, strategy, data, *mergeFieldPaths) { + public fun set(documentRef: DocumentReference, strategy: SerializationStrategy, data: T, encodeDefaults: Boolean, vararg mergeFieldPaths: FieldPath): Transaction = set(documentRef, strategy, data, *mergeFieldPaths) { this.encodeDefaults = encodeDefaults } - inline fun set(documentRef: DocumentReference, strategy: SerializationStrategy, data: T, vararg mergeFieldPaths: FieldPath, buildSettings: EncodeSettings.Builder.() -> Unit = {}): Transaction = setEncoded(documentRef, encodeAsObject(strategy, data, buildSettings), SetOptions.MergeFieldPaths(mergeFieldPaths.asList())) + public inline fun set(documentRef: DocumentReference, strategy: SerializationStrategy, data: T, vararg mergeFieldPaths: FieldPath, buildSettings: EncodeSettings.Builder.() -> Unit = {}): Transaction = setEncoded(documentRef, encodeAsObject(strategy, data, buildSettings), SetOptions.MergeFieldPaths(mergeFieldPaths.asList())) @PublishedApi internal fun setEncoded(documentRef: DocumentReference, encodedData: EncodedObject, setOptions: SetOptions): Transaction = Transaction(nativeWrapper.setEncoded(documentRef, encodedData, setOptions)) @Deprecated("Deprecated. Use builder instead", replaceWith = ReplaceWith("update(documentRef, data) { this.encodeDefaults = encodeDefaults }")) - fun update(documentRef: DocumentReference, data: Any, encodeDefaults: Boolean) = update(documentRef, data) { + public fun update(documentRef: DocumentReference, data: Any, encodeDefaults: Boolean): Transaction = update(documentRef, data) { this.encodeDefaults = encodeDefaults } - inline fun update(documentRef: DocumentReference, data: Any, buildSettings: EncodeSettings.Builder.() -> Unit = {}) = updateEncoded(documentRef, encodeAsObject(data, buildSettings)) + public inline fun update(documentRef: DocumentReference, data: Any, buildSettings: EncodeSettings.Builder.() -> Unit = {}): Transaction = updateEncoded(documentRef, encodeAsObject(data, buildSettings)) @Deprecated("Deprecated. Use builder instead", replaceWith = ReplaceWith("update(documentRef, strategy, data) { this.encodeDefaults = encodeDefaults }")) - fun update(documentRef: DocumentReference, strategy: SerializationStrategy, data: T, encodeDefaults: Boolean) = update(documentRef, strategy, data) { + public fun update(documentRef: DocumentReference, strategy: SerializationStrategy, data: T, encodeDefaults: Boolean): Transaction = update(documentRef, strategy, data) { this.encodeDefaults = encodeDefaults } - inline fun update(documentRef: DocumentReference, strategy: SerializationStrategy, data: T, buildSettings: EncodeSettings.Builder.() -> Unit = {}) = updateEncoded(documentRef, encodeAsObject(strategy, data, buildSettings)) + public inline fun update(documentRef: DocumentReference, strategy: SerializationStrategy, data: T, buildSettings: EncodeSettings.Builder.() -> Unit = {}): Transaction = updateEncoded(documentRef, encodeAsObject(strategy, data, buildSettings)) @JvmName("updateFields") - inline fun update(documentRef: DocumentReference, vararg fieldsAndValues: Pair, buildSettings: EncodeSettings.Builder.() -> Unit = {}) = updateEncodedFieldsAndValues(documentRef, encodeFieldAndValue(fieldsAndValues, buildSettings).orEmpty()) + public inline fun update(documentRef: DocumentReference, vararg fieldsAndValues: Pair, buildSettings: EncodeSettings.Builder.() -> Unit = {}): Transaction = updateEncodedFieldsAndValues(documentRef, encodeFieldAndValue(fieldsAndValues, buildSettings).orEmpty()) + @JvmName("updateFieldPaths") - inline fun update(documentRef: DocumentReference, vararg fieldsAndValues: Pair, buildSettings: EncodeSettings.Builder.() -> Unit = {}) = updateEncodedFieldPathsAndValues(documentRef, encodeFieldAndValue(fieldsAndValues, buildSettings).orEmpty()) + public inline fun update(documentRef: DocumentReference, vararg fieldsAndValues: Pair, buildSettings: EncodeSettings.Builder.() -> Unit = {}): Transaction = updateEncodedFieldPathsAndValues(documentRef, encodeFieldAndValue(fieldsAndValues, buildSettings).orEmpty()) @PublishedApi internal fun updateEncoded(documentRef: DocumentReference, encodedData: EncodedObject): Transaction = Transaction(nativeWrapper.updateEncoded(documentRef, encodedData)) @@ -184,182 +195,185 @@ data class Transaction internal constructor(@PublishedApi internal val nativeWra @PublishedApi internal fun updateEncodedFieldPathsAndValues(documentRef: DocumentReference, encodedFieldsAndValues: List>): Transaction = Transaction(nativeWrapper.updateEncodedFieldPathsAndValues(documentRef, encodedFieldsAndValues)) - fun delete(documentRef: DocumentReference): Transaction = Transaction(nativeWrapper.delete(documentRef)) - suspend fun get(documentRef: DocumentReference): DocumentSnapshot = DocumentSnapshot(nativeWrapper.get(documentRef)) + public fun delete(documentRef: DocumentReference): Transaction = Transaction(nativeWrapper.delete(documentRef)) + public suspend fun get(documentRef: DocumentReference): DocumentSnapshot = DocumentSnapshot(nativeWrapper.get(documentRef)) } -expect open class NativeQuery +public expect open class NativeQuery -open class Query internal constructor(internal val nativeQuery: NativeQueryWrapper) { +public open class Query internal constructor(internal val nativeQuery: NativeQueryWrapper) { - constructor(native: NativeQuery) : this(NativeQueryWrapper(native)) + public constructor(native: NativeQuery) : this(NativeQueryWrapper(native)) - open val native = nativeQuery.native + public open val native: NativeQuery = nativeQuery.native - fun limit(limit: Number): Query = Query(nativeQuery.limit(limit)) - val snapshots: Flow = nativeQuery.snapshots - fun snapshots(includeMetadataChanges: Boolean = false): Flow = nativeQuery.snapshots(includeMetadataChanges) - suspend fun get(source: Source = Source.DEFAULT): QuerySnapshot = nativeQuery.get(source) + public fun limit(limit: Number): Query = Query(nativeQuery.limit(limit)) + public val snapshots: Flow = nativeQuery.snapshots + public fun snapshots(includeMetadataChanges: Boolean = false): Flow = nativeQuery.snapshots(includeMetadataChanges) + public suspend fun get(source: Source = Source.DEFAULT): QuerySnapshot = nativeQuery.get(source) - fun where(builder: FilterBuilder.() -> Filter?) = builder(FilterBuilder())?.let { Query(nativeQuery.where(it)) } ?: this + public fun where(builder: FilterBuilder.() -> Filter?): Query = builder(FilterBuilder())?.let { Query(nativeQuery.where(it)) } ?: this - fun orderBy(field: String, direction: Direction = Direction.ASCENDING) = Query(nativeQuery.orderBy(field, direction)) - fun orderBy(field: FieldPath, direction: Direction = Direction.ASCENDING) = Query(nativeQuery.orderBy(field.encoded, direction)) + public fun orderBy(field: String, direction: Direction = Direction.ASCENDING): Query = Query(nativeQuery.orderBy(field, direction)) + public fun orderBy(field: FieldPath, direction: Direction = Direction.ASCENDING): Query = Query(nativeQuery.orderBy(field.encoded, direction)) - fun startAfter(document: DocumentSnapshot) = Query(nativeQuery.startAfter(document.native)) - fun startAfter(vararg fieldValues: Any) = Query(nativeQuery.startAfter(*(fieldValues.map { it.safeValue }.toTypedArray()))) - fun startAt(document: DocumentSnapshot) = Query(nativeQuery.startAt(document.native)) - fun startAt(vararg fieldValues: Any) = Query(nativeQuery.startAt(*(fieldValues.map { it.safeValue }.toTypedArray()))) + public fun startAfter(document: DocumentSnapshot): Query = Query(nativeQuery.startAfter(document.native)) + public fun startAfter(vararg fieldValues: Any): Query = Query(nativeQuery.startAfter(*(fieldValues.map { it.safeValue }.toTypedArray()))) + public fun startAt(document: DocumentSnapshot): Query = Query(nativeQuery.startAt(document.native)) + public fun startAt(vararg fieldValues: Any): Query = Query(nativeQuery.startAt(*(fieldValues.map { it.safeValue }.toTypedArray()))) - fun endBefore(document: DocumentSnapshot) = Query(nativeQuery.endBefore(document.native)) - fun endBefore(vararg fieldValues: Any) = Query(nativeQuery.endBefore(*(fieldValues.map { it.safeValue }.toTypedArray()))) - fun endAt(document: DocumentSnapshot) = Query(nativeQuery.endAt(document.native)) - fun endAt(vararg fieldValues: Any) = Query(nativeQuery.endAt(*(fieldValues.map { it.safeValue }.toTypedArray()))) + public fun endBefore(document: DocumentSnapshot): Query = Query(nativeQuery.endBefore(document.native)) + public fun endBefore(vararg fieldValues: Any): Query = Query(nativeQuery.endBefore(*(fieldValues.map { it.safeValue }.toTypedArray()))) + public fun endAt(document: DocumentSnapshot): Query = Query(nativeQuery.endAt(document.native)) + public fun endAt(vararg fieldValues: Any): Query = Query(nativeQuery.endAt(*(fieldValues.map { it.safeValue }.toTypedArray()))) } @Deprecated("Deprecated in favor of using a [FilterBuilder]", replaceWith = ReplaceWith("where { field equalTo equalTo }", "dev.gitlive.firebase.firestore")) -fun Query.where(field: String, equalTo: Any?) = where { +public fun Query.where(field: String, equalTo: Any?): Query = where { field equalTo equalTo } @Deprecated("Deprecated in favor of using a [FilterBuilder]", replaceWith = ReplaceWith("where { path equalTo equalTo }", "dev.gitlive.firebase.firestore")) -fun Query.where(path: FieldPath, equalTo: Any?) = where { +public fun Query.where(path: FieldPath, equalTo: Any?): Query = where { path equalTo equalTo } @Deprecated("Deprecated in favor of using a [FilterBuilder]", replaceWith = ReplaceWith("where { }", "dev.gitlive.firebase.firestore")) -fun Query.where(field: String, lessThan: Any? = null, greaterThan: Any? = null, arrayContains: Any? = null) = where { +public fun Query.where(field: String, lessThan: Any? = null, greaterThan: Any? = null, arrayContains: Any? = null): Query = where { all( *listOfNotNull( lessThan?.let { field lessThan it }, greaterThan?.let { field greaterThan it }, - arrayContains?.let { field contains it } - ).toTypedArray() + arrayContains?.let { field contains it }, + ).toTypedArray(), ) } @Deprecated("Deprecated in favor of using a [FilterBuilder]", replaceWith = ReplaceWith("where { }", "dev.gitlive.firebase.firestore")) -fun Query.where(path: FieldPath, lessThan: Any? = null, greaterThan: Any? = null, arrayContains: Any? = null) = where { +public fun Query.where(path: FieldPath, lessThan: Any? = null, greaterThan: Any? = null, arrayContains: Any? = null): Query = where { all( *listOfNotNull( lessThan?.let { path lessThan it }, greaterThan?.let { path greaterThan it }, - arrayContains?.let { path contains it } - ).toTypedArray() + arrayContains?.let { path contains it }, + ).toTypedArray(), ) } @Deprecated("Deprecated in favor of using a [FilterBuilder]", replaceWith = ReplaceWith("where { }", "dev.gitlive.firebase.firestore")) -fun Query.where(field: String, inArray: List? = null, arrayContainsAny: List? = null) = where { +public fun Query.where(field: String, inArray: List? = null, arrayContainsAny: List? = null): Query = where { all( *listOfNotNull( inArray?.let { field inArray it }, - arrayContainsAny?.let { field containsAny it }, - ).toTypedArray() + arrayContainsAny?.let { field containsAny it }, + ).toTypedArray(), ) } @Deprecated("Deprecated in favor of using a [FilterBuilder]", replaceWith = ReplaceWith("where { }", "dev.gitlive.firebase.firestore")) -fun Query.where(path: FieldPath, inArray: List? = null, arrayContainsAny: List? = null) = where { +public fun Query.where(path: FieldPath, inArray: List? = null, arrayContainsAny: List? = null): Query = where { all( *listOfNotNull( inArray?.let { path inArray it }, - arrayContainsAny?.let { path containsAny it }, - ).toTypedArray() + arrayContainsAny?.let { path containsAny it }, + ).toTypedArray(), ) } -expect class NativeWriteBatch +public expect class NativeWriteBatch -data class WriteBatch internal constructor(@PublishedApi internal val nativeWrapper: NativeWriteBatchWrapper) { +public data class WriteBatch internal constructor(@PublishedApi internal val nativeWrapper: NativeWriteBatchWrapper) { - constructor(native: NativeWriteBatch) : this(NativeWriteBatchWrapper(native)) + public constructor(native: NativeWriteBatch) : this(NativeWriteBatchWrapper(native)) - val native = nativeWrapper.native + public val native: NativeWriteBatch = nativeWrapper.native @Deprecated("Deprecated. Use builder instead", replaceWith = ReplaceWith("set(documentRef, data, merge) { this.encodeDefaults = encodeDefaults }")) - inline fun set(documentRef: DocumentReference, data: T, encodeDefaults: Boolean, merge: Boolean = false) = set(documentRef, data, merge) { + public inline fun set(documentRef: DocumentReference, data: T, encodeDefaults: Boolean, merge: Boolean = false): WriteBatch = set(documentRef, data, merge) { this.encodeDefaults = encodeDefaults } - inline fun set(documentRef: DocumentReference, data: T, merge: Boolean = false, buildSettings: EncodeSettings.Builder.() -> Unit = {}) = + public inline fun set(documentRef: DocumentReference, data: T, merge: Boolean = false, buildSettings: EncodeSettings.Builder.() -> Unit = {}): WriteBatch = setEncoded(documentRef, encodeAsObject(data, buildSettings), if (merge) SetOptions.Merge else SetOptions.Overwrite) @Deprecated("Deprecated. Use builder instead", replaceWith = ReplaceWith("set(documentRef, data, mergeFields) { this.encodeDefaults = encodeDefaults }")) - inline fun set(documentRef: DocumentReference, data: T, encodeDefaults: Boolean, vararg mergeFields: String) = set(documentRef, data, *mergeFields) { + public inline fun set(documentRef: DocumentReference, data: T, encodeDefaults: Boolean, vararg mergeFields: String): WriteBatch = set(documentRef, data, *mergeFields) { this.encodeDefaults = encodeDefaults } - inline fun set(documentRef: DocumentReference, data: T, vararg mergeFields: String, buildSettings: EncodeSettings.Builder.() -> Unit = {}) = + public inline fun set(documentRef: DocumentReference, data: T, vararg mergeFields: String, buildSettings: EncodeSettings.Builder.() -> Unit = {}): WriteBatch = setEncoded(documentRef, encodeAsObject(data, buildSettings), SetOptions.MergeFields(mergeFields.asList())) @Deprecated("Deprecated. Use builder instead", replaceWith = ReplaceWith("set(documentRef, data, mergeFieldPaths) { this.encodeDefaults = encodeDefaults }")) - inline fun set(documentRef: DocumentReference, data: T, encodeDefaults: Boolean, vararg mergeFieldPaths: FieldPath) = set(documentRef, data, *mergeFieldPaths) { + public inline fun set(documentRef: DocumentReference, data: T, encodeDefaults: Boolean, vararg mergeFieldPaths: FieldPath): WriteBatch = set(documentRef, data, *mergeFieldPaths) { this.encodeDefaults = encodeDefaults } - inline fun set(documentRef: DocumentReference, data: T, vararg mergeFieldPaths: FieldPath, buildSettings: EncodeSettings.Builder.() -> Unit = {}) = + public inline fun set(documentRef: DocumentReference, data: T, vararg mergeFieldPaths: FieldPath, buildSettings: EncodeSettings.Builder.() -> Unit = {}): WriteBatch = setEncoded(documentRef, encodeAsObject(data, buildSettings), SetOptions.MergeFieldPaths(mergeFieldPaths.asList())) @Deprecated("Deprecated. Use builder instead", replaceWith = ReplaceWith("set(documentRef, strategy, data, merge) { this.encodeDefaults = encodeDefaults }")) - fun set(documentRef: DocumentReference, strategy: SerializationStrategy, data: T, encodeDefaults: Boolean, merge: Boolean = false) = set(documentRef, strategy, data, merge) { + public fun set(documentRef: DocumentReference, strategy: SerializationStrategy, data: T, encodeDefaults: Boolean, merge: Boolean = false): WriteBatch = set(documentRef, strategy, data, merge) { this.encodeDefaults = encodeDefaults } - inline fun set(documentRef: DocumentReference, strategy: SerializationStrategy, data: T, merge: Boolean = false, buildSettings: EncodeSettings.Builder.() -> Unit = {}) = + public inline fun set(documentRef: DocumentReference, strategy: SerializationStrategy, data: T, merge: Boolean = false, buildSettings: EncodeSettings.Builder.() -> Unit = {}): WriteBatch = setEncoded(documentRef, encodeAsObject(strategy, data, buildSettings), if (merge) SetOptions.Merge else SetOptions.Overwrite) @Deprecated("Deprecated. Use builder instead", replaceWith = ReplaceWith("set(documentRef, strategy, data, mergeFields) { this.encodeDefaults = encodeDefaults }")) - fun set(documentRef: DocumentReference, strategy: SerializationStrategy, data: T, encodeDefaults: Boolean, vararg mergeFields: String) = set(documentRef, strategy, data, *mergeFields){ + public fun set(documentRef: DocumentReference, strategy: SerializationStrategy, data: T, encodeDefaults: Boolean, vararg mergeFields: String): WriteBatch = set(documentRef, strategy, data, *mergeFields) { this.encodeDefaults = encodeDefaults } - inline fun set(documentRef: DocumentReference, strategy: SerializationStrategy, data: T, vararg mergeFields: String, buildSettings: EncodeSettings.Builder.() -> Unit = {}) = + public inline fun set(documentRef: DocumentReference, strategy: SerializationStrategy, data: T, vararg mergeFields: String, buildSettings: EncodeSettings.Builder.() -> Unit = {}): WriteBatch = setEncoded(documentRef, encodeAsObject(strategy, data, buildSettings), SetOptions.MergeFields(mergeFields.asList())) @Deprecated("Deprecated. Use builder instead", replaceWith = ReplaceWith("set(documentRef, strategy, data, mergeFieldPaths) { this.encodeDefaults = encodeDefaults }")) - fun set(documentRef: DocumentReference, strategy: SerializationStrategy, data: T, encodeDefaults: Boolean, vararg mergeFieldPaths: FieldPath) = set(documentRef, strategy, data, *mergeFieldPaths) { + public fun set(documentRef: DocumentReference, strategy: SerializationStrategy, data: T, encodeDefaults: Boolean, vararg mergeFieldPaths: FieldPath): WriteBatch = set(documentRef, strategy, data, *mergeFieldPaths) { this.encodeDefaults = encodeDefaults } - inline fun set(documentRef: DocumentReference, strategy: SerializationStrategy, data: T, vararg mergeFieldPaths: FieldPath, buildSettings: EncodeSettings.Builder.() -> Unit = {}) = + public inline fun set(documentRef: DocumentReference, strategy: SerializationStrategy, data: T, vararg mergeFieldPaths: FieldPath, buildSettings: EncodeSettings.Builder.() -> Unit = {}): WriteBatch = setEncoded(documentRef, encodeAsObject(strategy, data, buildSettings), SetOptions.MergeFieldPaths(mergeFieldPaths.asList())) @PublishedApi - internal fun setEncoded(documentRef: DocumentReference, encodedData: EncodedObject, setOptions: SetOptions) = WriteBatch(nativeWrapper.setEncoded(documentRef, encodedData, setOptions)) + internal fun setEncoded(documentRef: DocumentReference, encodedData: EncodedObject, setOptions: SetOptions): WriteBatch = WriteBatch(nativeWrapper.setEncoded(documentRef, encodedData, setOptions)) @Deprecated("Deprecated. Use builder instead", replaceWith = ReplaceWith("update(documentRef, data) { this.encodeDefaults = encodeDefaults }")) - inline fun update(documentRef: DocumentReference, data: T, encodeDefaults: Boolean) = update(documentRef, data) { + public inline fun update(documentRef: DocumentReference, data: T, encodeDefaults: Boolean): WriteBatch = update(documentRef, data) { this.encodeDefaults = encodeDefaults } - inline fun update(documentRef: DocumentReference, data: T, buildSettings: EncodeSettings.Builder.() -> Unit = {}) = + public inline fun update(documentRef: DocumentReference, data: T, buildSettings: EncodeSettings.Builder.() -> Unit = {}): WriteBatch = updateEncoded(documentRef, encodeAsObject(data, buildSettings)) @Deprecated("Deprecated. Use builder instead", replaceWith = ReplaceWith("update(documentRef, strategy, data) { this.encodeDefaults = encodeDefaults }")) - fun update(documentRef: DocumentReference, strategy: SerializationStrategy, data: T, encodeDefaults: Boolean) = update(documentRef, strategy, data) { + public fun update(documentRef: DocumentReference, strategy: SerializationStrategy, data: T, encodeDefaults: Boolean): WriteBatch = update(documentRef, strategy, data) { this.encodeDefaults = encodeDefaults } - inline fun update(documentRef: DocumentReference, strategy: SerializationStrategy, data: T, buildSettings: EncodeSettings.Builder.() -> Unit = {}) = + public inline fun update(documentRef: DocumentReference, strategy: SerializationStrategy, data: T, buildSettings: EncodeSettings.Builder.() -> Unit = {}): WriteBatch = updateEncoded(documentRef, encodeAsObject(strategy, data, buildSettings)) @JvmName("updateField") - inline fun update(documentRef: DocumentReference, vararg fieldsAndValues: Pair, buildSettings: EncodeSettings.Builder.() -> Unit = {}) = updateEncodedFieldsAndValues(documentRef, encodeFieldAndValue(fieldsAndValues, buildSettings).orEmpty()) + public inline fun update(documentRef: DocumentReference, vararg fieldsAndValues: Pair, buildSettings: EncodeSettings.Builder.() -> Unit = {}): WriteBatch = updateEncodedFieldsAndValues(documentRef, encodeFieldAndValue(fieldsAndValues, buildSettings).orEmpty()) + @JvmName("updateFieldPath") - inline fun update(documentRef: DocumentReference, vararg fieldsAndValues: Pair, buildSettings: EncodeSettings.Builder.() -> Unit = {}) = updateEncodedFieldPathsAndValues(documentRef, encodeFieldAndValue(fieldsAndValues, buildSettings).orEmpty()) + public inline fun update(documentRef: DocumentReference, vararg fieldsAndValues: Pair, buildSettings: EncodeSettings.Builder.() -> Unit = {}): WriteBatch = updateEncodedFieldPathsAndValues(documentRef, encodeFieldAndValue(fieldsAndValues, buildSettings).orEmpty()) @PublishedApi - internal fun updateEncoded(documentRef: DocumentReference, encodedData: EncodedObject) = WriteBatch(nativeWrapper.updateEncoded(documentRef, encodedData)) + internal fun updateEncoded(documentRef: DocumentReference, encodedData: EncodedObject): WriteBatch = WriteBatch(nativeWrapper.updateEncoded(documentRef, encodedData)) @PublishedApi - internal fun updateEncodedFieldsAndValues(documentRef: DocumentReference, encodedFieldsAndValues: List>) = WriteBatch(nativeWrapper.updateEncodedFieldsAndValues(documentRef, encodedFieldsAndValues)) + internal fun updateEncodedFieldsAndValues(documentRef: DocumentReference, encodedFieldsAndValues: List>): WriteBatch = WriteBatch(nativeWrapper.updateEncodedFieldsAndValues(documentRef, encodedFieldsAndValues)) @PublishedApi - internal fun updateEncodedFieldPathsAndValues(documentRef: DocumentReference, encodedFieldsAndValues: List>) = WriteBatch(nativeWrapper.updateEncodedFieldPathsAndValues(documentRef, encodedFieldsAndValues)) + internal fun updateEncodedFieldPathsAndValues(documentRef: DocumentReference, encodedFieldsAndValues: List>): WriteBatch = WriteBatch(nativeWrapper.updateEncodedFieldPathsAndValues(documentRef, encodedFieldsAndValues)) - fun delete(documentRef: DocumentReference): WriteBatch = WriteBatch(nativeWrapper.delete(documentRef)) - suspend fun commit() = nativeWrapper.commit() + public fun delete(documentRef: DocumentReference): WriteBatch = WriteBatch(nativeWrapper.delete(documentRef)) + public suspend fun commit() { + nativeWrapper.commit() + } } /** A class representing a platform specific Firebase DocumentReference. */ -expect class NativeDocumentReferenceType +public expect class NativeDocumentReferenceType /** A class representing a Firebase DocumentReference. */ @Serializable(with = DocumentReferenceSerializer::class) -data class DocumentReference internal constructor(@PublishedApi internal val native: NativeDocumentReference) { +public data class DocumentReference internal constructor(@PublishedApi internal val native: NativeDocumentReference) { internal val nativeValue get() = native.nativeValue @@ -367,116 +381,175 @@ data class DocumentReference internal constructor(@PublishedApi internal val nat val path: String get() = native.path val snapshots: Flow get() = native.snapshots.map(::DocumentSnapshot) val parent: CollectionReference get() = CollectionReference(native.parent) - fun snapshots(includeMetadataChanges: Boolean = false): Flow = native.snapshots(includeMetadataChanges).map(::DocumentSnapshot) + public fun snapshots(includeMetadataChanges: Boolean = false): Flow = native.snapshots(includeMetadataChanges).map(::DocumentSnapshot) - fun collection(collectionPath: String): CollectionReference = CollectionReference(native.collection(collectionPath)) - suspend fun get(source: Source = Source.DEFAULT): DocumentSnapshot = DocumentSnapshot(native.get(source)) + public fun collection(collectionPath: String): CollectionReference = CollectionReference(native.collection(collectionPath)) + public suspend fun get(source: Source = Source.DEFAULT): DocumentSnapshot = DocumentSnapshot(native.get(source)) @Deprecated("Deprecated. Use builder instead", replaceWith = ReplaceWith("set(data, merge) { this.encodeDefaults = encodeDefaults }")) - suspend inline fun set(data: T, encodeDefaults: Boolean, merge: Boolean = false) = set(data, merge) { - this.encodeDefaults = encodeDefaults + public suspend inline fun set(data: T, encodeDefaults: Boolean, merge: Boolean = false) { + set(data, merge) { + this.encodeDefaults = encodeDefaults + } + } + public suspend inline fun set(data: T, merge: Boolean = false, buildSettings: EncodeSettings.Builder.() -> Unit = {}) { + native.setEncoded( + encodeAsObject(data, buildSettings), + if (merge) SetOptions.Merge else SetOptions.Overwrite, + ) } - suspend inline fun set(data: T, merge: Boolean = false, buildSettings: EncodeSettings.Builder.() -> Unit = {}) = native.setEncoded( - encodeAsObject(data, buildSettings), if (merge) SetOptions.Merge else SetOptions.Overwrite) @Deprecated("Deprecated. Use builder instead", replaceWith = ReplaceWith("set(data, mergeFields) { this.encodeDefaults = encodeDefaults }")) - suspend inline fun set(data: T, encodeDefaults: Boolean, vararg mergeFields: String) = set(data, *mergeFields) { - this.encodeDefaults = encodeDefaults + public suspend inline fun set(data: T, encodeDefaults: Boolean, vararg mergeFields: String) { + set(data, *mergeFields) { + this.encodeDefaults = encodeDefaults + } + } + public suspend inline fun set(data: T, vararg mergeFields: String, buildSettings: EncodeSettings.Builder.() -> Unit = {}) { + native.setEncoded( + encodeAsObject(data, buildSettings), + SetOptions.MergeFields(mergeFields.asList()), + ) } - suspend inline fun set(data: T, vararg mergeFields: String, buildSettings: EncodeSettings.Builder.() -> Unit = {}) = native.setEncoded( - encodeAsObject(data, buildSettings), SetOptions.MergeFields(mergeFields.asList())) @Deprecated("Deprecated. Use builder instead", replaceWith = ReplaceWith("set(data, mergeFieldPaths) { this.encodeDefaults = encodeDefaults }")) - suspend inline fun set(data: T, encodeDefaults: Boolean, vararg mergeFieldPaths: FieldPath) = set(data, *mergeFieldPaths) { - this.encodeDefaults = encodeDefaults + public suspend inline fun set(data: T, encodeDefaults: Boolean, vararg mergeFieldPaths: FieldPath) { + set(data, *mergeFieldPaths) { + this.encodeDefaults = encodeDefaults + } + } + public suspend inline fun set(data: T, vararg mergeFieldPaths: FieldPath, buildSettings: EncodeSettings.Builder.() -> Unit = {}) { + native.setEncoded( + encodeAsObject(data, buildSettings), + SetOptions.MergeFieldPaths(mergeFieldPaths.asList()), + ) } - suspend inline fun set(data: T, vararg mergeFieldPaths: FieldPath, buildSettings: EncodeSettings.Builder.() -> Unit = {}) = native.setEncoded( - encodeAsObject(data, buildSettings), SetOptions.MergeFieldPaths(mergeFieldPaths.asList())) @Deprecated("Deprecated. Use builder instead", replaceWith = ReplaceWith("set(strategy, data, merge) { this.encodeDefaults = encodeDefaults }")) - suspend fun set(strategy: SerializationStrategy, data: T, encodeDefaults: Boolean, merge: Boolean = false) = set(strategy, data, merge) { - this.encodeDefaults = encodeDefaults + public suspend fun set(strategy: SerializationStrategy, data: T, encodeDefaults: Boolean, merge: Boolean = false) { + set(strategy, data, merge) { + this.encodeDefaults = encodeDefaults + } + } + public suspend inline fun set(strategy: SerializationStrategy, data: T, merge: Boolean = false, buildSettings: EncodeSettings.Builder.() -> Unit = {}) { + native.setEncoded( + encodeAsObject(strategy, data, buildSettings), + if (merge) SetOptions.Merge else SetOptions.Overwrite, + ) } - suspend inline fun set(strategy: SerializationStrategy, data: T, merge: Boolean = false, buildSettings: EncodeSettings.Builder.() -> Unit = {}) = native.setEncoded( - encodeAsObject(strategy, data, buildSettings), if (merge) SetOptions.Merge else SetOptions.Overwrite) @Deprecated("Deprecated. Use builder instead", replaceWith = ReplaceWith("set(strategy, data, mergeFields) { this.encodeDefaults = encodeDefaults }")) - suspend fun set(strategy: SerializationStrategy, data: T, encodeDefaults: Boolean, vararg mergeFields: String) = set(strategy, data, *mergeFields) { - this.encodeDefaults = encodeDefaults + public suspend fun set(strategy: SerializationStrategy, data: T, encodeDefaults: Boolean, vararg mergeFields: String) { + set(strategy, data, *mergeFields) { + this.encodeDefaults = encodeDefaults + } + } + public suspend inline fun set(strategy: SerializationStrategy, data: T, vararg mergeFields: String, buildSettings: EncodeSettings.Builder.() -> Unit = {}) { + native.setEncoded( + encodeAsObject(strategy, data, buildSettings), + SetOptions.MergeFields(mergeFields.asList()), + ) } - suspend inline fun set(strategy: SerializationStrategy, data: T, vararg mergeFields: String, buildSettings: EncodeSettings.Builder.() -> Unit = {}) = native.setEncoded( - encodeAsObject(strategy, data, buildSettings), SetOptions.MergeFields(mergeFields.asList())) @Deprecated("Deprecated. Use builder instead", replaceWith = ReplaceWith("set(strategy, data, mergeFieldPaths) { this.encodeDefaults = encodeDefaults }")) - suspend fun set(strategy: SerializationStrategy, data: T, encodeDefaults: Boolean, vararg mergeFieldPaths: FieldPath) = set(strategy, data, *mergeFieldPaths) { - this.encodeDefaults = encodeDefaults + public suspend fun set(strategy: SerializationStrategy, data: T, encodeDefaults: Boolean, vararg mergeFieldPaths: FieldPath) { + set(strategy, data, *mergeFieldPaths) { + this.encodeDefaults = encodeDefaults + } + } + public suspend inline fun set(strategy: SerializationStrategy, data: T, vararg mergeFieldPaths: FieldPath, buildSettings: EncodeSettings.Builder.() -> Unit = {}) { + native.setEncoded( + encodeAsObject(strategy, data, buildSettings), + SetOptions.MergeFieldPaths(mergeFieldPaths.asList()), + ) } - suspend inline fun set(strategy: SerializationStrategy, data: T, vararg mergeFieldPaths: FieldPath, buildSettings: EncodeSettings.Builder.() -> Unit = {}) = native.setEncoded( - encodeAsObject(strategy, data, buildSettings), SetOptions.MergeFieldPaths(mergeFieldPaths.asList())) @Deprecated("Deprecated. Use builder instead", replaceWith = ReplaceWith("update(data) { this.encodeDefaults = encodeDefaults }")) - suspend inline fun update(data: T, encodeDefaults: Boolean) = update(data) { - this.encodeDefaults = encodeDefaults + public suspend inline fun update(data: T, encodeDefaults: Boolean) { + update(data) { + this.encodeDefaults = encodeDefaults + } + } + public suspend inline fun update(data: T, buildSettings: EncodeSettings.Builder.() -> Unit = {}) { + native.updateEncoded(encodeAsObject(data, buildSettings)) } - suspend inline fun update(data: T, buildSettings: EncodeSettings.Builder.() -> Unit = {}) = native.updateEncoded(encodeAsObject(data, buildSettings)) @Deprecated("Deprecated. Use builder instead", replaceWith = ReplaceWith("update(strategy, data) { this.encodeDefaults = encodeDefaults }")) - suspend fun update(strategy: SerializationStrategy, data: T, encodeDefaults: Boolean) = update(strategy, data) { - this.encodeDefaults = encodeDefaults + public suspend fun update(strategy: SerializationStrategy, data: T, encodeDefaults: Boolean) { + update(strategy, data) { + this.encodeDefaults = encodeDefaults + } + } + public suspend inline fun update(strategy: SerializationStrategy, data: T, buildSettings: EncodeSettings.Builder.() -> Unit = {}) { + native.updateEncoded( + encodeAsObject(strategy, data, buildSettings), + ) } - suspend inline fun update(strategy: SerializationStrategy, data: T, buildSettings: EncodeSettings.Builder.() -> Unit = {}) = native.updateEncoded( - encodeAsObject(strategy, data, buildSettings) - ) @JvmName("updateFields") - suspend inline fun update(vararg fieldsAndValues: Pair, buildSettings: EncodeSettings.Builder.() -> Unit = {}) = native.updateEncodedFieldsAndValues(encodeFieldAndValue(fieldsAndValues, buildSettings).orEmpty()) + public suspend inline fun update(vararg fieldsAndValues: Pair, buildSettings: EncodeSettings.Builder.() -> Unit = {}) { + native.updateEncodedFieldsAndValues( + encodeFieldAndValue( + fieldsAndValues, + buildSettings, + ).orEmpty(), + ) + } @JvmName("updateFieldPaths") - suspend inline fun update(vararg fieldsAndValues: Pair, buildSettings: EncodeSettings.Builder.() -> Unit = {}) = native.updateEncodedFieldPathsAndValues(encodeFieldAndValue(fieldsAndValues, buildSettings).orEmpty()) + public suspend inline fun update(vararg fieldsAndValues: Pair, buildSettings: EncodeSettings.Builder.() -> Unit = {}) { + native.updateEncodedFieldPathsAndValues( + encodeFieldAndValue( + fieldsAndValues, + buildSettings, + ).orEmpty(), + ) + } - suspend fun delete() = native.delete() + public suspend fun delete() { + native.delete() + } } -expect class NativeCollectionReference : NativeQuery +public expect class NativeCollectionReference : NativeQuery -data class CollectionReference internal constructor(@PublishedApi internal val nativeWrapper: NativeCollectionReferenceWrapper) : Query(nativeWrapper) { +public data class CollectionReference internal constructor(@PublishedApi internal val nativeWrapper: NativeCollectionReferenceWrapper) : Query(nativeWrapper) { - constructor(native: NativeCollectionReference) : this(NativeCollectionReferenceWrapper(native)) + public constructor(native: NativeCollectionReference) : this(NativeCollectionReferenceWrapper(native)) - override val native = nativeWrapper.native + override val native: NativeCollectionReference = nativeWrapper.native val path: String get() = nativeWrapper.path val document: DocumentReference get() = DocumentReference(nativeWrapper.document) val parent: DocumentReference? get() = nativeWrapper.parent?.let(::DocumentReference) - fun document(documentPath: String): DocumentReference = DocumentReference(nativeWrapper.document(documentPath)) + public fun document(documentPath: String): DocumentReference = DocumentReference(nativeWrapper.document(documentPath)) @Deprecated("Deprecated. Use builder instead", replaceWith = ReplaceWith("add(data) { this.encodeDefaults = encodeDefaults }")) - suspend inline fun add(data: T, encodeDefaults: Boolean) = add(data) { + public suspend inline fun add(data: T, encodeDefaults: Boolean): DocumentReference = add(data) { this.encodeDefaults = encodeDefaults } - suspend inline fun add(data: T, buildSettings: EncodeSettings.Builder.() -> Unit = {}) = addEncoded( - encodeAsObject(data, buildSettings) + public suspend inline fun add(data: T, buildSettings: EncodeSettings.Builder.() -> Unit = {}): DocumentReference = addEncoded( + encodeAsObject(data, buildSettings), ) @Deprecated("Deprecated. Use builder instead", replaceWith = ReplaceWith("add(strategy, data) { this.encodeDefaults = encodeDefaults }")) - suspend fun add(strategy: SerializationStrategy, data: T, encodeDefaults: Boolean) = add(strategy, data) { + public suspend fun add(strategy: SerializationStrategy, data: T, encodeDefaults: Boolean): DocumentReference = add(strategy, data) { this.encodeDefaults = encodeDefaults } - suspend inline fun add(strategy: SerializationStrategy, data: T, buildSettings: EncodeSettings.Builder.() -> Unit = {}) = addEncoded( - encodeAsObject(strategy, data, buildSettings) + public suspend inline fun add(strategy: SerializationStrategy, data: T, buildSettings: EncodeSettings.Builder.() -> Unit = {}): DocumentReference = addEncoded( + encodeAsObject(strategy, data, buildSettings), ) @PublishedApi internal suspend fun addEncoded(data: EncodedObject): DocumentReference = DocumentReference(nativeWrapper.addEncoded(data)) } -expect class FirebaseFirestoreException : FirebaseException +public expect class FirebaseFirestoreException : FirebaseException -@Suppress("EXTENSION_SHADOWED_BY_MEMBER") -expect val FirebaseFirestoreException.code: FirestoreExceptionCode +public expect val FirebaseFirestoreException.code: FirestoreExceptionCode -expect enum class FirestoreExceptionCode { +public expect enum class FirestoreExceptionCode { OK, CANCELLED, UNKNOWN, @@ -493,93 +566,93 @@ expect enum class FirestoreExceptionCode { INTERNAL, UNAVAILABLE, DATA_LOSS, - UNAUTHENTICATED + UNAUTHENTICATED, } -expect enum class Direction { +public expect enum class Direction { ASCENDING, - DESCENDING + DESCENDING, } -expect class QuerySnapshot { - val documents: List - val documentChanges: List - val metadata: SnapshotMetadata +public expect class QuerySnapshot { + public val documents: List + public val documentChanges: List + public val metadata: SnapshotMetadata } -expect enum class ChangeType { - ADDED , +public expect enum class ChangeType { + ADDED, MODIFIED, - REMOVED + REMOVED, } -expect class DocumentChange { - val document: DocumentSnapshot - val newIndex: Int - val oldIndex: Int - val type: ChangeType +public expect class DocumentChange { + public val document: DocumentSnapshot + public val newIndex: Int + public val oldIndex: Int + public val type: ChangeType } -expect class NativeDocumentSnapshot +public expect class NativeDocumentSnapshot -data class DocumentSnapshot internal constructor(@PublishedApi internal val nativeWrapper: NativeDocumentSnapshotWrapper) { +public data class DocumentSnapshot internal constructor(@PublishedApi internal val nativeWrapper: NativeDocumentSnapshotWrapper) { - constructor(native: NativeDocumentSnapshot) : this(NativeDocumentSnapshotWrapper(native)) + public constructor(native: NativeDocumentSnapshot) : this(NativeDocumentSnapshotWrapper(native)) - val native = nativeWrapper.native + public val native: NativeDocumentSnapshot = nativeWrapper.native val exists: Boolean get() = nativeWrapper.exists val id: String get() = nativeWrapper.id val reference: DocumentReference get() = DocumentReference(nativeWrapper.reference) val metadata: SnapshotMetadata get() = nativeWrapper.metadata - fun contains(field: String): Boolean = nativeWrapper.contains(field) - fun contains(fieldPath: FieldPath): Boolean = nativeWrapper.contains(fieldPath.encoded) + public fun contains(field: String): Boolean = nativeWrapper.contains(field) + public fun contains(fieldPath: FieldPath): Boolean = nativeWrapper.contains(fieldPath.encoded) - inline fun get(field: String, serverTimestampBehavior: ServerTimestampBehavior = ServerTimestampBehavior.NONE, buildSettings: DecodeSettings.Builder.() -> Unit = {}): T = decode(value = getEncoded(field, serverTimestampBehavior), buildSettings) - inline fun get(field: String, strategy: DeserializationStrategy, serverTimestampBehavior: ServerTimestampBehavior = ServerTimestampBehavior.NONE, buildSettings: DecodeSettings.Builder.() -> Unit = {}): T = decode(strategy, getEncoded(field, serverTimestampBehavior), buildSettings) + public inline fun get(field: String, serverTimestampBehavior: ServerTimestampBehavior = ServerTimestampBehavior.NONE, buildSettings: DecodeSettings.Builder.() -> Unit = {}): T = decode(value = getEncoded(field, serverTimestampBehavior), buildSettings) + public inline fun get(field: String, strategy: DeserializationStrategy, serverTimestampBehavior: ServerTimestampBehavior = ServerTimestampBehavior.NONE, buildSettings: DecodeSettings.Builder.() -> Unit = {}): T = decode(strategy, getEncoded(field, serverTimestampBehavior), buildSettings) @PublishedApi internal fun getEncoded(field: String, serverTimestampBehavior: ServerTimestampBehavior = ServerTimestampBehavior.NONE): Any? = nativeWrapper.getEncoded(field, serverTimestampBehavior) - inline fun get(fieldPath: FieldPath, serverTimestampBehavior: ServerTimestampBehavior = ServerTimestampBehavior.NONE, buildSettings: DecodeSettings.Builder.() -> Unit = {}): T = decode(value = getEncoded(fieldPath, serverTimestampBehavior), buildSettings) - inline fun get(fieldPath: FieldPath, strategy: DeserializationStrategy, serverTimestampBehavior: ServerTimestampBehavior = ServerTimestampBehavior.NONE, buildSettings: DecodeSettings.Builder.() -> Unit = {}): T = decode(strategy, getEncoded(fieldPath, serverTimestampBehavior), buildSettings) + public inline fun get(fieldPath: FieldPath, serverTimestampBehavior: ServerTimestampBehavior = ServerTimestampBehavior.NONE, buildSettings: DecodeSettings.Builder.() -> Unit = {}): T = decode(value = getEncoded(fieldPath, serverTimestampBehavior), buildSettings) + public inline fun get(fieldPath: FieldPath, strategy: DeserializationStrategy, serverTimestampBehavior: ServerTimestampBehavior = ServerTimestampBehavior.NONE, buildSettings: DecodeSettings.Builder.() -> Unit = {}): T = decode(strategy, getEncoded(fieldPath, serverTimestampBehavior), buildSettings) @PublishedApi internal fun getEncoded(fieldPath: FieldPath, serverTimestampBehavior: ServerTimestampBehavior = ServerTimestampBehavior.NONE): Any? = nativeWrapper.getEncoded(fieldPath.encoded, serverTimestampBehavior) - - inline fun data(serverTimestampBehavior: ServerTimestampBehavior = ServerTimestampBehavior.NONE, buildSettings: DecodeSettings.Builder.() -> Unit = {}): T = decode(encodedData(serverTimestampBehavior), buildSettings) - inline fun data(strategy: DeserializationStrategy, serverTimestampBehavior: ServerTimestampBehavior = ServerTimestampBehavior.NONE, buildSettings: DecodeSettings.Builder.() -> Unit = {}): T = decode(strategy, encodedData(serverTimestampBehavior), buildSettings) + public inline fun data(serverTimestampBehavior: ServerTimestampBehavior = ServerTimestampBehavior.NONE, buildSettings: DecodeSettings.Builder.() -> Unit = {}): T = decode(encodedData(serverTimestampBehavior), buildSettings) + public inline fun data(strategy: DeserializationStrategy, serverTimestampBehavior: ServerTimestampBehavior = ServerTimestampBehavior.NONE, buildSettings: DecodeSettings.Builder.() -> Unit = {}): T = decode(strategy, encodedData(serverTimestampBehavior), buildSettings) @PublishedApi internal fun encodedData(serverTimestampBehavior: ServerTimestampBehavior = ServerTimestampBehavior.NONE): Any? = nativeWrapper.encodedData(serverTimestampBehavior) } -enum class ServerTimestampBehavior { +public enum class ServerTimestampBehavior { ESTIMATE, NONE, - PREVIOUS + PREVIOUS, } -expect class SnapshotMetadata { - val hasPendingWrites: Boolean - val isFromCache: Boolean +public expect class SnapshotMetadata { + public val hasPendingWrites: Boolean + public val isFromCache: Boolean } -expect class FieldPath(vararg fieldNames: String) { - companion object { - val documentId: FieldPath +public expect class FieldPath(vararg fieldNames: String) { + public companion object { + public val documentId: FieldPath } + @Deprecated("Use companion object instead", replaceWith = ReplaceWith("FieldPath.documentId")) - val documentId: FieldPath - val encoded: EncodedFieldPath + public val documentId: FieldPath + public val encoded: EncodedFieldPath } -expect class EncodedFieldPath +public expect class EncodedFieldPath -enum class Source { +public enum class Source { CACHE, SERVER, - DEFAULT -} \ No newline at end of file + DEFAULT, +} diff --git a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/helpers.kt b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/helpers.kt index bde2fd6bf..766836a76 100644 --- a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/helpers.kt +++ b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/helpers.kt @@ -3,13 +3,13 @@ package dev.gitlive.firebase.firestore import dev.gitlive.firebase.EncodeSettings import kotlin.jvm.JvmName -//** Helper method to perform an update operation. */ +// ** Helper method to perform an update operation. */ @JvmName("performUpdateFields") @PublishedApi internal inline fun encodeFieldAndValue( fieldsAndValues: Array>, buildSettings: EncodeSettings.Builder.() -> Unit, -) = encodeFieldAndValue(fieldsAndValues, encodeField = { it }, encodeValue = { encode(it, buildSettings) }) +): List>? = encodeFieldAndValue(fieldsAndValues, encodeField = { it }, encodeValue = { encode(it, buildSettings) }) /** Helper method to perform an update operation. */ @JvmName("performUpdateFieldPaths") @@ -17,22 +17,22 @@ internal inline fun encodeFieldAndValue( internal inline fun encodeFieldAndValue( fieldsAndValues: Array>, buildSettings: EncodeSettings.Builder.() -> Unit, -) = encodeFieldAndValue(fieldsAndValues, { it.encoded }, { encode(it, buildSettings) }) +): List>? = encodeFieldAndValue(fieldsAndValues, { it.encoded }, { encode(it, buildSettings) }) /** Helper method to perform an update operation in Android and JS. */ @PublishedApi internal inline fun encodeFieldAndValue( fieldsAndValues: Array>, encodeField: (T) -> K, - encodeValue: (Any?) -> Any? -) : List>? = + encodeValue: (Any?) -> Any?, +): List>? = fieldsAndValues.takeUnless { fieldsAndValues.isEmpty() } ?.map { (field, value) -> encodeField(field) to value?.let { encodeValue(it) } } internal fun List>.performUpdate( - update: (K, Any?, Array) -> R + update: (K, Any?, Array) -> R, ) = update( this[0].first, this[0].second, - this.drop(1).flatMap { (field, value) -> listOf(field, value) }.toTypedArray() + this.drop(1).flatMap { (field, value) -> listOf(field, value) }.toTypedArray(), ) diff --git a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeCollectionReferenceWrapper.kt b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeCollectionReferenceWrapper.kt index f4b38be4f..ec602068a 100644 --- a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeCollectionReferenceWrapper.kt +++ b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeCollectionReferenceWrapper.kt @@ -4,8 +4,7 @@ import dev.gitlive.firebase.firestore.NativeCollectionReference import dev.gitlive.firebase.internal.EncodedObject @PublishedApi -internal expect class NativeCollectionReferenceWrapper internal constructor(native: NativeCollectionReference) : - NativeQueryWrapper { +internal expect class NativeCollectionReferenceWrapper internal constructor(native: NativeCollectionReference) : NativeQueryWrapper { override val native: NativeCollectionReference @@ -15,4 +14,4 @@ internal expect class NativeCollectionReferenceWrapper internal constructor(nati fun document(documentPath: String): NativeDocumentReference suspend fun addEncoded(data: EncodedObject): NativeDocumentReference -} \ No newline at end of file +} diff --git a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentReference.kt b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentReference.kt index b50248ae9..1b7ebf63f 100644 --- a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentReference.kt +++ b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentReference.kt @@ -24,4 +24,4 @@ internal expect class NativeDocumentReference(nativeValue: NativeDocumentReferen suspend fun updateEncodedFieldsAndValues(encodedFieldsAndValues: List>) suspend fun updateEncodedFieldPathsAndValues(encodedFieldsAndValues: List>) suspend fun delete() -} \ No newline at end of file +} diff --git a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentSnapshotWrapper.kt b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentSnapshotWrapper.kt index 5db75d0e2..ee7450ffa 100644 --- a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentSnapshotWrapper.kt +++ b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentSnapshotWrapper.kt @@ -21,4 +21,4 @@ internal expect class NativeDocumentSnapshotWrapper internal constructor(native: fun getEncoded(field: String, serverTimestampBehavior: ServerTimestampBehavior = ServerTimestampBehavior.NONE): Any? fun getEncoded(fieldPath: EncodedFieldPath, serverTimestampBehavior: ServerTimestampBehavior = ServerTimestampBehavior.NONE): Any? fun encodedData(serverTimestampBehavior: ServerTimestampBehavior = ServerTimestampBehavior.NONE): Any? -} \ No newline at end of file +} diff --git a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeFirebaseFirestoreWrapper.kt b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeFirebaseFirestoreWrapper.kt index dc6957177..207fbbb9b 100644 --- a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeFirebaseFirestoreWrapper.kt +++ b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeFirebaseFirestoreWrapper.kt @@ -21,4 +21,4 @@ internal expect class NativeFirebaseFirestoreWrapper internal constructor(native fun useEmulator(host: String, port: Int) suspend fun disableNetwork() suspend fun enableNetwork() -} \ No newline at end of file +} diff --git a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeQueryWrapper.kt b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeQueryWrapper.kt index 8a2d8228b..ebc7d8a1e 100644 --- a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeQueryWrapper.kt +++ b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeQueryWrapper.kt @@ -33,4 +33,4 @@ internal expect open class NativeQueryWrapper internal constructor(native: Nativ fun endBefore(vararg fieldValues: Any): NativeQuery fun endAt(document: NativeDocumentSnapshot): NativeQuery fun endAt(vararg fieldValues: Any): NativeQuery -} \ No newline at end of file +} diff --git a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeTransactionWrapper.kt b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeTransactionWrapper.kt index abc7776a2..bb78bd1ef 100644 --- a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeTransactionWrapper.kt +++ b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeTransactionWrapper.kt @@ -16,4 +16,4 @@ internal expect class NativeTransactionWrapper internal constructor(native: Nati fun updateEncodedFieldPathsAndValues(documentRef: DocumentReference, encodedFieldsAndValues: List>): NativeTransactionWrapper fun delete(documentRef: DocumentReference): NativeTransactionWrapper suspend fun get(documentRef: DocumentReference): NativeDocumentSnapshotWrapper -} \ No newline at end of file +} diff --git a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeWriteBatchWrapper.kt b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeWriteBatchWrapper.kt index 60a2e9564..219aee2ed 100644 --- a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeWriteBatchWrapper.kt +++ b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeWriteBatchWrapper.kt @@ -14,4 +14,4 @@ internal expect class NativeWriteBatchWrapper internal constructor(native: Nativ fun updateEncodedFieldPathsAndValues(documentRef: DocumentReference, encodedFieldsAndValues: List>): NativeWriteBatchWrapper fun delete(documentRef: DocumentReference): NativeWriteBatchWrapper suspend fun commit() -} \ No newline at end of file +} diff --git a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/internal/SafeValue.kt b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/internal/SafeValue.kt index f424b244d..afca32060 100644 --- a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/internal/SafeValue.kt +++ b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/internal/SafeValue.kt @@ -11,4 +11,4 @@ internal val Any.safeValue: Any get() = when (this) { is Map<*, *> -> this.mapNotNull { (key, value) -> key?.let { it.safeValue to value?.safeValue } } is Collection<*> -> this.mapNotNull { it?.safeValue } else -> this -} \ No newline at end of file +} diff --git a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/internal/SetOptions.kt b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/internal/SetOptions.kt index 84fcbe604..badaba656 100644 --- a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/internal/SetOptions.kt +++ b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/internal/SetOptions.kt @@ -10,4 +10,4 @@ internal sealed class SetOptions { data class MergeFieldPaths(val fieldPaths: List) : SetOptions() { val encodedFieldPaths = fieldPaths.map { it.encoded } } -} \ No newline at end of file +} diff --git a/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/FirestoreSourceTest.kt b/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/FirestoreSourceTest.kt index d59ce53c2..a3db14a9b 100644 --- a/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/FirestoreSourceTest.kt +++ b/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/FirestoreSourceTest.kt @@ -33,15 +33,15 @@ class FirestoreSourceTest { databaseUrl = "https://fir-kotlin-sdk.firebaseio.com", storageBucket = "fir-kotlin-sdk.appspot.com", projectId = "fir-kotlin-sdk", - gcmSenderId = "846484016111" - ) + gcmSenderId = "846484016111", + ), ) firestore = Firebase.firestore(app).apply { useEmulator(emulatorHost, 8080) settings = firestoreSettings(settings) { cacheSettings = if (persistenceEnabled) { - persistentCacheSettings { } + persistentCacheSettings { } } else { memoryCacheSettings { } } @@ -102,6 +102,7 @@ class FirestoreSourceTest { assertTrue(doc.exists) assertFalse(doc.metadata.isFromCache) } + @Test fun testGet() = runTest { initializeFirebase(persistenceEnabled = false) @@ -119,5 +120,4 @@ class FirestoreSourceTest { // Firebase defaults to first fetching from server assertFalse(doc.metadata.isFromCache) } - -} \ No newline at end of file +} diff --git a/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/GeoPointTests.kt b/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/GeoPointTests.kt index b97eb8378..755787664 100644 --- a/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/GeoPointTests.kt +++ b/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/GeoPointTests.kt @@ -10,10 +10,9 @@ import kotlin.test.assertEquals @Serializable data class TestDataWithGeoPoint( val uid: String, - val location: GeoPoint + val location: GeoPoint, ) -@Suppress("UNCHECKED_CAST") class GeoPointTests { @Test @@ -23,7 +22,7 @@ class GeoPointTests { val encoded = encodedAsMap( encode(item) { encodeDefaults = false - } + }, ) assertEquals("123", encoded["uid"]) // check GeoPoint is encoded to a platform representation @@ -35,7 +34,7 @@ class GeoPointTests { val geoPoint = GeoPoint(12.3, 45.6) val obj = mapOf( "uid" to "123", - "location" to geoPoint.nativeValue + "location" to geoPoint.nativeValue, ).asEncoded() val decoded: TestDataWithGeoPoint = decode(obj) assertEquals("123", decoded.uid) @@ -46,6 +45,6 @@ class GeoPointTests { @Test @IgnoreJs fun serializers() = runTest { - assertEquals(GeoPointSerializer, GeoPoint(0.0,0.0).firebaseSerializer()) + assertEquals(GeoPointSerializer, GeoPoint(0.0, 0.0).firebaseSerializer()) } } diff --git a/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/TimestampTests.kt b/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/TimestampTests.kt index 625a3f68c..10d8c1a63 100644 --- a/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/TimestampTests.kt +++ b/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/TimestampTests.kt @@ -19,7 +19,7 @@ data class TestData( val uid: String, val createdAt: Timestamp, var updatedAt: BaseTimestamp, - val deletedAt: BaseTimestamp? + val deletedAt: BaseTimestamp?, ) class TimestampTests { @@ -42,9 +42,9 @@ class TimestampTests { "uid" to "uid123", "createdAt" to timestamp.nativeValue, "updatedAt" to timestamp.nativeValue, - "deletedAt" to null + "deletedAt" to null, ), - encode(item) { encodeDefaults = false } + encode(item) { encodeDefaults = false }, ) } @@ -57,9 +57,9 @@ class TimestampTests { "uid" to "uid123", "createdAt" to timestamp.nativeValue, "updatedAt" to FieldValue.serverTimestamp.nativeValue, - "deletedAt" to FieldValue.serverTimestamp.nativeValue + "deletedAt" to FieldValue.serverTimestamp.nativeValue, ), - encode(item) { encodeDefaults = false } + encode(item) { encodeDefaults = false }, ) } @@ -70,7 +70,7 @@ class TimestampTests { "uid" to "uid123", "createdAt" to timestamp.nativeValue, "updatedAt" to timestamp.nativeValue, - "deletedAt" to timestamp.nativeValue + "deletedAt" to timestamp.nativeValue, ) val decoded: TestData = decode(TestData.serializer(), obj) assertEquals("uid123", decoded.uid) @@ -97,7 +97,7 @@ class TimestampTests { "uid" to "uid123", "createdAt" to Timestamp.now().nativeValue, "updatedAt" to Timestamp.now().nativeValue, - "deletedAt" to null + "deletedAt" to null, ) val decoded: TestData = decode(TestData.serializer(), obj) assertEquals("uid123", decoded.uid) diff --git a/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt b/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt index 1e2aa707b..a95310bfc 100644 --- a/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt +++ b/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt @@ -38,6 +38,7 @@ expect val context: Any /** @return a map extracted from the encoded data. */ expect fun encodedAsMap(encoded: Any?): Map + /** @return pairs as raw encoded data. */ expect fun Map.asEncoded(): Any @@ -56,7 +57,7 @@ class FirebaseFirestoreTest { @Serializable data class FirestoreTimeTest( val prop1: String, - val time: BaseTimestamp? + val time: BaseTimestamp?, ) companion object { @@ -71,7 +72,7 @@ class FirebaseFirestoreTest { "bbb", 0.0, 2, - listOf("b", "bb", "ccc") + listOf("b", "bb", "ccc"), ) val testThree = FirestoreTest( "ccc", @@ -94,8 +95,8 @@ class FirebaseFirestoreTest { databaseUrl = "https://fir-kotlin-sdk.firebaseio.com", storageBucket = "fir-kotlin-sdk.appspot.com", projectId = "fir-kotlin-sdk", - gcmSenderId = "846484016111" - ) + gcmSenderId = "846484016111", + ), ) firestore = Firebase.firestore(app).apply { @@ -219,7 +220,7 @@ class FirebaseFirestoreTest { doc.set( FirestoreTimeTest.serializer(), - FirestoreTimeTest("ServerTimestampBehavior", Timestamp.ServerTimestamp) + FirestoreTimeTest("ServerTimestampBehavior", Timestamp.ServerTimestamp), ) val pendingWritesSnapshot = deferredPendingWritesSnapshot.await() @@ -238,13 +239,12 @@ class FirebaseFirestoreTest { strategy = FirestoreTest.serializer(), data = FirestoreTest( prop1 = "prop1", - time = 123.0 + time = 123.0, ), ) batch.commit() assertEquals("prop1", doc.get().data(FirestoreTest.serializer()).prop1) - } @Test @@ -513,8 +513,8 @@ class FirebaseFirestoreTest { strategy = FirestoreTest.serializer(), data = FirestoreTest( prop1 = "prop1-set", - time = 125.0 - ) + time = 125.0, + ), ) batch.commit() @@ -530,19 +530,18 @@ class FirebaseFirestoreTest { set( FirestoreTest( prop1 = "prop1", - time = 123.0 - ) + time = 123.0, + ), ) } - val batch = firestore.batch() batch.update( documentRef = doc, strategy = FirestoreTest.serializer(), data = FirestoreTest( prop1 = "prop1-updated", - time = 123.0 + time = 123.0, ), ) { encodeDefaults = false @@ -560,8 +559,8 @@ class FirebaseFirestoreTest { set( FirestoreTest( prop1 = "prop1", - time = 123.0 - ) + time = 123.0, + ), ) } val batch = firestore.batch() @@ -570,7 +569,7 @@ class FirebaseFirestoreTest { strategy = FirestoreTest.serializer(), data = FirestoreTest( prop1 = "prop1-set", - time = 126.0 + time = 126.0, ), ) { encodeDefaults = false @@ -586,7 +585,7 @@ class FirebaseFirestoreTest { @Serializable data class DoubleTimestamp( @Serializable(with = DoubleAsTimestampSerializer::class) - val time: Double? + val time: Double?, ) val doc = firestore @@ -598,12 +597,12 @@ class FirebaseFirestoreTest { } nonSkippedDelay(100) // makes possible to catch pending writes snapshot - doc.set(DoubleTimestamp.serializer(), DoubleTimestamp(DoubleAsTimestampSerializer.serverTimestamp)) + doc.set(DoubleTimestamp.serializer(), DoubleTimestamp(DoubleAsTimestampSerializer.SERVER_TIMESTAMP)) val pendingWritesSnapshot = deferredPendingWritesSnapshot.await() assertTrue(pendingWritesSnapshot.metadata.hasPendingWrites) - assertNotNull(pendingWritesSnapshot.get("time", DoubleAsTimestampSerializer, serverTimestampBehavior = ServerTimestampBehavior.ESTIMATE )) - assertNotEquals(DoubleAsTimestampSerializer.serverTimestamp, pendingWritesSnapshot.data(DoubleTimestamp.serializer(), serverTimestampBehavior = ServerTimestampBehavior.ESTIMATE).time) + assertNotNull(pendingWritesSnapshot.get("time", DoubleAsTimestampSerializer, serverTimestampBehavior = ServerTimestampBehavior.ESTIMATE)) + assertNotEquals(DoubleAsTimestampSerializer.SERVER_TIMESTAMP, pendingWritesSnapshot.data(DoubleTimestamp.serializer(), serverTimestampBehavior = ServerTimestampBehavior.ESTIMATE).time) } @Test @@ -611,12 +610,12 @@ class FirebaseFirestoreTest { @Serializable data class LegacyDocument( @Serializable(with = DoubleAsTimestampSerializer::class) - val time: Double + val time: Double, ) @Serializable data class NewDocument( - val time: Timestamp + val time: Timestamp, ) val doc = firestore @@ -635,7 +634,7 @@ class FirebaseFirestoreTest { fun testQueryByTimestamp() = runTest { @Serializable data class DocumentWithTimestamp( - val time: Timestamp + val time: Timestamp, ) val collection = firestore @@ -689,7 +688,7 @@ class FirebaseFirestoreTest { fun testDocumentReferenceSerialization() = runTest { @Serializable data class DataWithDocumentReference( - val documentReference: DocumentReference + val documentReference: DocumentReference, ) fun getCollection() = firestore.collection("documentReferenceSerialization") @@ -712,7 +711,7 @@ class FirebaseFirestoreTest { // update data val updatedData = DataWithDocumentReference(documentRef2) getDocument().update( - FieldPath(DataWithDocumentReference::documentReference.name) to updatedData.documentReference.withSerializer(DocumentReferenceSerializer) + FieldPath(DataWithDocumentReference::documentReference.name) to updatedData.documentReference.withSerializer(DocumentReferenceSerializer), ) // verify update val updatedSavedData = getDocument().get().data(DataWithDocumentReference.serializer()) @@ -723,12 +722,12 @@ class FirebaseFirestoreTest { data class TestDataWithDocumentReference( val uid: String, val reference: DocumentReference, - val optionalReference: DocumentReference? + val optionalReference: DocumentReference?, ) @Serializable data class TestDataWithOptionalDocumentReference( - val optionalReference: DocumentReference? + val optionalReference: DocumentReference?, ) @Test @@ -738,7 +737,7 @@ class FirebaseFirestoreTest { val encoded = encodedAsMap( encode(item) { encodeDefaults = false - } + }, ) assertEquals("123", encoded["uid"]) assertEquals(doc.nativeValue, encoded["reference"]) @@ -751,7 +750,7 @@ class FirebaseFirestoreTest { val encoded = encodedAsMap( encode(item) { encodeDefaults = false - } + }, ) assertNull(encoded["optionalReference"]) } @@ -762,7 +761,7 @@ class FirebaseFirestoreTest { val obj = mapOf( "uid" to "123", "reference" to doc.nativeValue, - "optionalReference" to doc.nativeValue + "optionalReference" to doc.nativeValue, ).asEncoded() val decoded: TestDataWithDocumentReference = decode(obj) assertEquals("123", decoded.uid) @@ -835,19 +834,19 @@ class FirebaseFirestoreTest { val fieldQuery = firestore .collection("testFirestoreQuerying") - .where { "prop1" notEqualTo testOne.prop1 } + .where { "prop1" notEqualTo testOne.prop1 } fieldQuery.assertDocuments(FirestoreTest.serializer(), testTwo, testThree) val pathQuery = firestore .collection("testFirestoreQuerying") - .where { FieldPath(FirestoreTest::prop1.name) notEqualTo testTwo.prop1 } + .where { FieldPath(FirestoreTest::prop1.name) notEqualTo testTwo.prop1 } pathQuery.assertDocuments(FirestoreTest.serializer(), testOne, testThree) val nullableQuery = firestore .collection("testFirestoreQuerying") - .where { FieldPath(FirestoreTest::optional.name) notEqualTo null } + .where { FieldPath(FirestoreTest::optional.name) notEqualTo null } nullableQuery.assertDocuments(FirestoreTest.serializer(), testOne, testThree) } @@ -915,7 +914,7 @@ class FirebaseFirestoreTest { val pathQuery = firestore .collection("testFirestoreQuerying") - .where { FieldPath(FirestoreTest::count.name) greaterThanOrEqualTo testTwo.count } + .where { FieldPath(FirestoreTest::count.name) greaterThanOrEqualTo testTwo.count } pathQuery.assertDocuments(FirestoreTest.serializer(), testTwo, testThree) } @@ -1014,7 +1013,7 @@ class FirebaseFirestoreTest { FieldPath(FirestoreTest::prop1.name) equalTo "aaa", FieldPath(FirestoreTest::count.name) equalTo 2, )!!, - FieldPath(FirestoreTest::list.name) contains "a" + FieldPath(FirestoreTest::list.name) contains "a", ) } andOrQuery.assertDocuments(FirestoreTest.serializer(), testOne) @@ -1033,7 +1032,7 @@ class FirebaseFirestoreTest { private suspend fun setupFirestoreData( documentOne: FirestoreTest = testOne, documentTwo: FirestoreTest = testTwo, - documentThree: FirestoreTest = testThree + documentThree: FirestoreTest = testThree, ) { firestore.collection("testFirestoreQuerying") .document("one") diff --git a/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/FieldValue.kt b/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/FieldValue.kt index f3c0efd0a..9eb6a8589 100644 --- a/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/FieldValue.kt +++ b/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/FieldValue.kt @@ -8,7 +8,7 @@ private typealias NativeFieldValue = FIRFieldValue /** Represents a Firebase FieldValue. */ @Serializable(with = FieldValueSerializer::class) -actual class FieldValue internal actual constructor(internal actual val nativeValue: Any) { +public actual class FieldValue internal actual constructor(internal actual val nativeValue: Any) { init { require(nativeValue is NativeFieldValue) } @@ -17,11 +17,11 @@ actual class FieldValue internal actual constructor(internal actual val nativeVa override fun hashCode(): Int = nativeValue.hashCode() override fun toString(): String = nativeValue.toString() - actual companion object { - actual val serverTimestamp: FieldValue get() = FieldValue(NativeFieldValue.fieldValueForServerTimestamp()) - actual val delete: FieldValue get() = FieldValue(NativeFieldValue.fieldValueForDelete()) - actual fun increment(value: Int): FieldValue = FieldValue(NativeFieldValue.fieldValueForIntegerIncrement(value.toLong())) - actual fun arrayUnion(vararg elements: Any): FieldValue = FieldValue(NativeFieldValue.fieldValueForArrayUnion(elements.asList())) - actual fun arrayRemove(vararg elements: Any): FieldValue = FieldValue(NativeFieldValue.fieldValueForArrayRemove(elements.asList())) + public actual companion object { + public actual val serverTimestamp: FieldValue get() = FieldValue(NativeFieldValue.fieldValueForServerTimestamp()) + public actual val delete: FieldValue get() = FieldValue(NativeFieldValue.fieldValueForDelete()) + public actual fun increment(value: Int): FieldValue = FieldValue(NativeFieldValue.fieldValueForIntegerIncrement(value.toLong())) + public actual fun arrayUnion(vararg elements: Any): FieldValue = FieldValue(NativeFieldValue.fieldValueForArrayUnion(elements.asList())) + public actual fun arrayRemove(vararg elements: Any): FieldValue = FieldValue(NativeFieldValue.fieldValueForArrayRemove(elements.asList())) } } diff --git a/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/GeoPoint.kt b/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/GeoPoint.kt index 409760667..5dc0fa8aa 100644 --- a/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/GeoPoint.kt +++ b/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/GeoPoint.kt @@ -4,14 +4,14 @@ import cocoapods.FirebaseFirestoreInternal.FIRGeoPoint import kotlinx.serialization.Serializable /** A class representing a platform specific Firebase GeoPoint. */ -actual typealias NativeGeoPoint = FIRGeoPoint +public actual typealias NativeGeoPoint = FIRGeoPoint /** A class representing a Firebase GeoPoint. */ @Serializable(with = GeoPointSerializer::class) -actual class GeoPoint internal actual constructor(internal actual val nativeValue: NativeGeoPoint) { - actual constructor(latitude: Double, longitude: Double) : this(NativeGeoPoint(latitude, longitude)) - actual val latitude: Double = nativeValue.latitude - actual val longitude: Double = nativeValue.longitude +public actual class GeoPoint internal actual constructor(internal actual val nativeValue: NativeGeoPoint) { + public actual constructor(latitude: Double, longitude: Double) : this(NativeGeoPoint(latitude, longitude)) + public actual val latitude: Double = nativeValue.latitude + public actual val longitude: Double = nativeValue.longitude override fun equals(other: Any?): Boolean = this === other || other is GeoPoint && nativeValue == other.nativeValue diff --git a/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/Timestamp.kt b/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/Timestamp.kt index aeedf8d01..d0eb95602 100644 --- a/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/Timestamp.kt +++ b/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/Timestamp.kt @@ -4,32 +4,32 @@ import cocoapods.FirebaseFirestoreInternal.FIRTimestamp import kotlinx.serialization.Serializable /** A class representing a platform specific Firebase Timestamp. */ -actual typealias NativeTimestamp = FIRTimestamp +public actual typealias NativeTimestamp = FIRTimestamp /** A base class that could be used to combine [Timestamp] and [Timestamp.ServerTimestamp] in the same field. */ @Serializable(with = BaseTimestampSerializer::class) -actual sealed class BaseTimestamp +public actual sealed class BaseTimestamp /** A class representing a Firebase Timestamp. */ @Serializable(with = TimestampSerializer::class) -actual class Timestamp internal actual constructor( - internal actual val nativeValue: NativeTimestamp -): BaseTimestamp() { - actual constructor(seconds: Long, nanoseconds: Int) : this(NativeTimestamp(seconds, nanoseconds)) +public actual class Timestamp internal actual constructor( + internal actual val nativeValue: NativeTimestamp, +) : BaseTimestamp() { + public actual constructor(seconds: Long, nanoseconds: Int) : this(NativeTimestamp(seconds, nanoseconds)) - actual val seconds: Long = nativeValue.seconds - actual val nanoseconds: Int = nativeValue.nanoseconds + public actual val seconds: Long = nativeValue.seconds + public actual val nanoseconds: Int = nativeValue.nanoseconds override fun equals(other: Any?): Boolean = this === other || other is Timestamp && nativeValue == other.nativeValue override fun hashCode(): Int = nativeValue.hashCode() override fun toString(): String = nativeValue.toString() - actual companion object { - actual fun now(): Timestamp = Timestamp(NativeTimestamp.timestamp()) + public actual companion object { + public actual fun now(): Timestamp = Timestamp(NativeTimestamp.timestamp()) } /** A server time timestamp. */ @Serializable(with = ServerTimestampSerializer::class) - actual object ServerTimestamp: BaseTimestamp() + public actual object ServerTimestamp : BaseTimestamp() } diff --git a/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/_encoders.kt b/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/_encoders.kt index 5bde38bac..c2907944a 100644 --- a/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/_encoders.kt +++ b/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/_encoders.kt @@ -3,10 +3,11 @@ package dev.gitlive.firebase.firestore import cocoapods.FirebaseFirestoreInternal.FIRFieldValue @PublishedApi -internal actual fun isSpecialValue(value: Any) = when(value) { +internal actual fun isSpecialValue(value: Any): Boolean = when (value) { is FIRFieldValue, is NativeGeoPoint, is NativeTimestamp, - is NativeDocumentReferenceType -> true + is NativeDocumentReferenceType, + -> true else -> false } diff --git a/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt b/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt index 2096f6381..37994beec 100644 --- a/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt +++ b/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt @@ -2,6 +2,8 @@ * Copyright (c) 2020 GitLive Ltd. Use of this source code is governed by the Apache 2.0 license. */ +@file:Suppress("EXTENSION_SHADOWED_BY_MEMBER") + package dev.gitlive.firebase.firestore import cocoapods.FirebaseFirestoreInternal.* @@ -10,7 +12,6 @@ import dev.gitlive.firebase.Firebase import dev.gitlive.firebase.FirebaseApp import dev.gitlive.firebase.FirebaseException import dev.gitlive.firebase.firestore.internal.NativeDocumentSnapshotWrapper -import kotlinx.cinterop.* import kotlinx.coroutines.CompletableDeferred import platform.Foundation.NSError import platform.Foundation.NSNumber @@ -18,63 +19,63 @@ import platform.Foundation.numberWithLong import platform.darwin.dispatch_get_main_queue import platform.darwin.dispatch_queue_t -actual val Firebase.firestore get() = +public actual val Firebase.firestore: FirebaseFirestore get() = FirebaseFirestore(FIRFirestore.firestore()) -actual fun Firebase.firestore(app: FirebaseApp): FirebaseFirestore = FirebaseFirestore( - FIRFirestore.firestoreForApp(app.ios as objcnames.classes.FIRApp) +public actual fun Firebase.firestore(app: FirebaseApp): FirebaseFirestore = FirebaseFirestore( + FIRFirestore.firestoreForApp(app.ios as objcnames.classes.FIRApp), ) -val LocalCacheSettings.ios: FIRLocalCacheSettingsProtocol get() = when (this) { +public val LocalCacheSettings.ios: FIRLocalCacheSettingsProtocol get() = when (this) { is LocalCacheSettings.Persistent -> FIRPersistentCacheSettings(NSNumber.numberWithLong(sizeBytes)) is LocalCacheSettings.Memory -> FIRMemoryCacheSettings( when (garbaseCollectorSettings) { is MemoryGarbageCollectorSettings.Eager -> FIRMemoryEagerGCSettings() is MemoryGarbageCollectorSettings.LRUGC -> FIRMemoryLRUGCSettings(NSNumber.numberWithLong(garbaseCollectorSettings.sizeBytes)) - } + }, ) } -actual typealias NativeFirebaseFirestore = FIRFirestore +public actual typealias NativeFirebaseFirestore = FIRFirestore -val FirebaseFirestore.ios get() = native +public val FirebaseFirestore.ios: NativeFirebaseFirestore get() = native -actual data class FirebaseFirestoreSettings( +public actual data class FirebaseFirestoreSettings( actual val sslEnabled: Boolean, actual val host: String, actual val cacheSettings: LocalCacheSettings, val dispatchQueue: dispatch_queue_t, ) { - actual companion object { - actual val CACHE_SIZE_UNLIMITED: Long = -1L + public actual companion object { + public actual val CACHE_SIZE_UNLIMITED: Long = -1L internal actual val DEFAULT_HOST: String = "firestore.googleapis.com" internal actual val MINIMUM_CACHE_BYTES: Long = 1 * 1024 * 1024 internal actual val DEFAULT_CACHE_SIZE_BYTES: Long = 100 * 1024 * 1024 } - actual class Builder( - actual var sslEnabled: Boolean, - actual var host: String, - actual var cacheSettings: LocalCacheSettings, - var dispatchQueue: dispatch_queue_t, + public actual class Builder( + public actual var sslEnabled: Boolean, + public actual var host: String, + public actual var cacheSettings: LocalCacheSettings, + public var dispatchQueue: dispatch_queue_t, ) { - actual constructor() : this( + public actual constructor() : this( true, DEFAULT_HOST, - persistentCacheSettings { }, + persistentCacheSettings { }, dispatch_get_main_queue(), ) - actual constructor(settings: FirebaseFirestoreSettings) : this( + public actual constructor(settings: FirebaseFirestoreSettings) : this( settings.sslEnabled, settings.host, settings.cacheSettings, settings.dispatchQueue, ) - actual fun build(): FirebaseFirestoreSettings = FirebaseFirestoreSettings(sslEnabled, host, cacheSettings, dispatchQueue) + public actual fun build(): FirebaseFirestoreSettings = FirebaseFirestoreSettings(sslEnabled, host, cacheSettings, dispatchQueue) } val ios: FIRFirestoreSettings get() = FIRFirestoreSettings().apply { @@ -85,9 +86,9 @@ actual data class FirebaseFirestoreSettings( } } -actual fun firestoreSettings( +public actual fun firestoreSettings( settings: FirebaseFirestoreSettings?, - builder: FirebaseFirestoreSettings.Builder.() -> Unit + builder: FirebaseFirestoreSettings.Builder.() -> Unit, ): FirebaseFirestoreSettings = FirebaseFirestoreSettings.Builder().apply { settings?.let { sslEnabled = it.sslEnabled @@ -97,32 +98,32 @@ actual fun firestoreSettings( } }.apply(builder).build() -actual typealias NativeWriteBatch = FIRWriteBatch +public actual typealias NativeWriteBatch = FIRWriteBatch -val WriteBatch.ios get() = native +public val WriteBatch.ios: NativeWriteBatch get() = native -actual typealias NativeTransaction = FIRTransaction +public actual typealias NativeTransaction = FIRTransaction -val Transaction.ios get() = native +public val Transaction.ios: NativeTransaction get() = native /** A class representing a platform specific Firebase DocumentReference. */ -actual typealias NativeDocumentReferenceType = FIRDocumentReference +public actual typealias NativeDocumentReferenceType = FIRDocumentReference -val DocumentReference.ios get() = native.ios +public val DocumentReference.ios: NativeDocumentReferenceType get() = native.ios -actual typealias NativeQuery = FIRQuery +public actual typealias NativeQuery = FIRQuery -val Query.ios get() = native +public val Query.ios: NativeQuery get() = native -actual typealias NativeCollectionReference = FIRCollectionReference +public actual typealias NativeCollectionReference = FIRCollectionReference -val CollectionReference.ios get() = native +public val CollectionReference.ios: NativeCollectionReference get() = native -actual class FirebaseFirestoreException(message: String, val code: FirestoreExceptionCode) : FirebaseException(message) +public actual class FirebaseFirestoreException(message: String, public val code: FirestoreExceptionCode) : FirebaseException(message) -actual val FirebaseFirestoreException.code: FirestoreExceptionCode get() = code +public actual val FirebaseFirestoreException.code: FirestoreExceptionCode get() = code -actual enum class FirestoreExceptionCode { +public actual enum class FirestoreExceptionCode { OK, CANCELLED, UNKNOWN, @@ -139,22 +140,22 @@ actual enum class FirestoreExceptionCode { INTERNAL, UNAVAILABLE, DATA_LOSS, - UNAUTHENTICATED + UNAUTHENTICATED, } -actual enum class Direction { +public actual enum class Direction { ASCENDING, - DESCENDING + DESCENDING, } -actual enum class ChangeType(internal val ios: FIRDocumentChangeType) { +public actual enum class ChangeType(internal val ios: FIRDocumentChangeType) { ADDED(FIRDocumentChangeTypeAdded), MODIFIED(FIRDocumentChangeTypeModified), - REMOVED(FIRDocumentChangeTypeRemoved) + REMOVED(FIRDocumentChangeTypeRemoved), } -fun NSError.toException() = when(domain) { - FIRFirestoreErrorDomain -> when(code) { +public fun NSError.toException(): FirebaseFirestoreException = when (domain) { + FIRFirestoreErrorDomain -> when (code) { FIRFirestoreErrorCodeOK -> FirestoreExceptionCode.OK FIRFirestoreErrorCodeCancelled -> FirestoreExceptionCode.CANCELLED FIRFirestoreErrorCodeUnknown -> FirestoreExceptionCode.UNKNOWN @@ -177,52 +178,52 @@ fun NSError.toException() = when(domain) { else -> FirestoreExceptionCode.UNKNOWN }.let { FirebaseFirestoreException(description!!, it) } -actual class QuerySnapshot(val ios: FIRQuerySnapshot) { - actual val documents +public actual class QuerySnapshot(public val ios: FIRQuerySnapshot) { + public actual val documents: List get() = ios.documents.map { DocumentSnapshot(NativeDocumentSnapshotWrapper(it as FIRDocumentSnapshot)) } - actual val documentChanges + public actual val documentChanges: List get() = ios.documentChanges.map { DocumentChange(it as FIRDocumentChange) } - actual val metadata: SnapshotMetadata get() = SnapshotMetadata(ios.metadata) + public actual val metadata: SnapshotMetadata get() = SnapshotMetadata(ios.metadata) } -actual class DocumentChange(val ios: FIRDocumentChange) { - actual val document: DocumentSnapshot +public actual class DocumentChange(public val ios: FIRDocumentChange) { + public actual val document: DocumentSnapshot get() = DocumentSnapshot(NativeDocumentSnapshotWrapper(ios.document)) - actual val newIndex: Int + public actual val newIndex: Int get() = ios.newIndex.toInt() - actual val oldIndex: Int + public actual val oldIndex: Int get() = ios.oldIndex.toInt() - actual val type: ChangeType - get() = ChangeType.values().first { it.ios == ios.type } + public actual val type: ChangeType + get() = ChangeType.entries.first { it.ios == ios.type } } -actual typealias NativeDocumentSnapshot = FIRDocumentSnapshot +public actual typealias NativeDocumentSnapshot = FIRDocumentSnapshot -val DocumentSnapshot.ios get() = native +public val DocumentSnapshot.ios: NativeDocumentSnapshot get() = native -actual class SnapshotMetadata(val ios: FIRSnapshotMetadata) { - actual val hasPendingWrites: Boolean get() = ios.pendingWrites - actual val isFromCache: Boolean get() = ios.fromCache +public actual class SnapshotMetadata(public val ios: FIRSnapshotMetadata) { + public actual val hasPendingWrites: Boolean get() = ios.pendingWrites + public actual val isFromCache: Boolean get() = ios.fromCache } -actual class FieldPath private constructor(val ios: FIRFieldPath) { - actual companion object { - actual val documentId = FieldPath(FIRFieldPath.documentID()) +public actual class FieldPath private constructor(public val ios: FIRFieldPath) { + public actual companion object { + public actual val documentId: FieldPath = FieldPath(FIRFieldPath.documentID()) } - actual constructor(vararg fieldNames: String) : this(FIRFieldPath(fieldNames.asList())) - actual val documentId: FieldPath get() = FieldPath.documentId - actual val encoded: EncodedFieldPath = ios + public actual constructor(vararg fieldNames: String) : this(FIRFieldPath(fieldNames.asList())) + public actual val documentId: FieldPath get() = FieldPath.documentId + public actual val encoded: EncodedFieldPath = ios override fun equals(other: Any?): Boolean = other is FieldPath && ios == other.ios override fun hashCode(): Int = ios.hashCode() override fun toString(): String = ios.toString() } -actual typealias EncodedFieldPath = FIRFieldPath +public actual typealias EncodedFieldPath = FIRFieldPath internal suspend inline fun awaitResult(function: (callback: (T?, NSError?) -> Unit) -> Unit): T { val job = CompletableDeferred() function { result, error -> - if(error == null) { + if (error == null) { job.complete(result) } else { job.completeExceptionally(error.toException()) @@ -234,7 +235,7 @@ internal suspend inline fun awaitResult(function: (callback: (T?, NS internal suspend inline fun await(function: (callback: (NSError?) -> Unit) -> T): T { val job = CompletableDeferred() val result = function { error -> - if(error == null) { + if (error == null) { job.complete(Unit) } else { job.completeExceptionally(error.toException()) diff --git a/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeCollectionReferenceWrapper.kt b/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeCollectionReferenceWrapper.kt index 339a88385..80cf9b96f 100644 --- a/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeCollectionReferenceWrapper.kt +++ b/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeCollectionReferenceWrapper.kt @@ -13,11 +13,11 @@ internal actual class NativeCollectionReferenceWrapper internal actual construct actual val document get() = NativeDocumentReference(native.documentWithAutoID()) - actual val parent get() = native.parent?.let{ NativeDocumentReference(it) } + actual val parent get() = native.parent?.let { NativeDocumentReference(it) } actual fun document(documentPath: String) = NativeDocumentReference(native.documentWithPath(documentPath)) actual suspend fun addEncoded(data: EncodedObject) = NativeDocumentReference(await { native.addDocumentWithData(data.ios, it) }) -} \ No newline at end of file +} diff --git a/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentReference.kt b/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentReference.kt index cd6f8fa31..14d75d4d9 100644 --- a/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentReference.kt +++ b/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentReference.kt @@ -2,7 +2,6 @@ package dev.gitlive.firebase.firestore.internal import dev.gitlive.firebase.firestore.EncodedFieldPath import dev.gitlive.firebase.firestore.NativeDocumentReferenceType -import dev.gitlive.firebase.firestore.NativeDocumentSnapshot import dev.gitlive.firebase.firestore.Source import dev.gitlive.firebase.firestore.await import dev.gitlive.firebase.firestore.awaitResult @@ -35,7 +34,6 @@ internal actual class NativeDocumentReference actual constructor(actual val nati actual val parent: NativeCollectionReferenceWrapper get() = NativeCollectionReferenceWrapper(ios.parent) - actual fun collection(collectionPath: String) = ios.collectionWithPath(collectionPath) actual suspend fun get(source: Source) = @@ -49,7 +47,7 @@ internal actual class NativeDocumentReference actual constructor(actual val nati is SetOptions.MergeFieldPaths -> ios.setData( encodedData.ios, setOptions.encodedFieldPaths, - it + it, ) } } @@ -70,7 +68,7 @@ internal actual class NativeDocumentReference actual constructor(actual val nati actual suspend fun delete() = await { ios.deleteDocumentWithCompletion(it) } - actual val snapshots get() = callbackFlow { + actual val snapshots get() = callbackFlow { val listener = ios.addSnapshotListener { snapshot, error -> snapshot?.let { trySend(snapshot) } error?.let { close(error.toException()) } @@ -82,4 +80,4 @@ internal actual class NativeDocumentReference actual constructor(actual val nati this === other || other is NativeDocumentReference && nativeValue == other.nativeValue override fun hashCode(): Int = nativeValue.hashCode() override fun toString(): String = nativeValue.toString() -} \ No newline at end of file +} diff --git a/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentSnapshotWrapper.kt b/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentSnapshotWrapper.kt index 929a906ce..c53e5ecee 100644 --- a/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentSnapshotWrapper.kt +++ b/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentSnapshotWrapper.kt @@ -34,9 +34,9 @@ internal actual class NativeDocumentSnapshotWrapper actual constructor(actual va actual val metadata: SnapshotMetadata get() = SnapshotMetadata(native.metadata) - fun ServerTimestampBehavior.toIos() : FIRServerTimestampBehavior = when (this) { + fun ServerTimestampBehavior.toIos(): FIRServerTimestampBehavior = when (this) { ServerTimestampBehavior.ESTIMATE -> FIRServerTimestampBehavior.FIRServerTimestampBehaviorEstimate ServerTimestampBehavior.NONE -> FIRServerTimestampBehavior.FIRServerTimestampBehaviorNone ServerTimestampBehavior.PREVIOUS -> FIRServerTimestampBehavior.FIRServerTimestampBehaviorPrevious } -} \ No newline at end of file +} diff --git a/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeFirebaseFirestoreWrapper.kt b/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeFirebaseFirestoreWrapper.kt index e95be1050..96326e4a2 100644 --- a/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeFirebaseFirestoreWrapper.kt +++ b/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeFirebaseFirestoreWrapper.kt @@ -37,7 +37,7 @@ internal actual class NativeFirebaseFirestoreWrapper internal actual constructor awaitResult { native.runTransactionWithBlock( { transaction, _ -> runBlocking { transaction!!.func() } }, - it + it, ) } as T @@ -60,4 +60,4 @@ internal actual class NativeFirebaseFirestoreWrapper internal actual constructor actual suspend fun enableNetwork() { await { native.enableNetworkWithCompletion(it) } } -} \ No newline at end of file +} diff --git a/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeQueryWrapper.kt b/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeQueryWrapper.kt index 4a050998e..876857ba6 100644 --- a/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeQueryWrapper.kt +++ b/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeQueryWrapper.kt @@ -16,14 +16,14 @@ import kotlinx.coroutines.flow.callbackFlow import platform.Foundation.NSNull @PublishedApi -internal actual open class NativeQueryWrapper internal actual constructor(actual open val native: NativeQuery) { +internal actual open class NativeQueryWrapper internal actual constructor(actual open val native: NativeQuery) { actual fun limit(limit: Number) = native.queryLimitedTo(limit.toLong()) actual suspend fun get(source: Source) = QuerySnapshot(awaitResult { native.getDocumentsWithSource(source.toIosSource(), it) }) - actual val snapshots get() = callbackFlow { + actual val snapshots get() = callbackFlow { val listener = native.addSnapshotListener { snapshot, error -> snapshot?.let { trySend(QuerySnapshot(snapshot)) } error?.let { close(error.toException()) } @@ -31,7 +31,7 @@ internal actual open class NativeQueryWrapper internal actual constructor(actual awaitClose { listener.remove() } } - actual fun snapshots(includeMetadataChanges: Boolean) = callbackFlow { + actual fun snapshots(includeMetadataChanges: Boolean) = callbackFlow { val listener = native.addSnapshotListenerWithIncludeMetadataChanges(includeMetadataChanges) { snapshot, error -> snapshot?.let { trySend(QuerySnapshot(snapshot)) } @@ -83,4 +83,4 @@ internal actual open class NativeQueryWrapper internal actual constructor(actual actual fun endBefore(vararg fieldValues: Any) = native.queryEndingBeforeValues(fieldValues.asList()) actual fun endAt(document: NativeDocumentSnapshot) = native.queryEndingAtDocument(document) actual fun endAt(vararg fieldValues: Any) = native.queryEndingAtValues(fieldValues.asList()) -} \ No newline at end of file +} diff --git a/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeTransactionWrapper.kt b/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeTransactionWrapper.kt index 809275539..772fcf8f4 100644 --- a/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeTransactionWrapper.kt +++ b/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeTransactionWrapper.kt @@ -13,7 +13,7 @@ internal actual class NativeTransactionWrapper actual constructor(actual val nat actual fun setEncoded( documentRef: DocumentReference, encodedData: EncodedObject, - setOptions: SetOptions + setOptions: SetOptions, ): NativeTransactionWrapper = when (setOptions) { is SetOptions.Merge -> native.setData(encodedData.ios, documentRef.ios, true) is SetOptions.Overwrite -> native.setData(encodedData.ios, documentRef.ios, false) @@ -25,18 +25,18 @@ internal actual class NativeTransactionWrapper actual constructor(actual val nat actual fun updateEncodedFieldsAndValues( documentRef: DocumentReference, - encodedFieldsAndValues: List> + encodedFieldsAndValues: List>, ): NativeTransactionWrapper = native.updateData( encodedFieldsAndValues.toMap(), - documentRef.ios + documentRef.ios, ).let { this } actual fun updateEncodedFieldPathsAndValues( documentRef: DocumentReference, - encodedFieldsAndValues: List> + encodedFieldsAndValues: List>, ): NativeTransactionWrapper = native.updateData( encodedFieldsAndValues.toMap(), - documentRef.ios + documentRef.ios, ).let { this } actual fun delete(documentRef: DocumentReference) = @@ -44,5 +44,4 @@ internal actual class NativeTransactionWrapper actual constructor(actual val nat actual suspend fun get(documentRef: DocumentReference) = throwError { NativeDocumentSnapshotWrapper(native.getDocument(documentRef.ios, it)!!) } - -} \ No newline at end of file +} diff --git a/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeWriteBatchWrapper.kt b/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeWriteBatchWrapper.kt index 628096433..45f28edba 100644 --- a/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeWriteBatchWrapper.kt +++ b/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeWriteBatchWrapper.kt @@ -14,7 +14,7 @@ internal actual class NativeWriteBatchWrapper actual constructor(actual val nati actual fun setEncoded( documentRef: DocumentReference, encodedData: EncodedObject, - setOptions: SetOptions + setOptions: SetOptions, ): NativeWriteBatchWrapper = when (setOptions) { is SetOptions.Merge -> native.setData(encodedData.ios, documentRef.ios, true) is SetOptions.Overwrite -> native.setData(encodedData.ios, documentRef.ios, false) @@ -26,22 +26,22 @@ internal actual class NativeWriteBatchWrapper actual constructor(actual val nati actual fun updateEncodedFieldsAndValues( documentRef: DocumentReference, - encodedFieldsAndValues: List> + encodedFieldsAndValues: List>, ): NativeWriteBatchWrapper = native.updateData( encodedFieldsAndValues.toMap(), - documentRef.ios + documentRef.ios, ).let { this } actual fun updateEncodedFieldPathsAndValues( documentRef: DocumentReference, - encodedFieldsAndValues: List> + encodedFieldsAndValues: List>, ): NativeWriteBatchWrapper = native.updateData( encodedFieldsAndValues.toMap(), - documentRef.ios + documentRef.ios, ).let { this } actual fun delete(documentRef: DocumentReference) = native.deleteDocument(documentRef.ios).let { this } actual suspend fun commit() = await { native.commitWithCompletion(it) } -} \ No newline at end of file +} diff --git a/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/throwError.kt b/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/throwError.kt index a298833f8..2c8e7a388 100644 --- a/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/throwError.kt +++ b/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/throwError.kt @@ -20,4 +20,4 @@ internal fun T.throwError(block: T.(errorPointer: CPointer runTestWithContextSwitch(create: suspend CoroutineScope.() -> T, test: s while (testRun.isActive) { NSRunLoop.mainRunLoop.runMode( NSDefaultRunLoopMode, - beforeDate = NSDate.create(timeInterval = 1.0, sinceDate = NSDate()) + beforeDate = NSDate.create(timeInterval = 1.0, sinceDate = NSDate()), ) yield() } testRun.await() } - class ContextSwitchTest { lateinit var firestore: FirebaseFirestore @@ -69,8 +69,8 @@ class ContextSwitchTest { databaseUrl = "https://fir-kotlin-sdk.firebaseio.com", storageBucket = "fir-kotlin-sdk.appspot.com", projectId = "fir-kotlin-sdk", - gcmSenderId = "846484016111" - ) + gcmSenderId = "846484016111", + ), ) firestore = Firebase.firestore(app).apply { @@ -87,11 +87,11 @@ class ContextSwitchTest { private data class TestFieldValuesOps( val initial: List, - val updates: List + val updates: List, ) { data class Update( val op: Pair, - val expected: List? + val expected: List?, ) } @@ -106,19 +106,19 @@ class ContextSwitchTest { updates = listOf( TestFieldValuesOps.Update( FieldPath(TestData::values.name) to FieldValue.arrayUnion(2), - listOf(1, 2) + listOf(1, 2), ), TestFieldValuesOps.Update( FieldPath(TestData::values.name) to FieldValue.arrayRemove(1), - listOf(2) + listOf(2), ), TestFieldValuesOps.Update( FieldPath(TestData::values.name) to FieldValue.delete, - null - ) - ) + null, + ), + ), ) - } + }, ) { data -> fun getDocument() = firestore.collection("fieldValuesOps") @@ -145,4 +145,4 @@ class ContextSwitchTest { val deletedList = getDocument().get().get(TestData::values.name, ListSerializer(Int.serializer()).nullable) assertEquals(data.updates[2].expected, deletedList) } -} \ No newline at end of file +} diff --git a/firebase-firestore/src/iosTest/kotlin/dev/gitlive/firebase/firestore/Ignore.kt b/firebase-firestore/src/iosTest/kotlin/dev/gitlive/firebase/firestore/Ignore.kt index 1f70d3731..e484ad9f6 100644 --- a/firebase-firestore/src/iosTest/kotlin/dev/gitlive/firebase/firestore/Ignore.kt +++ b/firebase-firestore/src/iosTest/kotlin/dev/gitlive/firebase/firestore/Ignore.kt @@ -2,5 +2,6 @@ package dev.gitlive.firebase.firestore @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) actual annotation class IgnoreJs + @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) actual annotation class IgnoreForAndroidUnitTest diff --git a/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/FieldValue.kt b/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/FieldValue.kt index 39aba6c99..5407e19d6 100644 --- a/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/FieldValue.kt +++ b/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/FieldValue.kt @@ -8,25 +8,26 @@ import dev.gitlive.firebase.firestore.externals.arrayUnion as jsArrayUnion import dev.gitlive.firebase.firestore.externals.increment as jsIncrement /** Represents a platform specific Firebase FieldValue. */ -typealias NativeFieldValue = dev.gitlive.firebase.firestore.externals.FieldValue +public typealias NativeFieldValue = dev.gitlive.firebase.firestore.externals.FieldValue /** Represents a Firebase FieldValue. */ @Serializable(with = FieldValueSerializer::class) -actual class FieldValue internal actual constructor(internal actual val nativeValue: Any) { +public actual class FieldValue internal actual constructor(internal actual val nativeValue: Any) { init { require(nativeValue is NativeFieldValue) } override fun equals(other: Any?): Boolean = - this === other || other is FieldValue && - (nativeValue as NativeFieldValue).isEqual(other.nativeValue as NativeFieldValue) + this === other || + other is FieldValue && + (nativeValue as NativeFieldValue).isEqual(other.nativeValue as NativeFieldValue) override fun hashCode(): Int = nativeValue.hashCode() override fun toString(): String = nativeValue.toString() - actual companion object { - actual val serverTimestamp: FieldValue get() = rethrow { FieldValue(jsServerTimestamp()) } - actual val delete: FieldValue get() = rethrow { FieldValue(deleteField()) } - actual fun increment(value: Int): FieldValue = rethrow { FieldValue(jsIncrement(value)) } - actual fun arrayUnion(vararg elements: Any): FieldValue = rethrow { FieldValue(jsArrayUnion(*elements)) } - actual fun arrayRemove(vararg elements: Any): FieldValue = rethrow { FieldValue(jsArrayRemove(*elements)) } + public actual companion object { + public actual val serverTimestamp: FieldValue get() = rethrow { FieldValue(jsServerTimestamp()) } + public actual val delete: FieldValue get() = rethrow { FieldValue(deleteField()) } + public actual fun increment(value: Int): FieldValue = rethrow { FieldValue(jsIncrement(value)) } + public actual fun arrayUnion(vararg elements: Any): FieldValue = rethrow { FieldValue(jsArrayUnion(*elements)) } + public actual fun arrayRemove(vararg elements: Any): FieldValue = rethrow { FieldValue(jsArrayRemove(*elements)) } } } diff --git a/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/GeoPoint.kt b/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/GeoPoint.kt index 2271e446e..0818e403c 100644 --- a/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/GeoPoint.kt +++ b/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/GeoPoint.kt @@ -3,14 +3,14 @@ package dev.gitlive.firebase.firestore import kotlinx.serialization.Serializable /** A class representing a platform specific Firebase GeoPoint. */ -actual typealias NativeGeoPoint = dev.gitlive.firebase.firestore.externals.GeoPoint +public actual typealias NativeGeoPoint = dev.gitlive.firebase.firestore.externals.GeoPoint /** A class representing a Firebase GeoPoint. */ @Serializable(with = GeoPointSerializer::class) -actual class GeoPoint internal actual constructor(internal actual val nativeValue: NativeGeoPoint) { - actual constructor(latitude: Double, longitude: Double) : this(NativeGeoPoint(latitude, longitude)) - actual val latitude: Double by nativeValue::latitude - actual val longitude: Double by nativeValue::longitude +public actual class GeoPoint internal actual constructor(internal actual val nativeValue: NativeGeoPoint) { + public actual constructor(latitude: Double, longitude: Double) : this(NativeGeoPoint(latitude, longitude)) + public actual val latitude: Double by nativeValue::latitude + public actual val longitude: Double by nativeValue::longitude override fun equals(other: Any?): Boolean = this === other || other is GeoPoint && nativeValue.isEqual(other.nativeValue) diff --git a/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/Timestamp.kt b/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/Timestamp.kt index dabec0055..bc18327ba 100644 --- a/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/Timestamp.kt +++ b/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/Timestamp.kt @@ -4,31 +4,31 @@ import kotlinx.serialization.Serializable /** A base class that could be used to combine [Timestamp] and [Timestamp.ServerTimestamp] in the same field. */ @Serializable(with = BaseTimestampSerializer::class) -actual sealed class BaseTimestamp +public actual sealed class BaseTimestamp /** A class representing a platform specific Firebase Timestamp. */ -actual typealias NativeTimestamp = dev.gitlive.firebase.firestore.externals.Timestamp +public actual typealias NativeTimestamp = dev.gitlive.firebase.firestore.externals.Timestamp /** A class representing a Firebase Timestamp. */ @Serializable(with = TimestampSerializer::class) -actual class Timestamp internal actual constructor( - internal actual val nativeValue: NativeTimestamp -): BaseTimestamp() { - actual constructor(seconds: Long, nanoseconds: Int) : this(NativeTimestamp(seconds.toDouble(), nanoseconds.toDouble())) +public actual class Timestamp internal actual constructor( + internal actual val nativeValue: NativeTimestamp, +) : BaseTimestamp() { + public actual constructor(seconds: Long, nanoseconds: Int) : this(NativeTimestamp(seconds.toDouble(), nanoseconds.toDouble())) - actual val seconds: Long = nativeValue.seconds.toLong() - actual val nanoseconds: Int = nativeValue.nanoseconds.toInt() + public actual val seconds: Long = nativeValue.seconds.toLong() + public actual val nanoseconds: Int = nativeValue.nanoseconds.toInt() override fun equals(other: Any?): Boolean = this === other || other is Timestamp && nativeValue.isEqual(other.nativeValue) override fun hashCode(): Int = nativeValue.toMillis().hashCode() override fun toString(): String = nativeValue.toString() - actual companion object { - actual fun now(): Timestamp = Timestamp(NativeTimestamp.now()) + public actual companion object { + public actual fun now(): Timestamp = Timestamp(NativeTimestamp.now()) } /** A server time timestamp. */ @Serializable(with = ServerTimestampSerializer::class) - actual object ServerTimestamp: BaseTimestamp() + public actual object ServerTimestamp : BaseTimestamp() } diff --git a/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/_encoders.kt b/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/_encoders.kt index 84445fb4d..a1e313dd6 100644 --- a/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/_encoders.kt +++ b/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/_encoders.kt @@ -1,10 +1,11 @@ package dev.gitlive.firebase.firestore @PublishedApi -internal actual fun isSpecialValue(value: Any) = when(value) { +internal actual fun isSpecialValue(value: Any): Boolean = when (value) { is NativeFieldValue, is NativeGeoPoint, is NativeTimestamp, - is NativeDocumentReferenceType -> true + is NativeDocumentReferenceType, + -> true else -> false } diff --git a/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/externals/firestore.kt b/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/externals/firestore.kt index 532118bfc..31c110099 100644 --- a/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/externals/firestore.kt +++ b/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/externals/firestore.kt @@ -8,327 +8,326 @@ import dev.gitlive.firebase.externals.FirebaseApp import kotlin.js.Json import kotlin.js.Promise -external fun documentId(): FieldPath - -external class FieldPath(vararg fieldNames: String) { - fun isEqual(other: FieldPath): Boolean +public external fun documentId(): FieldPath +public external class FieldPath(vararg fieldNames: String) { + public fun isEqual(other: FieldPath): Boolean } -external fun refEqual(left: DocumentReference, right: DocumentReference): Boolean +public external fun refEqual(left: DocumentReference, right: DocumentReference): Boolean -external fun addDoc(reference: CollectionReference, data: Any): Promise +public external fun addDoc(reference: CollectionReference, data: Any): Promise -external fun arrayRemove(vararg elements: Any): FieldValue +public external fun arrayRemove(vararg elements: Any): FieldValue -external fun arrayUnion(vararg elements: Any): FieldValue +public external fun arrayUnion(vararg elements: Any): FieldValue -external fun clearIndexedDbPersistence(firestore: Firestore): Promise +public external fun clearIndexedDbPersistence(firestore: Firestore): Promise -external fun collection(firestore: Firestore, collectionPath: String): CollectionReference +public external fun collection(firestore: Firestore, collectionPath: String): CollectionReference -external fun collection(reference: DocumentReference, collectionPath: String): CollectionReference +public external fun collection(reference: DocumentReference, collectionPath: String): CollectionReference -external fun collectionGroup(firestore: Firestore, collectionId: String): Query +public external fun collectionGroup(firestore: Firestore, collectionId: String): Query -external fun connectFirestoreEmulator( +public external fun connectFirestoreEmulator( firestore: Firestore, host: String, port: Int, - options: Any? = definedExternally + options: Any? = definedExternally, ) -external fun deleteDoc(reference: DocumentReference): Promise +public external fun deleteDoc(reference: DocumentReference): Promise -external fun deleteField(): FieldValue +public external fun deleteField(): FieldValue -external fun disableNetwork(firestore: Firestore): Promise +public external fun disableNetwork(firestore: Firestore): Promise -external fun doc(firestore: Firestore, documentPath: String): DocumentReference +public external fun doc(firestore: Firestore, documentPath: String): DocumentReference -external fun doc(firestore: CollectionReference, documentPath: String? = definedExternally): DocumentReference +public external fun doc(firestore: CollectionReference, documentPath: String? = definedExternally): DocumentReference -external fun enableIndexedDbPersistence( +public external fun enableIndexedDbPersistence( firestore: Firestore, - persistenceSettings: Any? = definedExternally + persistenceSettings: Any? = definedExternally, ): Promise -external fun enableNetwork(firestore: Firestore): Promise +public external fun enableNetwork(firestore: Firestore): Promise -external fun endAt(document: DocumentSnapshot): QueryConstraint +public external fun endAt(document: DocumentSnapshot): QueryConstraint -external fun endAt(vararg fieldValues: Any): QueryConstraint +public external fun endAt(vararg fieldValues: Any): QueryConstraint -external fun endBefore(document: DocumentSnapshot): QueryConstraint +public external fun endBefore(document: DocumentSnapshot): QueryConstraint -external fun endBefore(vararg fieldValues: Any): QueryConstraint +public external fun endBefore(vararg fieldValues: Any): QueryConstraint -external fun getDoc( +public external fun getDoc( reference: DocumentReference, - options: Any? = definedExternally + options: Any? = definedExternally, ): Promise -external fun getDocFromCache( +public external fun getDocFromCache( reference: DocumentReference, ): Promise -external fun getDocFromServer( +public external fun getDocFromServer( reference: DocumentReference, ): Promise -external fun getDocs(query: Query): Promise +public external fun getDocs(query: Query): Promise -external fun getDocsFromCache(query: Query): Promise +public external fun getDocsFromCache(query: Query): Promise -external fun getDocsFromServer(query: Query): Promise +public external fun getDocsFromServer(query: Query): Promise -external fun getFirestore(app: FirebaseApp? = definedExternally): Firestore +public external fun getFirestore(app: FirebaseApp? = definedExternally): Firestore -external fun increment(n: Int): FieldValue +public external fun increment(n: Int): FieldValue -external fun initializeFirestore(app: FirebaseApp, settings: dynamic = definedExternally, databaseId: String? = definedExternally): Firestore +public external fun initializeFirestore(app: FirebaseApp, settings: dynamic = definedExternally, databaseId: String? = definedExternally): Firestore -external fun limit(limit: Number): QueryConstraint +public external fun limit(limit: Number): QueryConstraint -external fun onSnapshot( +public external fun onSnapshot( reference: DocumentReference, next: (snapshot: DocumentSnapshot) -> Unit, - error: (error: Throwable) -> Unit + error: (error: Throwable) -> Unit, ): Unsubscribe -external fun onSnapshot( +public external fun onSnapshot( reference: DocumentReference, options: Json, next: (snapshot: DocumentSnapshot) -> Unit, - error: (error: Throwable) -> Unit + error: (error: Throwable) -> Unit, ): Unsubscribe -external fun onSnapshot( +public external fun onSnapshot( reference: Query, next: (snapshot: QuerySnapshot) -> Unit, - error: (error: Throwable) -> Unit + error: (error: Throwable) -> Unit, ): Unsubscribe -external fun onSnapshot( +public external fun onSnapshot( reference: Query, options: Json, next: (snapshot: QuerySnapshot) -> Unit, - error: (error: Throwable) -> Unit + error: (error: Throwable) -> Unit, ): Unsubscribe -external fun orderBy(field: String, direction: Any): QueryConstraint +public external fun orderBy(field: String, direction: Any): QueryConstraint -external fun orderBy(field: FieldPath, direction: Any): QueryConstraint +public external fun orderBy(field: FieldPath, direction: Any): QueryConstraint -external fun query(query: Query, vararg queryConstraints: QueryConstraint): Query +public external fun query(query: Query, vararg queryConstraints: QueryConstraint): Query -external fun runTransaction( +public external fun runTransaction( firestore: Firestore, updateFunction: (transaction: Transaction) -> Promise, - options: Any? = definedExternally + options: Any? = definedExternally, ): Promise -external fun serverTimestamp(): FieldValue +public external fun serverTimestamp(): FieldValue -external fun setDoc( +public external fun setDoc( documentReference: DocumentReference, data: Any, - options: Any? = definedExternally + options: Any? = definedExternally, ): Promise -external fun setLogLevel(logLevel: String) +public external fun setLogLevel(logLevel: String) -external fun startAfter(document: DocumentSnapshot): QueryConstraint +public external fun startAfter(document: DocumentSnapshot): QueryConstraint -external fun startAfter(vararg fieldValues: Any): QueryConstraint +public external fun startAfter(vararg fieldValues: Any): QueryConstraint -external fun startAt(document: DocumentSnapshot): QueryConstraint +public external fun startAt(document: DocumentSnapshot): QueryConstraint -external fun startAt(vararg fieldValues: Any): QueryConstraint +public external fun startAt(vararg fieldValues: Any): QueryConstraint -external fun updateDoc(reference: DocumentReference, data: Any): Promise +public external fun updateDoc(reference: DocumentReference, data: Any): Promise -external fun updateDoc( +public external fun updateDoc( reference: DocumentReference, field: String, value: Any?, - vararg moreFieldsAndValues: Any? + vararg moreFieldsAndValues: Any?, ): Promise -external fun updateDoc( +public external fun updateDoc( reference: DocumentReference, field: FieldPath, value: Any?, - vararg moreFieldsAndValues: Any? + vararg moreFieldsAndValues: Any?, ): Promise -external fun where(field: String, opStr: String, value: Any?): QueryConstraint +public external fun where(field: String, opStr: String, value: Any?): QueryConstraint -external fun where(field: FieldPath, opStr: String, value: Any?): QueryConstraint +public external fun where(field: FieldPath, opStr: String, value: Any?): QueryConstraint -external fun and(vararg queryConstraints: QueryConstraint): QueryConstraint +public external fun and(vararg queryConstraints: QueryConstraint): QueryConstraint -external fun or(vararg queryConstraints: QueryConstraint): QueryConstraint +public external fun or(vararg queryConstraints: QueryConstraint): QueryConstraint -external fun writeBatch(firestore: Firestore): WriteBatch +public external fun writeBatch(firestore: Firestore): WriteBatch -external interface Firestore { - val app: FirebaseApp +public external interface Firestore { + public val app: FirebaseApp } -external class GeoPoint constructor(latitude: Double, longitude: Double) { - val latitude: Double - val longitude: Double - fun isEqual(other: GeoPoint): Boolean +public external class GeoPoint(latitude: Double, longitude: Double) { + public val latitude: Double + public val longitude: Double + public fun isEqual(other: GeoPoint): Boolean } -external interface CollectionReference : Query { - val id: String - val path: String - val parent: DocumentReference? +public external interface CollectionReference : Query { + public val id: String + public val path: String + public val parent: DocumentReference? } -external interface DocumentChange { - val doc: DocumentSnapshot - val newIndex: Int - val oldIndex: Int - val type: String +public external interface DocumentChange { + public val doc: DocumentSnapshot + public val newIndex: Int + public val oldIndex: Int + public val type: String } -external class DocumentReference { - val id: String - val path: String - val parent: CollectionReference +public external class DocumentReference { + public val id: String + public val path: String + public val parent: CollectionReference } -external interface DocumentSnapshot { - val id: String - val ref: DocumentReference - val metadata: SnapshotMetadata - fun data(options: Any? = definedExternally): Any? - fun exists(): Boolean - fun get(fieldPath: String, options: Any? = definedExternally): Any? - fun get(fieldPath: FieldPath, options: Any? = definedExternally): Any? +public external interface DocumentSnapshot { + public val id: String + public val ref: DocumentReference + public val metadata: SnapshotMetadata + public fun data(options: Any? = definedExternally): Any? + public fun exists(): Boolean + public fun get(fieldPath: String, options: Any? = definedExternally): Any? + public fun get(fieldPath: FieldPath, options: Any? = definedExternally): Any? } -external class FieldValue { - fun isEqual(other: FieldValue): Boolean +public external class FieldValue { + public fun isEqual(other: FieldValue): Boolean } -external interface Query +public external interface Query -external interface QueryConstraint +public external interface QueryConstraint -external interface QuerySnapshot { - val docs: Array - val empty: Boolean - val metadata: SnapshotMetadata - fun docChanges(): Array +public external interface QuerySnapshot { + public val docs: Array + public val empty: Boolean + public val metadata: SnapshotMetadata + public fun docChanges(): Array } -external interface SnapshotMetadata { - val hasPendingWrites: Boolean - val fromCache: Boolean +public external interface SnapshotMetadata { + public val hasPendingWrites: Boolean + public val fromCache: Boolean } -external interface Transaction { - fun get(documentReference: DocumentReference): Promise +public external interface Transaction { + public fun get(documentReference: DocumentReference): Promise - fun set( + public fun set( documentReference: DocumentReference, data: Any, - options: Any? = definedExternally + options: Any? = definedExternally, ): Transaction - fun update(documentReference: DocumentReference, data: Any): Transaction + public fun update(documentReference: DocumentReference, data: Any): Transaction - fun update( + public fun update( documentReference: DocumentReference, field: String, value: Any?, - vararg moreFieldsAndValues: Any? + vararg moreFieldsAndValues: Any?, ): Transaction - fun update( + public fun update( documentReference: DocumentReference, field: FieldPath, value: Any?, - vararg moreFieldsAndValues: Any? + vararg moreFieldsAndValues: Any?, ): Transaction - fun delete(documentReference: DocumentReference): Transaction + public fun delete(documentReference: DocumentReference): Transaction } -external interface WriteBatch { - fun commit(): Promise +public external interface WriteBatch { + public fun commit(): Promise - fun delete(documentReference: DocumentReference): WriteBatch + public fun delete(documentReference: DocumentReference): WriteBatch - fun set( + public fun set( documentReference: DocumentReference, data: Any, - options: Any? = definedExternally + options: Any? = definedExternally, ): WriteBatch - fun update(documentReference: DocumentReference, data: Any): WriteBatch + public fun update(documentReference: DocumentReference, data: Any): WriteBatch - fun update( + public fun update( documentReference: DocumentReference, field: String, value: Any?, - vararg moreFieldsAndValues: Any? + vararg moreFieldsAndValues: Any?, ): WriteBatch - fun update( + public fun update( documentReference: DocumentReference, field: FieldPath, value: Any?, - vararg moreFieldsAndValues: Any? + vararg moreFieldsAndValues: Any?, ): WriteBatch } -external class Timestamp(seconds: Double, nanoseconds: Double) { - companion object { - fun now(): Timestamp +public external class Timestamp(seconds: Double, nanoseconds: Double) { + public companion object { + public fun now(): Timestamp } - val seconds: Double - val nanoseconds: Double - fun toMillis(): Double + public val seconds: Double + public val nanoseconds: Double + public fun toMillis(): Double - fun isEqual(other: Timestamp): Boolean + public fun isEqual(other: Timestamp): Boolean } -external interface FirestoreLocalCache { - val kind: String +public external interface FirestoreLocalCache { + public val kind: String } -external interface MemoryLocalCache : FirestoreLocalCache -external interface PersistentLocalCache : FirestoreLocalCache +public external interface MemoryLocalCache : FirestoreLocalCache +public external interface PersistentLocalCache : FirestoreLocalCache -external interface MemoryCacheSettings { - val garbageCollector: MemoryGarbageCollector +public external interface MemoryCacheSettings { + public val garbageCollector: MemoryGarbageCollector } -external interface MemoryGarbageCollector { - val kind: String +public external interface MemoryGarbageCollector { + public val kind: String } -external interface MemoryLruGarbageCollector : MemoryGarbageCollector -external interface MemoryEagerGarbageCollector : MemoryGarbageCollector +public external interface MemoryLruGarbageCollector : MemoryGarbageCollector +public external interface MemoryEagerGarbageCollector : MemoryGarbageCollector -external interface PersistentCacheSettings { - val cacheSizeBytes: Int - val tabManager: PersistentTabManager +public external interface PersistentCacheSettings { + public val cacheSizeBytes: Int + public val tabManager: PersistentTabManager } -external interface PersistentTabManager { - val kind: String +public external interface PersistentTabManager { + public val kind: String } -external fun memoryLocalCache(settings: MemoryCacheSettings): MemoryLocalCache -external fun memoryEagerGarbageCollector(): MemoryEagerGarbageCollector -external fun memoryLruGarbageCollector(settings: dynamic = definedExternally): MemoryLruGarbageCollector -external fun persistentLocalCache(settings: PersistentCacheSettings): PersistentLocalCache -external fun persistentSingleTabManager(settings: dynamic = definedExternally): PersistentTabManager -external fun persistentMultipleTabManager(): PersistentTabManager +public external fun memoryLocalCache(settings: MemoryCacheSettings): MemoryLocalCache +public external fun memoryEagerGarbageCollector(): MemoryEagerGarbageCollector +public external fun memoryLruGarbageCollector(settings: dynamic = definedExternally): MemoryLruGarbageCollector +public external fun persistentLocalCache(settings: PersistentCacheSettings): PersistentLocalCache +public external fun persistentSingleTabManager(settings: dynamic = definedExternally): PersistentTabManager +public external fun persistentMultipleTabManager(): PersistentTabManager diff --git a/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt b/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt index c6cce33b9..698be65e2 100644 --- a/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt +++ b/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt @@ -10,19 +10,12 @@ import dev.gitlive.firebase.FirebaseException import dev.gitlive.firebase.externals.getApp import dev.gitlive.firebase.firestore.externals.MemoryCacheSettings import dev.gitlive.firebase.firestore.externals.PersistentCacheSettings -import dev.gitlive.firebase.firestore.externals.getDoc -import dev.gitlive.firebase.firestore.externals.getDocFromCache -import dev.gitlive.firebase.firestore.externals.getDocFromServer -import dev.gitlive.firebase.firestore.externals.getDocs -import dev.gitlive.firebase.firestore.externals.getDocsFromCache -import dev.gitlive.firebase.firestore.externals.getDocsFromServer import dev.gitlive.firebase.firestore.externals.memoryEagerGarbageCollector import dev.gitlive.firebase.firestore.externals.memoryLocalCache import dev.gitlive.firebase.firestore.externals.memoryLruGarbageCollector import dev.gitlive.firebase.firestore.externals.persistentLocalCache import dev.gitlive.firebase.firestore.internal.NativeDocumentSnapshotWrapper import dev.gitlive.firebase.firestore.internal.NativeFirebaseFirestoreWrapper -import dev.gitlive.firebase.firestore.internal.SetOptions import kotlin.js.Json import kotlin.js.json import dev.gitlive.firebase.firestore.externals.Firestore as JsFirestore @@ -38,71 +31,74 @@ import dev.gitlive.firebase.firestore.externals.Transaction as JsTransaction import dev.gitlive.firebase.firestore.externals.WriteBatch as JsWriteBatch import dev.gitlive.firebase.firestore.externals.documentId as jsDocumentId -actual val Firebase.firestore get() = +public actual val Firebase.firestore: FirebaseFirestore get() = rethrow { FirebaseFirestore(NativeFirebaseFirestoreWrapper(getApp())) } -actual fun Firebase.firestore(app: FirebaseApp) = +public actual fun Firebase.firestore(app: FirebaseApp): FirebaseFirestore = rethrow { FirebaseFirestore(NativeFirebaseFirestoreWrapper(app.js)) } -actual data class NativeFirebaseFirestore(val js: JsFirestore) +public actual data class NativeFirebaseFirestore(val js: JsFirestore) -val FirebaseFirestore.js: JsFirestore get() = native.js +public val FirebaseFirestore.js: JsFirestore get() = native.js -actual data class FirebaseFirestoreSettings( +public actual data class FirebaseFirestoreSettings( actual val sslEnabled: Boolean, actual val host: String, actual val cacheSettings: LocalCacheSettings, ) { - actual companion object { - actual val CACHE_SIZE_UNLIMITED: Long = -1L + public actual companion object { + public actual val CACHE_SIZE_UNLIMITED: Long = -1L internal actual val DEFAULT_HOST: String = "firestore.googleapis.com" internal actual val MINIMUM_CACHE_BYTES: Long = 1 * 1024 * 1024 + // According to documentation, default JS Firestore cache size is 40MB, not 100MB internal actual val DEFAULT_CACHE_SIZE_BYTES: Long = 40 * 1024 * 1024 } - actual class Builder internal constructor( - actual var sslEnabled: Boolean, - actual var host: String, - actual var cacheSettings: LocalCacheSettings, + public actual class Builder internal constructor( + public actual var sslEnabled: Boolean, + public actual var host: String, + public actual var cacheSettings: LocalCacheSettings, ) { - actual constructor() : this( + public actual constructor() : this( true, DEFAULT_HOST, - persistentCacheSettings { }, + persistentCacheSettings { }, ) - actual constructor(settings: FirebaseFirestoreSettings) : this(settings.sslEnabled, settings.host, settings.cacheSettings) + public actual constructor(settings: FirebaseFirestoreSettings) : this(settings.sslEnabled, settings.host, settings.cacheSettings) - actual fun build(): FirebaseFirestoreSettings = FirebaseFirestoreSettings(sslEnabled, host, cacheSettings) + public actual fun build(): FirebaseFirestoreSettings = FirebaseFirestoreSettings(sslEnabled, host, cacheSettings) } @Suppress("UNCHECKED_CAST_TO_EXTERNAL_INTERFACE") val js: Json get() = json().apply { set("ssl", sslEnabled) set("host", host) - set("localCache", - when (cacheSettings) { - is LocalCacheSettings.Persistent -> persistentLocalCache( - json( - "cacheSizeBytes" to cacheSettings.sizeBytes - ).asDynamic() as PersistentCacheSettings - ) - is LocalCacheSettings.Memory -> { - val garbageCollecorSettings = when (val garbageCollectorSettings = cacheSettings.garbaseCollectorSettings) { - is MemoryGarbageCollectorSettings.Eager -> memoryEagerGarbageCollector() - is MemoryGarbageCollectorSettings.LRUGC -> memoryLruGarbageCollector(json("cacheSizeBytes" to garbageCollectorSettings.sizeBytes)) + set( + "localCache", + when (cacheSettings) { + is LocalCacheSettings.Persistent -> persistentLocalCache( + json( + "cacheSizeBytes" to cacheSettings.sizeBytes, + ).asDynamic() as PersistentCacheSettings, + ) + is LocalCacheSettings.Memory -> { + val garbageCollecorSettings = when (val garbageCollectorSettings = cacheSettings.garbaseCollectorSettings) { + is MemoryGarbageCollectorSettings.Eager -> memoryEagerGarbageCollector() + is MemoryGarbageCollectorSettings.LRUGC -> memoryLruGarbageCollector(json("cacheSizeBytes" to garbageCollectorSettings.sizeBytes)) + } + memoryLocalCache(json("garbageCollector" to garbageCollecorSettings).asDynamic() as MemoryCacheSettings) } - memoryLocalCache(json("garbageCollector" to garbageCollecorSettings).asDynamic() as MemoryCacheSettings) - } - }) + }, + ) } } -actual fun firestoreSettings( +public actual fun firestoreSettings( settings: FirebaseFirestoreSettings?, - builder: FirebaseFirestoreSettings.Builder.() -> Unit + builder: FirebaseFirestoreSettings.Builder.() -> Unit, ): FirebaseFirestoreSettings = FirebaseFirestoreSettings.Builder().apply { settings?.let { sslEnabled = it.sslEnabled @@ -111,79 +107,81 @@ actual fun firestoreSettings( } }.apply(builder).build() -actual data class NativeWriteBatch(val js: JsWriteBatch) +public actual data class NativeWriteBatch(val js: JsWriteBatch) -val WriteBatch.js get() = native.js +public val WriteBatch.js: dev.gitlive.firebase.firestore.externals.WriteBatch get() = native.js -actual data class NativeTransaction(val js: JsTransaction) +public actual data class NativeTransaction(val js: JsTransaction) -val Transaction.js get() = native.js +public val Transaction.js: dev.gitlive.firebase.firestore.externals.Transaction get() = native.js /** A class representing a platform specific Firebase DocumentReference. */ -actual typealias NativeDocumentReferenceType = JsDocumentReference +public actual typealias NativeDocumentReferenceType = JsDocumentReference -val DocumentReference.js get() = native.js +public val DocumentReference.js: NativeDocumentReferenceType get() = native.js -actual open class NativeQuery(open val js: JsQuery) +public actual open class NativeQuery(public open val js: JsQuery) internal val JsQuery.wrapped get() = NativeQuery(this) -val Query.js get() = native.js +public val Query.js: dev.gitlive.firebase.firestore.externals.Query get() = native.js -actual data class NativeCollectionReference(override val js: JsCollectionReference) : NativeQuery(js) +public actual data class NativeCollectionReference(override val js: JsCollectionReference) : NativeQuery(js) -val CollectionReference.js get() = native.js +public val CollectionReference.js: dev.gitlive.firebase.firestore.externals.CollectionReference get() = native.js -actual class FirebaseFirestoreException(cause: Throwable, val code: FirestoreExceptionCode) : FirebaseException(code.toString(), cause) +public actual class FirebaseFirestoreException(cause: Throwable, public val code: FirestoreExceptionCode) : FirebaseException(code.toString(), cause) @Suppress("EXTENSION_SHADOWED_BY_MEMBER") -actual val FirebaseFirestoreException.code: FirestoreExceptionCode get() = code +public actual val FirebaseFirestoreException.code: FirestoreExceptionCode get() = code -actual class QuerySnapshot(val js: JsQuerySnapshot) { - actual val documents +public actual class QuerySnapshot(public val js: JsQuerySnapshot) { + public actual val documents: List get() = js.docs.map { DocumentSnapshot(NativeDocumentSnapshotWrapper(it)) } - actual val documentChanges + public actual val documentChanges: List get() = js.docChanges().map { DocumentChange(it) } - actual val metadata: SnapshotMetadata get() = SnapshotMetadata(js.metadata) + public actual val metadata: SnapshotMetadata get() = SnapshotMetadata(js.metadata) } -actual class DocumentChange(val js: JsDocumentChange) { - actual val document: DocumentSnapshot +public actual class DocumentChange(public val js: JsDocumentChange) { + public actual val document: DocumentSnapshot get() = DocumentSnapshot(NativeDocumentSnapshotWrapper(js.doc)) - actual val newIndex: Int + public actual val newIndex: Int get() = js.newIndex - actual val oldIndex: Int + public actual val oldIndex: Int get() = js.oldIndex - actual val type: ChangeType + public actual val type: ChangeType get() = ChangeType.entries.first { it.jsString == js.type } } -actual data class NativeDocumentSnapshot(val js: JsDocumentSnapshot) +public actual data class NativeDocumentSnapshot(val js: JsDocumentSnapshot) -val DocumentSnapshot.js get() = native.js +public val DocumentSnapshot.js: dev.gitlive.firebase.firestore.externals.DocumentSnapshot get() = native.js -actual class SnapshotMetadata(val js: JsSnapshotMetadata) { - actual val hasPendingWrites: Boolean get() = js.hasPendingWrites - actual val isFromCache: Boolean get() = js.fromCache +public actual class SnapshotMetadata(public val js: JsSnapshotMetadata) { + public actual val hasPendingWrites: Boolean get() = js.hasPendingWrites + public actual val isFromCache: Boolean get() = js.fromCache } -actual class FieldPath private constructor(val js: JsFieldPath) { +public actual class FieldPath private constructor(public val js: JsFieldPath) { - actual companion object { - actual val documentId = FieldPath(jsDocumentId()) + public actual companion object { + public actual val documentId: FieldPath = FieldPath(jsDocumentId()) } - actual constructor(vararg fieldNames: String) : this(dev.gitlive.firebase.firestore.rethrow { - JsFieldPath(*fieldNames) - }) - actual val documentId: FieldPath get() = FieldPath.documentId - actual val encoded: EncodedFieldPath = js + public actual constructor(vararg fieldNames: String) : this( + dev.gitlive.firebase.firestore.rethrow { + JsFieldPath(*fieldNames) + }, + ) + public actual val documentId: FieldPath get() = FieldPath.documentId + public actual val encoded: EncodedFieldPath = js override fun equals(other: Any?): Boolean = other is FieldPath && js.isEqual(other.js) override fun hashCode(): Int = js.hashCode() override fun toString(): String = js.toString() } -actual typealias EncodedFieldPath = JsFieldPath +public actual typealias EncodedFieldPath = JsFieldPath -actual enum class FirestoreExceptionCode { +public actual enum class FirestoreExceptionCode { OK, CANCELLED, UNKNOWN, @@ -200,18 +198,18 @@ actual enum class FirestoreExceptionCode { INTERNAL, UNAVAILABLE, DATA_LOSS, - UNAUTHENTICATED + UNAUTHENTICATED, } -actual enum class Direction(internal val jsString : String) { +public actual enum class Direction(internal val jsString: String) { ASCENDING("asc"), - DESCENDING("desc"); + DESCENDING("desc"), } -actual enum class ChangeType(internal val jsString : String) { +public actual enum class ChangeType(internal val jsString: String) { ADDED("added"), MODIFIED("modified"), - REMOVED("removed"); + REMOVED("removed"), } internal inline fun T.rethrow(function: T.() -> R): R = dev.gitlive.firebase.firestore.rethrow { function() } @@ -221,7 +219,7 @@ internal inline fun rethrow(function: () -> R): R { return function() } catch (e: Exception) { throw e - } catch(e: dynamic) { + } catch (e: dynamic) { throw errorToException(e) } } @@ -231,25 +229,25 @@ internal fun errorToException(e: dynamic) = (e?.code ?: e?.message ?: "") .lowercase() .let { when { - "cancelled" in it -> FirebaseFirestoreException(e, FirestoreExceptionCode.CANCELLED) - "invalid-argument" in it -> FirebaseFirestoreException(e, FirestoreExceptionCode.INVALID_ARGUMENT) - "deadline-exceeded" in it -> FirebaseFirestoreException(e, FirestoreExceptionCode.DEADLINE_EXCEEDED) - "not-found" in it -> FirebaseFirestoreException(e, FirestoreExceptionCode.NOT_FOUND) - "already-exists" in it -> FirebaseFirestoreException(e, FirestoreExceptionCode.ALREADY_EXISTS) - "permission-denied" in it -> FirebaseFirestoreException(e, FirestoreExceptionCode.PERMISSION_DENIED) - "resource-exhausted" in it -> FirebaseFirestoreException(e, FirestoreExceptionCode.RESOURCE_EXHAUSTED) - "failed-precondition" in it -> FirebaseFirestoreException(e, FirestoreExceptionCode.FAILED_PRECONDITION) - "aborted" in it -> FirebaseFirestoreException(e, FirestoreExceptionCode.ABORTED) - "out-of-range" in it -> FirebaseFirestoreException(e, FirestoreExceptionCode.OUT_OF_RANGE) - "unimplemented" in it -> FirebaseFirestoreException(e, FirestoreExceptionCode.UNIMPLEMENTED) - "internal" in it -> FirebaseFirestoreException(e, FirestoreExceptionCode.INTERNAL) - "unavailable" in it -> FirebaseFirestoreException(e, FirestoreExceptionCode.UNAVAILABLE) - "data-loss" in it -> FirebaseFirestoreException(e, FirestoreExceptionCode.DATA_LOSS) - "unauthenticated" in it -> FirebaseFirestoreException(e, FirestoreExceptionCode.UNAUTHENTICATED) - "unknown" in it -> FirebaseFirestoreException(e, FirestoreExceptionCode.UNKNOWN) + "cancelled" in it -> FirebaseFirestoreException(e.unsafeCast(), FirestoreExceptionCode.CANCELLED) + "invalid-argument" in it -> FirebaseFirestoreException(e.unsafeCast(), FirestoreExceptionCode.INVALID_ARGUMENT) + "deadline-exceeded" in it -> FirebaseFirestoreException(e.unsafeCast(), FirestoreExceptionCode.DEADLINE_EXCEEDED) + "not-found" in it -> FirebaseFirestoreException(e.unsafeCast(), FirestoreExceptionCode.NOT_FOUND) + "already-exists" in it -> FirebaseFirestoreException(e.unsafeCast(), FirestoreExceptionCode.ALREADY_EXISTS) + "permission-denied" in it -> FirebaseFirestoreException(e.unsafeCast(), FirestoreExceptionCode.PERMISSION_DENIED) + "resource-exhausted" in it -> FirebaseFirestoreException(e.unsafeCast(), FirestoreExceptionCode.RESOURCE_EXHAUSTED) + "failed-precondition" in it -> FirebaseFirestoreException(e.unsafeCast(), FirestoreExceptionCode.FAILED_PRECONDITION) + "aborted" in it -> FirebaseFirestoreException(e.unsafeCast(), FirestoreExceptionCode.ABORTED) + "out-of-range" in it -> FirebaseFirestoreException(e.unsafeCast(), FirestoreExceptionCode.OUT_OF_RANGE) + "unimplemented" in it -> FirebaseFirestoreException(e.unsafeCast(), FirestoreExceptionCode.UNIMPLEMENTED) + "internal" in it -> FirebaseFirestoreException(e.unsafeCast(), FirestoreExceptionCode.INTERNAL) + "unavailable" in it -> FirebaseFirestoreException(e.unsafeCast(), FirestoreExceptionCode.UNAVAILABLE) + "data-loss" in it -> FirebaseFirestoreException(e.unsafeCast(), FirestoreExceptionCode.DATA_LOSS) + "unauthenticated" in it -> FirebaseFirestoreException(e.unsafeCast(), FirestoreExceptionCode.UNAUTHENTICATED) + "unknown" in it -> FirebaseFirestoreException(e.unsafeCast(), FirestoreExceptionCode.UNKNOWN) else -> { println("Unknown error code in ${JSON.stringify(e)}") - FirebaseFirestoreException(e, FirestoreExceptionCode.UNKNOWN) + FirebaseFirestoreException(e.unsafeCast(), FirestoreExceptionCode.UNKNOWN) } } } diff --git a/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/JSQueryGet.kt b/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/JSQueryGet.kt deleted file mode 100644 index 51524558a..000000000 --- a/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/JSQueryGet.kt +++ /dev/null @@ -1,7 +0,0 @@ -package dev.gitlive.firebase.firestore.internal - -import dev.gitlive.firebase.firestore.Source -import dev.gitlive.firebase.firestore.externals.Query -import dev.gitlive.firebase.firestore.externals.getDocs -import dev.gitlive.firebase.firestore.externals.getDocsFromCache -import dev.gitlive.firebase.firestore.externals.getDocsFromServer diff --git a/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeCollectionReferenceWrapper.kt b/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeCollectionReferenceWrapper.kt index f3f475006..8d453eb47 100644 --- a/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeCollectionReferenceWrapper.kt +++ b/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeCollectionReferenceWrapper.kt @@ -17,22 +17,22 @@ internal actual class NativeCollectionReferenceWrapper internal actual construct override val js: CollectionReference = native.js actual val path: String - get() = rethrow { js.path } + get() = rethrow { js.path } actual val document get() = rethrow { NativeDocumentReference(doc(js)) } - actual val parent get() = rethrow { js.parent?.let{ NativeDocumentReference(it) } } + actual val parent get() = rethrow { js.parent?.let { NativeDocumentReference(it) } } actual fun document(documentPath: String) = rethrow { NativeDocumentReference( doc( js, - documentPath - ) + documentPath, + ), ) } actual suspend fun addEncoded(data: EncodedObject) = rethrow { NativeDocumentReference(addDoc(js, data.js).await()) } -} \ No newline at end of file +} diff --git a/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentReference.kt b/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentReference.kt index f38a8faf0..88ca1828e 100644 --- a/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentReference.kt +++ b/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentReference.kt @@ -41,25 +41,25 @@ internal actual class NativeDocumentReference actual constructor(actual val nati NativeCollectionReference( dev.gitlive.firebase.firestore.externals.collection( js, - collectionPath - ) + collectionPath, + ), ) } actual suspend fun get(source: Source) = rethrow { NativeDocumentSnapshot( - js.get(source).await() + js.get(source).await(), ) } actual val snapshots: Flow get() = snapshots() - actual fun snapshots(includeMetadataChanges: Boolean) = callbackFlow { + actual fun snapshots(includeMetadataChanges: Boolean) = callbackFlow { val unsubscribe = onSnapshot( js, json("includeMetadataChanges" to includeMetadataChanges), { trySend(NativeDocumentSnapshot(it)) }, - { close(errorToException(it)) } + { close(errorToException(it)) }, ) awaitClose { unsubscribe() } } @@ -68,10 +68,12 @@ internal actual class NativeDocumentReference actual constructor(actual val nati setDoc(js, encodedData.js, setOptions.js).await() } - actual suspend fun updateEncoded(encodedData: EncodedObject) = rethrow { updateDoc( - js, - encodedData.js - ).await() } + actual suspend fun updateEncoded(encodedData: EncodedObject) = rethrow { + updateDoc( + js, + encodedData.js, + ).await() + } actual suspend fun updateEncodedFieldsAndValues(encodedFieldsAndValues: List>) { rethrow { @@ -95,10 +97,12 @@ internal actual class NativeDocumentReference actual constructor(actual val nati actual suspend fun delete() = rethrow { deleteDoc(js).await() } override fun equals(other: Any?): Boolean = - this === other || other is NativeDocumentReference && refEqual( - nativeValue, - other.nativeValue - ) + this === other || + other is NativeDocumentReference && + refEqual( + nativeValue, + other.nativeValue, + ) override fun hashCode(): Int = nativeValue.hashCode() override fun toString(): String = "DocumentReference(path=$path)" } @@ -107,4 +111,4 @@ private fun NativeDocumentReferenceType.get(source: Source) = when (source) { Source.DEFAULT -> getDoc(this) Source.CACHE -> getDocFromCache(this) Source.SERVER -> getDocFromServer(this) -} \ No newline at end of file +} diff --git a/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentSnapshotWrapper.kt b/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentSnapshotWrapper.kt index dfc83769a..b4b35b66a 100644 --- a/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentSnapshotWrapper.kt +++ b/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentSnapshotWrapper.kt @@ -9,7 +9,7 @@ import dev.gitlive.firebase.firestore.rethrow import kotlin.js.json @PublishedApi -internal actual class NativeDocumentSnapshotWrapper actual internal constructor(actual val native: NativeDocumentSnapshot) { +internal actual class NativeDocumentSnapshotWrapper internal actual constructor(actual val native: NativeDocumentSnapshot) { constructor(js: DocumentSnapshot) : this(NativeDocumentSnapshot(js)) @@ -37,4 +37,4 @@ internal actual class NativeDocumentSnapshotWrapper actual internal constructor( fun getTimestampsOptions(serverTimestampBehavior: ServerTimestampBehavior) = json("serverTimestamps" to serverTimestampBehavior.name.lowercase()) -} \ No newline at end of file +} diff --git a/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeFirebaseFirestoreWrapper.kt b/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeFirebaseFirestoreWrapper.kt index d56860720..919286d00 100644 --- a/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeFirebaseFirestoreWrapper.kt +++ b/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeFirebaseFirestoreWrapper.kt @@ -21,8 +21,8 @@ import kotlinx.coroutines.await import kotlinx.coroutines.promise internal actual class NativeFirebaseFirestoreWrapper internal constructor( - private val createNative: NativeFirebaseFirestoreWrapper.() -> NativeFirebaseFirestore -){ + private val createNative: NativeFirebaseFirestoreWrapper.() -> NativeFirebaseFirestore, +) { internal actual constructor(native: NativeFirebaseFirestore) : this({ native }) internal constructor(app: FirebaseApp) : this( @@ -32,9 +32,9 @@ internal actual class NativeFirebaseFirestoreWrapper internal constructor( emulatorSettings?.run { connectFirestoreEmulator(it, host, port) } - } + }, ) - } + }, ) private data class EmulatorSettings(val host: String, val port: Int) @@ -61,8 +61,8 @@ internal actual class NativeFirebaseFirestoreWrapper internal constructor( NativeCollectionReference( dev.gitlive.firebase.firestore.externals.collection( js, - collectionPath - ) + collectionPath, + ), ) } @@ -70,8 +70,8 @@ internal actual class NativeFirebaseFirestoreWrapper internal constructor( NativeQuery( dev.gitlive.firebase.firestore.externals.collectionGroup( js, - collectionId - ) + collectionId, + ), ) } @@ -79,8 +79,8 @@ internal actual class NativeFirebaseFirestoreWrapper internal constructor( NativeDocumentReference( doc( js, - documentPath - ) + documentPath, + ), ) } @@ -91,9 +91,12 @@ internal actual class NativeFirebaseFirestoreWrapper internal constructor( @OptIn(DelicateCoroutinesApi::class) actual suspend fun runTransaction(func: suspend NativeTransaction.() -> T) = - rethrow { dev.gitlive.firebase.firestore.externals.runTransaction( - js, - { GlobalScope.promise { NativeTransaction(it).func() } }).await() } + rethrow { + dev.gitlive.firebase.firestore.externals.runTransaction( + js, + { GlobalScope.promise { NativeTransaction(it).func() } }, + ).await() + } actual suspend fun clearPersistence() = rethrow { clearIndexedDbPersistence(js).await() } @@ -112,4 +115,4 @@ internal actual class NativeFirebaseFirestoreWrapper internal constructor( actual suspend fun enableNetwork() { rethrow { dev.gitlive.firebase.firestore.externals.enableNetwork(js).await() } } -} \ No newline at end of file +} diff --git a/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeQueryWrapper.kt b/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeQueryWrapper.kt index 61c98df06..40c86e3b7 100644 --- a/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeQueryWrapper.kt +++ b/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeQueryWrapper.kt @@ -26,17 +26,17 @@ import kotlinx.coroutines.flow.callbackFlow import kotlin.js.json @PublishedApi -internal actual open class NativeQueryWrapper actual internal constructor(actual open val native: NativeQuery) { +internal actual open class NativeQueryWrapper internal actual constructor(actual open val native: NativeQuery) { constructor(js: Query) : this(NativeQuery(js)) open val js: Query get() = native.js - actual suspend fun get(source: Source) = rethrow { QuerySnapshot(js.get(source).await()) } + actual suspend fun get(source: Source) = rethrow { QuerySnapshot(js.get(source).await()) } actual fun limit(limit: Number) = query( js, - dev.gitlive.firebase.firestore.externals.limit(limit) + dev.gitlive.firebase.firestore.externals.limit(limit), ).wrapped actual fun where(filter: Filter) = query(js, filter.toQueryConstraint()).wrapped @@ -83,64 +83,80 @@ internal actual open class NativeQueryWrapper actual internal constructor(actual query(js, dev.gitlive.firebase.firestore.externals.orderBy(field, direction.jsString)).wrapped } - actual fun startAfter(document: NativeDocumentSnapshot) = rethrow { query( - js, - dev.gitlive.firebase.firestore.externals.startAfter(document.js) - ).wrapped } + actual fun startAfter(document: NativeDocumentSnapshot) = rethrow { + query( + js, + dev.gitlive.firebase.firestore.externals.startAfter(document.js), + ).wrapped + } - actual fun startAfter(vararg fieldValues: Any) = rethrow { query( - js, - dev.gitlive.firebase.firestore.externals.startAfter(*fieldValues) - ).wrapped } + actual fun startAfter(vararg fieldValues: Any) = rethrow { + query( + js, + dev.gitlive.firebase.firestore.externals.startAfter(*fieldValues), + ).wrapped + } - actual fun startAt(document: NativeDocumentSnapshot) = rethrow { query( - js, - dev.gitlive.firebase.firestore.externals.startAt(document.js) - ).wrapped } + actual fun startAt(document: NativeDocumentSnapshot) = rethrow { + query( + js, + dev.gitlive.firebase.firestore.externals.startAt(document.js), + ).wrapped + } - actual fun startAt(vararg fieldValues: Any) = rethrow { query( - js, - dev.gitlive.firebase.firestore.externals.startAt(*fieldValues) - ).wrapped } + actual fun startAt(vararg fieldValues: Any) = rethrow { + query( + js, + dev.gitlive.firebase.firestore.externals.startAt(*fieldValues), + ).wrapped + } - actual fun endBefore(document: NativeDocumentSnapshot) = rethrow { query( - js, - dev.gitlive.firebase.firestore.externals.endBefore(document.js) - ).wrapped } + actual fun endBefore(document: NativeDocumentSnapshot) = rethrow { + query( + js, + dev.gitlive.firebase.firestore.externals.endBefore(document.js), + ).wrapped + } - actual fun endBefore(vararg fieldValues: Any) = rethrow { query( - js, - dev.gitlive.firebase.firestore.externals.endBefore(*fieldValues) - ).wrapped } + actual fun endBefore(vararg fieldValues: Any) = rethrow { + query( + js, + dev.gitlive.firebase.firestore.externals.endBefore(*fieldValues), + ).wrapped + } - actual fun endAt(document: NativeDocumentSnapshot) = rethrow { query( - js, - dev.gitlive.firebase.firestore.externals.endAt(document.js) - ).wrapped } + actual fun endAt(document: NativeDocumentSnapshot) = rethrow { + query( + js, + dev.gitlive.firebase.firestore.externals.endAt(document.js), + ).wrapped + } - actual fun endAt(vararg fieldValues: Any) = rethrow { query( - js, - dev.gitlive.firebase.firestore.externals.endAt(*fieldValues) - ).wrapped } + actual fun endAt(vararg fieldValues: Any) = rethrow { + query( + js, + dev.gitlive.firebase.firestore.externals.endAt(*fieldValues), + ).wrapped + } - actual val snapshots get() = callbackFlow { + actual val snapshots get() = callbackFlow { val unsubscribe = rethrow { onSnapshot( js, { trySend(QuerySnapshot(it)) }, - { close(errorToException(it)) } + { close(errorToException(it)) }, ) } awaitClose { rethrow { unsubscribe() } } } - actual fun snapshots(includeMetadataChanges: Boolean) = callbackFlow { + actual fun snapshots(includeMetadataChanges: Boolean) = callbackFlow { val unsubscribe = rethrow { onSnapshot( js, json("includeMetadataChanges" to includeMetadataChanges), { trySend(QuerySnapshot(it)) }, - { close(errorToException(it)) } + { close(errorToException(it)) }, ) } awaitClose { rethrow { unsubscribe() } } @@ -151,4 +167,4 @@ private fun Query.get(source: Source) = when (source) { Source.DEFAULT -> getDocs(this) Source.CACHE -> getDocsFromCache(this) Source.SERVER -> getDocsFromServer(this) -} \ No newline at end of file +} diff --git a/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeTransactionWrapper.kt b/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeTransactionWrapper.kt index 9bcabf42d..b7b43d1a2 100644 --- a/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeTransactionWrapper.kt +++ b/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeTransactionWrapper.kt @@ -12,7 +12,7 @@ import dev.gitlive.firebase.internal.js import kotlinx.coroutines.await @PublishedApi -internal actual class NativeTransactionWrapper actual internal constructor(actual val native: NativeTransaction) { +internal actual class NativeTransactionWrapper internal actual constructor(actual val native: NativeTransaction) { constructor(js: Transaction) : this(NativeTransaction(js)) @@ -21,7 +21,7 @@ internal actual class NativeTransactionWrapper actual internal constructor(actua actual fun setEncoded( documentRef: DocumentReference, encodedData: EncodedObject, - setOptions: SetOptions + setOptions: SetOptions, ): NativeTransactionWrapper = rethrow { js.set(documentRef.js, encodedData.js, setOptions.js) } @@ -32,7 +32,7 @@ internal actual class NativeTransactionWrapper actual internal constructor(actua actual fun updateEncodedFieldsAndValues( documentRef: DocumentReference, - encodedFieldsAndValues: List> + encodedFieldsAndValues: List>, ): NativeTransactionWrapper = rethrow { encodedFieldsAndValues.performUpdate { field, value, moreFieldsAndValues -> js.update(documentRef.js, field, value, *moreFieldsAndValues) @@ -41,7 +41,7 @@ internal actual class NativeTransactionWrapper actual internal constructor(actua actual fun updateEncodedFieldPathsAndValues( documentRef: DocumentReference, - encodedFieldsAndValues: List> + encodedFieldsAndValues: List>, ): NativeTransactionWrapper = rethrow { encodedFieldsAndValues.performUpdate { field, value, moreFieldsAndValues -> js.update(documentRef.js, field, value, *moreFieldsAndValues) @@ -54,4 +54,4 @@ internal actual class NativeTransactionWrapper actual internal constructor(actua actual suspend fun get(documentRef: DocumentReference) = rethrow { NativeDocumentSnapshotWrapper(js.get(documentRef.js).await()) } -} \ No newline at end of file +} diff --git a/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeWriteBatchWrapper.kt b/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeWriteBatchWrapper.kt index 819e563d1..f1ceee19a 100644 --- a/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeWriteBatchWrapper.kt +++ b/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeWriteBatchWrapper.kt @@ -12,7 +12,7 @@ import dev.gitlive.firebase.internal.js import kotlinx.coroutines.await @PublishedApi -internal actual class NativeWriteBatchWrapper actual internal constructor(actual val native: NativeWriteBatch) { +internal actual class NativeWriteBatchWrapper internal actual constructor(actual val native: NativeWriteBatch) { constructor(js: WriteBatch) : this(NativeWriteBatch(js)) @@ -21,7 +21,7 @@ internal actual class NativeWriteBatchWrapper actual internal constructor(actual actual fun setEncoded( documentRef: DocumentReference, encodedData: EncodedObject, - setOptions: SetOptions + setOptions: SetOptions, ): NativeWriteBatchWrapper = rethrow { js.set(documentRef.js, encodedData.js, setOptions.js) }.let { this } actual fun updateEncoded(documentRef: DocumentReference, encodedData: EncodedObject): NativeWriteBatchWrapper = rethrow { js.update(documentRef.js, encodedData.js) } @@ -29,7 +29,7 @@ internal actual class NativeWriteBatchWrapper actual internal constructor(actual actual fun updateEncodedFieldsAndValues( documentRef: DocumentReference, - encodedFieldsAndValues: List> + encodedFieldsAndValues: List>, ): NativeWriteBatchWrapper = rethrow { encodedFieldsAndValues.performUpdate { field, value, moreFieldsAndValues -> js.update(documentRef.js, field, value, *moreFieldsAndValues) @@ -38,7 +38,7 @@ internal actual class NativeWriteBatchWrapper actual internal constructor(actual actual fun updateEncodedFieldPathsAndValues( documentRef: DocumentReference, - encodedFieldsAndValues: List> + encodedFieldsAndValues: List>, ): NativeWriteBatchWrapper = rethrow { encodedFieldsAndValues.performUpdate { field, value, moreFieldsAndValues -> js.update(documentRef.js, field, value, *moreFieldsAndValues) @@ -50,4 +50,4 @@ internal actual class NativeWriteBatchWrapper actual internal constructor(actual .let { this } actual suspend fun commit() = rethrow { js.commit().await() } -} \ No newline at end of file +} diff --git a/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/SetOptions.kt b/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/SetOptions.kt index 3857ad03a..24b667d32 100644 --- a/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/SetOptions.kt +++ b/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/SetOptions.kt @@ -5,8 +5,8 @@ import kotlin.js.json internal val SetOptions.js: Json get() = when (this) { - is SetOptions.Merge -> json("merge" to true) - is SetOptions.Overwrite -> json("merge" to false) - is SetOptions.MergeFields -> json("mergeFields" to fields.toTypedArray()) - is SetOptions.MergeFieldPaths -> json("mergeFields" to encodedFieldPaths.toTypedArray()) -} + is SetOptions.Merge -> json("merge" to true) + is SetOptions.Overwrite -> json("merge" to false) + is SetOptions.MergeFields -> json("mergeFields" to fields.toTypedArray()) + is SetOptions.MergeFieldPaths -> json("mergeFields" to encodedFieldPaths.toTypedArray()) + } diff --git a/firebase-firestore/src/jsTest/kotlin/dev/gitlive/firebase/firestore/Ignore.kt b/firebase-firestore/src/jsTest/kotlin/dev/gitlive/firebase/firestore/Ignore.kt index 65c18a3c9..d2119d902 100644 --- a/firebase-firestore/src/jsTest/kotlin/dev/gitlive/firebase/firestore/Ignore.kt +++ b/firebase-firestore/src/jsTest/kotlin/dev/gitlive/firebase/firestore/Ignore.kt @@ -3,5 +3,6 @@ package dev.gitlive.firebase.firestore import kotlin.test.Ignore actual typealias IgnoreJs = Ignore + @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) actual annotation class IgnoreForAndroidUnitTest diff --git a/firebase-firestore/src/jsTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt b/firebase-firestore/src/jsTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt index 7dc9a19a8..9c6ba0d4c 100644 --- a/firebase-firestore/src/jsTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt +++ b/firebase-firestore/src/jsTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt @@ -10,10 +10,8 @@ actual val emulatorHost: String = "localhost" actual val context: Any = Unit -actual fun encodedAsMap(encoded: Any?): Map { - return (js("Object").entries(encoded) as Array>).associate { - it[0] as String to it[1] - } +actual fun encodedAsMap(encoded: Any?): Map = (js("Object").entries(encoded) as Array>).associate { + it[0] as String to it[1] } actual fun Map.asEncoded(): Any = json(*entries.map { (key, value) -> key to value }.toTypedArray()) diff --git a/firebase-firestore/src/jvmTest/kotlin/dev/gitlive/firebase/firestore/Ignore.kt b/firebase-firestore/src/jvmTest/kotlin/dev/gitlive/firebase/firestore/Ignore.kt index 1f70d3731..e484ad9f6 100644 --- a/firebase-firestore/src/jvmTest/kotlin/dev/gitlive/firebase/firestore/Ignore.kt +++ b/firebase-firestore/src/jvmTest/kotlin/dev/gitlive/firebase/firestore/Ignore.kt @@ -2,5 +2,6 @@ package dev.gitlive.firebase.firestore @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) actual annotation class IgnoreJs + @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) actual annotation class IgnoreForAndroidUnitTest diff --git a/firebase-functions/api/android/firebase-functions.api b/firebase-functions/api/android/firebase-functions.api new file mode 100644 index 000000000..5ec851b78 --- /dev/null +++ b/firebase-functions/api/android/firebase-functions.api @@ -0,0 +1,50 @@ +public final class dev/gitlive/firebase/functions/FirebaseFunctions { + public final fun component1 ()Lcom/google/firebase/functions/FirebaseFunctions; + public final fun copy (Lcom/google/firebase/functions/FirebaseFunctions;)Ldev/gitlive/firebase/functions/FirebaseFunctions; + public static synthetic fun copy$default (Ldev/gitlive/firebase/functions/FirebaseFunctions;Lcom/google/firebase/functions/FirebaseFunctions;ILjava/lang/Object;)Ldev/gitlive/firebase/functions/FirebaseFunctions; + public fun equals (Ljava/lang/Object;)Z + public final fun getAndroid ()Lcom/google/firebase/functions/FirebaseFunctions; + public fun hashCode ()I + public final fun httpsCallable (Ljava/lang/String;Ljava/lang/Long;)Ldev/gitlive/firebase/functions/HttpsCallableReference; + public static synthetic fun httpsCallable$default (Ldev/gitlive/firebase/functions/FirebaseFunctions;Ljava/lang/String;Ljava/lang/Long;ILjava/lang/Object;)Ldev/gitlive/firebase/functions/HttpsCallableReference; + public fun toString ()Ljava/lang/String; + public final fun useEmulator (Ljava/lang/String;I)V +} + +public final class dev/gitlive/firebase/functions/FunctionsKt { + public static final fun functions (Ldev/gitlive/firebase/Firebase;Ldev/gitlive/firebase/FirebaseApp;)Ldev/gitlive/firebase/functions/FirebaseFunctions; + public static final fun functions (Ldev/gitlive/firebase/Firebase;Ldev/gitlive/firebase/FirebaseApp;Ljava/lang/String;)Ldev/gitlive/firebase/functions/FirebaseFunctions; + public static final fun functions (Ldev/gitlive/firebase/Firebase;Ljava/lang/String;)Ldev/gitlive/firebase/functions/FirebaseFunctions; + public static final fun getCode (Lcom/google/firebase/functions/FirebaseFunctionsException;)Lcom/google/firebase/functions/FirebaseFunctionsException$Code; + public static final fun getDetails (Lcom/google/firebase/functions/FirebaseFunctionsException;)Ljava/lang/Object; + public static final fun getFunctions (Ldev/gitlive/firebase/Firebase;)Ldev/gitlive/firebase/functions/FirebaseFunctions; +} + +public final class dev/gitlive/firebase/functions/HttpsCallableReference { + public final fun getNative ()Ldev/gitlive/firebase/functions/NativeHttpsCallableReference; + public final fun invoke (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun invoke (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun invoke (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static synthetic fun invoke$default (Ldev/gitlive/firebase/functions/HttpsCallableReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; +} + +public final class dev/gitlive/firebase/functions/HttpsCallableResult { + public fun (Lcom/google/firebase/functions/HttpsCallableResult;)V + public final fun data (Lkotlinx/serialization/DeserializationStrategy;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; + public static synthetic fun data$default (Ldev/gitlive/firebase/functions/HttpsCallableResult;Lkotlinx/serialization/DeserializationStrategy;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/lang/Object; + public final fun getAndroid ()Lcom/google/firebase/functions/HttpsCallableResult; +} + +public final class dev/gitlive/firebase/functions/NativeHttpsCallableReference { + public fun (Lcom/google/firebase/functions/HttpsCallableReference;)V + public final fun component1 ()Lcom/google/firebase/functions/HttpsCallableReference; + public final fun copy (Lcom/google/firebase/functions/HttpsCallableReference;)Ldev/gitlive/firebase/functions/NativeHttpsCallableReference; + public static synthetic fun copy$default (Ldev/gitlive/firebase/functions/NativeHttpsCallableReference;Lcom/google/firebase/functions/HttpsCallableReference;ILjava/lang/Object;)Ldev/gitlive/firebase/functions/NativeHttpsCallableReference; + public fun equals (Ljava/lang/Object;)Z + public final fun getAndroid ()Lcom/google/firebase/functions/HttpsCallableReference; + public fun hashCode ()I + public final fun invoke (Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun invoke (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public fun toString ()Ljava/lang/String; +} + diff --git a/firebase-functions/api/jvm/firebase-functions.api b/firebase-functions/api/jvm/firebase-functions.api new file mode 100644 index 000000000..5ec851b78 --- /dev/null +++ b/firebase-functions/api/jvm/firebase-functions.api @@ -0,0 +1,50 @@ +public final class dev/gitlive/firebase/functions/FirebaseFunctions { + public final fun component1 ()Lcom/google/firebase/functions/FirebaseFunctions; + public final fun copy (Lcom/google/firebase/functions/FirebaseFunctions;)Ldev/gitlive/firebase/functions/FirebaseFunctions; + public static synthetic fun copy$default (Ldev/gitlive/firebase/functions/FirebaseFunctions;Lcom/google/firebase/functions/FirebaseFunctions;ILjava/lang/Object;)Ldev/gitlive/firebase/functions/FirebaseFunctions; + public fun equals (Ljava/lang/Object;)Z + public final fun getAndroid ()Lcom/google/firebase/functions/FirebaseFunctions; + public fun hashCode ()I + public final fun httpsCallable (Ljava/lang/String;Ljava/lang/Long;)Ldev/gitlive/firebase/functions/HttpsCallableReference; + public static synthetic fun httpsCallable$default (Ldev/gitlive/firebase/functions/FirebaseFunctions;Ljava/lang/String;Ljava/lang/Long;ILjava/lang/Object;)Ldev/gitlive/firebase/functions/HttpsCallableReference; + public fun toString ()Ljava/lang/String; + public final fun useEmulator (Ljava/lang/String;I)V +} + +public final class dev/gitlive/firebase/functions/FunctionsKt { + public static final fun functions (Ldev/gitlive/firebase/Firebase;Ldev/gitlive/firebase/FirebaseApp;)Ldev/gitlive/firebase/functions/FirebaseFunctions; + public static final fun functions (Ldev/gitlive/firebase/Firebase;Ldev/gitlive/firebase/FirebaseApp;Ljava/lang/String;)Ldev/gitlive/firebase/functions/FirebaseFunctions; + public static final fun functions (Ldev/gitlive/firebase/Firebase;Ljava/lang/String;)Ldev/gitlive/firebase/functions/FirebaseFunctions; + public static final fun getCode (Lcom/google/firebase/functions/FirebaseFunctionsException;)Lcom/google/firebase/functions/FirebaseFunctionsException$Code; + public static final fun getDetails (Lcom/google/firebase/functions/FirebaseFunctionsException;)Ljava/lang/Object; + public static final fun getFunctions (Ldev/gitlive/firebase/Firebase;)Ldev/gitlive/firebase/functions/FirebaseFunctions; +} + +public final class dev/gitlive/firebase/functions/HttpsCallableReference { + public final fun getNative ()Ldev/gitlive/firebase/functions/NativeHttpsCallableReference; + public final fun invoke (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun invoke (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun invoke (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static synthetic fun invoke$default (Ldev/gitlive/firebase/functions/HttpsCallableReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; +} + +public final class dev/gitlive/firebase/functions/HttpsCallableResult { + public fun (Lcom/google/firebase/functions/HttpsCallableResult;)V + public final fun data (Lkotlinx/serialization/DeserializationStrategy;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; + public static synthetic fun data$default (Ldev/gitlive/firebase/functions/HttpsCallableResult;Lkotlinx/serialization/DeserializationStrategy;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/lang/Object; + public final fun getAndroid ()Lcom/google/firebase/functions/HttpsCallableResult; +} + +public final class dev/gitlive/firebase/functions/NativeHttpsCallableReference { + public fun (Lcom/google/firebase/functions/HttpsCallableReference;)V + public final fun component1 ()Lcom/google/firebase/functions/HttpsCallableReference; + public final fun copy (Lcom/google/firebase/functions/HttpsCallableReference;)Ldev/gitlive/firebase/functions/NativeHttpsCallableReference; + public static synthetic fun copy$default (Ldev/gitlive/firebase/functions/NativeHttpsCallableReference;Lcom/google/firebase/functions/HttpsCallableReference;ILjava/lang/Object;)Ldev/gitlive/firebase/functions/NativeHttpsCallableReference; + public fun equals (Ljava/lang/Object;)Z + public final fun getAndroid ()Lcom/google/firebase/functions/HttpsCallableReference; + public fun hashCode ()I + public final fun invoke (Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun invoke (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public fun toString ()Ljava/lang/String; +} + diff --git a/firebase-functions/build.gradle.kts b/firebase-functions/build.gradle.kts index 9a6e33f97..c096f47e5 100644 --- a/firebase-functions/build.gradle.kts +++ b/firebase-functions/build.gradle.kts @@ -47,6 +47,8 @@ android { val supportIosTarget = project.property("skipIosTarget") != "true" kotlin { + explicitApi() + @OptIn(ExperimentalKotlinGradlePluginApi::class) compilerOptions { freeCompilerArgs.add("-Xexpect-actual-classes") diff --git a/firebase-functions/src/androidMain/kotlin/dev/gitlive/firebase/functions/functions.kt b/firebase-functions/src/androidMain/kotlin/dev/gitlive/firebase/functions/functions.kt index a63ba87f5..60b2b7493 100644 --- a/firebase-functions/src/androidMain/kotlin/dev/gitlive/firebase/functions/functions.kt +++ b/firebase-functions/src/androidMain/kotlin/dev/gitlive/firebase/functions/functions.kt @@ -12,27 +12,29 @@ import kotlinx.coroutines.tasks.await import kotlinx.serialization.DeserializationStrategy import java.util.concurrent.TimeUnit -actual val Firebase.functions +public actual val Firebase.functions: FirebaseFunctions get() = FirebaseFunctions(com.google.firebase.functions.FirebaseFunctions.getInstance()) -actual fun Firebase.functions(region: String) = +public actual fun Firebase.functions(region: String): FirebaseFunctions = FirebaseFunctions(com.google.firebase.functions.FirebaseFunctions.getInstance(region)) -actual fun Firebase.functions(app: FirebaseApp) = +public actual fun Firebase.functions(app: FirebaseApp): FirebaseFunctions = FirebaseFunctions(com.google.firebase.functions.FirebaseFunctions.getInstance(app.android)) -actual fun Firebase.functions(app: FirebaseApp, region: String) = +public actual fun Firebase.functions(app: FirebaseApp, region: String): FirebaseFunctions = FirebaseFunctions(com.google.firebase.functions.FirebaseFunctions.getInstance(app.android, region)) -actual data class FirebaseFunctions internal constructor(val android: com.google.firebase.functions.FirebaseFunctions) { - actual fun httpsCallable(name: String, timeout: Long?) = +public actual data class FirebaseFunctions internal constructor(public val android: com.google.firebase.functions.FirebaseFunctions) { + public actual fun httpsCallable(name: String, timeout: Long?): HttpsCallableReference = HttpsCallableReference(android.getHttpsCallable(name).apply { timeout?.let { setTimeout(it, TimeUnit.MILLISECONDS) } }.native) - actual fun useEmulator(host: String, port: Int) = android.useEmulator(host, port) + public actual fun useEmulator(host: String, port: Int) { + android.useEmulator(host, port) + } } @PublishedApi -internal actual data class NativeHttpsCallableReference(val android: com.google.firebase.functions.HttpsCallableReference){ +internal actual data class NativeHttpsCallableReference(val android: com.google.firebase.functions.HttpsCallableReference) { actual suspend fun invoke(encodedData: Any): HttpsCallableResult = HttpsCallableResult(android.call(encodedData).await()) actual suspend fun invoke(): HttpsCallableResult = HttpsCallableResult(android.call().await()) } @@ -41,19 +43,21 @@ internal val com.google.firebase.functions.HttpsCallableReference.native get() = internal val HttpsCallableReference.android: com.google.firebase.functions.HttpsCallableReference get() = native.android -actual class HttpsCallableResult constructor(val android: com.google.firebase.functions.HttpsCallableResult) { +public actual class HttpsCallableResult(public val android: com.google.firebase.functions.HttpsCallableResult) { - actual inline fun data() = + public actual inline fun data(): T = decode(value = android.data) - actual inline fun data(strategy: DeserializationStrategy, buildSettings: DecodeSettings.Builder.() -> Unit) = + public actual inline fun data(strategy: DeserializationStrategy, buildSettings: DecodeSettings.Builder.() -> Unit): T = decode(strategy, android.data, buildSettings) } -actual typealias FirebaseFunctionsException = com.google.firebase.functions.FirebaseFunctionsException +public actual typealias FirebaseFunctionsException = com.google.firebase.functions.FirebaseFunctionsException -actual val FirebaseFunctionsException.code: FunctionsExceptionCode get() = code +@Suppress("ConflictingExtensionProperty") +public actual val FirebaseFunctionsException.code: FunctionsExceptionCode get() = code -actual val FirebaseFunctionsException.details: Any? get() = details +@Suppress("ConflictingExtensionProperty") +public actual val FirebaseFunctionsException.details: Any? get() = details -actual typealias FunctionsExceptionCode = com.google.firebase.functions.FirebaseFunctionsException.Code +public actual typealias FunctionsExceptionCode = com.google.firebase.functions.FirebaseFunctionsException.Code diff --git a/firebase-functions/src/commonMain/kotlin/dev/gitlive/firebase/functions/functions.kt b/firebase-functions/src/commonMain/kotlin/dev/gitlive/firebase/functions/functions.kt index f9582a212..849c34c87 100644 --- a/firebase-functions/src/commonMain/kotlin/dev/gitlive/firebase/functions/functions.kt +++ b/firebase-functions/src/commonMain/kotlin/dev/gitlive/firebase/functions/functions.kt @@ -14,9 +14,9 @@ import kotlinx.serialization.DeserializationStrategy import kotlinx.serialization.SerializationStrategy /** FirebaseFunctions lets you call Cloud Functions for Firebase. */ -expect class FirebaseFunctions { +public expect class FirebaseFunctions { /** Returns a reference to the callable HTTPS trigger with the given name. */ - fun httpsCallable(name: String, timeout: Long? = null): HttpsCallableReference + public fun httpsCallable(name: String, timeout: Long? = null): HttpsCallableReference /** * Modifies this FirebaseFunctions instance to communicate with the Cloud Functions emulator. @@ -26,7 +26,7 @@ expect class FirebaseFunctions { * @param host the emulator host (for example, 10.0.2.2) * @param port the emulator port (for example, 5001) */ - fun useEmulator(host: String, port: Int) + public fun useEmulator(host: String, port: Int) } @PublishedApi @@ -36,12 +36,12 @@ internal expect class NativeHttpsCallableReference { } /** A reference to a particular Callable HTTPS trigger in Cloud Functions. */ -class HttpsCallableReference internal constructor( +public class HttpsCallableReference internal constructor( @PublishedApi - internal val native: NativeHttpsCallableReference + internal val native: NativeHttpsCallableReference, ) { @Deprecated("Deprecated. Use builder instead", replaceWith = ReplaceWith("invoke(data) { this.encodeDefaults = encodeDefaults }")) - suspend inline operator fun invoke(data: T, encodeDefaults: Boolean) = invoke(data) { + public suspend inline operator fun invoke(data: T, encodeDefaults: Boolean): HttpsCallableResult = invoke(data) { this.encodeDefaults = encodeDefaults } @@ -60,14 +60,14 @@ class HttpsCallableReference internal constructor( * @return A Task that will be completed when the HTTPS request has completed. * @see FirebaseFunctionsException */ - suspend inline operator fun invoke(data: T, buildSettings: EncodeSettings.Builder.() -> Unit = {}): HttpsCallableResult = native.invoke(encodedData = encode(data, buildSettings)!!) + public suspend inline operator fun invoke(data: T, buildSettings: EncodeSettings.Builder.() -> Unit = {}): HttpsCallableResult = native.invoke(encodedData = encode(data, buildSettings)!!) @Deprecated("Deprecated. Use builder instead", replaceWith = ReplaceWith("invoke(strategy, data) { this.encodeDefaults = encodeDefaults }")) - suspend operator fun invoke(strategy: SerializationStrategy, data: T, encodeDefaults: Boolean): HttpsCallableResult = invoke(strategy, data) { + public suspend operator fun invoke(strategy: SerializationStrategy, data: T, encodeDefaults: Boolean): HttpsCallableResult = invoke(strategy, data) { this.encodeDefaults = encodeDefaults } - suspend inline operator fun invoke(strategy: SerializationStrategy, data: T, buildSettings: EncodeSettings.Builder.() -> Unit = {}): HttpsCallableResult = invoke(encode(strategy, data, buildSettings)!!) + public suspend inline operator fun invoke(strategy: SerializationStrategy, data: T, buildSettings: EncodeSettings.Builder.() -> Unit = {}): HttpsCallableResult = invoke(encode(strategy, data, buildSettings)!!) /** * Executes this HTTPS endpoint asynchronously without arguments. @@ -78,53 +78,51 @@ class HttpsCallableReference internal constructor( * * @return A [HttpsCallableResult] that will contain the result. */ - suspend operator fun invoke(): HttpsCallableResult = native.invoke() + public suspend operator fun invoke(): HttpsCallableResult = native.invoke() } -expect class HttpsCallableResult { - inline fun data(): T - inline fun data(strategy: DeserializationStrategy, buildSettings: DecodeSettings.Builder.() -> Unit = {}): T +public expect class HttpsCallableResult { + public inline fun data(): T + public inline fun data(strategy: DeserializationStrategy, buildSettings: DecodeSettings.Builder.() -> Unit = {}): T } /** Returns the [FirebaseFunctions] instance of the default [FirebaseApp]. */ -expect val Firebase.functions: FirebaseFunctions +public expect val Firebase.functions: FirebaseFunctions /** Returns the [FirebaseFunctions] instance of a given [region]. */ -expect fun Firebase.functions(region: String): FirebaseFunctions +public expect fun Firebase.functions(region: String): FirebaseFunctions /** Returns the [FirebaseFunctions] instance of a given [FirebaseApp]. */ -expect fun Firebase.functions(app: FirebaseApp): FirebaseFunctions +public expect fun Firebase.functions(app: FirebaseApp): FirebaseFunctions /** Returns the [FirebaseFunctions] instance of a given [FirebaseApp] and [region]. */ -expect fun Firebase.functions(app: FirebaseApp, region: String): FirebaseFunctions +public expect fun Firebase.functions(app: FirebaseApp, region: String): FirebaseFunctions /** * Exception that gets thrown when an operation on Firebase Functions fails. */ -expect class FirebaseFunctionsException: FirebaseException +public expect class FirebaseFunctionsException : FirebaseException /** * Returns the error code for this exception. * * @return [code] [FunctionsExceptionCode] that caused the exception. */ -@Suppress("EXTENSION_SHADOWED_BY_MEMBER") -expect val FirebaseFunctionsException.code: FunctionsExceptionCode +public expect val FirebaseFunctionsException.code: FunctionsExceptionCode /** * Returns the message for this exception. * * @return [details] message for this exception. */ -@Suppress("EXTENSION_SHADOWED_BY_MEMBER") -expect val FirebaseFunctionsException.details: Any? +public expect val FirebaseFunctionsException.details: Any? /** * The set of error status codes that can be returned from a Callable HTTPS tigger. These are the * canonical error codes for Google APIs, as documented here: * https://github.com/googleapis/googleapis/blob/master/google/rpc/code.proto#L26 */ -expect enum class FunctionsExceptionCode { +public expect enum class FunctionsExceptionCode { OK, CANCELLED, UNKNOWN, @@ -141,5 +139,5 @@ expect enum class FunctionsExceptionCode { INTERNAL, UNAVAILABLE, DATA_LOSS, - UNAUTHENTICATED + UNAUTHENTICATED, } diff --git a/firebase-functions/src/iosMain/kotlin/dev/gitlive/firebase/functions/functions.kt b/firebase-functions/src/iosMain/kotlin/dev/gitlive/firebase/functions/functions.kt index 1e295d1fd..1d130bd12 100644 --- a/firebase-functions/src/iosMain/kotlin/dev/gitlive/firebase/functions/functions.kt +++ b/firebase-functions/src/iosMain/kotlin/dev/gitlive/firebase/functions/functions.kt @@ -2,6 +2,8 @@ * Copyright (c) 2020 GitLive Ltd. Use of this source code is governed by the Apache 2.0 license. */ +@file:Suppress("EXTENSION_SHADOWED_BY_MEMBER") + package dev.gitlive.firebase.functions import cocoapods.FirebaseFunctions.FIRFunctions @@ -16,30 +18,30 @@ import kotlinx.coroutines.CompletableDeferred import kotlinx.serialization.DeserializationStrategy import platform.Foundation.NSError -actual val Firebase.functions +public actual val Firebase.functions: FirebaseFunctions get() = FirebaseFunctions(FIRFunctions.functions()) -actual fun Firebase.functions(region: String) = +public actual fun Firebase.functions(region: String): FirebaseFunctions = FirebaseFunctions(FIRFunctions.functionsForRegion(region)) -@Suppress("CAST_NEVER_SUCCEEDS") -actual fun Firebase.functions(app: FirebaseApp): FirebaseFunctions = FirebaseFunctions( - FIRFunctions.functionsForApp(app.ios as objcnames.classes.FIRApp) +public actual fun Firebase.functions(app: FirebaseApp): FirebaseFunctions = FirebaseFunctions( + FIRFunctions.functionsForApp(app.ios as objcnames.classes.FIRApp), ) -@Suppress("CAST_NEVER_SUCCEEDS") -actual fun Firebase.functions( +public actual fun Firebase.functions( app: FirebaseApp, region: String, ): FirebaseFunctions = FirebaseFunctions( - FIRFunctions.functionsForApp(app.ios as objcnames.classes.FIRApp, region = region) + FIRFunctions.functionsForApp(app.ios as objcnames.classes.FIRApp, region = region), ) -actual data class FirebaseFunctions internal constructor(val ios: FIRFunctions) { - actual fun httpsCallable(name: String, timeout: Long?) = - HttpsCallableReference(ios.HTTPSCallableWithName(name).apply { timeout?.let { setTimeoutInterval(it/1000.0) } }.native) +public actual data class FirebaseFunctions internal constructor(public val ios: FIRFunctions) { + public actual fun httpsCallable(name: String, timeout: Long?): HttpsCallableReference = + HttpsCallableReference(ios.HTTPSCallableWithName(name).apply { timeout?.let { setTimeoutInterval(it / 1000.0) } }.native) - actual fun useEmulator(host: String, port: Int) = ios.useEmulatorWithHost(host, port.toLong()) + public actual fun useEmulator(host: String, port: Int) { + ios.useEmulatorWithHost(host, port.toLong()) + } } @PublishedApi @@ -52,22 +54,22 @@ internal val FIRHTTPSCallable.native get() = NativeHttpsCallableReference(this) internal val HttpsCallableReference.ios: FIRHTTPSCallable get() = native.ios -actual class HttpsCallableResult constructor(val ios: FIRHTTPSCallableResult) { +public actual class HttpsCallableResult(public val ios: FIRHTTPSCallableResult) { - actual inline fun data() = + public actual inline fun data(): T = decode(value = ios.data()) - actual inline fun data(strategy: DeserializationStrategy, buildSettings: DecodeSettings.Builder.() -> Unit) = + public actual inline fun data(strategy: DeserializationStrategy, buildSettings: DecodeSettings.Builder.() -> Unit): T = decode(strategy, ios.data(), buildSettings) } -actual class FirebaseFunctionsException(message: String, val code: FunctionsExceptionCode, val details: Any?) : FirebaseException(message) +public actual class FirebaseFunctionsException(message: String, public val code: FunctionsExceptionCode, public val details: Any?) : FirebaseException(message) -actual val FirebaseFunctionsException.code: FunctionsExceptionCode get() = code +public actual val FirebaseFunctionsException.code: FunctionsExceptionCode get() = code -actual val FirebaseFunctionsException.details: Any? get() = details +public actual val FirebaseFunctionsException.details: Any? get() = details -actual enum class FunctionsExceptionCode { +public actual enum class FunctionsExceptionCode { OK, CANCELLED, UNKNOWN, @@ -84,10 +86,11 @@ actual enum class FunctionsExceptionCode { INTERNAL, UNAVAILABLE, DATA_LOSS, - UNAUTHENTICATED + UNAUTHENTICATED, } -//todo uncomment once https://github.com/firebase/firebase-ios-sdk/issues/11862 fixed -internal fun NSError.toException() = when(domain) { + +// todo uncomment once https://github.com/firebase/firebase-ios-sdk/issues/11862 fixed +internal fun NSError.toException() = when (domain) { // FIRFunctionsErrorDomain -> when(code) { // FIRFunctionsErrorCodeOK -> FunctionsExceptionCode.OK // FIRFunctionsErrorCodeCancelled -> FunctionsExceptionCode.CANCELLED @@ -109,12 +112,18 @@ internal fun NSError.toException() = when(domain) { // else -> FunctionsExceptionCode.UNKNOWN // } else -> FunctionsExceptionCode.UNKNOWN -}.let { FirebaseFunctionsException(description!!, it, null/*userInfo[FIRFunctionsErrorDetails]*/) } +}.let { + FirebaseFunctionsException( + description!!, + it, + null, // userInfo[FIRFunctionsErrorDetails + ) +} internal suspend inline fun T.await(function: T.(callback: (NSError?) -> Unit) -> Unit) { val job = CompletableDeferred() function { error -> - if(error == null) { + if (error == null) { job.complete(Unit) } else { job.completeExceptionally(error.toException()) @@ -126,7 +135,7 @@ internal suspend inline fun T.await(function: T.(callback: (NSError?) -> Uni internal suspend inline fun T.awaitResult(function: T.(callback: (R?, NSError?) -> Unit) -> Unit): R { val job = CompletableDeferred() function { result, error -> - if(error == null) { + if (error == null) { job.complete(result) } else { job.completeExceptionally(error.toException()) diff --git a/firebase-functions/src/jsMain/kotlin/dev/gitlive/firebase/functions/externals/HttpsCallableExt.kt b/firebase-functions/src/jsMain/kotlin/dev/gitlive/firebase/functions/externals/HttpsCallableExt.kt index ef4d3f6f0..219260d7e 100644 --- a/firebase-functions/src/jsMain/kotlin/dev/gitlive/firebase/functions/externals/HttpsCallableExt.kt +++ b/firebase-functions/src/jsMain/kotlin/dev/gitlive/firebase/functions/externals/HttpsCallableExt.kt @@ -6,5 +6,5 @@ package dev.gitlive.firebase.functions.externals import kotlin.js.Promise -operator fun HttpsCallable.invoke() = asDynamic()() as Promise -operator fun HttpsCallable.invoke(data: Any?) = asDynamic()(data) as Promise +public operator fun HttpsCallable.invoke(): Promise = asDynamic()() as Promise +public operator fun HttpsCallable.invoke(data: Any?): Promise = asDynamic()(data) as Promise diff --git a/firebase-functions/src/jsMain/kotlin/dev/gitlive/firebase/functions/externals/functions.kt b/firebase-functions/src/jsMain/kotlin/dev/gitlive/firebase/functions/externals/functions.kt index 7cf5388c6..c0898b956 100644 --- a/firebase-functions/src/jsMain/kotlin/dev/gitlive/firebase/functions/externals/functions.kt +++ b/firebase-functions/src/jsMain/kotlin/dev/gitlive/firebase/functions/externals/functions.kt @@ -6,19 +6,19 @@ package dev.gitlive.firebase.functions.externals import dev.gitlive.firebase.externals.FirebaseApp import kotlin.js.Json -external fun connectFunctionsEmulator(functions: Functions, host: String, port: Int) +public external fun connectFunctionsEmulator(functions: Functions, host: String, port: Int) -external fun getFunctions( +public external fun getFunctions( app: FirebaseApp? = definedExternally, - regionOrCustomDomain: String? = definedExternally + regionOrCustomDomain: String? = definedExternally, ): Functions -external fun httpsCallable(functions: Functions, name: String, options: Json?): HttpsCallable +public external fun httpsCallable(functions: Functions, name: String, options: Json?): HttpsCallable -external interface Functions +public external interface Functions -external interface HttpsCallableResult { - val data: Any? +public external interface HttpsCallableResult { + public val data: Any? } -external interface HttpsCallable +public external interface HttpsCallable diff --git a/firebase-functions/src/jsMain/kotlin/dev/gitlive/firebase/functions/functions.kt b/firebase-functions/src/jsMain/kotlin/dev/gitlive/firebase/functions/functions.kt index 3657e89f0..6a9e7422f 100644 --- a/firebase-functions/src/jsMain/kotlin/dev/gitlive/firebase/functions/functions.kt +++ b/firebase-functions/src/jsMain/kotlin/dev/gitlive/firebase/functions/functions.kt @@ -2,6 +2,8 @@ * Copyright (c) 2020 GitLive Ltd. Use of this source code is governed by the Apache 2.0 license. */ +@file:Suppress("EXTENSION_SHADOWED_BY_MEMBER") + package dev.gitlive.firebase.functions import dev.gitlive.firebase.DecodeSettings @@ -20,23 +22,25 @@ import kotlinx.serialization.DeserializationStrategy import kotlin.js.json import dev.gitlive.firebase.functions.externals.HttpsCallableResult as JsHttpsCallableResult -actual val Firebase.functions: FirebaseFunctions +public actual val Firebase.functions: FirebaseFunctions get() = rethrow { FirebaseFunctions(getFunctions()) } -actual fun Firebase.functions(region: String) = +public actual fun Firebase.functions(region: String): FirebaseFunctions = rethrow { FirebaseFunctions(getFunctions(regionOrCustomDomain = region)) } -actual fun Firebase.functions(app: FirebaseApp) = +public actual fun Firebase.functions(app: FirebaseApp): FirebaseFunctions = rethrow { FirebaseFunctions(getFunctions(app.js)) } -actual fun Firebase.functions(app: FirebaseApp, region: String) = +public actual fun Firebase.functions(app: FirebaseApp, region: String): FirebaseFunctions = rethrow { FirebaseFunctions(getFunctions(app.js, region)) } -actual class FirebaseFunctions internal constructor(val js: Functions) { - actual fun httpsCallable(name: String, timeout: Long?) = - rethrow { HttpsCallableReference( httpsCallable(js, name, timeout?.let { json("timeout" to timeout.toDouble()) }).native) } +public actual class FirebaseFunctions internal constructor(public val js: Functions) { + public actual fun httpsCallable(name: String, timeout: Long?): HttpsCallableReference = + rethrow { HttpsCallableReference(httpsCallable(js, name, timeout?.let { json("timeout" to timeout.toDouble()) }).native) } - actual fun useEmulator(host: String, port: Int) = connectFunctionsEmulator(js, host, port) + public actual fun useEmulator(host: String, port: Int) { + connectFunctionsEmulator(js, host, port) + } } @PublishedApi @@ -48,27 +52,26 @@ internal actual data class NativeHttpsCallableReference(val js: HttpsCallable) { } @PublishedApi -internal val HttpsCallable.native get() = NativeHttpsCallableReference(this) +internal val HttpsCallable.native: NativeHttpsCallableReference get() = NativeHttpsCallableReference(this) -val HttpsCallableReference.js: HttpsCallable get() = native.js +public val HttpsCallableReference.js: HttpsCallable get() = native.js -actual class HttpsCallableResult(val js: JsHttpsCallableResult) { +public actual class HttpsCallableResult(public val js: JsHttpsCallableResult) { - actual inline fun data() = + public actual inline fun data(): T = rethrow { decode(value = js.data) } - actual inline fun data(strategy: DeserializationStrategy, buildSettings: DecodeSettings.Builder.() -> Unit) = + public actual inline fun data(strategy: DeserializationStrategy, buildSettings: DecodeSettings.Builder.() -> Unit): T = rethrow { decode(strategy, js.data, buildSettings) } - } -actual class FirebaseFunctionsException(cause: Throwable, val code: FunctionsExceptionCode, val details: Any?) : FirebaseException(cause.message, cause) +public actual class FirebaseFunctionsException(cause: Throwable, public val code: FunctionsExceptionCode, public val details: Any?) : FirebaseException(cause.message, cause) -actual val FirebaseFunctionsException.code: FunctionsExceptionCode get() = code +public actual val FirebaseFunctionsException.code: FunctionsExceptionCode get() = code -actual val FirebaseFunctionsException.details: Any? get() = details +public actual val FirebaseFunctionsException.details: Any? get() = details -actual enum class FunctionsExceptionCode { +public actual enum class FunctionsExceptionCode { OK, CANCELLED, UNKNOWN, @@ -85,8 +88,9 @@ actual enum class FunctionsExceptionCode { INTERNAL, UNAVAILABLE, DATA_LOSS, - UNAUTHENTICATED + UNAUTHENTICATED, } + @PublishedApi internal inline fun T.rethrow(function: T.() -> R): R = dev.gitlive.firebase.functions.rethrow { function() } @@ -96,36 +100,36 @@ internal inline fun rethrow(function: () -> R): R { return function() } catch (e: Exception) { throw e - } catch(e: dynamic) { + } catch (e: dynamic) { throw errorToException(e) } } @PublishedApi -internal fun errorToException(e: dynamic) = (e?.code ?: e?.message ?: "") +internal fun errorToException(e: dynamic): FirebaseFunctionsException = (e?.code ?: e?.message ?: "") .toString() .lowercase() .let { when { - "cancelled" in it -> FirebaseFunctionsException(e, FunctionsExceptionCode.CANCELLED, e.details) - "invalid-argument" in it -> FirebaseFunctionsException(e, FunctionsExceptionCode.INVALID_ARGUMENT, e.details) - "deadline-exceeded" in it -> FirebaseFunctionsException(e, FunctionsExceptionCode.DEADLINE_EXCEEDED, e.details) - "not-found" in it -> FirebaseFunctionsException(e, FunctionsExceptionCode.NOT_FOUND, e.details) - "already-exists" in it -> FirebaseFunctionsException(e, FunctionsExceptionCode.ALREADY_EXISTS, e.details) - "permission-denied" in it -> FirebaseFunctionsException(e, FunctionsExceptionCode.PERMISSION_DENIED, e.details) - "resource-exhausted" in it -> FirebaseFunctionsException(e, FunctionsExceptionCode.RESOURCE_EXHAUSTED, e.details) - "failed-precondition" in it -> FirebaseFunctionsException(e, FunctionsExceptionCode.FAILED_PRECONDITION, e.details) - "aborted" in it -> FirebaseFunctionsException(e, FunctionsExceptionCode.ABORTED, e.details) - "out-of-range" in it -> FirebaseFunctionsException(e, FunctionsExceptionCode.OUT_OF_RANGE, e.details) - "unimplemented" in it -> FirebaseFunctionsException(e, FunctionsExceptionCode.UNIMPLEMENTED, e.details) - "internal" in it -> FirebaseFunctionsException(e, FunctionsExceptionCode.INTERNAL, e.details) - "unavailable" in it -> FirebaseFunctionsException(e, FunctionsExceptionCode.UNAVAILABLE, e.details) - "data-loss" in it -> FirebaseFunctionsException(e, FunctionsExceptionCode.DATA_LOSS, e.details) - "unauthenticated" in it -> FirebaseFunctionsException(e, FunctionsExceptionCode.UNAUTHENTICATED, e.details) - "unknown" in it -> FirebaseFunctionsException(e, FunctionsExceptionCode.UNKNOWN, e.details) + "cancelled" in it -> FirebaseFunctionsException(e.unsafeCast(), FunctionsExceptionCode.CANCELLED, e.details) + "invalid-argument" in it -> FirebaseFunctionsException(e.unsafeCast(), FunctionsExceptionCode.INVALID_ARGUMENT, e.details) + "deadline-exceeded" in it -> FirebaseFunctionsException(e.unsafeCast(), FunctionsExceptionCode.DEADLINE_EXCEEDED, e.details) + "not-found" in it -> FirebaseFunctionsException(e.unsafeCast(), FunctionsExceptionCode.NOT_FOUND, e.details) + "already-exists" in it -> FirebaseFunctionsException(e.unsafeCast(), FunctionsExceptionCode.ALREADY_EXISTS, e.details) + "permission-denied" in it -> FirebaseFunctionsException(e.unsafeCast(), FunctionsExceptionCode.PERMISSION_DENIED, e.details) + "resource-exhausted" in it -> FirebaseFunctionsException(e.unsafeCast(), FunctionsExceptionCode.RESOURCE_EXHAUSTED, e.details) + "failed-precondition" in it -> FirebaseFunctionsException(e.unsafeCast(), FunctionsExceptionCode.FAILED_PRECONDITION, e.details) + "aborted" in it -> FirebaseFunctionsException(e.unsafeCast(), FunctionsExceptionCode.ABORTED, e.details) + "out-of-range" in it -> FirebaseFunctionsException(e.unsafeCast(), FunctionsExceptionCode.OUT_OF_RANGE, e.details) + "unimplemented" in it -> FirebaseFunctionsException(e.unsafeCast(), FunctionsExceptionCode.UNIMPLEMENTED, e.details) + "internal" in it -> FirebaseFunctionsException(e.unsafeCast(), FunctionsExceptionCode.INTERNAL, e.details) + "unavailable" in it -> FirebaseFunctionsException(e.unsafeCast(), FunctionsExceptionCode.UNAVAILABLE, e.details) + "data-loss" in it -> FirebaseFunctionsException(e.unsafeCast(), FunctionsExceptionCode.DATA_LOSS, e.details) + "unauthenticated" in it -> FirebaseFunctionsException(e.unsafeCast(), FunctionsExceptionCode.UNAUTHENTICATED, e.details) + "unknown" in it -> FirebaseFunctionsException(e.unsafeCast(), FunctionsExceptionCode.UNKNOWN, e.details) else -> { println("Unknown error code in ${JSON.stringify(e)}") - FirebaseFunctionsException(e, FunctionsExceptionCode.UNKNOWN, e.details) + FirebaseFunctionsException(e.unsafeCast(), FunctionsExceptionCode.UNKNOWN, e.details) } } } diff --git a/firebase-installations/api/android/firebase-installations.api b/firebase-installations/api/android/firebase-installations.api new file mode 100644 index 000000000..ae71ffadf --- /dev/null +++ b/firebase-installations/api/android/firebase-installations.api @@ -0,0 +1,12 @@ +public final class dev/gitlive/firebase/installations/FirebaseInstallations { + public final fun delete (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun getAndroid ()Lcom/google/firebase/installations/FirebaseInstallations; + public final fun getId (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun getToken (ZLkotlin/coroutines/Continuation;)Ljava/lang/Object; +} + +public final class dev/gitlive/firebase/installations/InstallationsKt { + public static final fun getInstallations (Ldev/gitlive/firebase/Firebase;)Ldev/gitlive/firebase/installations/FirebaseInstallations; + public static final fun installations (Ldev/gitlive/firebase/Firebase;Ldev/gitlive/firebase/FirebaseApp;)Ldev/gitlive/firebase/installations/FirebaseInstallations; +} + diff --git a/firebase-installations/api/jvm/firebase-installations.api b/firebase-installations/api/jvm/firebase-installations.api new file mode 100644 index 000000000..ae71ffadf --- /dev/null +++ b/firebase-installations/api/jvm/firebase-installations.api @@ -0,0 +1,12 @@ +public final class dev/gitlive/firebase/installations/FirebaseInstallations { + public final fun delete (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun getAndroid ()Lcom/google/firebase/installations/FirebaseInstallations; + public final fun getId (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun getToken (ZLkotlin/coroutines/Continuation;)Ljava/lang/Object; +} + +public final class dev/gitlive/firebase/installations/InstallationsKt { + public static final fun getInstallations (Ldev/gitlive/firebase/Firebase;)Ldev/gitlive/firebase/installations/FirebaseInstallations; + public static final fun installations (Ldev/gitlive/firebase/Firebase;Ldev/gitlive/firebase/FirebaseApp;)Ldev/gitlive/firebase/installations/FirebaseInstallations; +} + diff --git a/firebase-installations/build.gradle.kts b/firebase-installations/build.gradle.kts index c19404e1c..8c0e125d8 100644 --- a/firebase-installations/build.gradle.kts +++ b/firebase-installations/build.gradle.kts @@ -47,6 +47,8 @@ android { val supportIosTarget = project.property("skipIosTarget") != "true" kotlin { + explicitApi() + @OptIn(ExperimentalKotlinGradlePluginApi::class) compilerOptions { freeCompilerArgs.add("-Xexpect-actual-classes") diff --git a/firebase-installations/src/androidMain/kotlin/dev/gitlive/firebase/installations/installations.kt b/firebase-installations/src/androidMain/kotlin/dev/gitlive/firebase/installations/installations.kt index f0fef861c..0eab2f686 100644 --- a/firebase-installations/src/androidMain/kotlin/dev/gitlive/firebase/installations/installations.kt +++ b/firebase-installations/src/androidMain/kotlin/dev/gitlive/firebase/installations/installations.kt @@ -4,20 +4,19 @@ import dev.gitlive.firebase.Firebase import dev.gitlive.firebase.FirebaseApp import kotlinx.coroutines.tasks.await -actual val Firebase.installations +public actual val Firebase.installations: FirebaseInstallations get() = FirebaseInstallations(com.google.firebase.installations.FirebaseInstallations.getInstance()) -actual fun Firebase.installations(app: FirebaseApp) - = FirebaseInstallations(com.google.firebase.installations.FirebaseInstallations.getInstance(app.android)) +public actual fun Firebase.installations(app: FirebaseApp): FirebaseInstallations = FirebaseInstallations(com.google.firebase.installations.FirebaseInstallations.getInstance(app.android)) -actual class FirebaseInstallations internal constructor(val android: com.google.firebase.installations.FirebaseInstallations) { +public actual class FirebaseInstallations internal constructor(public val android: com.google.firebase.installations.FirebaseInstallations) { - actual suspend fun delete() = android.delete().await().let { } + public actual suspend fun delete(): Unit = android.delete().await().let { } - actual suspend fun getId(): String = android.id.await() + public actual suspend fun getId(): String = android.id.await() - actual suspend fun getToken(forceRefresh: Boolean): String = + public actual suspend fun getToken(forceRefresh: Boolean): String = android.getToken(forceRefresh).await().token } -actual typealias FirebaseInstallationsException = com.google.firebase.installations.FirebaseInstallationsException +public actual typealias FirebaseInstallationsException = com.google.firebase.installations.FirebaseInstallationsException diff --git a/firebase-installations/src/commonMain/kotlin/dev/gitlive/firebase/installations/installations.kt b/firebase-installations/src/commonMain/kotlin/dev/gitlive/firebase/installations/installations.kt index f6034e373..0cbea09ec 100644 --- a/firebase-installations/src/commonMain/kotlin/dev/gitlive/firebase/installations/installations.kt +++ b/firebase-installations/src/commonMain/kotlin/dev/gitlive/firebase/installations/installations.kt @@ -3,14 +3,12 @@ package dev.gitlive.firebase.installations import dev.gitlive.firebase.Firebase import dev.gitlive.firebase.FirebaseApp import dev.gitlive.firebase.FirebaseException -import kotlinx.serialization.DeserializationStrategy -import kotlinx.serialization.SerializationStrategy /** Returns the [FirebaseInstallations] instance of the default [FirebaseApp]. */ -expect val Firebase.installations: FirebaseInstallations +public expect val Firebase.installations: FirebaseInstallations /** Returns the [FirebaseInstallations] instance of a given [FirebaseApp]. */ -expect fun Firebase.installations(app: FirebaseApp): FirebaseInstallations +public expect fun Firebase.installations(app: FirebaseApp): FirebaseInstallations /** * Entry point for Firebase installations. @@ -20,19 +18,19 @@ expect fun Firebase.installations(app: FirebaseApp): FirebaseInstallations * - provides an auth token for a Firebase installation * - provides a API to perform GDPR-compliant deletion of a Firebase installation. */ -expect class FirebaseInstallations { +public expect class FirebaseInstallations { /** * Call to delete this Firebase app installation from the Firebase backend. This call may cause * Firebase Cloud Messaging, Firebase Remote Config, Firebase A/B Testing, or Firebase In-App * Messaging to not function properly. */ - suspend fun delete() + public suspend fun delete() /** * Returns a globally unique identifier of this Firebase app installation. This is a url-safe * base64 string of a 128-bit integer. */ - suspend fun getId(): String + public suspend fun getId(): String /** * Returns a valid authentication token for the Firebase installation. Generates a new token if @@ -42,11 +40,10 @@ expect class FirebaseInstallations { * * @param forceRefresh Options to get an auth token either by force refreshing or not. */ - suspend fun getToken(forceRefresh: Boolean): String + public suspend fun getToken(forceRefresh: Boolean): String } /** * Exception that gets thrown when an operation on Firebase Installations fails. */ -expect class FirebaseInstallationsException: FirebaseException - +public expect class FirebaseInstallationsException : FirebaseException diff --git a/firebase-installations/src/iosMain/kotlin/dev/gitlive/firebase/installations/installations.kt b/firebase-installations/src/iosMain/kotlin/dev/gitlive/firebase/installations/installations.kt index a15687e0e..f6d55b33f 100644 --- a/firebase-installations/src/iosMain/kotlin/dev/gitlive/firebase/installations/installations.kt +++ b/firebase-installations/src/iosMain/kotlin/dev/gitlive/firebase/installations/installations.kt @@ -7,32 +7,32 @@ import dev.gitlive.firebase.FirebaseException import kotlinx.coroutines.CompletableDeferred import platform.Foundation.* -actual val Firebase.installations +public actual val Firebase.installations: FirebaseInstallations get() = FirebaseInstallations(FIRInstallations.installations()) -actual fun Firebase.installations(app: FirebaseApp): FirebaseInstallations = FirebaseInstallations( - FIRInstallations.installationsWithApp(app.ios as objcnames.classes.FIRApp) +public actual fun Firebase.installations(app: FirebaseApp): FirebaseInstallations = FirebaseInstallations( + FIRInstallations.installationsWithApp(app.ios as objcnames.classes.FIRApp), ) -actual class FirebaseInstallations internal constructor(val ios: FIRInstallations) { +public actual class FirebaseInstallations internal constructor(public val ios: FIRInstallations) { - actual suspend fun delete() = ios.await { deleteWithCompletion(completion = it) } + public actual suspend fun delete(): Unit = ios.await { deleteWithCompletion(completion = it) } - actual suspend fun getId(): String = ios.awaitResult { installationIDWithCompletion(completion = it) } + public actual suspend fun getId(): String = ios.awaitResult { installationIDWithCompletion(completion = it) } - actual suspend fun getToken(forceRefresh: Boolean): String { + public actual suspend fun getToken(forceRefresh: Boolean): String { val result: FIRInstallationsAuthTokenResult = ios.awaitResult { authTokenForcingRefresh(forceRefresh = forceRefresh, completion = it) } return result.authToken } } -actual class FirebaseInstallationsException(message: String): FirebaseException(message) +public actual class FirebaseInstallationsException(message: String) : FirebaseException(message) internal suspend inline fun T.await(function: T.(callback: (NSError?) -> Unit) -> Unit) { val job = CompletableDeferred() function { error -> - if(error == null) { + if (error == null) { job.complete(Unit) } else { job.completeExceptionally(FirebaseInstallationsException(error.toString())) @@ -44,7 +44,7 @@ internal suspend inline fun T.await(function: T.(callback: (NSError?) -> Uni internal suspend inline fun T.awaitResult(function: T.(callback: (R?, NSError?) -> Unit) -> Unit): R { val job = CompletableDeferred() function { result, error -> - if(error == null) { + if (error == null) { job.complete(result) } else { job.completeExceptionally(FirebaseInstallationsException(error.toString())) diff --git a/firebase-installations/src/jsMain/kotlin/dev/gitlive/firebase/installations/externals/installations.kt b/firebase-installations/src/jsMain/kotlin/dev/gitlive/firebase/installations/externals/installations.kt index c2b236f76..c88f343cd 100644 --- a/firebase-installations/src/jsMain/kotlin/dev/gitlive/firebase/installations/externals/installations.kt +++ b/firebase-installations/src/jsMain/kotlin/dev/gitlive/firebase/installations/externals/installations.kt @@ -6,12 +6,12 @@ package dev.gitlive.firebase.installations.externals import dev.gitlive.firebase.externals.FirebaseApp import kotlin.js.Promise -external fun delete(installations: Installations): Promise +public external fun delete(installations: Installations): Promise -external fun getId(installations: Installations): Promise +public external fun getId(installations: Installations): Promise -external fun getInstallations(app: FirebaseApp? = definedExternally): Installations +public external fun getInstallations(app: FirebaseApp? = definedExternally): Installations -external fun getToken(installations: Installations, forceRefresh: Boolean): Promise +public external fun getToken(installations: Installations, forceRefresh: Boolean): Promise -external interface Installations +public external interface Installations diff --git a/firebase-installations/src/jsMain/kotlin/dev/gitlive/firebase/installations/installations.kt b/firebase-installations/src/jsMain/kotlin/dev/gitlive/firebase/installations/installations.kt index e99edf7cc..c64d91fe7 100644 --- a/firebase-installations/src/jsMain/kotlin/dev/gitlive/firebase/installations/installations.kt +++ b/firebase-installations/src/jsMain/kotlin/dev/gitlive/firebase/installations/installations.kt @@ -6,23 +6,23 @@ import dev.gitlive.firebase.FirebaseException import dev.gitlive.firebase.installations.externals.* import kotlinx.coroutines.await -actual val Firebase.installations +public actual val Firebase.installations: FirebaseInstallations get() = rethrow { FirebaseInstallations(getInstallations()) } -actual fun Firebase.installations(app: FirebaseApp) = +public actual fun Firebase.installations(app: FirebaseApp): FirebaseInstallations = rethrow { FirebaseInstallations(getInstallations(app.js)) } -actual class FirebaseInstallations internal constructor(val js: Installations) { +public actual class FirebaseInstallations internal constructor(public val js: Installations) { - actual suspend fun delete() = rethrow { delete(js).await() } + public actual suspend fun delete(): Unit = rethrow { delete(js).await() } - actual suspend fun getId(): String = rethrow { getId(js).await() } + public actual suspend fun getId(): String = rethrow { getId(js).await() } - actual suspend fun getToken(forceRefresh: Boolean): String = + public actual suspend fun getToken(forceRefresh: Boolean): String = rethrow { getToken(js, forceRefresh).await() } } -actual open class FirebaseInstallationsException(code: String?, cause: Throwable): FirebaseException(code, cause) +public actual open class FirebaseInstallationsException(code: String?, cause: Throwable) : FirebaseException(code, cause) internal inline fun T.rethrow(function: T.() -> R): R = dev.gitlive.firebase.installations.rethrow { function() } @@ -31,7 +31,7 @@ internal inline fun rethrow(function: () -> R): R { return function() } catch (e: Exception) { throw e - } catch(e: dynamic) { - throw FirebaseInstallationsException(e.code as String?, e) + } catch (e: dynamic) { + throw FirebaseInstallationsException(e.code.unsafeCast(), e.unsafeCast()) } } diff --git a/firebase-messaging/api/android/firebase-messaging.api b/firebase-messaging/api/android/firebase-messaging.api new file mode 100644 index 000000000..8ccebcd66 --- /dev/null +++ b/firebase-messaging/api/android/firebase-messaging.api @@ -0,0 +1,12 @@ +public final class dev/gitlive/firebase/messaging/FirebaseMessaging { + public fun (Lcom/google/firebase/messaging/FirebaseMessaging;)V + public final fun getAndroid ()Lcom/google/firebase/messaging/FirebaseMessaging; + public final fun getToken (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun subscribeToTopic (Ljava/lang/String;)V + public final fun unsubscribeFromTopic (Ljava/lang/String;)V +} + +public final class dev/gitlive/firebase/messaging/android { + public static final fun getMessaging (Ldev/gitlive/firebase/Firebase;)Ldev/gitlive/firebase/messaging/FirebaseMessaging; +} + diff --git a/firebase-messaging/api/jvm/firebase-messaging.api b/firebase-messaging/api/jvm/firebase-messaging.api new file mode 100644 index 000000000..ce326f8ee --- /dev/null +++ b/firebase-messaging/api/jvm/firebase-messaging.api @@ -0,0 +1,11 @@ +public final class dev/gitlive/firebase/messaging/FirebaseMessaging { + public fun ()V + public final fun getToken (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun subscribeToTopic (Ljava/lang/String;)V + public final fun unsubscribeFromTopic (Ljava/lang/String;)V +} + +public final class dev/gitlive/firebase/messaging/android { + public static final fun getMessaging (Ldev/gitlive/firebase/Firebase;)Ldev/gitlive/firebase/messaging/FirebaseMessaging; +} + diff --git a/firebase-messaging/build.gradle.kts b/firebase-messaging/build.gradle.kts index 48e5f5d27..6ede39801 100644 --- a/firebase-messaging/build.gradle.kts +++ b/firebase-messaging/build.gradle.kts @@ -47,6 +47,8 @@ android { val supportIosTarget = project.property("skipIosTarget") != "true" kotlin { + explicitApi() + @OptIn(ExperimentalKotlinGradlePluginApi::class) compilerOptions { freeCompilerArgs.add("-Xexpect-actual-classes") diff --git a/firebase-messaging/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/messaging/messaging.kt b/firebase-messaging/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/messaging/messaging.kt index 059bf03d6..eef7d337e 100644 --- a/firebase-messaging/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/messaging/messaging.kt +++ b/firebase-messaging/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/messaging/messaging.kt @@ -21,8 +21,8 @@ class AndroidInstrumentedFirebaseMessagingTest : FirebaseMessagingTest() { databaseUrl = "https://fir-kotlin-sdk.firebaseio.com", storageBucket = "fir-kotlin-sdk.appspot.com", projectId = "fir-kotlin-sdk", - gcmSenderId = "846484016111" - ) + gcmSenderId = "846484016111", + ), ) } -} \ No newline at end of file +} diff --git a/firebase-messaging/src/androidMain/kotlin/dev/gitlive/firebase/messaging/messaging.kt b/firebase-messaging/src/androidMain/kotlin/dev/gitlive/firebase/messaging/messaging.kt index 5fba05385..256520af8 100644 --- a/firebase-messaging/src/androidMain/kotlin/dev/gitlive/firebase/messaging/messaging.kt +++ b/firebase-messaging/src/androidMain/kotlin/dev/gitlive/firebase/messaging/messaging.kt @@ -1,20 +1,21 @@ @file:JvmName("android") + package dev.gitlive.firebase.messaging import dev.gitlive.firebase.Firebase import kotlinx.coroutines.tasks.await -actual val Firebase.messaging: FirebaseMessaging +public actual val Firebase.messaging: FirebaseMessaging get() = FirebaseMessaging(com.google.firebase.messaging.FirebaseMessaging.getInstance()) -actual class FirebaseMessaging(val android: com.google.firebase.messaging.FirebaseMessaging) { - actual fun subscribeToTopic(topic: String) { +public actual class FirebaseMessaging(public val android: com.google.firebase.messaging.FirebaseMessaging) { + public actual fun subscribeToTopic(topic: String) { android.subscribeToTopic(topic) } - actual fun unsubscribeFromTopic(topic: String) { + public actual fun unsubscribeFromTopic(topic: String) { android.unsubscribeFromTopic(topic) } - actual suspend fun getToken(): String = android.token.await() -} \ No newline at end of file + public actual suspend fun getToken(): String = android.token.await() +} diff --git a/firebase-messaging/src/commonMain/kotlin/dev/gitlive/firebase/messaging/messaging.kt b/firebase-messaging/src/commonMain/kotlin/dev/gitlive/firebase/messaging/messaging.kt index f6e8b6d65..6428778d8 100644 --- a/firebase-messaging/src/commonMain/kotlin/dev/gitlive/firebase/messaging/messaging.kt +++ b/firebase-messaging/src/commonMain/kotlin/dev/gitlive/firebase/messaging/messaging.kt @@ -4,28 +4,28 @@ import dev.gitlive.firebase.Firebase import dev.gitlive.firebase.FirebaseApp /** Returns the [FirebaseMessaging] instance of the default [FirebaseApp]. */ -expect val Firebase.messaging: FirebaseMessaging +public expect val Firebase.messaging: FirebaseMessaging /** * Top level [Firebase Cloud Messaging](https://firebase.google.com/docs/cloud-messaging/) * singleton that provides methods for subscribing to topics and sending upstream messages. */ -expect class FirebaseMessaging { +public expect class FirebaseMessaging { /** * Subscribe to a topic. * @param topic The topic to subscribe to. */ - fun subscribeToTopic(topic: String) + public fun subscribeToTopic(topic: String) /** * Unsubscribe from a topic. * @param topic The topic to unsubscribe from. */ - fun unsubscribeFromTopic(topic: String) + public fun unsubscribeFromTopic(topic: String) /** * Get FCM token for client * @return [String] FCM token */ - suspend fun getToken(): String + public suspend fun getToken(): String } diff --git a/firebase-messaging/src/commonTest/kotlin/dev/gitlive/firebase/messaging/messaging.kt b/firebase-messaging/src/commonTest/kotlin/dev/gitlive/firebase/messaging/messaging.kt index e29682ee6..a098cb24f 100644 --- a/firebase-messaging/src/commonTest/kotlin/dev/gitlive/firebase/messaging/messaging.kt +++ b/firebase-messaging/src/commonTest/kotlin/dev/gitlive/firebase/messaging/messaging.kt @@ -10,4 +10,4 @@ abstract class FirebaseMessagingTest { fun initialization() { assertNotNull(Firebase.messaging) } -} \ No newline at end of file +} diff --git a/firebase-messaging/src/iosMain/kotlin/dev/gitlive/firebase/messaging/messaging.kt b/firebase-messaging/src/iosMain/kotlin/dev/gitlive/firebase/messaging/messaging.kt index b2511d86a..5a9d697aa 100644 --- a/firebase-messaging/src/iosMain/kotlin/dev/gitlive/firebase/messaging/messaging.kt +++ b/firebase-messaging/src/iosMain/kotlin/dev/gitlive/firebase/messaging/messaging.kt @@ -5,25 +5,25 @@ import dev.gitlive.firebase.Firebase import kotlinx.coroutines.CompletableDeferred import platform.Foundation.NSError -actual val Firebase.messaging: FirebaseMessaging +public actual val Firebase.messaging: FirebaseMessaging get() = FirebaseMessaging(FIRMessaging.messaging()) -actual class FirebaseMessaging(val ios: FIRMessaging) { - actual fun subscribeToTopic(topic: String) { +public actual class FirebaseMessaging(public val ios: FIRMessaging) { + public actual fun subscribeToTopic(topic: String) { ios.subscribeToTopic(topic) } - actual fun unsubscribeFromTopic(topic: String) { + public actual fun unsubscribeFromTopic(topic: String) { ios.unsubscribeFromTopic(topic) } - actual suspend fun getToken(): String = awaitResult { ios.tokenWithCompletion(it) } + public actual suspend fun getToken(): String = awaitResult { ios.tokenWithCompletion(it) } } -suspend inline fun T.await(function: T.(callback: (NSError?) -> Unit) -> Unit) { +public suspend inline fun T.await(function: T.(callback: (NSError?) -> Unit) -> Unit) { val job = CompletableDeferred() function { error -> - if(error == null) { + if (error == null) { job.complete(Unit) } else { job.completeExceptionally(Exception(error.toString())) @@ -32,14 +32,14 @@ suspend inline fun T.await(function: T.(callback: (NSError?) -> Unit) -> Uni job.await() } -suspend inline fun T.awaitResult(function: T.(callback: (R?, NSError?) -> Unit) -> Unit): R { +public suspend inline fun T.awaitResult(function: T.(callback: (R?, NSError?) -> Unit) -> Unit): R { val job = CompletableDeferred() function { result, error -> - if(error == null) { + if (error == null) { job.complete(result) } else { job.completeExceptionally(Exception(error.toString())) } } return job.await() as R -} \ No newline at end of file +} diff --git a/firebase-messaging/src/iosTest/kotlin/dev/gitlive/firebase/messaging/messaging.kt b/firebase-messaging/src/iosTest/kotlin/dev/gitlive/firebase/messaging/messaging.kt index 3501ed370..1a64584ed 100644 --- a/firebase-messaging/src/iosTest/kotlin/dev/gitlive/firebase/messaging/messaging.kt +++ b/firebase-messaging/src/iosTest/kotlin/dev/gitlive/firebase/messaging/messaging.kt @@ -1,3 +1,3 @@ package dev.gitlive.firebase.messaging -class IOSFirebaseMessagingTest : FirebaseMessagingTest() \ No newline at end of file +class IOSFirebaseMessagingTest : FirebaseMessagingTest() diff --git a/firebase-messaging/src/jsMain/kotlin/dev/gitlive/firebase/messaging/externals/messaging.kt b/firebase-messaging/src/jsMain/kotlin/dev/gitlive/firebase/messaging/externals/messaging.kt index 5e6c48100..c7a7af487 100644 --- a/firebase-messaging/src/jsMain/kotlin/dev/gitlive/firebase/messaging/externals/messaging.kt +++ b/firebase-messaging/src/jsMain/kotlin/dev/gitlive/firebase/messaging/externals/messaging.kt @@ -3,10 +3,10 @@ package dev.gitlive.firebase.messaging.externals import dev.gitlive.firebase.externals.FirebaseApp import kotlin.js.Promise -external fun getMessaging( +public external fun getMessaging( app: FirebaseApp? = definedExternally, ): Messaging -external fun getToken(messaging: Messaging = definedExternally, options: dynamic = definedExternally): Promise +public external fun getToken(messaging: Messaging = definedExternally, options: dynamic = definedExternally): Promise -external interface Messaging \ No newline at end of file +public external interface Messaging diff --git a/firebase-messaging/src/jsMain/kotlin/dev/gitlive/firebase/messaging/messaging.kt b/firebase-messaging/src/jsMain/kotlin/dev/gitlive/firebase/messaging/messaging.kt index 223a15338..2304dc172 100644 --- a/firebase-messaging/src/jsMain/kotlin/dev/gitlive/firebase/messaging/messaging.kt +++ b/firebase-messaging/src/jsMain/kotlin/dev/gitlive/firebase/messaging/messaging.kt @@ -5,22 +5,21 @@ import dev.gitlive.firebase.messaging.externals.Messaging import dev.gitlive.firebase.messaging.externals.getMessaging import kotlinx.coroutines.await - -actual val Firebase.messaging: FirebaseMessaging +public actual val Firebase.messaging: FirebaseMessaging get() = FirebaseMessaging(getMessaging()) -actual class FirebaseMessaging(val js: Messaging) { - actual fun subscribeToTopic(topic: String) { +public actual class FirebaseMessaging(public val js: Messaging) { + public actual fun subscribeToTopic(topic: String) { // This is not supported in the JS SDK // https://firebase.google.com/docs/reference/js/messaging_.md#@firebase/messaging throw NotImplementedError("Subscribing to topics is not supported in the JS SDK") } - actual fun unsubscribeFromTopic(topic: String) { + public actual fun unsubscribeFromTopic(topic: String) { // This is not supported in the JS SDK // https://firebase.google.com/docs/reference/js/messaging_.md#@firebase/messaging throw NotImplementedError("Unsubscribing from topics is not supported in the JS SDK") } - actual suspend fun getToken(): String = dev.gitlive.firebase.messaging.externals.getToken(js).await() -} \ No newline at end of file + public actual suspend fun getToken(): String = dev.gitlive.firebase.messaging.externals.getToken(js).await() +} diff --git a/firebase-messaging/src/jvmMain/kotlin/dev/gitlive/firebase/messaging/messaging.kt b/firebase-messaging/src/jvmMain/kotlin/dev/gitlive/firebase/messaging/messaging.kt index 6b8f3b82a..b41d244f3 100644 --- a/firebase-messaging/src/jvmMain/kotlin/dev/gitlive/firebase/messaging/messaging.kt +++ b/firebase-messaging/src/jvmMain/kotlin/dev/gitlive/firebase/messaging/messaging.kt @@ -1,21 +1,22 @@ @file:JvmName("android") + package dev.gitlive.firebase.messaging import dev.gitlive.firebase.Firebase -actual val Firebase.messaging: FirebaseMessaging +public actual val Firebase.messaging: FirebaseMessaging get() = TODO("Not yet implemented") -actual class FirebaseMessaging { - actual fun subscribeToTopic(topic: String) { +public actual class FirebaseMessaging { + public actual fun subscribeToTopic(topic: String) { TODO("Not yet implemented") } - actual fun unsubscribeFromTopic(topic: String) { + public actual fun unsubscribeFromTopic(topic: String) { TODO("Not yet implemented") } - actual suspend fun getToken(): String { + public actual suspend fun getToken(): String { TODO("Not yet implemented") } -} \ No newline at end of file +} diff --git a/firebase-perf/api/android/firebase-perf.api b/firebase-perf/api/android/firebase-perf.api new file mode 100644 index 000000000..730cbc4d4 --- /dev/null +++ b/firebase-perf/api/android/firebase-perf.api @@ -0,0 +1,34 @@ +public final class dev/gitlive/firebase/perf/FirebasePerformance { + public fun (Lcom/google/firebase/perf/FirebasePerformance;)V + public final fun getAndroid ()Lcom/google/firebase/perf/FirebasePerformance; + public final fun isPerformanceCollectionEnabled ()Z + public final fun newTrace (Ljava/lang/String;)Ldev/gitlive/firebase/perf/metrics/Trace; + public final fun setPerformanceCollectionEnabled (Z)V +} + +public class dev/gitlive/firebase/perf/FirebasePerformanceException : com/google/firebase/FirebaseException { + public fun (Ljava/lang/String;)V +} + +public final class dev/gitlive/firebase/perf/PerformanceKt { + public static final fun getPerformance (Ldev/gitlive/firebase/Firebase;)Ldev/gitlive/firebase/perf/FirebasePerformance; + public static final fun performance (Ldev/gitlive/firebase/Firebase;Ldev/gitlive/firebase/FirebaseApp;)Ldev/gitlive/firebase/perf/FirebasePerformance; +} + +public final class dev/gitlive/firebase/perf/metrics/Trace { + public final fun getAttribute (Ljava/lang/String;)Ljava/lang/String; + public final fun getAttributes ()Ljava/util/Map; + public final fun getLongMetric (Ljava/lang/String;)J + public final fun incrementMetric (Ljava/lang/String;J)V + public final fun putAttribute (Ljava/lang/String;Ljava/lang/String;)V + public final fun putMetric (Ljava/lang/String;J)V + public final fun removeAttribute (Ljava/lang/String;)V + public final fun start ()V + public final fun stop ()V + public final fun updateSession (Ldev/gitlive/firebase/perf/session/PerfSession;)V +} + +public final class dev/gitlive/firebase/perf/session/PerfSession { + public final fun getAndroid ()Lcom/google/firebase/perf/session/PerfSession; +} + diff --git a/firebase-perf/api/jvm/firebase-perf.api b/firebase-perf/api/jvm/firebase-perf.api new file mode 100644 index 000000000..e3e8c9056 --- /dev/null +++ b/firebase-perf/api/jvm/firebase-perf.api @@ -0,0 +1,24 @@ +public final class dev/gitlive/firebase/perf/FirebasePerformance { + public fun ()V + public final fun isPerformanceCollectionEnabled ()Z + public final fun newTrace (Ljava/lang/String;)Ldev/gitlive/firebase/perf/metrics/Trace; + public final fun setPerformanceCollectionEnabled (Z)V +} + +public class dev/gitlive/firebase/perf/FirebasePerformanceException : com/google/firebase/FirebaseException { +} + +public final class dev/gitlive/firebase/perf/Performance_jvmKt { + public static final fun getPerformance (Ldev/gitlive/firebase/Firebase;)Ldev/gitlive/firebase/perf/FirebasePerformance; + public static final fun performance (Ldev/gitlive/firebase/Firebase;Ldev/gitlive/firebase/FirebaseApp;)Ldev/gitlive/firebase/perf/FirebasePerformance; +} + +public final class dev/gitlive/firebase/perf/metrics/Trace { + public fun ()V + public final fun getLongMetric (Ljava/lang/String;)J + public final fun incrementMetric (Ljava/lang/String;J)V + public final fun putMetric (Ljava/lang/String;J)V + public final fun start ()V + public final fun stop ()V +} + diff --git a/firebase-perf/build.gradle.kts b/firebase-perf/build.gradle.kts index f23237d72..3a4356d8c 100644 --- a/firebase-perf/build.gradle.kts +++ b/firebase-perf/build.gradle.kts @@ -48,6 +48,8 @@ android { val supportIosTarget = project.property("skipIosTarget") != "true" kotlin { + explicitApi() + @OptIn(ExperimentalKotlinGradlePluginApi::class) compilerOptions { freeCompilerArgs.add("-Xexpect-actual-classes") diff --git a/firebase-perf/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt b/firebase-perf/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt index 894b90f25..5db4a766f 100644 --- a/firebase-perf/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt +++ b/firebase-perf/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt @@ -23,15 +23,15 @@ class AndroidTraceTest { @BeforeTest fun initializeFirebase() { val app = Firebase.apps(context).firstOrNull() ?: Firebase.initialize( - dev.gitlive.firebase.perf.context, + context, FirebaseOptions( applicationId = "1:846484016111:ios:dd1f6688bad7af768c841a", apiKey = "AIzaSyCK87dcMFhzCz_kJVs2cT2AVlqOTLuyWV0", databaseUrl = "https://fir-kotlin-sdk.firebaseio.com", storageBucket = "fir-kotlin-sdk.appspot.com", projectId = "fir-kotlin-sdk", - gcmSenderId = "846484016111" - ) + gcmSenderId = "846484016111", + ), ) performance = Firebase.performance(app) @@ -87,4 +87,4 @@ class AndroidTraceTest { assertEquals("Test Put Attribute Value", trace.getAttribute("Test_Put_Attribute")) trace.stop() } -} \ No newline at end of file +} diff --git a/firebase-perf/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/perf/performance.kt b/firebase-perf/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/perf/performance.kt index 045b947fe..3317b9f48 100644 --- a/firebase-perf/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/perf/performance.kt +++ b/firebase-perf/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/perf/performance.kt @@ -3,12 +3,11 @@ */ @file:JvmName("tests") + package dev.gitlive.firebase.perf import androidx.test.platform.app.InstrumentationRegistry -actual val emulatorHost: String = "10.0.2.2" - actual val context: Any = InstrumentationRegistry.getInstrumentation().targetContext @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) diff --git a/firebase-perf/src/androidMain/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt b/firebase-perf/src/androidMain/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt index 3375b2cd4..a4f373fc9 100644 --- a/firebase-perf/src/androidMain/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt +++ b/firebase-perf/src/androidMain/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt @@ -3,25 +3,39 @@ package dev.gitlive.firebase.perf.metrics import com.google.firebase.perf.metrics.Trace import dev.gitlive.firebase.perf.session.PerfSession -actual class Trace internal constructor(private val android: Trace) { +public actual class Trace internal constructor(private val android: Trace) { - actual fun start() = android.start() + public actual fun start() { + android.start() + } - actual fun stop() = android.stop() + public actual fun stop() { + android.stop() + } - actual fun getLongMetric(metricName: String): Long = android.getLongMetric(metricName) + public actual fun getLongMetric(metricName: String): Long = android.getLongMetric(metricName) - actual fun incrementMetric(metricName: String, incrementBy: Long) = android.incrementMetric(metricName, incrementBy) + public actual fun incrementMetric(metricName: String, incrementBy: Long) { + android.incrementMetric(metricName, incrementBy) + } - actual fun putMetric(metricName: String, value: Long) = android.putMetric(metricName, value) + public actual fun putMetric(metricName: String, value: Long) { + android.putMetric(metricName, value) + } - fun getAttributes(): Map = android.attributes + public fun getAttributes(): Map = android.attributes - fun getAttribute(attribute: String): String? = android.getAttribute(attribute) + public fun getAttribute(attribute: String): String? = android.getAttribute(attribute) - fun putAttribute(attribute: String, value: String) = android.putAttribute(attribute, value) + public fun putAttribute(attribute: String, value: String) { + android.putAttribute(attribute, value) + } - fun removeAttribute(attribute: String) = android.removeAttribute(attribute) + public fun removeAttribute(attribute: String) { + android.removeAttribute(attribute) + } - fun updateSession(session: PerfSession) = android.updateSession(session.android) -} \ No newline at end of file + public fun updateSession(session: PerfSession) { + android.updateSession(session.android) + } +} diff --git a/firebase-perf/src/androidMain/kotlin/dev/gitlive/firebase/perf/performance.kt b/firebase-perf/src/androidMain/kotlin/dev/gitlive/firebase/perf/performance.kt index ea5beb3fb..ce1f6e0af 100644 --- a/firebase-perf/src/androidMain/kotlin/dev/gitlive/firebase/perf/performance.kt +++ b/firebase-perf/src/androidMain/kotlin/dev/gitlive/firebase/perf/performance.kt @@ -5,21 +5,21 @@ import dev.gitlive.firebase.Firebase import dev.gitlive.firebase.FirebaseApp import dev.gitlive.firebase.perf.metrics.Trace -actual val Firebase.performance get() = +public actual val Firebase.performance: FirebasePerformance get() = FirebasePerformance(com.google.firebase.perf.FirebasePerformance.getInstance()) -actual fun Firebase.performance(app: FirebaseApp) = +public actual fun Firebase.performance(app: FirebaseApp): FirebasePerformance = FirebasePerformance(app.android.get(com.google.firebase.perf.FirebasePerformance::class.java)) -actual class FirebasePerformance(val android: com.google.firebase.perf.FirebasePerformance){ +public actual class FirebasePerformance(public val android: com.google.firebase.perf.FirebasePerformance) { - actual fun newTrace(traceName: String): Trace = Trace(android.newTrace(traceName)) + public actual fun newTrace(traceName: String): Trace = Trace(android.newTrace(traceName)) - actual fun isPerformanceCollectionEnabled() = android.isPerformanceCollectionEnabled + public actual fun isPerformanceCollectionEnabled(): Boolean = android.isPerformanceCollectionEnabled - actual fun setPerformanceCollectionEnabled(enable: Boolean) { + public actual fun setPerformanceCollectionEnabled(enable: Boolean) { android.isPerformanceCollectionEnabled = enable } } -actual open class FirebasePerformanceException(message: String) : FirebaseException(message) +public actual open class FirebasePerformanceException(message: String) : FirebaseException(message) diff --git a/firebase-perf/src/androidMain/kotlin/dev/gitlive/firebase/perf/session/PerfSession.kt b/firebase-perf/src/androidMain/kotlin/dev/gitlive/firebase/perf/session/PerfSession.kt index 80e0a2c0d..744ec782c 100644 --- a/firebase-perf/src/androidMain/kotlin/dev/gitlive/firebase/perf/session/PerfSession.kt +++ b/firebase-perf/src/androidMain/kotlin/dev/gitlive/firebase/perf/session/PerfSession.kt @@ -2,5 +2,4 @@ package dev.gitlive.firebase.perf.session import com.google.firebase.perf.session.PerfSession -class PerfSession internal constructor(val android: PerfSession) { -} \ No newline at end of file +public class PerfSession internal constructor(public val android: PerfSession) diff --git a/firebase-perf/src/androidUnitTest/kotlin/dev/gitlive/firebase/perf/performance.kt b/firebase-perf/src/androidUnitTest/kotlin/dev/gitlive/firebase/perf/performance.kt index a69661aac..9a83fb97b 100644 --- a/firebase-perf/src/androidUnitTest/kotlin/dev/gitlive/firebase/perf/performance.kt +++ b/firebase-perf/src/androidUnitTest/kotlin/dev/gitlive/firebase/perf/performance.kt @@ -3,6 +3,7 @@ */ @file:JvmName("tests") + package dev.gitlive.firebase.perf import org.junit.Ignore diff --git a/firebase-perf/src/commonMain/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt b/firebase-perf/src/commonMain/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt index afee39e56..81b4ed7c1 100644 --- a/firebase-perf/src/commonMain/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt +++ b/firebase-perf/src/commonMain/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt @@ -1,12 +1,12 @@ package dev.gitlive.firebase.perf.metrics /** Trace allows you to set beginning and end of a certain action in your app. */ -expect class Trace { +public expect class Trace { /** Starts this trace. */ - fun start() + public fun start() /** Stops this trace. */ - fun stop() + public fun stop() /** * Gets the value of the metric with the given name in the current trace. If a metric with the @@ -16,7 +16,7 @@ expect class Trace { * leading underscore '_' character, max length is 100 characters. * @return Value of the metric or 0 if it hasn't yet been set. */ - fun getLongMetric(metricName: String): Long + public fun getLongMetric(metricName: String): Long /** * Atomically increments the metric with the given name in this trace by the incrementBy value. If @@ -27,7 +27,7 @@ expect class Trace { * whitespace, no leading underscore [_] character, max length of 100 characters. * @param incrementBy Amount by which the metric has to be incremented. */ - fun incrementMetric(metricName: String, incrementBy: Long) + public fun incrementMetric(metricName: String, incrementBy: Long) /** * Sets the value of the metric with the given name in this trace to the value provided. If a @@ -39,5 +39,5 @@ expect class Trace { * leading underscore '_' character, max length is 100 characters. * @param value The value to which the metric should be set to. */ - fun putMetric(metricName: String, value: Long) -} \ No newline at end of file + public fun putMetric(metricName: String, value: Long) +} diff --git a/firebase-perf/src/commonMain/kotlin/dev/gitlive/firebase/perf/performance.kt b/firebase-perf/src/commonMain/kotlin/dev/gitlive/firebase/perf/performance.kt index 02180b03c..5cf4f45c2 100644 --- a/firebase-perf/src/commonMain/kotlin/dev/gitlive/firebase/perf/performance.kt +++ b/firebase-perf/src/commonMain/kotlin/dev/gitlive/firebase/perf/performance.kt @@ -6,10 +6,10 @@ import dev.gitlive.firebase.FirebaseException import dev.gitlive.firebase.perf.metrics.Trace /** Returns the [FirebasePerformance] instance of the default [FirebaseApp]. */ -expect val Firebase.performance: FirebasePerformance +public expect val Firebase.performance: FirebasePerformance /** Returns the [FirebasePerformance] instance of a given [FirebaseApp]. */ -expect fun Firebase.performance(app: FirebaseApp): FirebasePerformance +public expect fun Firebase.performance(app: FirebaseApp): FirebasePerformance /** * The Firebase Performance Monitoring API. @@ -19,7 +19,7 @@ expect fun Firebase.performance(app: FirebaseApp): FirebasePerformance * This SDK uses FirebaseInstallations to identify the app instance and periodically sends data * to the Firebase backend. To stop sending performance events, call [setPerformanceCollectionEnabled] with value [false]. */ -expect class FirebasePerformance { +public expect class FirebasePerformance { /** * Creates a Trace object with given name. * @@ -27,7 +27,7 @@ expect class FirebasePerformance { * underscore '_' character. * @return the new Trace object. */ - fun newTrace(traceName: String): Trace + public fun newTrace(traceName: String): Trace /** * Determines whether performance monitoring is enabled or disabled. This respects the Firebase @@ -38,7 +38,7 @@ expect class FirebasePerformance { * disabled. This is for dynamic enable/disable state. This does not reflect whether * instrumentation is enabled/disabled in Gradle properties. */ - fun isPerformanceCollectionEnabled(): Boolean + public fun isPerformanceCollectionEnabled(): Boolean /** * Enables or disables performance monitoring. This setting is persisted and applied on future @@ -62,10 +62,10 @@ expect class FirebasePerformance { * * @param enable Should performance monitoring be enabled */ - fun setPerformanceCollectionEnabled(enable: Boolean) + public fun setPerformanceCollectionEnabled(enable: Boolean) } /** * Exception that gets thrown when an operation on Firebase Performance fails. */ -expect open class FirebasePerformanceException : FirebaseException \ No newline at end of file +public expect open class FirebasePerformanceException : FirebaseException diff --git a/firebase-perf/src/commonTest/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt b/firebase-perf/src/commonTest/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt index 252bf751f..e3298744d 100644 --- a/firebase-perf/src/commonTest/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt +++ b/firebase-perf/src/commonTest/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt @@ -25,15 +25,15 @@ class TraceTest { @BeforeTest fun initializeFirebase() { val app = Firebase.apps(context).firstOrNull() ?: Firebase.initialize( - dev.gitlive.firebase.perf.context, + context, FirebaseOptions( applicationId = "1:846484016111:ios:dd1f6688bad7af768c841a", apiKey = "AIzaSyCK87dcMFhzCz_kJVs2cT2AVlqOTLuyWV0", databaseUrl = "https://fir-kotlin-sdk.firebaseio.com", storageBucket = "fir-kotlin-sdk.appspot.com", projectId = "fir-kotlin-sdk", - gcmSenderId = "846484016111" - ) + gcmSenderId = "846484016111", + ), ) performance = Firebase.performance(app) @@ -54,7 +54,7 @@ class TraceTest { trace.start() trace.putMetric("Get Long Metric Test", 1L) - assertEquals(1L, trace.getLongMetric("Get Long Metric Test")) + assertEquals(1L, trace.getLongMetric("Get Long Metric Test")) trace.stop() } @@ -66,7 +66,7 @@ class TraceTest { trace.incrementMetric("Get Increment Metric Test", 1L) - assertEquals(2L, trace.getLongMetric("Get Increment Metric Test")) + assertEquals(2L, trace.getLongMetric("Get Increment Metric Test")) trace.stop() } @@ -76,7 +76,7 @@ class TraceTest { trace.start() trace.putMetric("Get Put Metric Test", 1L) - assertEquals(1L, trace.getLongMetric("Get Put Metric Test")) + assertEquals(1L, trace.getLongMetric("Get Put Metric Test")) trace.stop() } -} \ No newline at end of file +} diff --git a/firebase-perf/src/commonTest/kotlin/dev/gitlive/firebase/perf/performance.kt b/firebase-perf/src/commonTest/kotlin/dev/gitlive/firebase/perf/performance.kt index 6ca689abc..69d44b621 100644 --- a/firebase-perf/src/commonTest/kotlin/dev/gitlive/firebase/perf/performance.kt +++ b/firebase-perf/src/commonTest/kotlin/dev/gitlive/firebase/perf/performance.kt @@ -14,7 +14,6 @@ import kotlinx.coroutines.delay import kotlin.test.* import kotlin.time.Duration.Companion.seconds -expect val emulatorHost: String expect val context: Any expect annotation class IgnoreForAndroidUnitTest() @@ -33,8 +32,8 @@ class FirebasePerformanceTest { databaseUrl = "https://fir-kotlin-sdk.firebaseio.com", storageBucket = "fir-kotlin-sdk.appspot.com", projectId = "fir-kotlin-sdk", - gcmSenderId = "846484016111" - ) + gcmSenderId = "846484016111", + ), ) performance = Firebase.performance(app) diff --git a/firebase-perf/src/iosMain/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt b/firebase-perf/src/iosMain/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt index 1b6390ebb..e3bc2781c 100644 --- a/firebase-perf/src/iosMain/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt +++ b/firebase-perf/src/iosMain/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt @@ -2,23 +2,23 @@ package dev.gitlive.firebase.perf.metrics import cocoapods.FirebasePerformance.FIRTrace -actual class Trace internal constructor(val ios: FIRTrace?) { +public actual class Trace internal constructor(public val ios: FIRTrace?) { - actual fun start() { + public actual fun start() { ios?.start() } - actual fun stop() { + public actual fun stop() { ios?.stop() } - actual fun getLongMetric(metricName: String): Long = ios?.valueForIntMetric(metricName) ?: 0L + public actual fun getLongMetric(metricName: String): Long = ios?.valueForIntMetric(metricName) ?: 0L - actual fun incrementMetric(metricName: String, incrementBy: Long) { + public actual fun incrementMetric(metricName: String, incrementBy: Long) { ios?.incrementMetric(metricName, incrementBy) } - actual fun putMetric(metricName: String, value: Long) { + public actual fun putMetric(metricName: String, value: Long) { ios?.setIntValue(value, metricName) } -} \ No newline at end of file +} diff --git a/firebase-perf/src/iosMain/kotlin/dev/gitlive/firebase/perf/performance.kt b/firebase-perf/src/iosMain/kotlin/dev/gitlive/firebase/perf/performance.kt index 9a008cdb9..22d75c376 100644 --- a/firebase-perf/src/iosMain/kotlin/dev/gitlive/firebase/perf/performance.kt +++ b/firebase-perf/src/iosMain/kotlin/dev/gitlive/firebase/perf/performance.kt @@ -6,21 +6,21 @@ import dev.gitlive.firebase.FirebaseApp import dev.gitlive.firebase.FirebaseException import dev.gitlive.firebase.perf.metrics.Trace -actual val Firebase.performance get() = +public actual val Firebase.performance: FirebasePerformance get() = FirebasePerformance(FIRPerformance.sharedInstance()) -actual fun Firebase.performance(app: FirebaseApp) = +public actual fun Firebase.performance(app: FirebaseApp): FirebasePerformance = FirebasePerformance(FIRPerformance.sharedInstance()) -actual class FirebasePerformance(val ios: FIRPerformance) { +public actual class FirebasePerformance(public val ios: FIRPerformance) { - actual fun newTrace(traceName: String): Trace = Trace(ios.traceWithName(traceName)) + public actual fun newTrace(traceName: String): Trace = Trace(ios.traceWithName(traceName)) - actual fun isPerformanceCollectionEnabled(): Boolean = ios.isDataCollectionEnabled() + public actual fun isPerformanceCollectionEnabled(): Boolean = ios.isDataCollectionEnabled() - actual fun setPerformanceCollectionEnabled(enable: Boolean) { + public actual fun setPerformanceCollectionEnabled(enable: Boolean) { ios.dataCollectionEnabled = enable } } -actual open class FirebasePerformanceException(message: String) : FirebaseException(message) \ No newline at end of file +public actual open class FirebasePerformanceException(message: String) : FirebaseException(message) diff --git a/firebase-perf/src/iosTest/kotlin/dev/gitlive/firebase/perf/performance.kt b/firebase-perf/src/iosTest/kotlin/dev/gitlive/firebase/perf/performance.kt index 67cfa78ac..621c85378 100644 --- a/firebase-perf/src/iosTest/kotlin/dev/gitlive/firebase/perf/performance.kt +++ b/firebase-perf/src/iosTest/kotlin/dev/gitlive/firebase/perf/performance.kt @@ -4,8 +4,6 @@ package dev.gitlive.firebase.perf -actual val emulatorHost: String = "localhost" - actual val context: Any = Unit @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) diff --git a/firebase-perf/src/jsMain/kotlin/dev/gitlive/firebase/perf/externals/performance.kt b/firebase-perf/src/jsMain/kotlin/dev/gitlive/firebase/perf/externals/performance.kt index dc6a04d0a..c20ca6ebc 100644 --- a/firebase-perf/src/jsMain/kotlin/dev/gitlive/firebase/perf/externals/performance.kt +++ b/firebase-perf/src/jsMain/kotlin/dev/gitlive/firebase/perf/externals/performance.kt @@ -5,23 +5,23 @@ package dev.gitlive.firebase.perf.externals import dev.gitlive.firebase.externals.FirebaseApp -external fun getPerformance(app: FirebaseApp? = definedExternally): FirebasePerformance +public external fun getPerformance(app: FirebaseApp? = definedExternally): FirebasePerformance -external fun trace(performance: FirebasePerformance, name: String): PerformanceTrace +public external fun trace(performance: FirebasePerformance, name: String): PerformanceTrace -external interface FirebasePerformance { - var dataCollectionEnabled: Boolean - var instrumentationEnabled: Boolean +public external interface FirebasePerformance { + public var dataCollectionEnabled: Boolean + public var instrumentationEnabled: Boolean } -external interface PerformanceTrace { - fun getAttribute(attr: String): String? - fun getAttributes(): Map - fun getMetric(metricName: String): Int - fun incrementMetric(metricName: String, num: Int? = definedExternally) - fun putAttribute(attr: String, value: String) - fun putMetric(metricName: String, num: Int) - fun removeAttribute(attr: String) - fun start() - fun stop() +public external interface PerformanceTrace { + public fun getAttribute(attr: String): String? + public fun getAttributes(): Map + public fun getMetric(metricName: String): Int + public fun incrementMetric(metricName: String, num: Int? = definedExternally) + public fun putAttribute(attr: String, value: String) + public fun putMetric(metricName: String, num: Int) + public fun removeAttribute(attr: String) + public fun start() + public fun stop() } diff --git a/firebase-perf/src/jsMain/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt b/firebase-perf/src/jsMain/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt index 8b891076e..5974449ac 100644 --- a/firebase-perf/src/jsMain/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt +++ b/firebase-perf/src/jsMain/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt @@ -3,23 +3,14 @@ package dev.gitlive.firebase.perf.metrics import dev.gitlive.firebase.perf.externals.PerformanceTrace import dev.gitlive.firebase.perf.rethrow +public actual class Trace internal constructor(private val js: PerformanceTrace) { -actual class Trace internal constructor(private val js: PerformanceTrace) { - - actual fun start() = rethrow { js.start() } - actual fun stop() = rethrow { js.stop() } - actual fun getLongMetric(metricName: String) = rethrow { js.getMetric(metricName).toLong() } - actual fun incrementMetric(metricName: String, incrementBy: Long) = rethrow { js.incrementMetric(metricName, incrementBy.toInt()) } - actual fun putMetric(metricName: String, value: Long) = rethrow { js.putMetric(metricName, value.toInt()) } - fun getAttribute(attribute: String): String? = rethrow { js.getAttribute(attribute) } - fun putAttribute(attribute: String, value: String) = rethrow { js.putAttribute(attribute, value) } - fun removeAttribute(attribute: String) = rethrow { js.removeAttribute(attribute) } - - internal fun primitiveHashMap(container: dynamic): HashMap { - val m = HashMap().asDynamic() - m.map = container - val keys = js("Object.keys") - m.`$size` = keys(container).length - return m - } + public actual fun start(): Unit = rethrow { js.start() } + public actual fun stop(): Unit = rethrow { js.stop() } + public actual fun getLongMetric(metricName: String): Long = rethrow { js.getMetric(metricName).toLong() } + public actual fun incrementMetric(metricName: String, incrementBy: Long): Unit = rethrow { js.incrementMetric(metricName, incrementBy.toInt()) } + public actual fun putMetric(metricName: String, value: Long): Unit = rethrow { js.putMetric(metricName, value.toInt()) } + public fun getAttribute(attribute: String): String? = rethrow { js.getAttribute(attribute) } + public fun putAttribute(attribute: String, value: String): Unit = rethrow { js.putAttribute(attribute, value) } + public fun removeAttribute(attribute: String): Unit = rethrow { js.removeAttribute(attribute) } } diff --git a/firebase-perf/src/jsMain/kotlin/dev/gitlive/firebase/perf/performance.kt b/firebase-perf/src/jsMain/kotlin/dev/gitlive/firebase/perf/performance.kt index ed27b5001..be4696645 100644 --- a/firebase-perf/src/jsMain/kotlin/dev/gitlive/firebase/perf/performance.kt +++ b/firebase-perf/src/jsMain/kotlin/dev/gitlive/firebase/perf/performance.kt @@ -8,36 +8,35 @@ import dev.gitlive.firebase.perf.externals.trace import dev.gitlive.firebase.perf.metrics.Trace import dev.gitlive.firebase.perf.externals.FirebasePerformance as JsFirebasePerformance -actual val Firebase.performance: FirebasePerformance +public actual val Firebase.performance: FirebasePerformance get() = rethrow { FirebasePerformance(getPerformance()) } -actual fun Firebase.performance(app: FirebaseApp): FirebasePerformance = rethrow { +public actual fun Firebase.performance(app: FirebaseApp): FirebasePerformance = rethrow { FirebasePerformance(getPerformance(app.js)) } -actual class FirebasePerformance internal constructor(val js: JsFirebasePerformance) { +public actual class FirebasePerformance internal constructor(public val js: JsFirebasePerformance) { - actual fun newTrace(traceName: String): Trace = rethrow { + public actual fun newTrace(traceName: String): Trace = rethrow { Trace(trace(js, traceName)) } - actual fun isPerformanceCollectionEnabled(): Boolean = js.dataCollectionEnabled + public actual fun isPerformanceCollectionEnabled(): Boolean = js.dataCollectionEnabled - actual fun setPerformanceCollectionEnabled(enable: Boolean) { + public actual fun setPerformanceCollectionEnabled(enable: Boolean) { js.dataCollectionEnabled = enable } - fun isInstrumentationEnabled(): Boolean = js.instrumentationEnabled + public fun isInstrumentationEnabled(): Boolean = js.instrumentationEnabled - fun setInstrumentationEnabled(enable: Boolean) { + public fun setInstrumentationEnabled(enable: Boolean) { js.instrumentationEnabled = enable } } -actual open class FirebasePerformanceException(code: String, cause: Throwable) : - FirebaseException(code, cause) +public actual open class FirebasePerformanceException(code: String, cause: Throwable) : FirebaseException(code, cause) internal inline fun rethrow(function: () -> R): R { try { @@ -56,7 +55,7 @@ internal fun errorToException(error: dynamic) = (error?.code ?: error?.message ? when { else -> { println("Unknown error code in ${JSON.stringify(error)}") - FirebasePerformanceException(code, error) + FirebasePerformanceException(code, error as Throwable) } } } diff --git a/firebase-perf/src/jsTest/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt b/firebase-perf/src/jsTest/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt index 0b7499ed0..686878e68 100644 --- a/firebase-perf/src/jsTest/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt +++ b/firebase-perf/src/jsTest/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt @@ -28,8 +28,8 @@ class JsTraceTest { databaseUrl = "https://fir-kotlin-sdk.firebaseio.com", storageBucket = "fir-kotlin-sdk.appspot.com", projectId = "fir-kotlin-sdk", - gcmSenderId = "846484016111" - ) + gcmSenderId = "846484016111", + ), ) performance = Firebase.performance(app) @@ -61,4 +61,4 @@ class JsTraceTest { assertEquals("Test Put Attribute Value", trace.getAttribute("Test_Put_Attribute")) trace.stop() } -} \ No newline at end of file +} diff --git a/firebase-perf/src/jsTest/kotlin/dev/gitlive/firebase/perf/performance.kt b/firebase-perf/src/jsTest/kotlin/dev/gitlive/firebase/perf/performance.kt index 20df3778f..821b92f54 100644 --- a/firebase-perf/src/jsTest/kotlin/dev/gitlive/firebase/perf/performance.kt +++ b/firebase-perf/src/jsTest/kotlin/dev/gitlive/firebase/perf/performance.kt @@ -11,8 +11,6 @@ import dev.gitlive.firebase.initialize import dev.gitlive.firebase.runTest import kotlin.test.* -actual val emulatorHost: String = "localhost" - actual val context: Any = Unit @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) @@ -32,8 +30,8 @@ class JsPerformanceTest { databaseUrl = "https://fir-kotlin-sdk.firebaseio.com", storageBucket = "fir-kotlin-sdk.appspot.com", projectId = "fir-kotlin-sdk", - gcmSenderId = "846484016111" - ) + gcmSenderId = "846484016111", + ), ) performance = Firebase.performance(app) diff --git a/firebase-perf/src/jvmMain/kotlin/dev/gitlive/firebase/perf/metrics/Trace.jvm.kt b/firebase-perf/src/jvmMain/kotlin/dev/gitlive/firebase/perf/metrics/Trace.jvm.kt index 43cfaec2a..03144fc7c 100644 --- a/firebase-perf/src/jvmMain/kotlin/dev/gitlive/firebase/perf/metrics/Trace.jvm.kt +++ b/firebase-perf/src/jvmMain/kotlin/dev/gitlive/firebase/perf/metrics/Trace.jvm.kt @@ -1,20 +1,19 @@ package dev.gitlive.firebase.perf.metrics -actual class Trace { - actual fun start() { +public actual class Trace { + public actual fun start() { } - actual fun stop() { + public actual fun stop() { } - actual fun getLongMetric(metricName: String): Long { + public actual fun getLongMetric(metricName: String): Long { TODO("Not yet implemented") } - actual fun incrementMetric(metricName: String, incrementBy: Long) { + public actual fun incrementMetric(metricName: String, incrementBy: Long) { } - actual fun putMetric(metricName: String, value: Long) { + public actual fun putMetric(metricName: String, value: Long) { } - -} \ No newline at end of file +} diff --git a/firebase-perf/src/jvmMain/kotlin/dev/gitlive/firebase/perf/performance.jvm.kt b/firebase-perf/src/jvmMain/kotlin/dev/gitlive/firebase/perf/performance.jvm.kt index 941a3bd8a..486e96c44 100644 --- a/firebase-perf/src/jvmMain/kotlin/dev/gitlive/firebase/perf/performance.jvm.kt +++ b/firebase-perf/src/jvmMain/kotlin/dev/gitlive/firebase/perf/performance.jvm.kt @@ -6,26 +6,25 @@ import dev.gitlive.firebase.FirebaseException import dev.gitlive.firebase.perf.metrics.Trace /** Returns the [FirebasePerformance] instance of the default [FirebaseApp]. */ -actual val Firebase.performance: FirebasePerformance +public actual val Firebase.performance: FirebasePerformance get() = TODO("Not yet implemented") /** Returns the [FirebasePerformance] instance of a given [FirebaseApp]. */ -actual fun Firebase.performance(app: FirebaseApp): FirebasePerformance { +public actual fun Firebase.performance(app: FirebaseApp): FirebasePerformance { TODO("Not yet implemented") } -actual class FirebasePerformance { - actual fun newTrace(traceName: String): Trace { +public actual class FirebasePerformance { + public actual fun newTrace(traceName: String): Trace { TODO("Not yet implemented") } - actual fun isPerformanceCollectionEnabled(): Boolean { + public actual fun isPerformanceCollectionEnabled(): Boolean { TODO("Not yet implemented") } - actual fun setPerformanceCollectionEnabled(enable: Boolean) { + public actual fun setPerformanceCollectionEnabled(enable: Boolean) { } - } -actual open class FirebasePerformanceException internal constructor(message: String) : FirebaseException(message) \ No newline at end of file +public actual open class FirebasePerformanceException internal constructor(message: String) : FirebaseException(message) diff --git a/firebase-perf/src/jvmTest/kotlin/dev/gitlive/firebase/perf/performance.kt b/firebase-perf/src/jvmTest/kotlin/dev/gitlive/firebase/perf/performance.kt index 0985f3b1f..958b1936c 100644 --- a/firebase-perf/src/jvmTest/kotlin/dev/gitlive/firebase/perf/performance.kt +++ b/firebase-perf/src/jvmTest/kotlin/dev/gitlive/firebase/perf/performance.kt @@ -3,12 +3,11 @@ */ @file:JvmName("tests") + package dev.gitlive.firebase.perf import dev.gitlive.firebase.testContext -actual val emulatorHost: String = "localhost" - actual val context: Any = testContext @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) diff --git a/firebase-storage/api/android/firebase-storage.api b/firebase-storage/api/android/firebase-storage.api new file mode 100644 index 000000000..6d6555bce --- /dev/null +++ b/firebase-storage/api/android/firebase-storage.api @@ -0,0 +1,113 @@ +public final class dev/gitlive/firebase/storage/Data { + public fun ([B)V + public final fun getData ()[B +} + +public final class dev/gitlive/firebase/storage/File { + public fun (Landroid/net/Uri;)V + public final fun getUri ()Landroid/net/Uri; +} + +public final class dev/gitlive/firebase/storage/FirebaseStorage { + public fun (Lcom/google/firebase/storage/FirebaseStorage;)V + public final fun getAndroid ()Lcom/google/firebase/storage/FirebaseStorage; + public final fun getMaxOperationRetryTimeMillis ()J + public final fun getMaxUploadRetryTimeMillis ()J + public final fun getReference ()Ldev/gitlive/firebase/storage/StorageReference; + public final fun reference (Ljava/lang/String;)Ldev/gitlive/firebase/storage/StorageReference; + public final fun setMaxOperationRetryTimeMillis (J)V + public final fun setMaxUploadRetryTimeMillis (J)V + public final fun useEmulator (Ljava/lang/String;I)V +} + +public final class dev/gitlive/firebase/storage/FirebaseStorageMetadata { + public fun ()V + public fun (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/Map;)V + public synthetic fun (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/Map;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun component1 ()Ljava/lang/String; + public final fun component2 ()Ljava/lang/String; + public final fun component3 ()Ljava/lang/String; + public final fun component4 ()Ljava/lang/String; + public final fun component5 ()Ljava/lang/String; + public final fun component6 ()Ljava/lang/String; + public final fun component7 ()Ljava/util/Map; + public final fun copy (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/Map;)Ldev/gitlive/firebase/storage/FirebaseStorageMetadata; + public static synthetic fun copy$default (Ldev/gitlive/firebase/storage/FirebaseStorageMetadata;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/Map;ILjava/lang/Object;)Ldev/gitlive/firebase/storage/FirebaseStorageMetadata; + public fun equals (Ljava/lang/Object;)Z + public final fun getCacheControl ()Ljava/lang/String; + public final fun getContentDisposition ()Ljava/lang/String; + public final fun getContentEncoding ()Ljava/lang/String; + public final fun getContentLanguage ()Ljava/lang/String; + public final fun getContentType ()Ljava/lang/String; + public final fun getCustomMetadata ()Ljava/util/Map; + public final fun getMd5Hash ()Ljava/lang/String; + public fun hashCode ()I + public final fun setCacheControl (Ljava/lang/String;)V + public final fun setContentDisposition (Ljava/lang/String;)V + public final fun setContentEncoding (Ljava/lang/String;)V + public final fun setContentLanguage (Ljava/lang/String;)V + public final fun setContentType (Ljava/lang/String;)V + public final fun setCustomMetadata (Ljava/lang/String;Ljava/lang/String;)V + public final fun setCustomMetadata (Ljava/util/Map;)V + public final fun setMd5Hash (Ljava/lang/String;)V + public fun toString ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/storage/ListResult { + public fun (Lcom/google/firebase/storage/ListResult;)V + public final fun getItems ()Ljava/util/List; + public final fun getPageToken ()Ljava/lang/String; + public final fun getPrefixes ()Ljava/util/List; +} + +public abstract class dev/gitlive/firebase/storage/Progress { + public synthetic fun (Ljava/lang/Number;Ljava/lang/Number;Lkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun getBytesTransferred ()Ljava/lang/Number; + public final fun getTotalByteCount ()Ljava/lang/Number; +} + +public final class dev/gitlive/firebase/storage/Progress$Paused : dev/gitlive/firebase/storage/Progress { +} + +public final class dev/gitlive/firebase/storage/Progress$Running : dev/gitlive/firebase/storage/Progress { +} + +public abstract interface class dev/gitlive/firebase/storage/ProgressFlow : kotlinx/coroutines/flow/Flow { + public abstract fun cancel ()V + public abstract fun pause ()V + public abstract fun resume ()V +} + +public final class dev/gitlive/firebase/storage/StorageKt { + public static final fun storageMetadata (Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/storage/FirebaseStorageMetadata; +} + +public final class dev/gitlive/firebase/storage/StorageReference { + public fun (Lcom/google/firebase/storage/StorageReference;)V + public final fun child (Ljava/lang/String;)Ldev/gitlive/firebase/storage/StorageReference; + public final fun delete (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun getAndroid ()Lcom/google/firebase/storage/StorageReference; + public final fun getBucket ()Ljava/lang/String; + public final fun getDownloadUrl (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun getMetadata (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun getName ()Ljava/lang/String; + public final fun getParent ()Ldev/gitlive/firebase/storage/StorageReference; + public final fun getPath ()Ljava/lang/String; + public final fun getRoot ()Ldev/gitlive/firebase/storage/StorageReference; + public final fun getStorage ()Ldev/gitlive/firebase/storage/FirebaseStorage; + public final fun listAll (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun putData (Ldev/gitlive/firebase/storage/Data;Ldev/gitlive/firebase/storage/FirebaseStorageMetadata;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static synthetic fun putData$default (Ldev/gitlive/firebase/storage/StorageReference;Ldev/gitlive/firebase/storage/Data;Ldev/gitlive/firebase/storage/FirebaseStorageMetadata;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; + public final fun putFile (Ldev/gitlive/firebase/storage/File;Ldev/gitlive/firebase/storage/FirebaseStorageMetadata;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static synthetic fun putFile$default (Ldev/gitlive/firebase/storage/StorageReference;Ldev/gitlive/firebase/storage/File;Ldev/gitlive/firebase/storage/FirebaseStorageMetadata;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; + public final fun putFileResumable (Ldev/gitlive/firebase/storage/File;Ldev/gitlive/firebase/storage/FirebaseStorageMetadata;)Ldev/gitlive/firebase/storage/ProgressFlow; + public static synthetic fun putFileResumable$default (Ldev/gitlive/firebase/storage/StorageReference;Ldev/gitlive/firebase/storage/File;Ldev/gitlive/firebase/storage/FirebaseStorageMetadata;ILjava/lang/Object;)Ldev/gitlive/firebase/storage/ProgressFlow; +} + +public final class dev/gitlive/firebase/storage/android { + public static final fun getStorage (Ldev/gitlive/firebase/Firebase;)Ldev/gitlive/firebase/storage/FirebaseStorage; + public static final fun storage (Ldev/gitlive/firebase/Firebase;Ldev/gitlive/firebase/FirebaseApp;)Ldev/gitlive/firebase/storage/FirebaseStorage; + public static final fun storage (Ldev/gitlive/firebase/Firebase;Ldev/gitlive/firebase/FirebaseApp;Ljava/lang/String;)Ldev/gitlive/firebase/storage/FirebaseStorage; + public static final fun storage (Ldev/gitlive/firebase/Firebase;Ljava/lang/String;)Ldev/gitlive/firebase/storage/FirebaseStorage; +} + diff --git a/firebase-storage/api/jvm/firebase-storage.api b/firebase-storage/api/jvm/firebase-storage.api new file mode 100644 index 000000000..bda703b4c --- /dev/null +++ b/firebase-storage/api/jvm/firebase-storage.api @@ -0,0 +1,112 @@ +public final class dev/gitlive/firebase/storage/Data { + public fun ()V +} + +public final class dev/gitlive/firebase/storage/File { + public fun ()V +} + +public final class dev/gitlive/firebase/storage/FirebaseStorage { + public fun ()V + public final fun getMaxOperationRetryTimeMillis ()J + public final fun getMaxUploadRetryTimeMillis ()J + public final fun getReference ()Ldev/gitlive/firebase/storage/StorageReference; + public final fun reference (Ljava/lang/String;)Ldev/gitlive/firebase/storage/StorageReference; + public final fun setMaxOperationRetryTimeMillis (J)V + public final fun setMaxUploadRetryTimeMillis (J)V + public final fun useEmulator (Ljava/lang/String;I)V +} + +public final class dev/gitlive/firebase/storage/FirebaseStorageException : com/google/firebase/FirebaseException { +} + +public final class dev/gitlive/firebase/storage/FirebaseStorageMetadata { + public fun ()V + public fun (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/Map;)V + public synthetic fun (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/Map;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun component1 ()Ljava/lang/String; + public final fun component2 ()Ljava/lang/String; + public final fun component3 ()Ljava/lang/String; + public final fun component4 ()Ljava/lang/String; + public final fun component5 ()Ljava/lang/String; + public final fun component6 ()Ljava/lang/String; + public final fun component7 ()Ljava/util/Map; + public final fun copy (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/Map;)Ldev/gitlive/firebase/storage/FirebaseStorageMetadata; + public static synthetic fun copy$default (Ldev/gitlive/firebase/storage/FirebaseStorageMetadata;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/Map;ILjava/lang/Object;)Ldev/gitlive/firebase/storage/FirebaseStorageMetadata; + public fun equals (Ljava/lang/Object;)Z + public final fun getCacheControl ()Ljava/lang/String; + public final fun getContentDisposition ()Ljava/lang/String; + public final fun getContentEncoding ()Ljava/lang/String; + public final fun getContentLanguage ()Ljava/lang/String; + public final fun getContentType ()Ljava/lang/String; + public final fun getCustomMetadata ()Ljava/util/Map; + public final fun getMd5Hash ()Ljava/lang/String; + public fun hashCode ()I + public final fun setCacheControl (Ljava/lang/String;)V + public final fun setContentDisposition (Ljava/lang/String;)V + public final fun setContentEncoding (Ljava/lang/String;)V + public final fun setContentLanguage (Ljava/lang/String;)V + public final fun setContentType (Ljava/lang/String;)V + public final fun setCustomMetadata (Ljava/lang/String;Ljava/lang/String;)V + public final fun setCustomMetadata (Ljava/util/Map;)V + public final fun setMd5Hash (Ljava/lang/String;)V + public fun toString ()Ljava/lang/String; +} + +public final class dev/gitlive/firebase/storage/ListResult { + public fun ()V + public final fun getItems ()Ljava/util/List; + public final fun getPageToken ()Ljava/lang/String; + public final fun getPrefixes ()Ljava/util/List; +} + +public abstract class dev/gitlive/firebase/storage/Progress { + public synthetic fun (Ljava/lang/Number;Ljava/lang/Number;Lkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun getBytesTransferred ()Ljava/lang/Number; + public final fun getTotalByteCount ()Ljava/lang/Number; +} + +public final class dev/gitlive/firebase/storage/Progress$Paused : dev/gitlive/firebase/storage/Progress { +} + +public final class dev/gitlive/firebase/storage/Progress$Running : dev/gitlive/firebase/storage/Progress { +} + +public abstract interface class dev/gitlive/firebase/storage/ProgressFlow : kotlinx/coroutines/flow/Flow { + public abstract fun cancel ()V + public abstract fun pause ()V + public abstract fun resume ()V +} + +public final class dev/gitlive/firebase/storage/StorageKt { + public static final fun storageMetadata (Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/storage/FirebaseStorageMetadata; +} + +public final class dev/gitlive/firebase/storage/StorageReference { + public fun ()V + public final fun child (Ljava/lang/String;)Ldev/gitlive/firebase/storage/StorageReference; + public final fun delete (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun getBucket ()Ljava/lang/String; + public final fun getDownloadUrl (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun getMetadata (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun getName ()Ljava/lang/String; + public final fun getParent ()Ldev/gitlive/firebase/storage/StorageReference; + public final fun getPath ()Ljava/lang/String; + public final fun getRoot ()Ldev/gitlive/firebase/storage/StorageReference; + public final fun getStorage ()Ldev/gitlive/firebase/storage/FirebaseStorage; + public final fun listAll (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun putData (Ldev/gitlive/firebase/storage/Data;Ldev/gitlive/firebase/storage/FirebaseStorageMetadata;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static synthetic fun putData$default (Ldev/gitlive/firebase/storage/StorageReference;Ldev/gitlive/firebase/storage/Data;Ldev/gitlive/firebase/storage/FirebaseStorageMetadata;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; + public final fun putFile (Ldev/gitlive/firebase/storage/File;Ldev/gitlive/firebase/storage/FirebaseStorageMetadata;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static synthetic fun putFile$default (Ldev/gitlive/firebase/storage/StorageReference;Ldev/gitlive/firebase/storage/File;Ldev/gitlive/firebase/storage/FirebaseStorageMetadata;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; + public final fun putFileResumable (Ldev/gitlive/firebase/storage/File;Ldev/gitlive/firebase/storage/FirebaseStorageMetadata;)Ldev/gitlive/firebase/storage/ProgressFlow; + public static synthetic fun putFileResumable$default (Ldev/gitlive/firebase/storage/StorageReference;Ldev/gitlive/firebase/storage/File;Ldev/gitlive/firebase/storage/FirebaseStorageMetadata;ILjava/lang/Object;)Ldev/gitlive/firebase/storage/ProgressFlow; +} + +public final class dev/gitlive/firebase/storage/Storage_jvmKt { + public static final fun getStorage (Ldev/gitlive/firebase/Firebase;)Ldev/gitlive/firebase/storage/FirebaseStorage; + public static final fun storage (Ldev/gitlive/firebase/Firebase;Ldev/gitlive/firebase/FirebaseApp;)Ldev/gitlive/firebase/storage/FirebaseStorage; + public static final fun storage (Ldev/gitlive/firebase/Firebase;Ldev/gitlive/firebase/FirebaseApp;Ljava/lang/String;)Ldev/gitlive/firebase/storage/FirebaseStorage; + public static final fun storage (Ldev/gitlive/firebase/Firebase;Ljava/lang/String;)Ldev/gitlive/firebase/storage/FirebaseStorage; +} + diff --git a/firebase-storage/build.gradle.kts b/firebase-storage/build.gradle.kts index 2ae659e33..76ac9a7cc 100644 --- a/firebase-storage/build.gradle.kts +++ b/firebase-storage/build.gradle.kts @@ -47,6 +47,8 @@ android { val supportIosTarget = project.property("skipIosTarget") != "true" kotlin { + explicitApi() + @OptIn(ExperimentalKotlinGradlePluginApi::class) compilerOptions { freeCompilerArgs.add("-Xexpect-actual-classes") diff --git a/firebase-storage/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/storage/storage.android.kt b/firebase-storage/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/storage/storage.android.kt index 22d885915..513d4847a 100644 --- a/firebase-storage/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/storage/storage.android.kt +++ b/firebase-storage/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/storage/storage.android.kt @@ -1,7 +1,3 @@ package dev.gitlive.firebase.storage -import android.net.Uri - -actual fun createTestData(): Data { - return Data("test".toByteArray()) -} \ No newline at end of file +actual fun createTestData(): Data = Data("test".toByteArray()) diff --git a/firebase-storage/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/storage/storage.kt b/firebase-storage/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/storage/storage.kt index 67a1affe0..c6965d33c 100644 --- a/firebase-storage/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/storage/storage.kt +++ b/firebase-storage/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/storage/storage.kt @@ -3,6 +3,7 @@ */ @file:JvmName("tests") + package dev.gitlive.firebase.storage import androidx.test.platform.app.InstrumentationRegistry diff --git a/firebase-storage/src/androidMain/kotlin/dev/gitlive/firebase/storage/storage.kt b/firebase-storage/src/androidMain/kotlin/dev/gitlive/firebase/storage/storage.kt index 6df20f6c3..93eebb946 100644 --- a/firebase-storage/src/androidMain/kotlin/dev/gitlive/firebase/storage/storage.kt +++ b/firebase-storage/src/androidMain/kotlin/dev/gitlive/firebase/storage/storage.kt @@ -3,12 +3,12 @@ */ @file:JvmName("android") + package dev.gitlive.firebase.storage import android.net.Uri import com.google.android.gms.tasks.OnCanceledListener import com.google.android.gms.tasks.OnCompleteListener -import com.google.android.gms.tasks.Task import com.google.firebase.storage.OnPausedListener import com.google.firebase.storage.OnProgressListener import com.google.firebase.storage.StorageMetadata @@ -20,61 +20,59 @@ import kotlinx.coroutines.channels.awaitClose import kotlinx.coroutines.channels.trySendBlocking import kotlinx.coroutines.flow.FlowCollector import kotlinx.coroutines.flow.callbackFlow -import kotlinx.coroutines.flow.channelFlow import kotlinx.coroutines.flow.emitAll -import kotlinx.coroutines.flow.first -import kotlinx.coroutines.launch import kotlinx.coroutines.tasks.await -actual val Firebase.storage get() = FirebaseStorage(com.google.firebase.storage.FirebaseStorage.getInstance()) +public actual val Firebase.storage: FirebaseStorage get() = FirebaseStorage(com.google.firebase.storage.FirebaseStorage.getInstance()) -actual fun Firebase.storage(url: String): FirebaseStorage = FirebaseStorage(com.google.firebase.storage.FirebaseStorage.getInstance(url)) +public actual fun Firebase.storage(url: String): FirebaseStorage = FirebaseStorage(com.google.firebase.storage.FirebaseStorage.getInstance(url)) -actual fun Firebase.storage(app: FirebaseApp) = FirebaseStorage(com.google.firebase.storage.FirebaseStorage.getInstance(app.android)) +public actual fun Firebase.storage(app: FirebaseApp): FirebaseStorage = FirebaseStorage(com.google.firebase.storage.FirebaseStorage.getInstance(app.android)) -actual fun Firebase.storage(app: FirebaseApp, url: String) = FirebaseStorage(com.google.firebase.storage.FirebaseStorage.getInstance(app.android, url)) +public actual fun Firebase.storage(app: FirebaseApp, url: String): FirebaseStorage = FirebaseStorage(com.google.firebase.storage.FirebaseStorage.getInstance(app.android, url)) -actual class FirebaseStorage(val android: com.google.firebase.storage.FirebaseStorage) { - actual val maxOperationRetryTimeMillis = android.maxOperationRetryTimeMillis - actual val maxUploadRetryTimeMillis = android.maxUploadRetryTimeMillis +public actual class FirebaseStorage(public val android: com.google.firebase.storage.FirebaseStorage) { + public actual val maxOperationRetryTimeMillis: Long = android.maxOperationRetryTimeMillis + public actual val maxUploadRetryTimeMillis: Long = android.maxUploadRetryTimeMillis - actual fun setMaxOperationRetryTimeMillis(maxOperationRetryTimeMillis: Long) { + public actual fun setMaxOperationRetryTimeMillis(maxOperationRetryTimeMillis: Long) { android.maxOperationRetryTimeMillis = maxOperationRetryTimeMillis } - actual fun setMaxUploadRetryTimeMillis(maxUploadRetryTimeMillis: Long) { + public actual fun setMaxUploadRetryTimeMillis(maxUploadRetryTimeMillis: Long) { android.maxUploadRetryTimeMillis = maxUploadRetryTimeMillis } - actual fun useEmulator(host: String, port: Int) { + public actual fun useEmulator(host: String, port: Int) { android.useEmulator(host, port) } - actual val reference get() = StorageReference(android.reference) - - actual fun reference(location: String )= StorageReference(android.getReference(location)) + public actual val reference: StorageReference get() = StorageReference(android.reference) + public actual fun reference(location: String): StorageReference = StorageReference(android.getReference(location)) } -actual class StorageReference(val android: com.google.firebase.storage.StorageReference) { - actual val name: String get() = android.name - actual val path: String get() = android.path - actual val bucket: String get() = android.bucket - actual val parent: StorageReference? get() = android.parent?.let { StorageReference(it) } - actual val root: StorageReference get() = StorageReference(android.root) - actual val storage: FirebaseStorage get() = FirebaseStorage(android.storage) +public actual class StorageReference(public val android: com.google.firebase.storage.StorageReference) { + public actual val name: String get() = android.name + public actual val path: String get() = android.path + public actual val bucket: String get() = android.bucket + public actual val parent: StorageReference? get() = android.parent?.let { StorageReference(it) } + public actual val root: StorageReference get() = StorageReference(android.root) + public actual val storage: FirebaseStorage get() = FirebaseStorage(android.storage) - actual suspend fun getMetadata(): FirebaseStorageMetadata? = android.metadata.await().toFirebaseStorageMetadata() + public actual suspend fun getMetadata(): FirebaseStorageMetadata? = android.metadata.await().toFirebaseStorageMetadata() - actual fun child(path: String): StorageReference = StorageReference(android.child(path)) + public actual fun child(path: String): StorageReference = StorageReference(android.child(path)) - actual suspend fun delete() = android.delete().await().run { Unit } + public actual suspend fun delete() { + android.delete().await() + } - actual suspend fun getDownloadUrl(): String = android.downloadUrl.await().toString() + public actual suspend fun getDownloadUrl(): String = android.downloadUrl.await().toString() - actual suspend fun listAll(): ListResult = ListResult(android.listAll().await()) + public actual suspend fun listAll(): ListResult = ListResult(android.listAll().await()) - actual suspend fun putFile(file: File, metadata: FirebaseStorageMetadata?) { + public actual suspend fun putFile(file: File, metadata: FirebaseStorageMetadata?) { if (metadata != null) { android.putFile(file.uri, metadata.toStorageMetadata()).await().run {} } else { @@ -82,7 +80,7 @@ actual class StorageReference(val android: com.google.firebase.storage.StorageRe } } - actual suspend fun putData(data: Data, metadata: FirebaseStorageMetadata?) { + public actual suspend fun putData(data: Data, metadata: FirebaseStorageMetadata?) { if (metadata != null) { android.putBytes(data.data, metadata.toStorageMetadata()).await().run {} } else { @@ -90,7 +88,7 @@ actual class StorageReference(val android: com.google.firebase.storage.StorageRe } } - actual fun putFileResumable(file: File, metadata: FirebaseStorageMetadata?): ProgressFlow { + public actual fun putFileResumable(file: File, metadata: FirebaseStorageMetadata?): ProgressFlow { val android = if (metadata != null) { android.putFile(file.uri, metadata.toStorageMetadata()) } else { @@ -123,31 +121,29 @@ actual class StorageReference(val android: com.google.firebase.storage.StorageRe } } -actual class ListResult(android: com.google.firebase.storage.ListResult) { - actual val prefixes: List = android.prefixes.map { StorageReference(it) } - actual val items: List = android.items.map { StorageReference(it) } - actual val pageToken: String? = android.pageToken +public actual class ListResult(android: com.google.firebase.storage.ListResult) { + public actual val prefixes: List = android.prefixes.map { StorageReference(it) } + public actual val items: List = android.items.map { StorageReference(it) } + public actual val pageToken: String? = android.pageToken } -actual class File(val uri: Uri) +public actual class File(public val uri: Uri) -actual class Data(val data: ByteArray) +public actual class Data(public val data: ByteArray) -actual typealias FirebaseStorageException = com.google.firebase.storage.StorageException +public actual typealias FirebaseStorageException = com.google.firebase.storage.StorageException -internal fun FirebaseStorageMetadata.toStorageMetadata(): StorageMetadata { - return StorageMetadata.Builder() - .setCacheControl(this.cacheControl) - .setContentDisposition(this.contentDisposition) - .setContentEncoding(this.contentEncoding) - .setContentLanguage(this.contentLanguage) - .setContentType(this.contentType) - .apply { - customMetadata.entries.forEach { - (key, value) -> setCustomMetadata(key, value) - } - }.build() -} +internal fun FirebaseStorageMetadata.toStorageMetadata(): StorageMetadata = StorageMetadata.Builder() + .setCacheControl(this.cacheControl) + .setContentDisposition(this.contentDisposition) + .setContentEncoding(this.contentEncoding) + .setContentLanguage(this.contentLanguage) + .setContentType(this.contentType) + .apply { + customMetadata.entries.forEach { (key, value) -> + setCustomMetadata(key, value) + } + }.build() internal fun StorageMetadata.toFirebaseStorageMetadata(): FirebaseStorageMetadata { val sdkMetadata = this @@ -162,4 +158,4 @@ internal fun StorageMetadata.toFirebaseStorageMetadata(): FirebaseStorageMetadat setCustomMetadata(it, sdkMetadata.getCustomMetadata(it)) } } -} \ No newline at end of file +} diff --git a/firebase-storage/src/androidUnitTest/kotlin/dev/gitlive/firebase/storage/storage.android.kt b/firebase-storage/src/androidUnitTest/kotlin/dev/gitlive/firebase/storage/storage.android.kt index 22d885915..513d4847a 100644 --- a/firebase-storage/src/androidUnitTest/kotlin/dev/gitlive/firebase/storage/storage.android.kt +++ b/firebase-storage/src/androidUnitTest/kotlin/dev/gitlive/firebase/storage/storage.android.kt @@ -1,7 +1,3 @@ package dev.gitlive.firebase.storage -import android.net.Uri - -actual fun createTestData(): Data { - return Data("test".toByteArray()) -} \ No newline at end of file +actual fun createTestData(): Data = Data("test".toByteArray()) diff --git a/firebase-storage/src/commonMain/kotlin/dev/gitlive/firebase/storage/storage.kt b/firebase-storage/src/commonMain/kotlin/dev/gitlive/firebase/storage/storage.kt index a928a25b1..06ae06660 100644 --- a/firebase-storage/src/commonMain/kotlin/dev/gitlive/firebase/storage/storage.kt +++ b/firebase-storage/src/commonMain/kotlin/dev/gitlive/firebase/storage/storage.kt @@ -4,21 +4,18 @@ import dev.gitlive.firebase.Firebase import dev.gitlive.firebase.FirebaseApp import dev.gitlive.firebase.FirebaseException import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.channelFlow -import kotlinx.coroutines.flow.first -import kotlinx.coroutines.launch /** Returns the [FirebaseStorage] instance of the default [FirebaseApp]. */ -expect val Firebase.storage: FirebaseStorage +public expect val Firebase.storage: FirebaseStorage /** Returns the [FirebaseStorage] instance of the default [FirebaseApp]. */ -expect fun Firebase.storage(url: String): FirebaseStorage +public expect fun Firebase.storage(url: String): FirebaseStorage /** Returns the [FirebaseStorage] instance of a given [FirebaseApp]. */ -expect fun Firebase.storage(app: FirebaseApp): FirebaseStorage +public expect fun Firebase.storage(app: FirebaseApp): FirebaseStorage /** Returns the [FirebaseStorage] instance of a given [FirebaseApp]. */ -expect fun Firebase.storage(app: FirebaseApp, url: String): FirebaseStorage +public expect fun Firebase.storage(app: FirebaseApp, url: String): FirebaseStorage /** * FirebaseStorage is a service that supports uploading and downloading large objects to Google @@ -30,21 +27,21 @@ expect fun Firebase.storage(app: FirebaseApp, url: String): FirebaseStorage * [Firebase.storage]. The storage location in this case will come the JSON * configuration file downloaded from the web. */ -expect class FirebaseStorage { +public expect class FirebaseStorage { /** * Returns the maximum time to retry operations other than upload and download if a failure * occurs. * * @return the maximum time in milliseconds. Defaults to 2 minutes (120,000 milliseconds). */ - val maxOperationRetryTimeMillis: Long + public val maxOperationRetryTimeMillis: Long /** * Returns the maximum time to retry an upload if a failure occurs. * * @return the maximum time in milliseconds. Defaults to 10 minutes (600,000 milliseconds). */ - val maxUploadRetryTimeMillis: Long + public val maxUploadRetryTimeMillis: Long /** * Sets the maximum time to retry operations other than upload and download if a failure occurs. @@ -52,7 +49,7 @@ expect class FirebaseStorage { * @param maxTransferRetryMillis the maximum time in milliseconds. Defaults to 2 minutes (120,000 * milliseconds). */ - fun setMaxOperationRetryTimeMillis(maxOperationRetryTimeMillis: Long) + public fun setMaxOperationRetryTimeMillis(maxOperationRetryTimeMillis: Long) /** * Sets the maximum time to retry an upload if a failure occurs. @@ -60,7 +57,7 @@ expect class FirebaseStorage { * @param maxTransferRetryMillis the maximum time in milliseconds. Defaults to 10 minutes (600,000 * milliseconds). */ - fun setMaxUploadRetryTimeMillis(maxUploadRetryTimeMillis: Long) + public fun setMaxUploadRetryTimeMillis(maxUploadRetryTimeMillis: Long) /** * Modifies this FirebaseStorage instance to communicate with the Storage emulator. @@ -70,14 +67,14 @@ expect class FirebaseStorage { * @param host the emulator host (for example, 10.0.2.2) * @param port the emulator port (for example, 9000) */ - fun useEmulator(host: String, port: Int) + public fun useEmulator(host: String, port: Int) /** * Creates a new [StorageReference] initialized at the root Firebase Storage location. * * @return An instance of [StorageReference]. */ - val reference: StorageReference + public val reference: StorageReference /** * Creates a new [StorageReference] initialized with a child Firebase Storage location. @@ -86,35 +83,34 @@ expect class FirebaseStorage { * "path/to/object" * @return An instance of [StorageReference] at the given child path. */ - fun reference(location: String): StorageReference - + public fun reference(location: String): StorageReference } /** * Represents a reference to a Google Cloud Storage object. Developers can upload and download * objects, get/set object metadata, and delete an object at a specified path. */ -expect class StorageReference { +public expect class StorageReference { /** * Returns the short name of this object. * * @return the name. */ - val name: String + public val name: String /** * Returns the full path to this object, not including the Google Cloud Storage bucket. * * @return the path. */ - val path: String + public val path: String /** * Return the Google Cloud Storage bucket that holds this object. * * @return the bucket. */ - val bucket: String + public val bucket: String /** * Returns a new instance of [StorageReference] pointing to the parent location or null if @@ -128,28 +124,28 @@ expect class StorageReference { * * @return the parent [StorageReference]. */ - val parent: StorageReference? + public val parent: StorageReference? /** * Returns a new instance of {@link StorageReference} pointing to the root location. * * @return the root {@link StorageReference}. */ - val root: StorageReference + public val root: StorageReference /** * Returns the [FirebaseStorage] service which created this reference. * * @return The [FirebaseStorage] service. */ - val storage: FirebaseStorage + public val storage: FirebaseStorage /** * Retrieves metadata associated with an object at this [StorageReference]. * * @return the metadata. */ - suspend fun getMetadata(): FirebaseStorageMetadata? + public suspend fun getMetadata(): FirebaseStorageMetadata? /** * Returns a new instance of [StorageReference] pointing to a child location of the current @@ -165,14 +161,14 @@ expect class StorageReference { * @param pathString The relative path from this reference. * @return the child [StorageReference]. */ - fun child(path: String): StorageReference + public fun child(path: String): StorageReference /** * Deletes the object at this {@link StorageReference}. * * @return A {@link Task} that indicates whether the operation succeeded or failed. */ - suspend fun delete() + public suspend fun delete() /** * Asynchronously retrieves a long lived download URL with a revokable token. This can be used to @@ -182,7 +178,7 @@ expect class StorageReference { * @return The [Uri] representing the download URL. You can feed this URL into a [URL] * and download the object via URL.openStream(). */ - suspend fun getDownloadUrl(): String + public suspend fun getDownloadUrl(): String /** * List all items (files) and prefixes (folders) under this StorageReference. @@ -196,7 +192,7 @@ expect class StorageReference { * @throws OutOfMemoryError If there are too many items at this location. * @return A [ListResult] that returns all items and prefixes under the current StorageReference. */ - suspend fun listAll(): ListResult + public suspend fun listAll(): ListResult /** * Asynchronously uploads from a content URI to this [StorageReference]. @@ -206,7 +202,7 @@ expect class StorageReference { * @param metadata [FirebaseStorageMetadata] containing additional information (MIME type, etc.) * about the object being uploaded. */ - suspend fun putFile(file: File, metadata: FirebaseStorageMetadata? = null) + public suspend fun putFile(file: File, metadata: FirebaseStorageMetadata? = null) /** * Asynchronously uploads byte data to this [StorageReference]. This is not recommended for @@ -216,7 +212,7 @@ expect class StorageReference { * @param metadata [FirebaseStorageMetadata] containing additional information (MIME type, etc.) * about the object being uploaded. */ - suspend fun putData(data: Data, metadata: FirebaseStorageMetadata? = null) + public suspend fun putData(data: Data, metadata: FirebaseStorageMetadata? = null) /** * Asynchronously uploads from a content URI to this [StorageReference]. @@ -227,55 +223,56 @@ expect class StorageReference { * about the object being uploaded. * @return A [ProgressFlow] that can be used to monitor and manage the upload. */ - fun putFileResumable(file: File, metadata: FirebaseStorageMetadata? = null): ProgressFlow + public fun putFileResumable(file: File, metadata: FirebaseStorageMetadata? = null): ProgressFlow } -expect class ListResult { - val prefixes: List - val items: List - val pageToken: String? +public expect class ListResult { + public val prefixes: List + public val items: List + public val pageToken: String? } /** * Represents a reference to a local file for all platforms. Every platform has its own constructor. */ -expect class File +public expect class File /** * Represents a reference to data for all platforms. Every platform has its own constructor. */ -expect class Data +public expect class Data /** * Represents the progress of an operation. */ -sealed class Progress(val bytesTransferred: Number, val totalByteCount: Number) { +public sealed class Progress(public val bytesTransferred: Number, public val totalByteCount: Number) { /** Represents the progress of an operation that is still running. */ - class Running internal constructor(bytesTransferred: Number, totalByteCount: Number): Progress(bytesTransferred, totalByteCount) + public class Running internal constructor(bytesTransferred: Number, totalByteCount: Number) : Progress(bytesTransferred, totalByteCount) + /** Represents the progress of an operation that is paused. */ - class Paused internal constructor(bytesTransferred: Number, totalByteCount: Number): Progress(bytesTransferred, totalByteCount) + public class Paused internal constructor(bytesTransferred: Number, totalByteCount: Number) : Progress(bytesTransferred, totalByteCount) } /** * A flow that emits [Progress] objects containing the state of an upload. */ -interface ProgressFlow : Flow { - fun pause() - fun resume() - fun cancel() +public interface ProgressFlow : Flow { + public fun pause() + public fun resume() + public fun cancel() } /** * Exception that gets thrown when an operation on Firebase Storage fails. */ -expect class FirebaseStorageException : FirebaseException +public expect class FirebaseStorageException : FirebaseException /** * Metadata for a [StorageReference]. Metadata stores default attributes such as size and * content type. You may also store custom metadata key value pairs. Metadata values may be used to * authorize operations using declarative validation rules. */ -data class FirebaseStorageMetadata( +public data class FirebaseStorageMetadata( /** * Returns the path of the [StorageReference] object. * @@ -323,7 +320,7 @@ data class FirebaseStorageMetadata( * * @return the metadata stored in the object. */ - var customMetadata: MutableMap = mutableMapOf() + var customMetadata: MutableMap = mutableMapOf(), ) { /** * Sets custom metadata @@ -331,7 +328,7 @@ data class FirebaseStorageMetadata( * @param key the key of the new value * @param value the value to set. */ - fun setCustomMetadata(key: String, value: String?) { + public fun setCustomMetadata(key: String, value: String?) { value?.let { customMetadata[key] = it } @@ -339,8 +336,8 @@ data class FirebaseStorageMetadata( } /** Returns a [FirebaseStorageMetadata] object initialized using the [init] function. */ -fun storageMetadata(init: FirebaseStorageMetadata.() -> Unit): FirebaseStorageMetadata { +public fun storageMetadata(init: FirebaseStorageMetadata.() -> Unit): FirebaseStorageMetadata { val metadata = FirebaseStorageMetadata() metadata.init() return metadata -} \ No newline at end of file +} diff --git a/firebase-storage/src/commonTest/kotlin/dev/gitlive/firebase/storage/storage.kt b/firebase-storage/src/commonTest/kotlin/dev/gitlive/firebase/storage/storage.kt index dcd147944..b55080175 100644 --- a/firebase-storage/src/commonTest/kotlin/dev/gitlive/firebase/storage/storage.kt +++ b/firebase-storage/src/commonTest/kotlin/dev/gitlive/firebase/storage/storage.kt @@ -35,8 +35,8 @@ class FirebaseStorageTest { databaseUrl = "https://fir-kotlin-sdk.firebaseio.com", storageBucket = "fir-kotlin-sdk.appspot.com", projectId = "fir-kotlin-sdk", - gcmSenderId = "846484016111" - ) + gcmSenderId = "846484016111", + ), ) storage = Firebase.storage(app).apply { @@ -95,8 +95,8 @@ class FirebaseStorageTest { val metadataResult = ref.getMetadata() assertNotNull(metadataResult) - assertEquals( metadata.customMetadata["key"], metadataResult.customMetadata["key"]) + assertEquals(metadata.customMetadata["key"], metadataResult.customMetadata["key"]) } } -expect fun createTestData(): Data \ No newline at end of file +expect fun createTestData(): Data diff --git a/firebase-storage/src/iosMain/kotlin/dev/gitlive/firebase/storage/storage.kt b/firebase-storage/src/iosMain/kotlin/dev/gitlive/firebase/storage/storage.kt index c30387c40..03e5a67aa 100644 --- a/firebase-storage/src/iosMain/kotlin/dev/gitlive/firebase/storage/storage.kt +++ b/firebase-storage/src/iosMain/kotlin/dev/gitlive/firebase/storage/storage.kt @@ -27,54 +27,53 @@ import platform.Foundation.NSData import platform.Foundation.NSError import platform.Foundation.NSURL - -actual val Firebase.storage get() = +public actual val Firebase.storage: FirebaseStorage get() = FirebaseStorage(FIRStorage.storage()) -actual fun Firebase.storage(url: String): FirebaseStorage = FirebaseStorage( - FIRStorage.storageWithURL(url) +public actual fun Firebase.storage(url: String): FirebaseStorage = FirebaseStorage( + FIRStorage.storageWithURL(url), ) -actual fun Firebase.storage(app: FirebaseApp): FirebaseStorage = FirebaseStorage( - FIRStorage.storageForApp(app.ios as objcnames.classes.FIRApp) +public actual fun Firebase.storage(app: FirebaseApp): FirebaseStorage = FirebaseStorage( + FIRStorage.storageForApp(app.ios as objcnames.classes.FIRApp), ) -actual fun Firebase.storage(app: FirebaseApp, url: String) = FirebaseStorage( - FIRStorage.storageForApp(app.ios as objcnames.classes.FIRApp, url) +public actual fun Firebase.storage(app: FirebaseApp, url: String): FirebaseStorage = FirebaseStorage( + FIRStorage.storageForApp(app.ios as objcnames.classes.FIRApp, url), ) -actual class FirebaseStorage(val ios: FIRStorage) { - actual val maxOperationRetryTimeMillis = ios.maxOperationRetryTime().toLong() - actual val maxUploadRetryTimeMillis = ios.maxUploadRetryTime().toLong() +public actual class FirebaseStorage(public val ios: FIRStorage) { + public actual val maxOperationRetryTimeMillis: Long = ios.maxOperationRetryTime().toLong() + public actual val maxUploadRetryTimeMillis: Long = ios.maxUploadRetryTime().toLong() - actual fun setMaxOperationRetryTimeMillis(maxOperationRetryTimeMillis: Long) { + public actual fun setMaxOperationRetryTimeMillis(maxOperationRetryTimeMillis: Long) { ios.setMaxOperationRetryTime(maxOperationRetryTimeMillis.toDouble()) } - actual fun setMaxUploadRetryTimeMillis(maxUploadRetryTimeMillis: Long) { + public actual fun setMaxUploadRetryTimeMillis(maxUploadRetryTimeMillis: Long) { ios.setMaxUploadRetryTime(maxUploadRetryTimeMillis.toDouble()) } - actual fun useEmulator(host: String, port: Int) { + public actual fun useEmulator(host: String, port: Int) { ios.useEmulatorWithHost(host, port.toLong()) } - actual val reference get() = StorageReference(ios.reference()) + public actual val reference: StorageReference get() = StorageReference(ios.reference()) - actual fun reference(location: String) = StorageReference(ios.referenceWithPath(location)) + public actual fun reference(location: String): StorageReference = StorageReference(ios.referenceWithPath(location)) } -actual class StorageReference(val ios: FIRStorageReference) { - actual val name: String get() = ios.name() - actual val path: String get() = ios.fullPath() - actual val bucket: String get() = ios.bucket() - actual val parent: StorageReference? get() = ios.parent()?.let { StorageReference(it) } - actual val root: StorageReference get() = StorageReference(ios.root()) - actual val storage: FirebaseStorage get() = FirebaseStorage(ios.storage()) +public actual class StorageReference(public val ios: FIRStorageReference) { + public actual val name: String get() = ios.name() + public actual val path: String get() = ios.fullPath() + public actual val bucket: String get() = ios.bucket() + public actual val parent: StorageReference? get() = ios.parent()?.let { StorageReference(it) } + public actual val root: StorageReference get() = StorageReference(ios.root()) + public actual val storage: FirebaseStorage get() = FirebaseStorage(ios.storage()) - actual fun child(path: String): StorageReference = StorageReference(ios.child(path)) + public actual fun child(path: String): StorageReference = StorageReference(ios.child(path)) - actual suspend fun getMetadata(): FirebaseStorageMetadata? = ios.awaitResult { + public actual suspend fun getMetadata(): FirebaseStorageMetadata? = ios.awaitResult { metadataWithCompletion { metadata, error -> if (error == null) { it.invoke(metadata?.toFirebaseStorageMetadata(), null) @@ -84,27 +83,27 @@ actual class StorageReference(val ios: FIRStorageReference) { } } - actual suspend fun delete() = await { ios.deleteWithCompletion(it) } + public actual suspend fun delete(): Unit = await { ios.deleteWithCompletion(it) } - actual suspend fun getDownloadUrl(): String = ios.awaitResult { + public actual suspend fun getDownloadUrl(): String = ios.awaitResult { downloadURLWithCompletion(completion = it) }.absoluteString()!! - actual suspend fun listAll(): ListResult = awaitResult { + public actual suspend fun listAll(): ListResult = awaitResult { ios.listAllWithCompletion { firStorageListResult, nsError -> it.invoke(firStorageListResult?.let { ListResult(it) }, nsError) } } - actual suspend fun putFile(file: File, metadata: FirebaseStorageMetadata?) = ios.awaitResult { callback -> + public actual suspend fun putFile(file: File, metadata: FirebaseStorageMetadata?): Unit = ios.awaitResult { callback -> putFile(file.url, metadata?.toFIRMetadata(), callback) }.run {} - actual suspend fun putData(data: Data, metadata: FirebaseStorageMetadata?) = ios.awaitResult { callback -> + public actual suspend fun putData(data: Data, metadata: FirebaseStorageMetadata?): Unit = ios.awaitResult { callback -> putData(data.data, metadata?.toFIRMetadata(), callback) }.run {} - actual fun putFileResumable(file: File, metadata: FirebaseStorageMetadata?): ProgressFlow { + public actual fun putFileResumable(file: File, metadata: FirebaseStorageMetadata?): ProgressFlow { val ios = ios.putFile(file.url, metadata?.toFIRMetadata()) val flow = callbackFlow { @@ -122,8 +121,9 @@ actual class StorageReference(val ios: FIRStorageReference) { } ios.observeStatus(FIRStorageTaskStatusSuccess) { close(FirebaseStorageException(it!!.error().toString())) } ios.observeStatus(FIRStorageTaskStatusFailure) { - when(it!!.error()!!.code) { - /*FIRStorageErrorCodeCancelled = */ -13040L -> cancel(it.error()!!.localizedDescription) + when (it!!.error()!!.code) { + /*FIRStorageErrorCodeCancelled = */ + -13040L -> cancel(it.error()!!.localizedDescription) else -> close(FirebaseStorageException(it.error().toString())) } } @@ -137,25 +137,24 @@ actual class StorageReference(val ios: FIRStorageReference) { override fun cancel() = ios.cancel() } } - } -actual class ListResult(ios: FIRStorageListResult) { - actual val prefixes: List = ios.prefixes().map { StorageReference(it as FIRStorageReference) } - actual val items: List = ios.items().map { StorageReference(it as FIRStorageReference) } - actual val pageToken: String? = ios.pageToken() +public actual class ListResult(ios: FIRStorageListResult) { + public actual val prefixes: List = ios.prefixes().map { StorageReference(it as FIRStorageReference) } + public actual val items: List = ios.items().map { StorageReference(it as FIRStorageReference) } + public actual val pageToken: String? = ios.pageToken() } -actual class File(val url: NSURL) +public actual class File(public val url: NSURL) -actual class Data(val data: NSData) +public actual class Data(public val data: NSData) -actual class FirebaseStorageException(message: String): FirebaseException(message) +public actual class FirebaseStorageException(message: String) : FirebaseException(message) internal suspend inline fun T.await(function: T.(callback: (NSError?) -> Unit) -> Unit) { val job = CompletableDeferred() function { error -> - if(error == null) { + if (error == null) { job.complete(Unit) } else { job.completeExceptionally(FirebaseStorageException(error.toString())) @@ -167,7 +166,7 @@ internal suspend inline fun T.await(function: T.(callback: (NSError?) -> Uni internal suspend inline fun T.awaitResult(function: T.(callback: (R?, NSError?) -> Unit) -> Unit): R { val job = CompletableDeferred() function { result, error -> - if(error == null) { + if (error == null) { job.complete(result) } else { job.completeExceptionally(FirebaseStorageException(error.toString())) @@ -203,4 +202,4 @@ internal fun FIRStorageMetadata.toFirebaseStorageMetadata(): FirebaseStorageMeta setCustomMetadata(it.key.toString(), it.value.toString()) } } -} \ No newline at end of file +} diff --git a/firebase-storage/src/iosTest/kotlin/dev/gitlive/firebase/storage/storage.ios.kt b/firebase-storage/src/iosTest/kotlin/dev/gitlive/firebase/storage/storage.ios.kt index b2da088d5..f7f974883 100644 --- a/firebase-storage/src/iosTest/kotlin/dev/gitlive/firebase/storage/storage.ios.kt +++ b/firebase-storage/src/iosTest/kotlin/dev/gitlive/firebase/storage/storage.ios.kt @@ -1,14 +1,7 @@ package dev.gitlive.firebase.storage import kotlinx.cinterop.BetaInteropApi -import kotlinx.cinterop.utf8 -import platform.Foundation.NSCoder -import platform.Foundation.NSData -import platform.Foundation.NSSearchPathDirectory -import platform.Foundation.NSSearchPathDomainMask -import platform.Foundation.NSSearchPathForDirectoriesInDomains import platform.Foundation.NSString -import platform.Foundation.NSURL import platform.Foundation.NSUTF8StringEncoding import platform.Foundation.create import platform.Foundation.dataUsingEncoding @@ -17,4 +10,4 @@ import platform.Foundation.dataUsingEncoding actual fun createTestData(): Data { val value = NSString.create(string = "test") return Data(value.dataUsingEncoding(NSUTF8StringEncoding, false)!!) -} \ No newline at end of file +} diff --git a/firebase-storage/src/jsMain/kotlin/dev/gitlive/firebase/storage/externals/storage.kt b/firebase-storage/src/jsMain/kotlin/dev/gitlive/firebase/storage/externals/storage.kt index b1a793d54..2cabf05ba 100644 --- a/firebase-storage/src/jsMain/kotlin/dev/gitlive/firebase/storage/externals/storage.kt +++ b/firebase-storage/src/jsMain/kotlin/dev/gitlive/firebase/storage/externals/storage.kt @@ -6,106 +6,105 @@ package dev.gitlive.firebase.storage.externals import dev.gitlive.firebase.externals.FirebaseApp import kotlin.js.Json import kotlin.js.Promise -import kotlin.js.collections.JsMap -external fun getStorage(app: FirebaseApp? = definedExternally, bucketUrl: String): FirebaseStorage +public external fun getStorage(app: FirebaseApp? = definedExternally, bucketUrl: String): FirebaseStorage -external fun getStorage(app: FirebaseApp? = definedExternally): FirebaseStorage +public external fun getStorage(app: FirebaseApp? = definedExternally): FirebaseStorage -external fun ref(storage: FirebaseStorage, url: String? = definedExternally): StorageReference -external fun ref(ref: StorageReference, path: String? = definedExternally): StorageReference +public external fun ref(storage: FirebaseStorage, url: String? = definedExternally): StorageReference +public external fun ref(ref: StorageReference, path: String? = definedExternally): StorageReference -external fun getDownloadURL(ref: StorageReference): Promise +public external fun getDownloadURL(ref: StorageReference): Promise -external fun getMetadata(ref: StorageReference): Promise -external fun updateMetadata(ref: StorageReference, metadata: SettableMetadata): Promise +public external fun getMetadata(ref: StorageReference): Promise +public external fun updateMetadata(ref: StorageReference, metadata: SettableMetadata): Promise -external fun uploadBytes(ref: StorageReference, file: dynamic, metadata: Json?): Promise -external fun uploadBytesResumable(ref: StorageReference, data: dynamic, metadata: Json?): UploadTask +public external fun uploadBytes(ref: StorageReference, file: dynamic, metadata: Json?): Promise +public external fun uploadBytesResumable(ref: StorageReference, data: dynamic, metadata: Json?): UploadTask -external fun deleteObject(ref: StorageReference): Promise +public external fun deleteObject(ref: StorageReference): Promise -external fun list(ref: StorageReference, options: ListOptions?): Promise -external fun listAll(ref: StorageReference): Promise +public external fun list(ref: StorageReference, options: ListOptions?): Promise +public external fun listAll(ref: StorageReference): Promise -external fun connectStorageEmulator( +public external fun connectStorageEmulator( storage: FirebaseStorage, host: String, port: Double, - options: Any? = definedExternally + options: Any? = definedExternally, ) -external interface FirebaseStorage { - var maxOperationRetryTime: Double - var maxUploadRetryTime: Double +public external interface FirebaseStorage { + public var maxOperationRetryTime: Double + public var maxUploadRetryTime: Double } -external interface StorageReference { - val bucket: String - val fullPath: String - val name: String - val parent: StorageReference? - val root: StorageReference - val storage: FirebaseStorage +public external interface StorageReference { + public val bucket: String + public val fullPath: String + public val name: String + public val parent: StorageReference? + public val root: StorageReference + public val storage: FirebaseStorage } -external interface ListOptions { - val maxResults: Double? - val pageToken: String? +public external interface ListOptions { + public val maxResults: Double? + public val pageToken: String? } -external interface ListResult { - val items: Array - val nextPageToken: String - val prefixes: Array +public external interface ListResult { + public val items: Array + public val nextPageToken: String + public val prefixes: Array } -external interface StorageError +public external interface StorageError -external interface SettableMetadata { - val cacheControl: String? - val contentDisposition: String? - val contentEncoding: String? - val contentLanguage: String? - val contentType: String? - val customMetadata: Json? +public external interface SettableMetadata { + public val cacheControl: String? + public val contentDisposition: String? + public val contentEncoding: String? + public val contentLanguage: String? + public val contentType: String? + public val customMetadata: Json? } -external interface UploadMetadata : SettableMetadata { - val md5Hash: String? +public external interface UploadMetadata : SettableMetadata { + public val md5Hash: String? } -external interface FullMetadata : UploadMetadata { - val bucket: String - val downloadTokens: Array? - val fullPath: String - val generation: String - val metageneration: String - val name: String - val ref: StorageReference? - val size: Double - val timeCreated: String - val updated: String +public external interface FullMetadata : UploadMetadata { + public val bucket: String + public val downloadTokens: Array? + public val fullPath: String + public val generation: String + public val metageneration: String + public val name: String + public val ref: StorageReference? + public val size: Double + public val timeCreated: String + public val updated: String } -external interface UploadResult { - val metadata: FullMetadata - val ref: StorageReference +public external interface UploadResult { + public val metadata: FullMetadata + public val ref: StorageReference } -external interface UploadTask { - fun cancel(): Boolean; - fun on(event: String, next: (snapshot: UploadTaskSnapshot) -> Unit, error: (a: StorageError) -> Unit, complete: () -> Unit): () -> Unit - fun pause(): Boolean; - fun resume(): Boolean; - fun then(onFulfilled: ((UploadTaskSnapshot) -> Unit)?, onRejected: ((StorageError) -> Unit)?): Promise - val snapshot: UploadTaskSnapshot +public external interface UploadTask { + public fun cancel(): Boolean + public fun on(event: String, next: (snapshot: UploadTaskSnapshot) -> Unit, error: (a: StorageError) -> Unit, complete: () -> Unit): () -> Unit + public fun pause(): Boolean + public fun resume(): Boolean + public fun then(onFulfilled: ((UploadTaskSnapshot) -> Unit)?, onRejected: ((StorageError) -> Unit)?): Promise + public val snapshot: UploadTaskSnapshot } -external interface UploadTaskSnapshot { - val bytesTransferred: Double - val ref: StorageReference - val state: String - val task: UploadTask - val totalBytes: Double -} \ No newline at end of file +public external interface UploadTaskSnapshot { + public val bytesTransferred: Double + public val ref: StorageReference + public val state: String + public val task: UploadTask + public val totalBytes: Double +} diff --git a/firebase-storage/src/jsMain/kotlin/dev/gitlive/firebase/storage/storage.kt b/firebase-storage/src/jsMain/kotlin/dev/gitlive/firebase/storage/storage.kt index 18430ca9e..8c1907b8e 100644 --- a/firebase-storage/src/jsMain/kotlin/dev/gitlive/firebase/storage/storage.kt +++ b/firebase-storage/src/jsMain/kotlin/dev/gitlive/firebase/storage/storage.kt @@ -17,67 +17,66 @@ import kotlinx.coroutines.flow.emitAll import kotlin.js.Json import kotlin.js.json -actual val Firebase.storage +public actual val Firebase.storage: FirebaseStorage get() = FirebaseStorage(getStorage()) -actual fun Firebase.storage(url: String): FirebaseStorage = FirebaseStorage(getStorage(null, url), ) +public actual fun Firebase.storage(url: String): FirebaseStorage = FirebaseStorage(getStorage(null, url)) -actual fun Firebase.storage(app: FirebaseApp) = FirebaseStorage(getStorage(app.js)) +public actual fun Firebase.storage(app: FirebaseApp): FirebaseStorage = FirebaseStorage(getStorage(app.js)) -actual fun Firebase.storage(app: FirebaseApp, url: String) = FirebaseStorage(getStorage(app.js, url)) +public actual fun Firebase.storage(app: FirebaseApp, url: String): FirebaseStorage = FirebaseStorage(getStorage(app.js, url)) -actual class FirebaseStorage(val js: dev.gitlive.firebase.storage.externals.FirebaseStorage) { - actual val maxOperationRetryTimeMillis = js.maxOperationRetryTime.toLong() - actual val maxUploadRetryTimeMillis = js.maxUploadRetryTime.toLong() +public actual class FirebaseStorage(public val js: dev.gitlive.firebase.storage.externals.FirebaseStorage) { + public actual val maxOperationRetryTimeMillis: Long = js.maxOperationRetryTime.toLong() + public actual val maxUploadRetryTimeMillis: Long = js.maxUploadRetryTime.toLong() - actual fun setMaxOperationRetryTimeMillis(maxOperationRetryTimeMillis: Long) { + public actual fun setMaxOperationRetryTimeMillis(maxOperationRetryTimeMillis: Long) { js.maxOperationRetryTime = maxOperationRetryTimeMillis.toDouble() } - actual fun setMaxUploadRetryTimeMillis(maxUploadRetryTimeMillis: Long) { + public actual fun setMaxUploadRetryTimeMillis(maxUploadRetryTimeMillis: Long) { js.maxUploadRetryTime = maxUploadRetryTimeMillis.toDouble() } - actual fun useEmulator(host: String, port: Int) { + public actual fun useEmulator(host: String, port: Int) { connectStorageEmulator(js, host, port.toDouble()) } - actual val reference: StorageReference get() = StorageReference(ref(js)) - - actual fun reference(location: String) = rethrow { StorageReference(ref(js, location)) } + public actual val reference: StorageReference get() = StorageReference(ref(js)) + public actual fun reference(location: String): StorageReference = rethrow { StorageReference(ref(js, location)) } } -actual class StorageReference(val js: dev.gitlive.firebase.storage.externals.StorageReference) { - actual val path: String get() = js.fullPath - actual val name: String get() = js.name - actual val bucket: String get() = js.bucket - actual val parent: StorageReference? get() = js.parent?.let { StorageReference(it) } - actual val root: StorageReference get() = StorageReference(js.root) - actual val storage: FirebaseStorage get() = FirebaseStorage(js.storage) +public actual class StorageReference(public val js: dev.gitlive.firebase.storage.externals.StorageReference) { + public actual val path: String get() = js.fullPath + public actual val name: String get() = js.name + public actual val bucket: String get() = js.bucket + public actual val parent: StorageReference? get() = js.parent?.let { StorageReference(it) } + public actual val root: StorageReference get() = StorageReference(js.root) + public actual val storage: FirebaseStorage get() = FirebaseStorage(js.storage) - actual suspend fun getMetadata(): FirebaseStorageMetadata? = rethrow { getMetadata(js).await().toFirebaseStorageMetadata() } + public actual suspend fun getMetadata(): FirebaseStorageMetadata? = rethrow { getMetadata(js).await().toFirebaseStorageMetadata() } - actual fun child(path: String): StorageReference = StorageReference(ref(js, path)) + public actual fun child(path: String): StorageReference = StorageReference(ref(js, path)) - actual suspend fun delete() = rethrow { deleteObject(js).await() } + public actual suspend fun delete(): Unit = rethrow { deleteObject(js).await() } - actual suspend fun getDownloadUrl(): String = rethrow { getDownloadURL(js).await().toString() } + public actual suspend fun getDownloadUrl(): String = rethrow { getDownloadURL(js).await().toString() } - actual suspend fun listAll(): ListResult = rethrow { ListResult(listAll(js).await()) } + public actual suspend fun listAll(): ListResult = rethrow { ListResult(listAll(js).await()) } - actual suspend fun putFile(file: File, metadata: FirebaseStorageMetadata?): Unit = rethrow { uploadBytes(js, file, metadata?.toStorageMetadata()).await() } + public actual suspend fun putFile(file: File, metadata: FirebaseStorageMetadata?): Unit = rethrow { uploadBytes(js, file, metadata?.toStorageMetadata()).await() } - actual suspend fun putData(data: Data, metadata: FirebaseStorageMetadata?): Unit = rethrow { uploadBytes(js, data.data, metadata?.toStorageMetadata()).await() } + public actual suspend fun putData(data: Data, metadata: FirebaseStorageMetadata?): Unit = rethrow { uploadBytes(js, data.data, metadata?.toStorageMetadata()).await() } - actual fun putFileResumable(file: File, metadata: FirebaseStorageMetadata?): ProgressFlow = rethrow { + public actual fun putFileResumable(file: File, metadata: FirebaseStorageMetadata?): ProgressFlow = rethrow { val uploadTask = uploadBytesResumable(js, file, metadata?.toStorageMetadata()) val flow = callbackFlow { val unsubscribe = uploadTask.on( "state_changed", { - when(it.state) { + when (it.state) { "paused" -> trySend(Progress.Paused(it.bytesTransferred, it.totalBytes)) "running" -> trySend(Progress.Running(it.bytesTransferred, it.totalBytes)) "canceled" -> cancel() @@ -86,7 +85,7 @@ actual class StorageReference(val js: dev.gitlive.firebase.storage.externals.Sto } }, { close(errorToException(it)) }, - { close() } + { close() }, ) awaitClose { unsubscribe() } } @@ -98,20 +97,18 @@ actual class StorageReference(val js: dev.gitlive.firebase.storage.externals.Sto override fun cancel() = uploadTask.cancel().run {} } } - } -actual class ListResult(js: dev.gitlive.firebase.storage.externals.ListResult) { - actual val prefixes: List = js.prefixes.map { StorageReference(it) } - actual val items: List = js.items.map { StorageReference(it) } - actual val pageToken: String? = js.nextPageToken +public actual class ListResult(js: dev.gitlive.firebase.storage.externals.ListResult) { + public actual val prefixes: List = js.prefixes.map { StorageReference(it) } + public actual val items: List = js.items.map { StorageReference(it) } + public actual val pageToken: String? = js.nextPageToken } -actual typealias File = org.w3c.files.File -actual class Data(val data: org.khronos.webgl.Uint8Array) +public actual typealias File = org.w3c.files.File +public actual class Data(public val data: org.khronos.webgl.Uint8Array) -actual open class FirebaseStorageException(code: String, cause: Throwable) : - FirebaseException(code, cause) +public actual open class FirebaseStorageException(code: String, cause: Throwable) : FirebaseException(code, cause) internal inline fun rethrow(function: () -> R): R { try { @@ -130,12 +127,11 @@ internal fun errorToException(error: dynamic) = (error?.code ?: error?.message ? when { else -> { println("Unknown error code in ${JSON.stringify(error)}") - FirebaseStorageException(code, error) + FirebaseStorageException(code, error as Throwable) } } } - internal fun UploadMetadata.toFirebaseStorageMetadata(): FirebaseStorageMetadata { val sdkMetadata = this return storageMetadata { @@ -161,5 +157,5 @@ internal fun FirebaseStorageMetadata.toStorageMetadata(): Json = json( "contentLanguage" to contentLanguage, "contentType" to contentType, "customMetadata" to json(*customMetadata.toList().toTypedArray()), - "md5Hash" to md5Hash -) \ No newline at end of file + "md5Hash" to md5Hash, +) diff --git a/firebase-storage/src/jsTest/kotlin/dev/gitlive/firebase/storage/storage.js.kt b/firebase-storage/src/jsTest/kotlin/dev/gitlive/firebase/storage/storage.js.kt index a3c6ff594..dbbe5fd82 100644 --- a/firebase-storage/src/jsTest/kotlin/dev/gitlive/firebase/storage/storage.js.kt +++ b/firebase-storage/src/jsTest/kotlin/dev/gitlive/firebase/storage/storage.js.kt @@ -2,4 +2,4 @@ package dev.gitlive.firebase.storage import org.khronos.webgl.Uint8Array -actual fun createTestData(): Data = Data(Uint8Array("test".encodeToByteArray().toTypedArray())) \ No newline at end of file +actual fun createTestData(): Data = Data(Uint8Array("test".encodeToByteArray().toTypedArray())) diff --git a/firebase-storage/src/jvmMain/kotlin/dev/gitlive/firebase/storage/storage.jvm.kt b/firebase-storage/src/jvmMain/kotlin/dev/gitlive/firebase/storage/storage.jvm.kt index 0c3829529..ac0c08868 100644 --- a/firebase-storage/src/jvmMain/kotlin/dev/gitlive/firebase/storage/storage.jvm.kt +++ b/firebase-storage/src/jvmMain/kotlin/dev/gitlive/firebase/storage/storage.jvm.kt @@ -5,93 +5,92 @@ import dev.gitlive.firebase.FirebaseApp import dev.gitlive.firebase.FirebaseException /** Returns the [FirebaseStorage] instance of the default [FirebaseApp]. */ -actual val Firebase.storage: FirebaseStorage +public actual val Firebase.storage: FirebaseStorage get() = TODO("Not yet implemented") -actual fun Firebase.storage(url: String): FirebaseStorage = TODO("Not yet implemented") +public actual fun Firebase.storage(url: String): FirebaseStorage = TODO("Not yet implemented") /** Returns the [FirebaseStorage] instance of a given [FirebaseApp]. */ -actual fun Firebase.storage(app: FirebaseApp): FirebaseStorage = TODO("Not yet implemented") +public actual fun Firebase.storage(app: FirebaseApp): FirebaseStorage = TODO("Not yet implemented") -actual fun Firebase.storage(app: FirebaseApp, url: String): FirebaseStorage = TODO("Not yet implemented") +public actual fun Firebase.storage(app: FirebaseApp, url: String): FirebaseStorage = TODO("Not yet implemented") -actual class FirebaseStorage { - actual val maxOperationRetryTimeMillis: Long +public actual class FirebaseStorage { + public actual val maxOperationRetryTimeMillis: Long get() = TODO("Not yet implemented") - actual val maxUploadRetryTimeMillis: Long + public actual val maxUploadRetryTimeMillis: Long get() = TODO("Not yet implemented") - actual fun setMaxOperationRetryTimeMillis(maxOperationRetryTimeMillis: Long) { + public actual fun setMaxOperationRetryTimeMillis(maxOperationRetryTimeMillis: Long) { } - actual fun setMaxUploadRetryTimeMillis(maxUploadRetryTimeMillis: Long) { + public actual fun setMaxUploadRetryTimeMillis(maxUploadRetryTimeMillis: Long) { } - actual fun useEmulator(host: String, port: Int) { + public actual fun useEmulator(host: String, port: Int) { } - actual val reference: StorageReference + public actual val reference: StorageReference get() = TODO("Not yet implemented") - actual fun reference(location: String): StorageReference { + public actual fun reference(location: String): StorageReference { TODO("Not yet implemented") } - } -actual class StorageReference { - actual val name: String +public actual class StorageReference { + public actual val name: String get() = TODO("Not yet implemented") - actual val path: String + public actual val path: String get() = TODO("Not yet implemented") - actual val bucket: String + public actual val bucket: String get() = TODO("Not yet implemented") - actual val parent: StorageReference? + public actual val parent: StorageReference? get() = TODO("Not yet implemented") - actual val root: StorageReference + public actual val root: StorageReference get() = TODO("Not yet implemented") - actual val storage: FirebaseStorage + public actual val storage: FirebaseStorage get() = TODO("Not yet implemented") - actual suspend fun getMetadata(): FirebaseStorageMetadata? { + public actual suspend fun getMetadata(): FirebaseStorageMetadata? { TODO("Not yet implemented") } - actual fun child(path: String): StorageReference { + public actual fun child(path: String): StorageReference { TODO("Not yet implemented") } - actual suspend fun delete() { + public actual suspend fun delete() { } - actual suspend fun getDownloadUrl(): String { + public actual suspend fun getDownloadUrl(): String { TODO("Not yet implemented") } - actual suspend fun listAll(): ListResult { + public actual suspend fun listAll(): ListResult { TODO("Not yet implemented") } - actual fun putFileResumable(file: File, metadata: FirebaseStorageMetadata?): ProgressFlow { + public actual fun putFileResumable(file: File, metadata: FirebaseStorageMetadata?): ProgressFlow { TODO("Not yet implemented") } - actual suspend fun putFile(file: File, metadata: FirebaseStorageMetadata?) { + public actual suspend fun putFile(file: File, metadata: FirebaseStorageMetadata?) { } - actual suspend fun putData(data: Data, metadata: FirebaseStorageMetadata?) { + public actual suspend fun putData(data: Data, metadata: FirebaseStorageMetadata?) { } } -actual class ListResult { - actual val prefixes: List +public actual class ListResult { + public actual val prefixes: List get() = TODO("Not yet implemented") - actual val items: List + public actual val items: List get() = TODO("Not yet implemented") - actual val pageToken: String? + public actual val pageToken: String? get() = TODO("Not yet implemented") } -actual class File -actual class FirebaseStorageException internal constructor(message: String) : FirebaseException(message) -actual class Data \ No newline at end of file +public actual class File +public actual class FirebaseStorageException internal constructor(message: String) : FirebaseException(message) +public actual class Data diff --git a/firebase-storage/src/jvmTest/kotlin/dev/gitlive/firebase/storage/storage.kt b/firebase-storage/src/jvmTest/kotlin/dev/gitlive/firebase/storage/storage.kt index 022903848..b7d065854 100644 --- a/firebase-storage/src/jvmTest/kotlin/dev/gitlive/firebase/storage/storage.kt +++ b/firebase-storage/src/jvmTest/kotlin/dev/gitlive/firebase/storage/storage.kt @@ -3,6 +3,7 @@ */ @file:JvmName("tests") + package dev.gitlive.firebase.storage import dev.gitlive.firebase.testContext diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 3fa86e861..7e3cb088b 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,8 +1,8 @@ [versions] agp = "8.2.2" -androidx-test-core = "1.5.0" -androidx-test-junit = "1.1.5" -androidx-test-runner = "1.5.2" +androidx-test-core = "1.6.0" +androidx-test-junit = "1.2.0" +androidx-test-runner = "1.6.0" ben-manes-versions = "0.51.0" firebase-bom = "33.1.1" gitlive-firebase-java-sdk = "0.4.3" @@ -11,6 +11,8 @@ junit = "4.13.2" kotlin = "2.0.0" kotlinx-coroutines = "1.9.0-RC" kotlinx-serialization = "1.7.0" +kotlinx-binarycompatibilityvalidator = "0.15.0-Beta.2" +kotlinter = "4.4.0" settings-api = "2.0" settings-language = "2.0" firebase-cocoapods = "10.28.0" @@ -49,7 +51,9 @@ dokka-base = { module = "org.jetbrains.dokka:dokka-base", version.ref = "dokka" android-application = { id = "com.android.application", version.ref = "agp" } ben-manes-versions = { id = "com.github.ben-manes.versions", version.ref = "ben-manes-versions" } kotlinx-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" } +kotlinx-binarycompatibilityvalidator = { id = "org.jetbrains.kotlinx.binary-compatibility-validator", version.ref = "kotlinx-binarycompatibilityvalidator" } multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" } native-cocoapods = { id = "org.jetbrains.kotlin.native.cocoapods", version.ref = "kotlin" } test-logger-plugin = { id = "com.adarshr.test-logger", version.ref = "test-logger-plugin" } dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" } +kotlinter = { id = "org.jmailen.kotlinter", version.ref = "kotlinter" } diff --git a/test-utils/api/android/test-utils.api b/test-utils/api/android/test-utils.api new file mode 100644 index 000000000..470377a53 --- /dev/null +++ b/test-utils/api/android/test-utils.api @@ -0,0 +1,8 @@ +public final class dev/gitlive/firebase/TestUtilsAndroid { + public static final fun nativeAssertEquals (Ljava/lang/Object;Ljava/lang/Object;)V + public static final fun nativeListOf ([Ljava/lang/Object;)Ljava/lang/Object; + public static final fun nativeMapOf ([Lkotlin/Pair;)Ljava/lang/Object; + public static final fun runBlockingTest (Lkotlin/jvm/functions/Function2;)V + public static final fun runTest (Lkotlin/jvm/functions/Function2;)V +} + diff --git a/test-utils/api/jvm/test-utils.api b/test-utils/api/jvm/test-utils.api new file mode 100644 index 000000000..cdab425c2 --- /dev/null +++ b/test-utils/api/jvm/test-utils.api @@ -0,0 +1,9 @@ +public final class dev/gitlive/firebase/TestUtilsJvm { + public static final fun getTestContext ()Landroid/app/Application; + public static final fun nativeAssertEquals (Ljava/lang/Object;Ljava/lang/Object;)V + public static final fun nativeListOf ([Ljava/lang/Object;)Ljava/lang/Object; + public static final fun nativeMapOf ([Lkotlin/Pair;)Ljava/lang/Object; + public static final fun runBlockingTest (Lkotlin/jvm/functions/Function2;)V + public static final fun runTest (Lkotlin/jvm/functions/Function2;)V +} + diff --git a/test-utils/src/commonMain/kotlin/dev/gitlive/firebase/TestUtils.kt b/test-utils/src/commonMain/kotlin/dev/gitlive/firebase/TestUtils.kt index cfddc6de9..99daabbf2 100644 --- a/test-utils/src/commonMain/kotlin/dev/gitlive/firebase/TestUtils.kt +++ b/test-utils/src/commonMain/kotlin/dev/gitlive/firebase/TestUtils.kt @@ -6,7 +6,6 @@ package dev.gitlive.firebase import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.test.TestResult -import kotlin.jvm.JvmName expect fun runTest(test: suspend CoroutineScope.() -> Unit): TestResult expect fun runBlockingTest(action: suspend CoroutineScope.() -> Unit) diff --git a/test-utils/src/iosMain/kotlin/dev/gitlive/firebase/TestUtils.kt b/test-utils/src/iosMain/kotlin/dev/gitlive/firebase/TestUtils.kt index ca7ee4a54..1bd12ad92 100644 --- a/test-utils/src/iosMain/kotlin/dev/gitlive/firebase/TestUtils.kt +++ b/test-utils/src/iosMain/kotlin/dev/gitlive/firebase/TestUtils.kt @@ -20,7 +20,7 @@ actual fun runTest(test: suspend CoroutineScope.() -> Unit) = runBlocking { while (testRun.isActive) { NSRunLoop.mainRunLoop.runMode( NSDefaultRunLoopMode, - beforeDate = NSDate.create(timeInterval = 1.0, sinceDate = NSDate()) + beforeDate = NSDate.create(timeInterval = 1.0, sinceDate = NSDate()), ) yield() } diff --git a/test-utils/src/jvmMain/kotlin/dev/gitlive/firebase/TestUtils.kt b/test-utils/src/jvmMain/kotlin/dev/gitlive/firebase/TestUtils.kt index 56ff3e31f..2658e6336 100644 --- a/test-utils/src/jvmMain/kotlin/dev/gitlive/firebase/TestUtils.kt +++ b/test-utils/src/jvmMain/kotlin/dev/gitlive/firebase/TestUtils.kt @@ -16,7 +16,9 @@ val testContext = Application().apply { val storage = mutableMapOf() override fun store(key: String, value: String) = storage.set(key, value) override fun retrieve(key: String) = storage[key] - override fun clear(key: String) { storage.remove(key) } + override fun clear(key: String) { + storage.remove(key) + } override fun log(msg: String) = println(msg) }) } @@ -28,4 +30,4 @@ actual fun nativeMapOf(vararg pairs: Pair): Any = mapOf(*pairs) actual fun nativeListOf(vararg elements: Any?): Any = listOf(*elements) actual fun nativeAssertEquals(expected: Any?, actual: Any?) { kotlin.test.assertEquals(expected, actual) -} \ No newline at end of file +}