diff --git a/packages/admob/lib/index.js.flow b/packages/admob/lib/index.js.flow deleted file mode 100644 index ecf94c6a01..0000000000 --- a/packages/admob/lib/index.js.flow +++ /dev/null @@ -1,68 +0,0 @@ -/* eslint-disable import/no-duplicates */ -/* - * Copyright (c) 2016-present Invertase Limited & Contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this library except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -import type { ReactNativeFirebaseModule } from '@react-native-firebase/app-types/index.js.flow'; - -export interface Statics {} - -export interface Module extends ReactNativeFirebaseModule {} - -declare module '@react-native-firebase/admob' { - import type { - ReactNativeFirebaseNamespace, - ReactNativeFirebaseModuleAndStatics, - } from '@react-native-firebase/app-types/index.js.flow'; - /** - * @example - * ```js - * import { firebase } from '@react-native-firebase/admob'; - * firebase.admob().X(...); - * ``` - */ - declare export var firebase: {} & ReactNativeFirebaseNamespace; - - /** - * @example - * ```js - * import admob from '@react-native-firebase/admob'; - * admob().X(...); - * ``` - */ - declare export default ReactNativeFirebaseModuleAndStatics; -} - -/** - * Attach namespace to `firebase.` and `FirebaseApp.`. - */ -declare module '@react-native-firebase/app-types' { - import type { ReactNativeFirebaseModuleAndStatics } from '@react-native-firebase/app-types/index.js.flow'; - - declare interface ReactNativeFirebaseNamespace { - /** - * Admob - */ - admob: ReactNativeFirebaseModuleAndStatics; - } - - declare interface FirebaseApp { - /** - * Admob - */ - admob(): Module; - } -} diff --git a/packages/analytics/lib/index.js.flow b/packages/analytics/lib/index.js.flow deleted file mode 100644 index cae27139a2..0000000000 --- a/packages/analytics/lib/index.js.flow +++ /dev/null @@ -1,1350 +0,0 @@ -/* eslint-disable import/no-duplicates */ -/* - * Copyright (c) 2016-present Invertase Limited & Contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this library except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -import type { ReactNativeFirebaseModule } from '@react-native-firebase/app-types/index.js.flow'; - -export interface Statics {} - -export interface AddToCartEventParameters { - /** - * An item ID. - */ - item_id: string; - /** - * An item name. - */ - item_name: string; - /** - * An item category. - */ - item_category: string; - /** - * Purchase quantity. - */ - quantity: number; - /** - * Purchase price. - */ - price?: number; - /** - * A context-specific numeric value which is accumulated automatically for each event type. Values - * can include revenue, distance, time and points. When a value is set, the accompanying `currency` - * parameter should also be defined. - */ - value?: number; - /** - * Purchase currency in 3 letter [ISO_4217](https://en.wikipedia.org/wiki/ISO_4217#Active_codes) format. E.g. `USD`. - */ - currency?: string; - /** - * Flight or Travel origin. E.g. `Mountain View, CA`. - */ - origin?: string; - /** - * The Google [Place ID](https://developers.google.com/places/place-id) that corresponds to the associated item (String). Alternatively, you can supply your own custom Location ID. - */ - item_location_id?: string; - /** - * Flight or Travel destination. E.g. `Mountain View, CA`. - */ - destination?: string; - /** - * The departure date, check-in date, or rental start date for the item (String). The parameter expects a date formatted as YYYY-MM-DD. - */ - start_date?: string; - /** - * The arrival date, check-out date, or rental end date for the item (String). The parameter expects a date formatted as YYYY-MM-DD. - */ - end_date?: string; -} - -export interface AddToWishlistEventParameters { - /** - * An item ID. - */ - item_id: string; - /** - * An item name. - */ - item_name: string; - /** - * An item category. - */ - item_category: string; - /** - * Purchase quantity. - */ - quantity: number; - /** - * Purchase price. - */ - price?: number; - /** - * A context-specific numeric value which is accumulated automatically for each event type. Values - * can include revenue, distance, time and points. When a value is set, the accompanying `currency` - * parameter should also be defined. - */ - value?: number; - /** - * Purchase currency in 3 letter [ISO_4217](https://en.wikipedia.org/wiki/ISO_4217#Active_codes) format. E.g. `USD`. - */ - currency?: string; - /** - * The Google [Place ID](https://developers.google.com/places/place-id) that corresponds to the associated item (String). Alternatively, you can supply your own custom Location ID. - */ - item_location_id?: string; -} - -export interface BeginCheckoutEventParameters { - /** - * A context-specific numeric value which is accumulated automatically for each event type. Values - * can include revenue, distance, time and points. When a value is set, the accompanying `currency` - * parameter should also be defined. - */ - value?: number; - /** - * Purchase currency in 3 letter [ISO_4217](https://en.wikipedia.org/wiki/ISO_4217#Active_codes) format. E.g. `USD`. - */ - currency?: string; - /** - * A single ID for a ecommerce group transaction. - */ - transaction_id?: string; - /** - * Number of nights staying at hotel. - */ - number_of_nights?: number; - /** - * Number of rooms for travel events. - */ - number_of_rooms?: number; - /** - * Number of passengers traveling. - */ - number_of_passengers?: number; - /** - * Flight or Travel origin. E.g. `Mountain View, CA`. - */ - origin?: string; - /** - * Flight or Travel destination. E.g. `Mountain View, CA`. - */ - destination?: string; - /** - * The departure date, check-in date, or rental start date for the item (String). The parameter expects a date formatted as YYYY-MM-DD. - */ - start_date?: string; - /** - * The arrival date, check-out date, or rental end date for the item (String). The parameter expects a date formatted as YYYY-MM-DD. - */ - end_date?: string; - /** - * Travel class. E.g. `business`. - */ - travel_class?: string; -} - -export interface CampaignDetailsEventParameters { - /** - * Used to identify a search engine, newsletter, or other source. - */ - source: string; - /** - * Used to identify a medium such as email or cost-per-click (cpc). - */ - medium: string; - /** - * Used for keyword analysis to identify a specific product promotion or strategic campaign. - */ - campaign: string; - /** - * Used with paid search to supply the keywords for ads. - */ - term?: string; - /** - * Used for A/B testing and content-targeted ads to differentiate ads or links that point to the same URL. - */ - content?: string; - /** - * A campaign detail click ID. - */ - aclid?: string; - cp1?: string; -} - -export interface EarnVirtualCurrencyEventParameters { - /** - * Name of virtual currency type. E.g. `gems`. - */ - virtual_currency_name: string; - /** - * A context-specific numeric value which is accumulated automatically for each event type. Values - * can include revenue, distance, time and points. - */ - value: number; -} - -export interface EcommercePurchaseEventParameters { - /** - * Purchase currency in 3 letter [ISO_4217](https://en.wikipedia.org/wiki/ISO_4217#Active_codes) format. E.g. `USD`. - */ - currency?: string; - /** - * A context-specific numeric value which is accumulated automatically for each event type. Values - * can include revenue, distance, time and points. When a value is set, the accompanying `currency` - * parameter should also be defined. - */ - value?: number; - /** - * A single ID for a ecommerce group transaction. - */ - transaction_id?: string; - /** - * Tax amount. - */ - tax?: number; - /** - * Shipping cost. - */ - shipping?: number; - /** - * Coupon code for a purchasable item. - */ - coupon?: string; - /** - * The Google [Place ID](https://developers.google.com/places/place-id) that corresponds to the associated event. Alternatively, you can supply your own custom Location ID. - */ - location?: string; - /** - * Number of nights staying at hotel. - */ - number_of_nights?: number; - /** - * Number of rooms for travel events. - */ - number_of_rooms?: number; - /** - * Number of passengers traveling. - */ - number_of_passengers?: number; - /** - * Flight or Travel origin. E.g. `Mountain View, CA`. - */ - origin?: string; - /** - * Flight or Travel destination. E.g. `Mountain View, CA`. - */ - destination?: string; - /** - * The departure date, check-in date, or rental start date for the item (String). The parameter expects a date formatted as YYYY-MM-DD. - */ - start_date?: string; - /** - * The arrival date, check-out date, or rental end date for the item (String). The parameter expects a date formatted as YYYY-MM-DD. - */ - end_date?: string; - /** - * Travel class. E.g. `business`. - */ - travel_class?: string; -} - -export interface GenerateLeadEventParameters { - /** - * Purchase currency in 3 letter [ISO_4217](https://en.wikipedia.org/wiki/ISO_4217#Active_codes) format. E.g. `USD`. - */ - currency?: string; - /** - * A context-specific numeric value which is accumulated automatically for each event type. Values - * can include revenue, distance, time and points. When a value is set, the accompanying `currency` - * parameter should also be defined. - */ - value?: number; -} - -export interface JoinGroupEventParameters { - /** - * Group/clan/guild id. - */ - group_id: string; -} - -export interface LevelEndEventParameters { - /** - * Level in game. - */ - level: number; - /** - * The result of an operation. - */ - success?: string; -} - -export interface LevelStartEventParameters { - /** - * Level in game. - */ - level: number; -} - -export interface LevelUpEventParameters { - /** - * Level in game. - */ - level: number; - /** - * Character used in game. - */ - character?: string; -} - -export interface LoginEventParameters { - /** - * The login method. E.g. `facebook.com`. - */ - method: string; -} - -export interface PostScoreEventParameters { - /** - * Score in game. - */ - score: int; - /** - * Level in game. - */ - level?: int; - /** - * Character used in game. - */ - character?: string; -} - -export interface PresentOfferEventParameters { - /** - * Score in game. - */ - score: int; - /** - * Level in game. - */ - level?: int; - /** - * Character used in game. - */ - character?: string; -} - -export interface PurchaseRefundEventParameters { - /** - * Purchase currency in 3 letter [ISO_4217](https://en.wikipedia.org/wiki/ISO_4217#Active_codes) format. E.g. `USD`. - */ - currency?: string; - /** - * A context-specific numeric value which is accumulated automatically for each event type. Values - * can include revenue, distance, time and points. When a value is set, the accompanying `currency` - * parameter should also be defined. - */ - value?: number; - /** - * A single ID for a ecommerce group transaction. - */ - transaction_id?: string; -} - -export interface RemoveFromCartEventParameters { - /** - * An item ID. - */ - item_id: string; - /** - * An item name. - */ - item_name: string; - /** - * An item category. - */ - item_category: string; - /** - * Purchase quantity. - */ - quantity?: number; - /** - * A context-specific numeric value which is accumulated automatically for each event type. Values - * can include revenue, distance, time and points. When a value is set, the accompanying `currency` - * parameter should also be defined. - */ - value?: number; - /** - * Purchase price. - */ - price?: number; - /** - * Purchase currency in 3 letter [ISO_4217](https://en.wikipedia.org/wiki/ISO_4217#Active_codes) format. E.g. `USD`. - */ - currency?: string; - /** - * The Google [Place ID](https://developers.google.com/places/place-id) that corresponds to the associated item (String). Alternatively, you can supply your own custom Location ID. - */ - item_location_id?: string; - /** - * The departure date, check-in date, or rental start date for the item (String). The parameter expects a date formatted as YYYY-MM-DD. - */ - start_date?: string; - /** - * The arrival date, check-out date, or rental end date for the item (String). The parameter expects a date formatted as YYYY-MM-DD. - */ - end_date?: string; - /** - * Flight or Travel origin. E.g. `Mountain View, CA`. - */ - origin?: string; - /** - * Flight or Travel destination. E.g. `Mountain View, CA`. - */ - destination?: string; -} - -export interface SearchEventParameters { - search_term: string; - /** - * Number of nights staying at hotel. - */ - number_of_nights?: number; - /** - * Number of rooms for travel events. - */ - number_of_rooms?: number; - /** - * Number of passengers traveling. - */ - number_of_passengers?: number; - /** - * Flight or Travel origin. E.g. `Mountain View, CA`. - */ - origin?: string; - /** - * Flight or Travel destination. E.g. `Mountain View, CA`. - */ - destination?: string; - /** - * The departure date, check-in date, or rental start date for the item (String). The parameter expects a date formatted as YYYY-MM-DD. - */ - start_date?: string; - /** - * The arrival date, check-out date, or rental end date for the item (String). The parameter expects a date formatted as YYYY-MM-DD. - */ - end_date?: string; - /** - * Travel class. E.g. `business`. - */ - travel_class?: string; -} - -export interface SelectContentEventParameters { - content_type: string; - /** - * An item ID. - */ - item_id: string; -} - -export interface SetCheckoutOptionEventParameters { - /** - * The checkout step (1..N). - */ - checkout_step: number; - /** - * Some option on a step in an ecommerce flow. - */ - checkout_option: string; -} - -export interface ShareEventParameters { - /** - * Type of content selected. - */ - content_type: string; - /** - * An item ID. - */ - item_id: string; -} - -export interface SignUpEventParameters { - /** - * A particular approach used in an operation; for example, "facebook" or "email" in the context of a sign_up or login event. - */ - method: string; -} - -export interface SpendVirtualCurrencyEventParameters { - /** - * An item name. - */ - item_name: string; - /** - * Name of virtual currency type. E.g. `gems`. - */ - virtual_currency_name: string; - /** - * A context-specific numeric value which is accumulated automatically for each event type. Values - * can include revenue, distance, time and points. When a value is set, the accompanying `currency` - * parameter should also be defined. - */ - value: number; -} - -export interface UnlockAchievementEventParameters { - /** - * Game achievement ID (String). - */ - achievement_id: string; -} - -export interface ViewItemEventParameters { - /** - * An item ID. - */ - item_id: string; - /** - * An item name. - */ - item_name: string; - /** - * An item category. - */ - item_category: string; - /** - * The Google [Place ID](https://developers.google.com/places/place-id) that corresponds to the associated item (String). Alternatively, you can supply your own custom Location ID. - */ - item_location_id?: string; - /** - * Purchase price. - */ - price?: number; - /** - * Purchase quantity. - */ - quantity?: number; - /** - * Purchase currency in 3 letter [ISO_4217](https://en.wikipedia.org/wiki/ISO_4217#Active_codes) format. E.g. `USD`. - */ - currency?: string; - /** - * A context-specific numeric value which is accumulated automatically for each event type. Values - * can include revenue, distance, time and points. When a value is set, the accompanying `currency` - * parameter should also be defined. - */ - value?: number; - /** - * Flight number for travel events. - */ - flight_number?: string; - /** - * Number of passengers traveling. - */ - number_of_passengers?: number; - /** - * Number of nights staying at hotel. - */ - number_of_nights?: number; - /** - * Number of rooms for travel events. - */ - number_of_rooms?: number; - /** - * Flight or Travel origin. E.g. `Mountain View, CA`. - */ - origin?: string; - /** - * Flight or Travel destination. E.g. `Mountain View, CA`. - */ - destination?: string; - /** - * The departure date, check-in date, or rental start date for the item (String). The parameter expects a date formatted as YYYY-MM-DD. - */ - start_date?: string; - /** - * The arrival date, check-out date, or rental end date for the item (String). The parameter expects a date formatted as YYYY-MM-DD. - */ - end_date?: string; - /** - * The search string/keywords used. - */ - search_term?: string; - /** - * Travel class. E.g. `business`. - */ - travel_class?: string; -} - -export interface ViewItemListEventParameters { - /** - * An item category. - */ - item_category: string; -} - -export interface ViewSearchResults { - /** - * The search string/keywords used. - */ - search_term: string; -} - -export interface Module extends ReactNativeFirebaseModule { - /** - * Log a custom event with optional params. - * - * #### Example - * - * ```js - * await firebase.analytics().logEvent('product_view', { - * id: '1234', - * }); - * ``` - * - * @param name Event name must not conflict with any Reserved Events. 100 characters is the maximum length for param key names. - * @param params Parameters to be sent and displayed with the event. - */ - logEvent(name: string, params?: { [key: string]: any }): Promise; - - /** - * If true, allows the device to collect analytical data and send it to Firebase. - * Useful for GDPR. - * - * #### Example - * - * ```js - * // Disable collection - * await firebase.analytics().setAnalyticsCollectionEnabled(false); - * ``` - * - * @param enabled A boolean value representing whether Analytics collection is enabled or disabled. Analytics collection is enabled by default. - */ - setAnalyticsCollectionEnabled(enabled: boolean): Promise; - - /** - * Sets the current screen name. - * - * #### Example - * - * ```js - * await firebase.analytics().setCurrentScreen('ProductScreen', 'ProductScreen'); - * ``` - * - * > Whilst screenClassOverride is optional, it is recommended it is - * always sent as your current class name. For example on Android it will always - * show as 'MainActivity' if you do not specify it. - * - * @param screenName A screen name, e.g. Product. - * @param screenClassOverride On Android, React Native runs in a single activity called - * 'MainActivity'. Setting this parameter overrides the default name shown on logs. - */ - setCurrentScreen(screenName: string, screenClassOverride?: string): Promise; - - /** - * Sets the minimum engagement time required before starting a session. - * - * #### Example - * - * ```js - * // 20 seconds - * await firebase.analytics().setMinimumSessionDuration(20000); - * ``` - * - * @param milliseconds The default value is 10000 (10 seconds). - */ - setMinimumSessionDuration(milliseconds: number): Promise; - - /** - * Sets the duration of inactivity that terminates the current session. - * - * #### Example - * - * ```js - * // 20 minutes - * await firebase.analytics().setMinimumSessionDuration(900000); - * ``` - * - * @param milliseconds The default value is 1800000 (30 minutes). - */ - setSessionTimeoutDuration(milliseconds: number): Promise; - - /** - * Gives a user a unique identification. - * - * #### Example - * - * ```js - * // Set User - * await firebase.analytics().setUserId('123456789'); - * // Remove User - * await firebase.analytics().setUserId(null); - * ``` - * - * @param id Set to null to remove a previously assigned id from analytics events - */ - setUserId(id: string | null): Promise; - - /** - * Sets a key/value pair of data on the current user. - * - * #### Example - * - * ```js - * await firebase.analytics().setUserProperty('account_type', 'gold'); - * ``` - * - * @param name A user property identifier. - * @param value Set to null to remove a previously assigned id from analytics events. - */ - setUserProperty(name: string, value: string | null): Promise; - - /** - * Sets multiple key/value pair of data on the current user. - * - * #### Example - * - * ```js - * await firebase.analytics().setUserProperties({ - * account_type: 'gold', - * account_name: 'Gold Badge', - * }); - * ``` - * - * @react-native-firebase - * @param properties Set a property value to null to remove it. - */ - setUserProperties(properties: { [key: string]: string | null }): Promise; - - /** - * Clears all analytics data for this instance from the device and resets the app instance ID. - * - * #### Example - * - * ```js - * await firebase.analytics().resetAnalyticsData(); - * ``` - */ - resetAnalyticsData(): Promise; - - /** - * Add Payment Info event. This event signifies that a user has submitted their payment information to your app. - * - * Via: `add_payment_info` - * - * #### Example - * - * ```js - * await firebase.analytics().logAddPaymentInfo(); - * ``` - */ - logAddPaymentInfo(): Promise; - - /** - * E-Commerce Add To Cart event. This event signifies that an item was added to a cart for purchase. - * Add this event to a funnel with {@link analytics#logEcommercePurchase} to gauge the effectiveness of your checkout process. - * - * If you supply the VALUE parameter, you must also supply the CURRENCY parameter so that revenue metrics can be computed accurately. - * - * Via: `add_to_cart` - * - * #### Example - * - * ```js - * await firebase.analytics().logAddToCart({ - * item_id: 'abcd', - * item_name: 't-shirt 1', - * item_category: 'shirts', - * quantity: 2, - * }); - * ``` - * - * @param params See {@link analytics.AddToCartEventParameters}. - */ - logAddToCart(params: AddToCartEventParameters): Promise; - - /** - * E-Commerce Add To Wishlist event. This event signifies that an item was added to a wishlist. - * Use this event to identify popular gift items in your app. - * - * If you supply the `value` parameter, you must also supply the `currency` parameter so that revenue metrics can be computed accurately. - * - * Via: `add_to_wishlist` - * - * #### Example - * - * ```js - * await firebase.analytics().logAddToWishlist({ - * item_id: 'abcd', - * item_name: 't-shirt 1', - * item_category: 'shirts', - * quantity: 2, - * }); - * ``` - * - * @param params See {@link analytics.AddToWishlistEventParameters}. - */ - logAddToWishlist(params: AddToWishlistEventParameters): Promise; - - /** - * App Open event. By logging this event when an App is moved to the foreground, developers can - * understand how often users leave and return during the course of a Session. Although Sessions - * are automatically reported, this event can provide further clarification around the continuous - * engagement of app-users. - * - * Via: `app_open` - * - * #### Example - * - * ```js - * await firebase.analytics().logAppOpen(); - * ``` - */ - logAppOpen(): Promise; - - /** - * E-Commerce Begin Checkout event. This event signifies that a user has begun the process of - * checking out. Add this event to a funnel with your {@link analytics#logEcommercePurchase} event to gauge the - * effectiveness of your checkout process. - * - * If you supply the `value` parameter, you must also supply the `currency` parameter so that revenue metrics can be computed accurately. - * - * Via: `begin_checkout` - * - * #### Example - * - * ```js - * await firebase.analytics().logBeginCheckout({ - * travel_class: 'business', - * }); - * ``` - * - * @param params See {@link analytics.BeginCheckoutEventParameters}. - */ - logBeginCheckout(params?: BeginCheckoutEventParameters): Promise; - - /** - * Log this event to supply the referral details of a re-engagement campaign. - * - * Via: `campaign_details` - * - * #### Example - * - * ```js - * await firebase.analytics().logCampaignDetails({ - * source: 'email', - * medium: 'cta_button', - * campaign: 'newsletter', - * }); - * ``` - * - * @param params See {@link analytics.CampaignDetailsEventParameters}. - */ - logCampaignDetails(params: CampaignDetailsEventParameters): Promise; - - /** - * Earn Virtual Currency event. This event tracks the awarding of virtual currency in your app. Log this along with - * {@link analytics.logSpendVirtualCurrency} to better understand your virtual economy. - * - * Via: `earn_virtual_currency` - * - * #### Example - * - * ```js - * await firebase.analytics().logEarnVirtualCurrency({ - * virtual_currency_name: 'coins', - * value: 100, - * }); - * ``` - * - * @param params See {@link analytics.EarnVirtualCurrencyEventParameters}. - */ - logEarnVirtualCurrency(params: EarnVirtualCurrencyEventParameters): Promise; - - /** - * E-Commerce Purchase event. This event signifies that an item was purchased by a user. This is - * different from the in-app purchase event, which is reported automatically for Google Play-based apps. - * - * If you supply the `value` parameter, you must also supply the `currency` parameter so that revenue metrics can be computed accurately. - * - * Via: `ecommerce_purchase` - * - * #### Example - * - * ```js - * await firebase.analytics().logEcommercePurchase({ - * coupon: 'BOGOFF', - * }); - * ``` - * - * @param params See {@link analytics.EcommercePurchaseEventParameters}. - */ - logEcommercePurchase(params?: EcommercePurchaseEventParameters): Promise; - - /** - * Generate Lead event. Log this event when a lead has been generated in the app to understand - * the efficacy of your install and re-engagement campaigns. - * - * If you supply the `value` parameter, you must also supply the `currency` parameter so that revenue metrics can be computed accurately. - * - * Via: `generate_lead` - * - * #### Example - * - * ```js - * await firebase.analytics().logGenerateLead({ - * currency: 'USD', - * value: 123, - * }); - * ``` - * - * @param params See {@link analytics.GenerateLeadEventParameters}. - */ - logGenerateLead(params?: GenerateLeadEventParameters): Promise; - - /** - * Join Group event. Log this event when a user joins a group such as a guild, team or family. - * Use this event to analyze how popular certain groups or social features are in your app - * - * Via: `join_group` - * - * #### Example - * - * ```js - * await firebase.analytics().logJoinGroup({ - * group_id: '12345', - * }); - * ``` - * - * @param params See {@link analytics.JoinGroupEventParameters}. - */ - logJoinGroup(params: JoinGroupEventParameters): Promise; - - /** - * Level End event. - * - * Via: `level_end` - * - * #### Example - * - * ```js - * await firebase.analytics().logLevelEnd({ - * level: 12, - * success: 'true' - * }); - * ``` - * - * @param params See {@link analytics.LevelEndEventParameters}. - */ - logLevelEnd(params: LevelEndEventParameters): Promise; - - /** - * Level Start event. - * - * Via: `level_start` - * - * #### Example - * - * ```js - * await firebase.analytics().logLevelStart({ - * level: 12, - * }); - * ``` - * - * @param params See {@link analytics.LevelStartEventParameters}. - */ - logLevelStart(params: LevelStartEventParameters): Promise; - - /** - * Level Up event. This event signifies that a player has leveled up in your gaming app. - * It can help you gauge the level distribution of your userbase and help you identify certain levels that are difficult to pass. - * - * Via: `level_up` - * - * #### Example - * - * ```js - * await firebase.analytics().logLevelUp({ - * level: 12, - * character: 'Snake', - * }); - * ``` - * - * @param params See {@link analytics.LevelUpEventParameters}. - */ - logLevelUp(params: LevelUpEventParameters): Promise; - - /** - * Login event. Apps with a login feature can report this event to signify that a user has logged in. - * - * Via: `login` - * - * #### Example - * - * ```js - * await firebase.analytics().logLogin({ - * method: 'facebook.com', - * }); - * ``` - * - * @param params See {@link analytics.LoginEventParameters}. - */ - logLogin(params: LoginEventParameters): Promise; - - /** - * Present Offer event. This event signifies that the app has presented a purchase offer to a user. - * Add this event to a funnel with the {@link analytics#logAddToCart} and {@link analytics#logEcommercePurchase} - * to gauge your conversion process. - * - * If you supply the `value` parameter, you must also supply the `currency` parameter so that revenue metrics can be computed accurately. - * - * Via: `present_offer` - * - * #### Example - * - * ```js - * await firebase.analytics().logPresentOffer({ - * item_id: 'abcd', - * item_name: 't-shirt', - * item_category: 'shirts', - * quantity: 1, - * price: 9.99, - * }); - * ``` - * - * @param params See {@link analytics.PresentOfferEventParameters}. - */ - logPresentOffer(params: PresentOfferEventParameters): Promise; - - /** - * E-Commerce Purchase Refund event. This event signifies that an item purchase was refunded. - * - * If you supply the `value` parameter, you must also supply the `currency` parameter so that revenue metrics can be computed accurately. - * - * Via: `purchase_refund` - * - * #### Example - * - * ```js - * await firebase.analytics().logPurchaseRefund({ - * transaction_id: 'abcd', - * }); - * ``` - * - * @param params See {@link analytics.PurchaseRefundEventParameters}. - */ - logPurchaseRefund(params?: PurchaseRefundEventParameters): Promise; - - /** - * Remove from cart event. - * - * Via: `remove_from_cart` - * - * #### Example - * - * ```js - * await firebase.analytics().logRemoveFromCart({ - * item_id: 'abcd', - * item_name: 't-shirt', - * item_category: 'shirts', - * }); - * ``` - * - * @param params See {@link analytics.RemoveFromCartEventParameters}. - */ - logRemoveFromCart(params: RemoveFromCartEventParameters): Promise; - - /** - * Search event. Apps that support search features can use this event to contextualize search - * operations by supplying the appropriate, corresponding parameters. This event can help you - * identify the most popular content in your app. - * - * Via: `search` - * - * #### Example - * - * ```js - * await firebase.analytics().logSearch({ - * search_term: 't-shirts', - * }); - * ``` - * - * @param params See {@link analytics.SearchEventParameters}. - */ - logSearch(params: SearchEventParameters): Promise; - - /** - * Select Content event. This general purpose event signifies that a user has selected some - * content of a certain type in an app. The content can be any object in your app. This event - * can help you identify popular content and categories of content in your app. - * - * Via: `select_content` - * - * #### Example - * - * ```js - * await firebase.analytics().logSelectContent({ - * content_type: 'clothing', - * item_id: 'abcd', - * }); - * ``` - * - * @param params See {@link analytics.SelectContentEventParameters}. - */ - logSelectContent(params: SelectContentEventParameters): Promise; - - /** - * Set checkout option event. - * - * Via: `set_checkout_option` - * - * #### Example - * - * ```js - * await firebase.analytics().logSetCheckoutOption({ - * checkout_step: 2, - * checkout_option: 'false', - * }); - * ``` - * - * @param params See {@link analytics.SetCheckoutOptionEventParameters}. - */ - logSetCheckoutOption(params: SetCheckoutOptionEventParameters): Promise; - - /** - * Share event. Apps with social features can log the Share event to identify the most viral content. - * - * Via: `share` - * - * #### Example - * - * ```js - * await firebase.analytics().logShare({ - * content_type: 't-shirts', - * item_id: '12345', - * method: 'twitter.com', - * }); - * ``` - * - * @param params See {@link analytics.ShareEventParameters}. - */ - logShare(params: ShareEventParameters): Promise; - - /** - * Sign Up event. This event indicates that a user has signed up for an account in your app. - * The parameter signifies the method by which the user signed up. Use this event to understand - * the different behaviors between logged in and logged out users. - * - * Via: `sign_up` - * - * #### Example - * - * ```js - * await firebase.analytics().logSignUp({ - * method: 'facebook.com', - * }); - * ``` - * - * @param params See {@link analytics.SignUpEventParameters}. - */ - logSignUp(params: SignUpEventParameters): Promise; - - /** - * Spend Virtual Currency event. This event tracks the sale of virtual goods in your app and can - * help you identify which virtual goods are the most popular objects of purchase. - * - * Via: `spend_virtual_currency` - * - * #### Example - * - * ```js - * await firebase.analytics().logSpendVirtualCurrency({ - * item_name: 'battle_pass', - * virtual_currency_name: 'coins', - * value: 100, - * }); - * ``` - * - * @param params See {@link analytics.SpendVirtualCurrencyEventParameters}. - */ - logSpendVirtualCurrency(params: SpendVirtualCurrencyEventParameters): Promise; - - /** - * Tutorial Begin event. This event signifies the start of the on-boarding process in your app. - * Use this in a funnel with {@link analytics#logTutorialComplete} to understand how many users - * complete this process and move on to the full app experience. - * - * Via: `tutorial_begin` - * - * #### Example - * - * ```js - * await firebase.analytics().logTutorialBegin(); - * ``` - */ - logTutorialBegin(): Promise; - - /** - * Tutorial End event. Use this event to signify the user's completion of your app's on-boarding process. - * Add this to a funnel with {@link analytics#logTutorialBegin} to understand how many users - * complete this process and move on to the full app experience. - * - * Via: `tutorial_complete` - * - * #### Example - * - * ```js - * await firebase.analytics().logTutorialComplete(); - * ``` - */ - logTutorialComplete(): Promise; - - /** - * Unlock Achievement event. Log this event when the user has unlocked an achievement in your game. - * Since achievements generally represent the breadth of a gaming experience, this event can help - * you understand how many users are experiencing all that your game has to offer. - * - * Via: `unlock_achievement` - * - * #### Example - * - * ```js - * await firebase.analytics().logUnlockAchievement({ - * achievement_id: '12345', - * }); - * ``` - * - * @param params See {@link analytics.UnlockAchievementEventParameters}. - */ - logUnlockAchievement(params: UnlockAchievementEventParameters): Promise; - - /** - * View Item event. This event signifies that some content was shown to the user. This content - * may be a product, a screen or just a simple image or text. Use the appropriate parameters - * to contextualize the event. Use this event to discover the most popular items viewed in your app. - * - * If you supply the `value` parameter, you must also supply the `currency` parameter so that revenue metrics can be computed accurately. - * - * Via: `view_item` - * - * #### Example - * - * ```js - * await firebase.analytics().logViewItem({ - * item_id: 'abcd', - * item_name: 't-shirt', - * item_category: 'shirts', - * }); - * ``` - * - * @param params See {@link analytics.ViewItemEventParameters}. - */ - logViewItem(params: ViewItemEventParameters): Promise; - - /** - * View Item List event. Log this event when the user has been presented with a list of items of a certain category. - * - * Via: `view_item_list` - * - * #### Example - * - * ```js - * await firebase.analytics().logViewItemList({ - * item_category: 't-shirts', - * }); - * ``` - * - * @param params See {@link analytics.ViewItemListEventParameters}. - */ - logViewItemList(params: ViewItemListEventParameters): Promise; - - /** - * View Search Results event. Log this event when the user has been presented with the results of a search. - * - * Via: `view_search_results` - * - * #### Example - * - * ```js - * await firebase.analytics().logViewSearchResults({ - * search_term: 'clothing', - * }); - * ``` - * - * @param params See {@link analytics.ViewSearchResults}. - */ - logViewSearchResults(params: ViewSearchResults): Promise; -} - -declare module '@react-native-firebase/analytics' { - import type { - ReactNativeFirebaseNamespace, - ReactNativeFirebaseModuleAndStatics, - } from '@react-native-firebase/app-types/index.js.flow'; - /** - * @example - * ```js - * import { firebase } from '@react-native-firebase/analytics'; - * firebase.analytics().logEvent(...); - * ``` - */ - declare export var firebase: {} & ReactNativeFirebaseNamespace; - - /** - * @example - * ```js - * import analytics from '@react-native-firebase/analytics'; - * analytics().logEvent(...); - * ``` - */ - declare export default ReactNativeFirebaseModuleAndStatics; -} - -/** - * Attach namespace to `firebase.` and `FirebaseApp.`. - */ -declare module '@react-native-firebase/app-types' { - import type { ReactNativeFirebaseModuleAndStatics } from '@react-native-firebase/app-types/index.js.flow'; - - declare interface ReactNativeFirebaseNamespace { - /** - * Analytics integrates across Firebase features and provides - * you with unlimited reporting for up to 500 distinct events - * that you can define using the Firebase SDK. Analytics reports - * help you understand clearly how your users behave, which enables - * you to make informed decisions regarding app marketing and - * performance optimizations. - */ - analytics: ReactNativeFirebaseModuleAndStatics; - } - - declare interface FirebaseApp { - /** - * Analytics integrates across Firebase features and provides - * you with unlimited reporting for up to 500 distinct events - * that you can define using the Firebase SDK. Analytics reports - * help you understand clearly how your users behave, which enables - * you to make informed decisions regarding app marketing and - * performance optimizations. - */ - analytics(): Module; - } -} diff --git a/packages/app-types/CHANGELOG.md b/packages/app-types/CHANGELOG.md deleted file mode 100644 index 9ebfe68fd4..0000000000 --- a/packages/app-types/CHANGELOG.md +++ /dev/null @@ -1,31 +0,0 @@ -# Change Log - -All notable changes to this project will be documented in this file. -See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. - -## [6.7.2](https://github.com/invertase/react-native-firebase/compare/@react-native-firebase/app-types@6.7.1...@react-native-firebase/app-types@6.7.2) (2020-05-13) - -**Note:** Version bump only for package @react-native-firebase/app-types - -## [6.7.1](https://github.com/invertase/react-native-firebase/compare/@react-native-firebase/app-types@6.7.1...@react-native-firebase/app-types@6.7.1) (2020-05-13) - -### Features - -- **messaging:** ios & android messaging updates & fixes ([#3339](https://github.com/invertase/react-native-firebase/issues/3339)) ([d66a611](https://github.com/invertase/react-native-firebase/commit/d66a6118f82005087f53b86571990fc071402153)) -- independently version packages ([#3513](https://github.com/invertase/react-native-firebase/issues/3513)) ([e2c2d64](https://github.com/invertase/react-native-firebase/commit/e2c2d64d2266cbdd14d4dcfefa64a08263f0af85)) - -# 6.3.0 (2020-02-04) - -# 6.2.0 (2019-12-08) - -# 6.1.0 (2019-11-26) - -## 6.0.4 (2019-11-17) - -## 6.0.3 (2019-10-25) - -## 6.0.2 (2019-10-18) - -## 6.0.1 (2019-10-07) - -# 0.1.0 (2019-07-30) diff --git a/packages/app-types/index.js.flow b/packages/app-types/index.js.flow deleted file mode 100644 index a9ebfdfb77..0000000000 --- a/packages/app-types/index.js.flow +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (c) 2016-present Invertase Limited & Contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this library except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -export type ReactNativeFirebaseModuleAndStatics = { - (): M, - +SDK_VERSION: string, -} & S; - -export type ReactNativeFirebaseModuleAndStaticsWithApp = { - (): M, - +SDK_VERSION: string, -} & S; - -export type FirebaseOptions = { - appId: string, - apiKey?: string, - authDomain?: string, - databaseURL: string, - projectId: string, - gaTrackingId?: string, - storageBucket: string, - messagingSenderId: string, - - /** - * iOS only - */ - clientId?: string, - - /** - * iOS only - */ - androidClientId?: string, - - /** - * iOS only - */ - deepLinkURLScheme?: string, - [name: string]: any, -}; - -export interface FirebaseAppConfig { - name?: string; - automaticDataCollectionEnabled?: boolean; -} - -export interface FirebaseApp { - +name: string; - +options: FirebaseOptions; - delete(): Promise; -} - -export interface ReactNativeFirebaseNamespace { - initializeApp(options: FirebaseOptions, config?: FirebaseAppConfig): FirebaseApp; - initializeApp(options: FirebaseOptions, name?: string): FirebaseApp; - - app: { - (name?: string): FirebaseApp, - }; - - apps: FirebaseApp[]; - - +SDK_VERSION: string; -} - -export interface ReactNativeFirebaseModule { - app: FirebaseApp; -} diff --git a/packages/app-types/package.json b/packages/app-types/package.json deleted file mode 100644 index a6c2272293..0000000000 --- a/packages/app-types/package.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "name": "@react-native-firebase/app-types", - "version": "6.7.2", - "author": "Invertase (http://invertase.io)", - "description": "@react-native-firebase/app-types", - "files": [ - "index.d.ts", - "index.js.flow", - "private.d.ts" - ], - "repository": { - "type": "git", - "url": "https://github.com/invertase/react-native-firebase/tree/master/packages/app-types" - }, - "license": "Apache-2.0", - "publishConfig": { - "access": "public" - } -} diff --git a/packages/app-types/tsconfig.json b/packages/app-types/tsconfig.json deleted file mode 100644 index 7958dfad41..0000000000 --- a/packages/app-types/tsconfig.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extends": "../../tsconfig.json", - "compilerOptions": { - "noEmit": true - }, - "exclude": ["dist/**/*"] -} diff --git a/packages/app/lib/index.js.flow b/packages/app/lib/index.js.flow deleted file mode 100644 index 6e7869dbe4..0000000000 --- a/packages/app/lib/index.js.flow +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2016-present Invertase Limited & Contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this library except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -/** - * @firebase firebase - */ -declare module 'react-native-firebase' { - import type { ReactNativeFirebaseNamespace } from '@react-native-firebase/app-types/index.js.flow'; - - declare export default {} & ReactNativeFirebaseNamespace; -} - -declare module '@react-native-firebase/app-types' { - declare interface ReactNativeFirebaseNamespace {} - - declare interface FirebaseApp {} -} diff --git a/packages/app/package.json b/packages/app/package.json index 94d2a6f657..2e649c82c9 100644 --- a/packages/app/package.json +++ b/packages/app/package.json @@ -54,7 +54,6 @@ "react-native": "*" }, "dependencies": { - "@react-native-firebase/app-types": "6.7.2", "opencollective-postinstall": "^2.0.1", "superstruct": "^0.6.2" }, diff --git a/packages/auth/lib/index.js.flow b/packages/auth/lib/index.js.flow deleted file mode 100644 index 5d3907668e..0000000000 --- a/packages/auth/lib/index.js.flow +++ /dev/null @@ -1,69 +0,0 @@ -/* eslint-disable import/no-duplicates */ -/* - * Copyright (c) 2016-present Invertase Limited & Contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this library except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// TODO ehesp -import type { ReactNativeFirebaseModule } from '@react-native-firebase/app-types/index.js.flow'; - -export interface Statics {} - -export interface Module extends ReactNativeFirebaseModule {} - -declare module '@react-native-firebase/auth' { - import type { - ReactNativeFirebaseNamespace, - ReactNativeFirebaseModuleAndStatics, - } from '@react-native-firebase/app-types/index.js.flow'; - /** - * @example - * ```js - * import { firebase } from '@react-native-firebase/auth'; - * firebase.auth().X(...); - * ``` - */ - declare export var firebase: {} & ReactNativeFirebaseNamespace; - - /** - * @example - * ```js - * import auth from '@react-native-firebase/auth'; - * auth().X(...); - * ``` - */ - declare export default ReactNativeFirebaseModuleAndStatics; -} - -/** - * Attach namespace to `firebase.` and `FirebaseApp.`. - */ -declare module '@react-native-firebase/app-types' { - import type { ReactNativeFirebaseModuleAndStatics } from '@react-native-firebase/app-types/index.js.flow'; - - declare interface ReactNativeFirebaseNamespace { - /** - * Auth - */ - auth: ReactNativeFirebaseModuleAndStatics; - } - - declare interface FirebaseApp { - /** - * Auth - */ - auth(): Module; - } -} diff --git a/packages/crashlytics/lib/index.js.flow b/packages/crashlytics/lib/index.js.flow deleted file mode 100644 index 2afae11eb9..0000000000 --- a/packages/crashlytics/lib/index.js.flow +++ /dev/null @@ -1,190 +0,0 @@ -/* eslint-disable import/no-duplicates */ -/* - * Copyright (c) 2016-present Invertase Limited & Contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this library except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -import type { ReactNativeFirebaseModule } from '@react-native-firebase/app-types/index.js.flow'; - -export interface Statics {} - -export interface Module extends ReactNativeFirebaseModule { - /** - * Whether Crashlytics reporting is enabled. - * - * #### Example - * - * ```js - * const isEnabled = firebase.crashlytics().isCrashlyticsCollectionEnabled; - * ``` - * - */ - isCrashlyticsCollectionEnabled: true; - - /** - * Cause your app to crash for testing purposes. - * - * #### Example - * - * ```js - * firebase.crashlytics().crash(); - * ``` - * - */ - crash(): void; - - /** - * Log a message that will appear in any subsequent Crash or Non-fatal error reports. - * - * #### Example - * - * ```js - * firebase.crashlytics().logEvent('Testing a crash'); - * firebase.crashlytics().crash(); - * ``` - * - * @param message - */ - log(message: string): void; - - /** - * Record a JavaScript Error. - * - * The JavaScript stack trace is converted into a mock native iOS or Android exception before submission. - * - * #### Example - * - * ```js - * firebase.crashlytics().recordError( - * new Error('An error was caught') - * ); - * ``` - * - * @param error Expects an instance of Error; e.g. classes that extend Error will also be supported. - */ - recordError(error: Error): void; - - /** - * Specify a user identifier which will be visible in the Firebase Crashlytics console. - * - * It is recommended for privacy purposes that this value be a value that's meaningless to a third-party - * observer; such as an arbitrary string that ties an end-user to a record in your system e.g. a database record id. - * - * #### Example - * - * ```js - * // Custom user id - * await firebase.crashlytics().setUserId('123456789'); - * // Firebase auth uid - * await firebase.crashlytics().setUserId( - * firebase.auth().currentUser.uid - * ); - * ``` - * - * @param userId An arbitrary string that ties an end-user to a record in your system e.g. a database record id. - */ - setUserId(userId: string): Promise; - - /** - * Sets a string value to be associated with the given attribute name which will be visible in the Firebase Crashlytics console. - * - * #### Example - * - * ```js - * await firebase.crashlytics().setAttribute('role', 'admin'); - * ``` - * - * @param name The name of the attribute to set. - * @param value A string value for the given attribute. - */ - setAttribute(name: string, value: string): Promise; - - /** - * Like `setAttribute` but for multiple attributes. - * - * #### Example - * - * ```js - * await firebase.crashlytics().setAttributes({ - * role: 'admin', - * followers: '13', - * }); - * ``` - * - * @param attributes An object of key/value attribute name and values. - */ - setAttributes(attributes: { [key: string]: string }): Promise; - - /** - * Enable/disable Crashlytics reporting. - * - * Use this for opt-in first user data collection flows combined with `firebase.json` settings to disable auto collection. - * - * #### Example - * - * ```js - * // Disable crash reporting - * await firebase.crashlytics().setCrashlyticsCollectionEnabled(false); - * ``` - * - * @param enabled A boolean value representing whether to enable Crashlytics error collection. - */ - setCrashlyticsCollectionEnabled(enabled: boolean): Promise; -} - -declare module '@react-native-firebase/crashlytics' { - import type { - ReactNativeFirebaseNamespace, - ReactNativeFirebaseModuleAndStatics, - } from '@react-native-firebase/app-types/index.js.flow'; - /** - * @example - * ```js - * import { firebase } from '@react-native-firebase/crashlytics'; - * firebase.crashlytics().X(...); - * ``` - */ - declare export var firebase: {} & ReactNativeFirebaseNamespace; - - /** - * @example - * ```js - * import crashlytics from '@react-native-firebase/crashlytics'; - * crashlytics().X(...); - * ``` - */ - declare export default ReactNativeFirebaseModuleAndStatics; -} - -/** - * Attach namespace to `firebase.` and `FirebaseApp.`. - */ -declare module '@react-native-firebase/app-types' { - import type { ReactNativeFirebaseModuleAndStatics } from '@react-native-firebase/app-types/index.js.flow'; - - declare interface ReactNativeFirebaseNamespace { - /** - * Crashlytics - */ - crashlytics: ReactNativeFirebaseModuleAndStatics; - } - - declare interface FirebaseApp { - /** - * Crashlytics - */ - crashlytics(): Module; - } -} diff --git a/packages/database/lib/index.js.flow b/packages/database/lib/index.js.flow deleted file mode 100644 index 219e031e4a..0000000000 --- a/packages/database/lib/index.js.flow +++ /dev/null @@ -1,68 +0,0 @@ -/* eslint-disable import/no-duplicates */ -/* - * Copyright (c) 2016-present Invertase Limited & Contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this library except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -import type { ReactNativeFirebaseModule } from '@react-native-firebase/app-types/index.js.flow'; - -export interface Statics {} - -export interface Module extends ReactNativeFirebaseModule {} - -declare module '@react-native-firebase/database' { - import type { - ReactNativeFirebaseNamespace, - ReactNativeFirebaseModuleAndStatics, - } from '@react-native-firebase/app-types/index.js.flow'; - /** - * @example - * ```js - * import { firebase } from '@react-native-firebase/database'; - * firebase.database().X(...); - * ``` - */ - declare export var firebase: {} & ReactNativeFirebaseNamespace; - - /** - * @example - * ```js - * import database from '@react-native-firebase/database'; - * database().X(...); - * ``` - */ - declare export default ReactNativeFirebaseModuleAndStatics; -} - -/** - * Attach namespace to `firebase.` and `FirebaseApp.`. - */ -declare module '@react-native-firebase/app-types' { - import type { ReactNativeFirebaseModuleAndStatics } from '@react-native-firebase/app-types/index.js.flow'; - - declare interface ReactNativeFirebaseNamespace { - /** - * Database - */ - database: ReactNativeFirebaseModuleAndStatics; - } - - declare interface FirebaseApp { - /** - * Database - */ - database(): Module; - } -} diff --git a/packages/dynamic-links/lib/index.js.flow b/packages/dynamic-links/lib/index.js.flow deleted file mode 100644 index 5d39e7074a..0000000000 --- a/packages/dynamic-links/lib/index.js.flow +++ /dev/null @@ -1,633 +0,0 @@ -/* eslint-disable import/no-duplicates */ -/* - * Copyright (c) 2016-present Invertase Limited & Contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this library except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -import type { ReactNativeFirebaseModule } from '@react-native-firebase/app-types/index.js.flow'; - -/** - * The DynamicLinkAnalyticsParameters interface provides functionality to add Google Analytic - * based parameters to a dynamic link. - * - * #### Example - * - * ```js - * const linkParams = firebase.dynamicLinks().newDynamicLinkParameters('https://invertase.io', 'https://xyz.page.link'); - * linkParams - * .analytics.setCampaign('banner') - * .analytics.setContent('Click Me'); - * - * const link = await firebase.dynamicLinks().buildLink(linkParams); - * ``` - */ -export interface DynamicLinkAnalyticsParameters { - /** - * Sets the campaign name. - * - * @param campaign The campaign name; The individual campaign name, slogan, promo code, etc. for a product. - */ - setCampaign(campaign: string): DynamicLinkParameters; - - /** - * Sets the campaign content. - * - * @param content The campaign content; used for A/B testing and content-targeted ads to differentiate ads or links that point to the same URL. - */ - setContent(content: string): DynamicLinkParameters; - - /** - * Sets the campaign medium. - * - * @param medium The campaign medium; used to identify a medium such as email or cost-per-click (cpc). - */ - setMedium(medium: string): DynamicLinkParameters; - - /** - * Sets the campaign source. - * - * @param source The campaign source; used to identify a search engine, newsletter, or other source. - */ - setSource(source: string): DynamicLinkParameters; - - /** - * Sets the campaign term. - * - * @param term The campaign term; used with paid search to supply the keywords for ads. - - */ - setTerm(term: string): DynamicLinkParameters; -} - -/** - * The DynamicLinkAndroidParameters interface provides functionality to configure the behaviour - * of dynamic links for Android devices. - * - * If any parameter is declared then the Android package name must also be set via `setPackageName` - * - * #### Example - * - * ```js - * const linkParams = firebase.dynamicLinks().newDynamicLinkParameters('https://invertase.io', 'https://xyz.page.link'); - * linkParams - * .android.setPackageName('io.invertase.testing') - * .android.setMinimumVersion('18'); - * - * const link = await firebase.dynamicLinks().buildLink(linkParams); - * ``` - */ -export interface DynamicLinkAndroidParameters { - /** - * Sets the link to open when the app isn't installed. Specify this to do something other than install your app from - * the Play Store when the app isn't installed, such as open the mobile web version of the content, or display a - * promotional page for your app. - * - * @param fallbackUrl The link to open on Android if the app is not installed. - */ - setFallbackUrl(fallbackUrl: string): DynamicLinkParameters; - - /** - * Sets the version code of the minimum version of your app that can open the link. - * - * @param minimumVersion The minimum version. - */ - setMinimumVersion(minimumVersion: string): DynamicLinkParameters; - - /** - * Sets the Android package name. - * - * @param packageName The package name of the Android app to use to open the link. The app must be connected to your project from the Overview page of the Firebase console. - */ - setPackageName(packageName: string): DynamicLinkParameters; -} - -/** - * The DynamicLinkIOSParameters interface provides functionality to configure the behaviour - * of dynamic links for iOS devices. - * - * If any parameter is declared then the iOS BundleId must also be set via `setBundleId` - * - * #### Example - * - * ```js - * const linkParams = firebase.dynamicLinks().newDynamicLinkParameters('https://invertase.io', 'https://xyz.page.link'); - * linkParams - * .ios.setBundleId('io.invertase.testing') - * .ios.setAppStoreId('123456789') - * .ios.setMinimumVersion('18'); - * - * const link = await firebase.dynamicLinks().buildLink(linkParams); - * ``` - */ -export interface DynamicLinkIOSParameters { - /** - * Sets the App Store ID, used to send users to the App Store when the app isn't installed. - * - * @param appStoreId The App Store ID. - */ - setAppStoreId(appStoreId: string): DynamicLinkParameters; - - /** - * Sets the iOS bundle ID. - * - * @param bundleId The bundle ID of the iOS app to use to open the link. The app must be connected to your project from the Overview page of the Firebase console. - */ - setBundleId(bundleId: string): DynamicLinkParameters; - - /** - * Sets the app's custom URL scheme, if defined to be something other than your app's parameters ID. - * - * @param customScheme The app's custom URL scheme. - */ - setCustomScheme(customScheme: string): DynamicLinkParameters; - - /** - * Sets the link to open when the app isn't installed. Specify this to do something other than install your app from - * the App Store when the app isn't installed, such as open the mobile web version of the content, or display a - * promotional page for your app. - * - * @param fallbackUrl The link to open on iOS if the app is not installed. - */ - setFallbackUrl(fallbackUrl: string): DynamicLinkParameters; - - /** - * Sets the bundle ID of the iOS app to use on iPads to open the link. The app must be connected to your project - * from the Overview page of the Firebase console. - * - * @param iPadBundleId The iPad parameters ID of the app. - */ - setIPadBundleId(iPadBundleId: string): DynamicLinkParameters; - - /** - * Sets the link to open on iPads when the app isn't installed. Specify this to do something other than install your - * app from the App Store when the app isn't installed, such as open the web version of the content, or display a - * promotional page for your app. Overrides the fallback link set by `setFallbackUrl` on iPad. - * - * @param iPadFallbackUrl The link to open on iPad if the app is not installed. - */ - setIPadFallbackUrl(iPadFallbackUrl: string): DynamicLinkParameters; - - /** - * Sets the minimum version of your app that can open the link. - * - * @param minimumVersion The minimum version. - */ - setMinimumVersion(minimumVersion: string): DynamicLinkParameters; -} - -/** - * The DynamicLinkITunesParameters interface provides functionality to add iTunes Connect Analytics - * based parameters to the created dynamic link. - * - * #### Example - * - * ```js - * const linkParams = firebase.dynamicLinks().newDynamicLinkParameters('https://invertase.io', 'https://xyz.page.link'); - * linkParams - * .itunes.setAffiliateToken('ABCDEFG'); - * - * const link = await firebase.dynamicLinks().buildLink(linkParams); - * ``` - */ -export interface DynamicLinkITunesParameters { - /** - * Sets the affiliate token. - * - * @param affiliateToken The affiliate token used to create affiliate-coded links. - */ - setAffiliateToken(affiliateToken: string): DynamicLinkParameters; - - /** - * Sets the campaign token. - * - * @param campaignToken The campaign token that developers can add to any link in order to track sales from a specific marketing campaign. - */ - setCampaignToken(campaignToken: string): DynamicLinkParameters; - - /** - * Sets the provider token. - * - * @param providerToken The provider token that enables analytics for Dynamic DynamicLinks from within iTunes Connect. - */ - setProviderToken(providerToken: string): DynamicLinkParameters; -} - -/** - * The DynamicLinkNavigationParameters interface provides functionality to specify how the navigation - * of the created link is handled. - * - * #### Example - * - * ```js - * const linkParams = firebase.dynamicLinks().newDynamicLinkParameters('https://invertase.io', 'https://xyz.page.link'); - * linkParams - * .navigation.setForcedRedirectEnabled(true); - * - * const link = await firebase.dynamicLinks().buildLink(linkParams); - * ``` - */ -export interface DynamicLinkNavigationParameters { - /** - * Sets whether to enable force redirecting or going to the app preview page. Defaults to false. - * - * @param forcedRedirectEnabled If true, app preview page will be disabled and there will be a redirect to the FDL. If false, go to the app preview page. - */ - setForcedRedirectEnabled(forcedRedirectEnabled: boolean): DynamicLinkParameters; -} - -/** - * The DynamicLinkSocialParameters interface provides functionality to add additional social - * meta-data to the URL. - * - * #### Example - * - * ```js - * const linkParams = firebase.dynamicLinks().newDynamicLinkParameters('https://invertase.io', 'https://xyz.page.link'); - * linkParams - * .social.setTitle('Social Application') - * .social.setDescriptionText('A Social Application'); - * - * const link = await firebase.dynamicLinks().buildLink(linkParams); - * ``` - */ -export interface DynamicLinkSocialParameters { - /** - * Sets the meta-tag description. - * - * @param descriptionText The description to use when the Dynamic Link is shared in a social post. - */ - setDescriptionText(descriptionText: string): DynamicLinkParameters; - - /** - * Sets the meta-tag image link. - * - * @param imageUrl The URL to an image related to this link. - */ - setImageUrl(imageUrl: string): DynamicLinkParameters; - - /** - * Sets the meta-tag title. - * - * @param title The title to use when the Dynamic Link is shared in a social post. - */ - setTitle(title: string): DynamicLinkParameters; -} - -/** - * The DynamicLinkParameters interface provides access to the Dynamic Link builder classes - * used to configure a created link. - * - * #### Example - * - * ```js - * const linkParams = firebase.dynamicLinks() - * .newDynamicLinkParameters('https://invertase.io', 'https://xyz.page.link'); - * - * linkParams.analytics.setCampaign('banner'); - * - * const link = await firebase.dynamicLinks().buildLink(linkParams); - * ``` - */ -export interface DynamicLinkParameters { - /** - * Access Google Analytics specific link parameters. - */ - analytics: DynamicLinkAnalyticsParameters; - - /** - * Access Android specific link parameters. - */ - android: DynamicLinkAndroidParameters; - - /** - * Access iOS specific link parameters. - */ - ios: DynamicLinkIOSParameters; - - /** - * Access iTunes Connect specific link parameters. - */ - itunes: DynamicLinkITunesParameters; - - /** - * Access navigation specific link parameters. - */ - navigation: DynamicLinkNavigationParameters; - - /** - * Access social specific link parameters. - */ - social: DynamicLinkSocialParameters; -} - -/** - * ShortLinkType determines the type of dynamic short link which Firebase creates. Used when building - * a new short link via `buildShortLink()`. - * - * #### Example - * - * ```js - * const linkParams = firebase.dynamicLinks() - * .newDynamicLinkParameters('https://invertase.io', 'https://xyz.page.link'); - * - * linkParams.analytics.setCampaign('banner'); - * - * const link = await firebase.dynamicLinks().buildShortLink( - * linkParams, - * firebase.dynamicLinks.ShortLinkType.UNGUESSABLE, - * ); - * ``` - */ -export interface ShortLinkType { - /** - * Shorten the path to a string that is only as long as needed to be unique, with a minimum length - * of 4 characters. Use this if sensitive information would not be exposed if a short - * Dynamic Link URL were guessed. - */ - SHORT: 'SHORT'; - - /** - * Shorten the path to an unguessable string. Such strings are created by base62-encoding randomly - * generated 96-bit numbers, and consist of 17 alphanumeric characters. Use unguessable strings - * to prevent your Dynamic DynamicLinks from being crawled, which can potentially expose sensitive information. - */ - UNGUESSABLE: 'UNGUESSABLE'; - - /** - * By default, Firebase returns a standard formatted link. - */ - DEFAULT: 'DEFAULT'; -} - -/** - * A received Dynamic Link from either `onLink` or `getInitialLink`. - */ -export interface DynamicLink { - /** - * The url of the dynamic link. - */ - url: string; - - /** - * The minimum app version (not system version) requested to process the dynamic link. - * This is retrieved from the imv= parameter of the Dynamic Link URL. - * - * If the app version of the opening app is less than the value of this property, - * then the app is expected to open AppStore to allow user to download most recent version. - * App can notify or ask the user before opening AppStore. - * - * Returns `null` if not specified - * - * #### Android - * - * On Android this returns a number value representing the apps [versionCode](https://developer.android.com/reference/android/content/pm/PackageInfo.html#versionCode). - * - * #### iOS - * - * On iOS this returns a string value representing the minimum app version (not the iOS system version). - */ - minimumAppVersion: number | string | null; -} - -/** - * Firebase Dynamic DynamicLinks Statics - * - * ```js - * firebase.dynamicLinks.X - * ``` - */ -export interface Statics { - /** - * Returns the {@link links.ShortLinkType} interface. - */ - ShortLinkType: ShortLinkType; - // TODO deprecate DynamicLink -} - -/** - * - * The Firebase Dynamic DynamicLinks service is available for the default app only. - * - * #### Example 1 - * - * Get the links instance for the **default app**: - * - * ```js - * const links = firebase.dynamicLinks(); - * ``` - */ -export interface Module extends ReactNativeFirebaseModule { - /** - * Creates new parameters which enhance the functionality of a created link. - * - * To create a DynamicLinkParameters, first populate it by using the setX methods available on the `DynamicLinkParameters` builder classes, - * then pass it to `firebase.dynamicLinks().buildLink(linkParams)` or `firebase.dynamicLinks().buildShortLink(linkParams, type)`. - * - * #### Example - * - * ```js - * const linkParams = firebase.dynamicLinks() - * .newDynamicLinkParameters('https://invertase.io', 'https://xyz.page.link'); - * - * linkParams.analytics.setCampaign('banner'); - * - * const link = await firebase.dynamicLinks().buildShortLink( - * linkParams, - * firebase.dynamicLinks.ShortLinkType.UNGUESSABLE, - * ); - * ``` - * - * @param link The link the target app will open. You can specify any URL the app can handle, such as a link to the app’s content, or a URL that initiates some app-specific logic such as crediting the user with a coupon, or displaying a specific welcome screen. This link must be a well-formatted URL, be properly URL-encoded, and use the HTTP or HTTPS scheme. - * @param domainURIPrefix Domain URI Prefix of your App. This value must be your assigned domain from the Firebase console. (e.g. https://xyz.page.link) The domain URI prefix must start with a valid HTTPS scheme (https://). - */ - newDynamicLinkParameters(link: string, domainURIPrefix: string): DynamicLinkParameters; - - /** - * Builds a Dynamic Link from the provided DynamicLinkParameters instances. - * - * #### Example - * - * ```js - * const linkParams = firebase.dynamicLinks() - * .newDynamicLinkParameters('https://invertase.io', 'https://xyz.page.link'); - * - * linkParams.analytics.setCampaign('banner'); - * - * const link = await firebase.dynamicLinks().buildLink(linkParams); - * ``` - * - * @param dynamicLinkParams An instance of DynamicLinkParameters created via `newDynamicLinkParameters` - */ - buildLink(dynamicLinkParams: DynamicLinkParameters): Promise; - - /** - * **Deprecated**: Creates a link from the provided DynamicLinkParameters instances. - * - * @deprecated Use `buildLink` with the same args instead. - * @param dynamicLinkParams An instance of DynamicLinkParameters created via `newDynamicLinkParameters` - */ - createDynamicLink(dynamicLinkParams: DynamicLinkParameters): Promise; - - /** - * Builds a short Dynamic Link from the provided DynamicLinkParameters instances. - * - * ```js - * const linkParams = firebase.dynamicLinks() - * .newDynamicLinkParameters('https://invertase.io', 'https://xyz.page.link'); - * - * linkParams.analytics.setCampaign('banner'); - * - * const link = await firebase.dynamicLinks().buildShortLink( - * linkParams, - * firebase.dynamicLinks.ShortLinkType.UNGUESSABLE, - * ); - * ``` - * - * @param dynamicLinkParams An instance of DynamicLinkParameters created via `newDynamicLinkParameters` - * @param shortLinkType The short link type, one of `ShortLinkType` from `firebase.dynamicLinks.ShortLinkType` - */ - buildShortLink( - dynamicLinkParams: DynamicLinkParameters, - shortLinkType?: ShortLinkType, - ): Promise; - - /** - * **Deprecated**: Creates a short Dynamic Link from the provided DynamicLinkParameters instances. - * - * @deprecated Use `buildShortLink` with the same args instead. - * @param dynamicLinkParams An instance of DynamicLinkParameters created via `newDynamicLinkParameters` - * @param shortLinkType The short link type, one of `ShortLinkType` from `firebase.dynamicLinks.ShortLinkType` - */ - createShortDynamicLink( - dynamicLinkParams: DynamicLinkParameters, - shortLinkType?: ShortLinkType, - ): Promise; - - /** - * Returns the URL that the app has been launched from. If the app was not launched from a URL the return value will be null. - * - * > Use {@link auth#isSignInWithEmailLink} to check if an inbound dynamic link is an email sign-in link. - * - * #### Example - * - * ```js - * async function bootstrapApp() { - * await initialLink = await firebase.dynamicLinks().getInitialLink(); - * - * if (initialLink) { - * // Handle dynamic link inside your own application - * if (initialLink === 'https://invertase.io/offer') return navigateTo('/offers') - * } - * } - * ``` - */ - getInitialLink(): Promise; - - /** - * Subscribe to URL open events while the app is still running. - * - * The listener is called from URL open events whilst the app is still running, use - * {@link links#getInitialLink} for URLs which cause the app to open from a previously closed / not running state. - * - * #### Example - * - * ```jsx - * function App() { - * const handleDynamicLink = (link) => { - * // Handle dynamic link inside your own application - * if (link === 'https://invertase.io/offer') return navigateTo('/offers') - * }; - * - * useEffect(() => { - * const unsubscribe = firebase.dynamicLinks().onLink(handleDynamicLink); - * // When the component unmounts, remove the listener - * return unsubscribe; - * }, []); - * - * return ; - * } - * ``` - * - * @returns Unsubscribe function, call the returned function to unsubscribe from all future events. - * @param listener The listener callback, called URL open events. - */ - onLink(listener: Function): Function; - - /** - * Resolve a given dynamic link (short or long) directly. - * - * This mimics the result of external link resolution, app open, and the DynamicLink you - * would get from {@link dynamic-links#getInitialLink} - * - * #### Example - * - * ```js - * const link = await firebase.dynamicLinks().resolveLink('https://invertase.io'); - * ``` - * - * Can throw error with message 'Invalid link parameter' if link parameter is null - * Can throw error with code 'not-found' if the link does not resolve - * Can throw error with code 'resolve-link-error' if there is a processing error - * - * @returns the resolved Dynamic Link URL - * @param link The Dynamic Link URL to resolve, either short or long - */ - resolveLink(link: string): Promise; -} - -declare module '@react-native-firebase/dynamic-links' { - import type { - ReactNativeFirebaseNamespace, - ReactNativeFirebaseModuleAndStatics, - } from '@react-native-firebase/app-types/index.js.flow'; - /** - * @example - * ```js - * import { firebase } from '@react-native-firebase/dynamic-links'; - * firebase.dynamicLinks().X(...); - * ``` - */ - declare export var firebase: {} & ReactNativeFirebaseNamespace; - - /** - * @example - * ```js - * import links from '@react-native-firebase/dynamic-links'; - * links().X(...); - * ``` - */ - declare export default ReactNativeFirebaseModuleAndStatics; -} - -/** - * Attach namespace to `firebase.` and `FirebaseApp.`. - */ -declare module '@react-native-firebase/app-types' { - import type { ReactNativeFirebaseModuleAndStatics } from '@react-native-firebase/app-types/index.js.flow'; - - declare interface ReactNativeFirebaseNamespace { - /** - * DynamicLinks - */ - links: ReactNativeFirebaseModuleAndStatics; - } - - declare interface FirebaseApp { - /** - * DynamicLinks - */ - links(): Module; - } -} diff --git a/packages/firestore/lib/index.js.flow b/packages/firestore/lib/index.js.flow deleted file mode 100644 index cb7b2a3fcd..0000000000 --- a/packages/firestore/lib/index.js.flow +++ /dev/null @@ -1,1836 +0,0 @@ -/* eslint-disable import/no-duplicates */ -/* - * Copyright (c) 2016-present Invertase Limited & Contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this library except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -import type { ReactNativeFirebaseModule } from '@react-native-firebase/app-types/index.js.flow'; - -/** - * An immutable object representing an array of bytes. - */ -export class Blob { - /** - * Creates a new Blob from the given Base64 string, converting it to bytes. - * - * @param base64 The Base64 string used to create the Blob object. - */ - static fromBase64String: (base64: string) => Blob; - - /** - * Creates a new Blob from the given Uint8Array. - * - * @param array The Uint8Array used to create the Blob object. - */ - static fromUint8Array: (array: Uint8Array) => Blob; - - /** - * Returns true if this `Blob` is equal to the provided one. - * - * @param other The `Blob` to compare against. - */ - isEqual: (other: Blob) => boolean; - - /** - * Returns the bytes of a Blob as a Base64-encoded string. - */ - toBase64: () => string; - - /** - * Returns the bytes of a Blob in a new Uint8Array. - */ - toUint8Array: () => Uint8Array; -} - -/** - * A `CollectionReference` object can be used for adding documents, getting document references, and querying for - * documents (using the methods inherited from `Query`). - */ -export interface CollectionReference extends Query { - /** - * The collection's identifier. - */ - id: string; - - /** - * A reference to the containing `DocumentReference` if this is a subcollection. If this isn't a - * subcollection, the reference is null. - */ - parent: DocumentReference | null; - - /** - * A string representing the path of the referenced collection (relative to the root of the database). - */ - path: string; - - /** - * Add a new document to this collection with the specified data, assigning it a document ID automatically. - * - * #### Example - * - * ```js - * const documentRef = await firebase.firestore().collection('users').add({ - * name: 'Ada Lovelace', - * age: 30, - * }); - * ``` - * - * @param data An Object containing the data for the new document. - */ - add(data: { [key]: value }): Promise; - - /** - * Get a DocumentReference for the document within the collection at the specified path. If no - * path is specified, an automatically-generated unique ID will be used for the returned DocumentReference. - * - * #### Example - * - * ```js - * await firebase.firestore().collection('users').doc('alovelace').set({ - * name: 'Ada Lovelace', - * age: 30, - * }); - * ``` - * - * @param documentPath A slash-separated path to a document. - */ - doc(documentPath?: string): DocumentReference; -} - -/** - * A DocumentChange represents a change to the documents matching a query. It contains the document affected and the - * type of change that occurred. - */ -export interface DocumentChange { - /** - * The document affected by this change. - */ - doc: DocumentSnapshot; - - /** - * The index of the changed document in the result set immediately after this `DocumentChange` - * (i.e. supposing that all prior `DocumentChange` objects and the current `DocumentChange` object have been applied). - * Is -1 for 'removed' events. - */ - newIndex: number; - - /** - * The index of the changed document in the result set immediately prior to this `DocumentChange` (i.e. - * supposing that all prior `DocumentChange` objects have been applied). Is -1 for 'added' events. - */ - oldIndex: number; - - /** - * The type of change ('added', 'modified', or 'removed'). - */ - type: DocumentChangeType; -} - -/** - * The type of a DocumentChange may be 'added', 'removed', or 'modified'. - */ -export type DocumentChangeType = 'added' | 'removed' | 'modified'; - -/** - * A `DocumentReference` refers to a document location in a Firestore database and can be used to write, read, or listen - * to the location. The document at the referenced location may or may not exist. A `DocumentReference` can also be used - * to create a `CollectionReference` to a subcollection. - */ -export interface DocumentReference { - /** - * The Firestore instance the document is in. This is useful for performing transactions, for example. - */ - firestore: Module; - - /** - * The document's identifier within its collection. - */ - id: string; - - /** - * The Collection this `DocumentReference` belongs to. - */ - parent: CollectionReference; - - /** - * A string representing the path of the referenced document (relative to the root of the database). - */ - path: string; - - /** - * Gets a `CollectionReference` instance that refers to the collection at the specified path. - * - * #### Example - * - * ```js - * const collectionRef = firebase.firestore().doc('users/alovelace').collection('orders'); - * ``` - * - * @param collectionPath A slash-separated path to a collection. - */ - collection(collectionPath: string): CollectionReference; - - /** - * Deletes the document referred to by this DocumentReference. - * - * #### Example - * - * ```js - * await firebase.firestore().doc('users/alovelace').delete(); - * ``` - * - * The Promise is resolved once the document has been successfully deleted from the backend - * (Note that it won't resolve while you're offline). - */ - delete(): Promise; - - /** - * Reads the document referred to by this DocumentReference. - * - * Note: By default, get() attempts to provide up-to-date data when possible by waiting for data - * from the server, but it may return cached data or fail if you are offline and the server cannot - * be reached. This behavior can be altered via the GetOptions parameter. - * - * #### Example - * - * ```js - * await firebase.firestore().doc('users/alovelace').get({ - * source: 'server', - * }); - * ``` - * - * @param options An object to configure the get behavior. - */ - get(options?: GetOptions): Promise; - - /** - * Returns true if this DocumentReference is equal to the provided one. - * - * #### Example - * - * ```js - * const alovelace = firebase.firestore().doc('users/alovelace'); - * const dsmith = firebase.firestore().doc('users/dsmith'); - * - * // false - * alovelace.isEqual(dsmith); - * ``` - * - * @param other The `DocumentReference` to compare against. - */ - isEqual(other: DocumentReference): boolean; - - /** - * Attaches a listener for DocumentSnapshot events. - * - * NOTE: Although an complete callback can be provided, it will never be called because the snapshot stream is never-ending. - * - * Returns an unsubscribe function to stop listening to events. - * - * #### Example - * - * ```js - * const unsubscribe = firebase.firestore().doc('users/alovelace') - * .onSnapshot({ - * error: (e) => console.error(e), - * next: (documentSnapshot) => {}, - * }); - * - * unsubscribe(); - * ``` - * - * @param observer A single object containing `next` and `error` callbacks. - */ - onSnapshot(observer: { complete?: Function, error?: Function, next?: Function }): Function; - - /** - * Attaches a listener for DocumentSnapshot events with snapshot listener options. - * - * NOTE: Although an complete callback can be provided, it will never be called because the snapshot stream is never-ending. - * - * Returns an unsubscribe function to stop listening to events. - * - * #### Example - * - * ```js - * const unsubscribe = firebase.firestore().doc('users/alovelace') - * .onSnapshot({ - * includeMetadataChanges: true, - * }, { - * error: (e) => console.error(e), - * next: (documentSnapshot) => {}, - * }); - * - * unsubscribe(); - * ``` - * - * @param options Options controlling the listen behavior. - * @param observer A single object containing `next` and `error` callbacks. - */ - onSnapshot( - options: SnapshotListenOptions, - observer: { complete?: Function, error?: Function, next?: Function }, - ): Function; - - /** - * Attaches a listener for DocumentSnapshot events. - * - * NOTE: Although an onCompletion callback can be provided, it will never be called because the snapshot stream is never-ending. - * - * Returns an unsubscribe function to stop listening to events. - * - * #### Example - * - * ```js - * const unsubscribe = firebase.firestore().doc('users/alovelace') - * .onSnapshot( - * (documentSnapshot) => {}, // onNext - * (error) => console.error(error), // onError - * ); - * - * unsubscribe(); - * ``` - * @param onNext A callback to be called every time a new `DocumentSnapshot` is available. - * @param onError A callback to be called if the listen fails or is cancelled. No further callbacks will occur. - * @param onCompletion An optional function which will never be called. - */ - onSnapshot(onNext: Function, onError?: Function, onCompletion?: Function): Function; - - /** - * Attaches a listener for DocumentSnapshot events with snapshot listener options. - * - * NOTE: Although an onCompletion callback can be provided, it will never be called because the snapshot stream is never-ending. - * - * Returns an unsubscribe function to stop listening to events. - * - * #### Example - * - * ```js - * const unsubscribe = firebase.firestore().doc('users/alovelace') - * .onSnapshot( - * { includeMetadataChanges: true }, // SnapshotListenerOptions - * (documentSnapshot) => {}, // onNext - * (error) => console.error(error), // onError - * ); - * - * unsubscribe(); - * ``` - * @param options Options controlling the listen behavior. - * @param onNext A callback to be called every time a new `DocumentSnapshot` is available. - * @param onError A callback to be called if the listen fails or is cancelled. No further callbacks will occur. - * @param onCompletion An optional function which will never be called. - */ - onSnapshot( - options: SnapshotListenOptions, - onNext: Function, - onError?: Function, - onCompletion?: Function, - ): Function; - - /** - * Writes to the document referred to by this DocumentReference. If the document does not yet - * exist, it will be created. If you pass SetOptions, the provided data can be merged into an - * existing document. - * - * #### Example - * - * ```js - * const user = firebase.firestore().doc('users/alovelace'); - * - * // Set new data - * await user.set({ - * name: 'Ada Lovelace', - * age: 30, - * city: 'LON', - * }); - * ``` - * - * @param data A map of the fields and values for the document. - * @param options An object to configure the set behavior. - */ - set(data: { [key]: value }, options?: SetOptions): Promise; - - /** - * Updates fields in the document referred to by this `DocumentReference`. The update will fail - * if applied to a document that does not exist. - * - * #### Example - * - * ``` - * const user = firebase.firestore().doc('users/alovelace'); - * - * // Update age but leave other fields untouched - * await user.update({ - * age: 31, - * }); - * ``` - * - * @param data An object containing the fields and values with which to update the document. Fields can contain dots to reference nested fields within the document. - */ - update(data: { [key]: value }): Promise; - - /** - * Updates fields in the document referred to by this DocumentReference. The update will fail if - * applied to a document that does not exist. - * - * #### Example - * - * ``` - * const user = firebase.firestore().doc('users/alovelace'); - * - * // Update age & city but leve other fields untouched - * await user.update('age', 31, 'city', 'SF'); - * ``` - * - * @param field The first field to update. - * @param value The first value. - * @param moreFieldsAndValues Additional key value pairs. - */ - update(field: string | FieldPath, value: any, ...moreFieldsAndValues: any[]): Promise; -} - -/** - * A DocumentSnapshot contains data read from a document in your Firestore database. The data can be extracted with - * .`data()` or `.get()` to get a specific field. - * - * For a DocumentSnapshot that points to a non-existing document, any data access will return 'undefined'. - * You can use the `exists` property to explicitly verify a document's existence. - */ -export interface DocumentSnapshot { - /** - * Property of the `DocumentSnapshot` that signals whether or not the data exists. True if the document exists. - */ - exists: boolean; - - /** - * Property of the `DocumentSnapshot` that provides the document's ID. - */ - id: string; - - /** - * Metadata about the `DocumentSnapshot`, including information about its source and local modifications. - */ - metadata: SnapshotMetadata; - - /** - * The `DocumentReference` for the document included in the `DocumentSnapshot`. - */ - ref: DocumentReference; - - /** - * Retrieves all fields in the document as an Object. Returns 'undefined' if the document doesn't exist. - * - * #### Example - * - * ```js - * const user = await firebase.firestore().doc('users/alovelace').get(); - * - * console.log('User', user.data()); - * ``` - */ - data(): { [key]: value } | undefined; - - /** - * Retrieves the field specified by fieldPath. Returns undefined if the document or field doesn't exist. - * - * #### Example - * - * ```js - * const user = await firebase.firestore().doc('users/alovelace').get(); - * - * console.log('Address ZIP Code', user.get('address.zip')); - * ``` - * - * @param fieldPath The path (e.g. 'foo' or 'foo.bar') to a specific field. - */ - get(fieldPath: string | FieldPath): any; - - /** - * Returns true if this `DocumentSnapshot` is equal to the provided one. - * - * #### Example - * - * ```js - * const user1 = await firebase.firestore().doc('users/alovelace').get(); - * const user2 = await firebase.firestore().doc('users/dsmith').get(); - * - * // false - * user1.isEqual(user2); - * ``` - * - * @param other The `DocumentSnapshot` to compare against. - */ - isEqual(other: DocumentSnapshot): boolean; -} - -/** - * A FieldPath refers to a field in a document. The path may consist of a single field name (referring to a - * top-level field in the document), or a list of field names (referring to a nested field in the document). - * - * Create a FieldPath by providing field names. If more than one field name is provided, the path will point to a nested field in a document. - * - * #### Example - * - * ```js - * const user = await firebase.firestore().doc('users/alovelace').get(); - * - * // Create a new field path - * const fieldPath = new firebase.firestore.FieldPath('address', 'zip'); - * - * console.log('Address ZIP Code', user.get(fieldPath)); - * ``` - */ -export class FieldPath { - /** - * Returns a special sentinel FieldPath to refer to the ID of a document. It can be used in queries to sort or filter by the document ID. - */ - static documentId: () => FieldPath; - - /** - * Creates a FieldPath from the provided field names. If more than one field name is provided, the path will point to a nested field in a document. - * - * #### Example - * - * ```js - * const fieldPath = new firebase.firestore.FieldPath('address', line', 'one'); - * ``` - * - * @param fieldNames A list of field names. - */ - // TODO don't think this is possible on flow? - // constructor(...fieldNames: string[]); - - /** - * Returns true if this `FieldPath` is equal to the provided one. - * - * #### Example - * - * ```js - * const fieldPath1 = new firebase.firestore.FieldPath('address', 'zip'); - * const fieldPath2 = new firebase.firestore.FieldPath('address', line', 'one'); - * - * // false - * fieldPath1.isEqual(fieldPath2); - * ``` - * - * @param other The `FieldPath` to compare against. - */ - isEqual: (other: FieldPath) => boolean; -} - -/** - * Sentinel values that can be used when writing document fields with `set()` or `update()`. - * - * #### Example - * - * ```js - * const increment = firebase.firestore.FieldValue.increment(1); - * - * await firebase.firestore().doc('users/alovelace).update({ - * age: increment, // increment age by 1 - * }); - * ``` - */ -export class FieldValue { - /** - * Returns a special value that can be used with `set()` or `update()` that tells the server to remove the given elements - * from any array value that already exists on the server. All instances of each element specified will be removed from - * the array. If the field being modified is not already an array it will be overwritten with an empty array. - * - * #### Example - * - * ```js - * const arrayRemove = firebase.firestore.FieldValue.arrayRemove(2, '3'); - * - * // Removes the values 2 & '3' from the values array on the document - * await docRef.update({ - * values: arrayRemove, - * }); - * ``` - * - * @param elements The elements to remove from the array. - */ - static arrayRemove: (...elements: any[]) => FieldValue; - - /** - * Returns a special value that can be used with `set()` or `update()` that tells the server to union the given - * elements with any array value that already exists on the server. Each specified element that doesn't already exist - * in the array will be added to the end. If the field being modified is not already an array it will be overwritten - * with an array containing exactly the specified elements. - * - * #### Example - * - * ```js - * const arrayUnion = firebase.firestore.FieldValue.arrayUnion(2, '3'); - * - * // Appends the values 2 & '3' onto the values array on the document - * await docRef.update({ - * values: arrayUnion, - * }); - * ``` - * - * @param elements The elements to union into the array. - */ - static arrayUnion: (...elements: any[]) => FieldValue; - - /** - * Returns a sentinel for use with update() to mark a field for deletion. - * - * #### Example - * - * ```js - * const delete = firebase.firestore.FieldValue.delete(); - * - * // Deletes the name field on the document - * await docRef.update({ - * name: delete, - * }); - * ``` - */ - static delete: () => FieldValue; - - /** - * Returns a special value that can be used with `set()` or `update()` that tells the server to increment the field's current value by the given value. - * - * If either the operand or the current field value uses floating point precision, all arithmetic follows IEEE 754 semantics. - * If both values are integers, values outside of JavaScript's safe number range (`Number.MIN_SAFE_INTEGER` to `Number.MAX_SAFE_INTEGER`) - * are also subject to precision loss. Furthermore, once processed by the Firestore backend, all integer operations are - * capped between -2^63 and 2^63-1. - * - * If the current field value is not of type `number`, or if the field does not yet exist, the transformation sets the field to the given value. - * - * #### Example - * - * ```js - * const increment = firebase.firestore.FieldValue.increment(1); - * - * // Increment the loginCount field by 1 on the document - * await docRef.update({ - * loginCount: increment, - * }); - * ``` - * - * @param n The value to increment by. - */ - static increment: (n: number) => FieldValue; - - /** - * Returns a sentinel used with set() or update() to include a server-generated timestamp in the written data. - * - * #### Example - * - * ```js - * const timestamp = firebase.firestore.FieldValue.serverTimestamp(); - * - * // Set the updatedAt field to the current server time - * await docRef.update({ - * updatedAt: timestamp, - * }); - * ``` - */ - static serverTimestamp: () => FieldValue; - - /** - * Returns true if this FieldValue is equal to the provided one. - * - * #### Example - * - * ```js - * const increment = firebase.firestore.FieldValue.increment(1); - * const timestamp = firebase.firestore.FieldValue.serverTimestamp(); - * - * // false - * increment.isEqual(timestamp); - * ``` - * - * @param other The FieldValue to compare against. - */ - isEqual: (other: FieldValue) => boolean; -} - -/** - * An immutable object representing a geo point in Firestore. The geo point is represented as latitude/longitude pair. - * - * Latitude values are in the range of [-90, 90]. Longitude values are in the range of [-180, 180]. - */ -export class GeoPoint { - /** - * Creates a new immutable GeoPoint object with the provided latitude and longitude values. - * - * #### Example - * - * ```js - * const geoPoint = new firebase.firestore.GeoPoint(60, -40); - * ``` - * - * @param latitude The latitude as number between -90 and 90. - * @param longitude The longitude as number between -180 and 180. - */ - // TODO don't think this is possible on flow? - // constructor(latitude: number, longitude: number); - - /** - * The latitude of this `GeoPoint` instance. - */ - latitude: number; - - /** - * The longitude of this `GeoPoint` instance. - */ - longitude: number; - - /** - * Returns true if this `GeoPoint` is equal to the provided one. - * - * #### Example - * - * ```js - * const geoPoint1 = new firebase.firestore.GeoPoint(60, -40); - * const geoPoint2 = new firebase.firestore.GeoPoint(60, -20); - * - * // false - * geoPoint1.isEqual(geoPoint2); - * ``` - * - * @param other The `GeoPoint` to compare against. - */ - isEqual: (other: GeoPoint) => boolean; -} - -/** - * An options object that configures the behavior of get() calls on DocumentReference and Query. - * By providing a GetOptions object, these methods can be configured to fetch results only from the - * server, only from the local cache or attempt to fetch results from the server and fall back to the - * cache (which is the default). - */ -export interface GetOptions { - /** - * Describes whether we should get from server or cache. - * - * Setting to `default` (or not setting at all), causes Firestore to try to retrieve an up-to-date (server-retrieved) - * snapshot, but fall back to returning cached data if the server can't be reached. - * - * Setting to `server` causes Firestore to avoid the cache, generating an error if the server cannot be reached. Note - * that the cache will still be updated if the server request succeeds. Also note that latency-compensation still - * takes effect, so any pending write operations will be visible in the returned data (merged into the server-provided data). - * - * Setting to `cache` causes Firestore to immediately return a value from the cache, ignoring the server completely - * (implying that the returned value may be stale with respect to the value on the server.) If there is no data in the - * cache to satisfy the `get()` call, `DocumentReference.get()` will return an error and `QuerySnapshot.get()` will return an - * empty `QuerySnapshot` with no documents. - */ - source: 'default' | 'server' | 'cache'; -} - -/** - * A Query refers to a `Query` which you can read or listen to. You can also construct refined `Query` objects by - * adding filters and ordering. - */ -export interface Query { - /** - * Creates and returns a new Query that ends at the provided document (inclusive). The end - * position is relative to the order of the query. The document must contain all of the - * fields provided in the orderBy of this query. - * - * #### Example - * - * ```js - * const user = await firebase.firestore().doc('users/alovelace').get(); - * - * // Get all users up to a specific user in order of age - * const querySnapshot = await firebase.firestore() - * .collection('users') - * .orderBy('age') - * .endAt(user); - * ``` - * - * > Cursor snapshot queries have limitations. Please see [Query limitations](/) for more information. - * - * @param snapshot The snapshot of the document to end at. - */ - endAt(snapshot: DocumentSnapshot): Query; - - /** - * Creates and returns a new Query that ends at the provided fields relative to the order of the query. - * The order of the field values must match the order of the order by clauses of the query. - * - * #### Example - * - * ```js - * // Get all users who's age is 30 or less - * const querySnapshot = await firebase.firestore() - * .collection('users') - * .orderBy('age') - * .endAt(30); - * ``` - * - * @param fieldValues The field values to end this query at, in order of the query's order by. - */ - endAt(...fieldValues: any[]): Query; - - /** - * Creates and returns a new Query that ends before the provided document (exclusive). The end - * position is relative to the order of the query. The document must contain all of the fields - * provided in the orderBy of this query. - * - * #### Example - * - * ```js - * const user = await firebase.firestore().doc('users/alovelace').get(); - * - * // Get all users up to, but not including, a specific user in order of age - * const querySnapshot = await firebase.firestore() - * .collection('users') - * .orderBy('age') - * .endBefore(user); - * ``` - * - * > Cursor snapshot queries have limitations. Please see [Query limitations](/) for more information. - * - * @param snapshot The snapshot of the document to end before. - */ - endBefore(snapshot: DocumentSnapshot): Query; - - /** - * Creates and returns a new Query that ends before the provided fields relative to the order of - * the query. The order of the field values must match the order of the order by clauses of the query. - * - * #### Example - * - * ```js - * // Get all users who's age is 29 or less - * const querySnapshot = await firebase.firestore() - * .collection('users') - * .orderBy('age') - * .endBefore(30); - * ``` - * - * @param fieldValues The field values to end this query before, in order of the query's order by. - */ - endBefore(...fieldValues: any[]): Query; - - /** - * Executes the query and returns the results as a QuerySnapshot. - * - * Note: By default, get() attempts to provide up-to-date data when possible by waiting for data from the server, - * but it may return cached data or fail if you are offline and the server cannot be reached. This behavior can be - * altered via the `GetOptions` parameter. - * - * #### Example - * - * ```js - * const querySnapshot = await firebase.firestore() - * .collection('users') - * .orderBy('age') - * .get({ - * source: 'server', - * }); - * ``` - * - * @param options An object to configure the get behavior. - */ - get(options?: GetOptions): Promise; - - /** - * Returns true if this Query is equal to the provided one. - * - * #### Example - * - * ```js - * const query = firebase.firestore() - * .collection('users') - * .orderBy('age'); - * - * // false - * query.isEqual( - * firebase.firestore() - * .collection('users') - * .orderBy('name') - * ); - * ``` - * - * @param other The `Query` to compare against. - */ - isEqual(other: Query): boolean; - - /** - * Creates and returns a new Query where the results are limited to the specified number of documents. - * - * #### Example - * - * ```js - * // Get 10 users in order of age - * const querySnapshot = firebase.firestore() - * .collection('users') - * .orderBy('age') - * .limit(10) - * .get(); - * ``` - * - * @param limit The maximum number of items to return. - */ - limit(limit: number): Query; - - /** - * Attaches a listener for `QuerySnapshot` events. - * - * NOTE: Although an complete callback can be provided, it will never be called because the snapshot stream is never-ending. - * - * Returns an unsubscribe function to stop listening to events. - * - * #### Example - * - * ```js - * const unsubscribe = firebase.firestore().collection('users') - * .onSnapshot({ - * error: (e) => console.error(e), - * next: (querySnapshot) => {}, - * }); - * - * unsubscribe(); - * ``` - * - * @param observer A single object containing `next` and `error` callbacks. - */ - onSnapshot(observer: { complete?: Function, error?: Function, next?: Function }): Function; - - /** - * Attaches a listener for `QuerySnapshot` events with snapshot listener options. - * - * NOTE: Although an complete callback can be provided, it will never be called because the snapshot stream is never-ending. - * - * Returns an unsubscribe function to stop listening to events. - * - * #### Example - * - * ```js - * const unsubscribe = firebase.firestore().collection('users') - * .onSnapshot({ - * includeMetadataChanges: true, - * }, { - * error: (e) => console.error(e), - * next: (querySnapshot) => {}, - * }); - * - * unsubscribe(); - * ``` - * - * @param options Options controlling the listen behavior. - * @param observer A single object containing `next` and `error` callbacks. - */ - onSnapshot( - options: SnapshotListenOptions, - observer: { complete?: Function, error?: Function, next?: Function }, - ): Function; - - /** - * Attaches a listener for `QuerySnapshot` events. - * - * NOTE: Although an onCompletion callback can be provided, it will never be called because the snapshot stream is never-ending. - * - * Returns an unsubscribe function to stop listening to events. - * - * #### Example - * - * ```js - * const unsubscribe = firebase.firestore().collection('users') - * .onSnapshot( - * (querySnapshot) => {}, // onNext - * (error) => console.error(error), // onError - * ); - * - * unsubscribe(); - * ``` - * @param onNext A callback to be called every time a new `QuerySnapshot` is available. - * @param onError A callback to be called if the listen fails or is cancelled. No further callbacks will occur. - * @param onCompletion An optional function which will never be called. - */ - onSnapshot(onNext: Function, onError?: Function, onCompletion?: Function): Function; - - /** - * Attaches a listener for `QuerySnapshot` events with snapshot listener options. - * - * NOTE: Although an onCompletion callback can be provided, it will never be called because the snapshot stream is never-ending. - * - * Returns an unsubscribe function to stop listening to events. - * - * #### Example - * - * ```js - * const unsubscribe = firebase.firestore().collection('users') - * .onSnapshot( - * { includeMetadataChanges: true }, // SnapshotListenerOptions - * (querySnapshot) => {}, // onNext - * (error) => console.error(error), // onError - * ); - * - * unsubscribe(); - * ``` - * @param options Options controlling the listen behavior. - * @param onNext A callback to be called every time a new `QuerySnapshot` is available. - * @param onError A callback to be called if the listen fails or is cancelled. No further callbacks will occur. - * @param onCompletion An optional function which will never be called. - */ - onSnapshot( - options: SnapshotListenOptions, - onNext: Function, - onError?: Function, - onCompletion?: Function, - ): Function; - - /** - * Creates and returns a new Query that's additionally sorted by the specified field, optionally in descending order instead of ascending. - * - * * #### Example - * - * #### Example - * - * ```js - * // Get users in order of age, descending - * const querySnapshot = firebase.firestore() - * .collection('users') - * .orderBy('age', 'desc') - * .get(); - * ``` - * - * @param fieldPath The field to sort by. Either a string or FieldPath instance. - * @param directionStr Optional direction to sort by (`asc` or `desc`). If not specified, order will be ascending. - */ - orderBy(fieldPath: string | FieldPath, directionStr?: 'asc' | 'desc'): Query; - - /** - * Creates and returns a new Query that starts after the provided document (exclusive). The start - * position is relative to the order of the query. The document must contain all of the fields - * provided in the orderBy of this query. - * - * #### Example - * - * ```js - * const user = await firebase.firestore().doc('users/alovelace').get(); - * - * // Get all users up to, but not including, a specific user in order of age - * const querySnapshot = await firebase.firestore() - * .collection('users') - * .orderBy('age') - * .startAfter(user); - * ``` - * - * > Cursor snapshot queries have limitations. Please see [Query limitations](/) for more information. - * - * @param snapshot The snapshot of the document to start after. - */ - startAfter(snapshot: DocumentSnapshot): Query; - - /** - * Creates and returns a new Query that starts after the provided fields relative to the order of - * the query. The order of the field values must match the order of the order by clauses of the query. - * - * #### Example - * - * ```js - * // Get all users who's age is above 30 - * const querySnapshot = await firebase.firestore() - * .collection('users') - * .orderBy('age') - * .startAfter(30); - * ``` - * - * @param fieldValues The field values to start this query after, in order of the query's order by. - */ - startAfter(...fieldValues: any[]): Query; - - /** - * Creates and returns a new Query that starts at the provided document (inclusive). The start - * position is relative to the order of the query. The document must contain all of the - * fields provided in the orderBy of this query. - * - * #### Example - * - * ```js - * const user = await firebase.firestore().doc('users/alovelace').get(); - * - * // Get all users up to a specific user in order of age - * const querySnapshot = await firebase.firestore() - * .collection('users') - * .orderBy('age') - * .startAt(user); - * ``` - * - * > Cursor snapshot queries have limitations. Please see [Query limitations](/) for more information. - * - * @param snapshot The snapshot of the document to start at. - */ - startAt(snapshot: DocumentSnapshot): Query; - - /** - * Creates and returns a new Query that starts at the provided fields relative to the order of the query. - * The order of the field values must match the order of the order by clauses of the query. - * - * #### Example - * - * ```js - * // Get all users who's age is 30 or above - * const querySnapshot = await firebase.firestore() - * .collection('users') - * .orderBy('age') - * .startAt(30); - * ``` - * - * @param fieldValues The field values to start this query at, in order of the query's order by. - */ - startAt(...fieldValues: any[]): Query; -} - -/** - * A `QuerySnapshot` contains zero or more `DocumentSnapshot` objects representing the results of a query. The documents - * can be accessed as an array via the `docs` property or enumerated using the `forEach` method. The number of documents - * can be determined via the `empty` and `size` properties. - */ -export interface QuerySnapshot { - /** - * An array of all the documents in the `QuerySnapshot`. - */ - docs: DocumentSnapshot[]; - - /** - * True if there are no documents in the `QuerySnapshot`. - */ - empty: boolean; - - /** - * Metadata about this snapshot, concerning its source and if it has local modifications. - */ - metadata: SnapshotMetadata; - - /** - * The query on which you called get or `onSnapshot` in order to `get` this `QuerySnapshot`. - */ - query: Query; - - /** - * The number of documents in the `QuerySnapshot`. - */ - size: number; - - /** - * Returns an array of the documents changes since the last snapshot. If this is the first snapshot, all documents - * will be in the list as added changes. - * - * To include metadata changes, ensure that the `onSnapshot()` method includes metadata changes. - * - * #### Example - * - * ```js - * firebase.firestore().collection('users') - * .onSnapshot((querySnapshot) => { - * console.log('Metadata Changes', querySnapshot.docChanges()); - * }); - * ``` - * - * #### Example - With metadata changes - * - * ```js - * firebase.firestore().collection('users') - * .onSnapshot({ includeMetadataChanges: true }, (querySnapshot) => { - * console.log('Metadata Changes', querySnapshot.docChanges({ - * includeMetadataChanges: true, - * })); - * }); - * ``` - * - * @param options `SnapshotListenOptions` that control whether metadata-only changes (i.e. only `DocumentSnapshot.metadata` changed) should trigger snapshot events. - */ - docChanges(options?: SnapshotListenOptions): DocumentChange[]; - - /** - * Enumerates all of the documents in the `QuerySnapshot`. - * - * #### Example - * - * ```js - * const querySnapshot = await firebase.firestore().collection('users').get(); - * - * querySnapshot.forEach((documentSnapshot) => { - * console.log('User', documentSnapshot.data()); - * }) - * ``` - * - * @param callback A callback to be called with a `DocumentSnapshot` for each document in the snapshot. - * @param thisArg The this binding for the callback. - */ - forEach(callback: Function, thisArg?: any): void; - - /** - * Returns true if this `QuerySnapshot` is equal to the provided one. - * - * #### Example - * - * ```js - * const querySnapshot1 = await firebase.firestore().collection('users').limit(5).get(); - * const querySnapshot2 = await firebase.firestore().collection('users').limit(10).get(); - * - * // false - * querySnapshot1.isEqual(querySnapshot2); - * ``` - * - * > This operation can be resource intensive when dealing with large datasets. - * - * @param other The `QuerySnapshot` to compare against. - */ - isEqual(other: QuerySnapshot): boolean; -} - -/** - * An options object that configures the behavior of set() calls in `DocumentReference`, `WriteBatch` and `Transaction`. - * These calls can be configured to perform granular merges instead of overwriting the target documents in their entirety - * by providing a `SetOptions` with `merge: true`. - * - * Using both `merge` and `mergeFields` together will throw an error. - */ -export interface SetOptions { - /** - * Changes the behavior of a `set()` call to only replace the values specified in its data argument. - * Fields omitted from the `set()` call remain untouched. - */ - merge: boolean; - - /** - * Changes the behavior of `set()` calls to only replace the specified field paths. - * Any field path that is not specified is ignored and remains untouched. - */ - mergeField: (string | FieldPath)[]; -} - -/** - * Specifies custom configurations for your Cloud Firestore instance. You must set these before invoking any other methods. - * - * Used with `firebase.firestore().settings()`. - */ -export interface Settings { - /** - * Enables or disables local persistent storage. - */ - persistence: boolean; - - /** - * An approximate cache size threshold for the on-disk data. If the cache grows beyond this size, Firestore will start - * removing data that hasn't been recently used. The size is not a guarantee that the cache will stay below that size, - * only that if the cache exceeds the given size, cleanup will be attempted. - * - * To disable garbage collection and set an unlimited cache size, use `firebase.firestore.CACHE_SIZE_UNLIMITED`. - */ - cacheSizeBytes: number; - - /** - * The hostname to connect to. - */ - host: string; - - /** - * Whether to use SSL when connecting. - */ - ssl: boolean; -} - -/** - * An options object that can be passed to `DocumentReference.onSnapshot()`, `Query.onSnapshot()` and `QuerySnapshot.docChanges()` - * to control which types of changes to include in the result set. - */ -export interface SnapshotListenOptions { - /** - * Include a change even if only the metadata of the query or of a document changed. Default is false. - */ - includeMetadataChanges: boolean; -} - -/** - * Metadata about a snapshot, describing the state of the snapshot. - */ -export interface SnapshotMetadata { - /** - * True if the snapshot includes local writes (`set()` or `update()` calls) that haven't been committed to the backend yet. - * If your listener has opted into metadata updates (via `SnapshotListenOptions`) you will receive another snapshot with - * `fromCache` equal to false once the client has received up-to-date data from the backend. - */ - fromCache: boolean; - - /** - * True if the snapshot contains the result of local writes (e.g. `set()` or `update()` calls) that have not yet been - * committed to the backend. If your listener has opted into metadata updates (via `SnapshotListenOptions`) you will - * receive another snapshot with `hasPendingWrites` equal to false once the writes have been committed to the backend. - */ - hasPendingWrites: boolean; - - /** - * Returns true if this `SnapshotMetadata` is equal to the provided one. - * - * @param other The `SnapshotMetadata` to compare against. - */ - isEqual(other: SnapshotMetadata): boolean; -} - -/** - * A Timestamp represents a point in time independent of any time zone or calendar, represented as seconds and - * fractions of seconds at nanosecond resolution in UTC Epoch time. - * - * It is encoded using the Proleptic Gregorian Calendar which extends the Gregorian calendar backwards to year one. - * It is encoded assuming all minutes are 60 seconds long, i.e. leap seconds are "smeared" so that no leap second table - * is needed for interpretation. Range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. - */ -export class Timestamp { - /** - * Creates a new timestamp from the given JavaScript [Date](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date). - * - * @param date The date to initialize the `Timestamp` from. - */ - static fromDate: (date: Date) => Timestamp; - - /** - * Creates a new timestamp from the given number of milliseconds. - * - * @param milliseconds Number of milliseconds since Unix epoch 1970-01-01T00:00:00Z. - */ - static fromMillis: (milliseconds: number) => Timestamp; - - /** - * Creates a new timestamp with the current date, with millisecond precision. - */ - static now: () => Timestamp; - - /** - * Creates a new timestamp. - * - * @param seconds The number of seconds of UTC time since Unix epoch 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive. - * @param nanoseconds The non-negative fractions of a second at nanosecond resolution. Negative second values with fractions must still have non-negative nanoseconds values that count forward in time. Must be from 0 to 999,999,999 inclusive. - */ - // TODO don't think this is possible on flow? - // constructor(seconds: number, nanoseconds: number); - - /** - * The number of nanoseconds of this `Timestamp`; - */ - nanoseconds: number; - - /** - * The number of seconds of this `Timestamp`. - */ - seconds: number; - - /** - * Returns true if this `Timestamp` is equal to the provided one. - * - * @param other The `Timestamp` to compare against. - */ - isEqual: (other: Timestamp) => boolean; - - /** - * Convert a Timestamp to a JavaScript Date object. This conversion causes a loss of precision since Date objects - * only support millisecond precision. - * - * Returns a JavaScript [Date](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) with - * millseconds precision. - */ - toDate: () => Date; - - /** - * Convert a timestamp to a numeric timestamp (in milliseconds since epoch). This operation causes a loss of precision. - * - * The point in time corresponding to this timestamp, represented as the number of milliseconds since Unix epoch 1970-01-01T00:00:00Z. - */ - toMillis: () => number; -} - -/** - * A reference to a transaction. The `Transaction` object passed to a transaction's updateFunction provides the methods to - * read and write data within the transaction context. See `Firestore.runTransaction()`. - * - * A transaction consists of any number of `get()` operations followed by any number of write operations such as set(), - * `update()`, or `delete()`. In the case of a concurrent edit, Cloud Firestore runs the entire transaction again. For example, - * if a transaction reads documents and another client modifies any of those documents, Cloud Firestore retries the transaction. - * This feature ensures that the transaction runs on up-to-date and consistent data. - * - * Transactions never partially apply writes. All writes execute at the end of a successful transaction. - * - * When using transactions, note that: - * - Read operations must come before write operations. - * - A function calling a transaction (transaction function) might run more than once if a concurrent edit affects a document that the transaction reads. - * - Transaction functions should not directly modify application state (return a value from the `updateFunction`). - * - Transactions will fail when the client is offline. - */ -export interface Transaction { - /** - * Deletes the document referred to by the provided `DocumentReference`. - * - * #### Example - * - * ```js - * const docRef = firebase.firestore().doc('users/alovelace'); - * - * await firebase.firestore().runTransaction((transaction) => { - * return transaction.delete(docRef); - * }); - * ``` - * - * @param documentRef A reference to the document to be deleted. - */ - delete(documentRef: DocumentReference): Transaction; - - /** - * Reads the document referenced by the provided `DocumentReference`. - * - * #### Example - * - * ```js - * const docRef = firebase.firestore().doc('users/alovelace'); - * - * await firebase.firestore().runTransaction(async (transaction) => { - * const snapshot = await transaction.get(docRef); - * // use snapshot with transaction (see set() or update()) - * ... - * }); - * ``` - * - * @param documentRef A reference to the document to be read. - */ - get(documentRef: DocumentReference): Promise; - - /** - * Writes to the document referred to by the provided `DocumentReference`. If the document does not exist yet, - * it will be created. If you pass `SetOptions`, the provided data can be merged into the existing document. - * - * #### Example - * - * ```js - * const docRef = firebase.firestore().doc('users/alovelace'); - * - * await firebase.firestore().runTransaction((transaction) => { - * const snapshot = await transaction.get(docRef); - * const snapshotData = snapshot.data(); - * - * return transaction.set(docRef, { - * ...data, - * age: 30, // new field - * }); - * }); - * ``` - * - * @param documentRef A reference to the document to be set. - * @param data An object of the fields and values for the document. - * @param options An object to configure the set behavior. - */ - set(documentRef: DocumentReference, data: { [key]: value }, options?: SetOptions): Transaction; - - /** - * Updates fields in the document referred to by the provided `DocumentReference`. The update will fail if applied - * to a document that does not exist. - * - * #### Example - * - * ```js - * const docRef = firebase.firestore().doc('users/alovelace'); - * - * await firebase.firestore().runTransaction((transaction) => { - * const snapshot = await transaction.get(docRef); - * - * return transaction.update(docRef, { - * age: snapshot.data().age + 1, - * }); - * }); - * ``` - * - * @param documentRef A reference to the document to be updated. - * @param data An object containing the fields and values with which to update the document. Fields can contain dots to reference nested fields within the document. - */ - update(documentRef: DocumentReference, data: { [key]: value }): Transaction; - - /** - * Updates fields in the document referred to by the provided DocumentReference. The update will fail if applied to - * a document that does not exist. - * - * Nested fields can be updated by providing dot-separated field path strings or by providing FieldPath objects. - * - * #### Example - * - * ```js - * const docRef = firebase.firestore().doc('users/alovelace'); - * - * await firebase.firestore().runTransaction((transaction) => { - * const snapshot = await transaction.get(docRef); - * - * return transaction.update(docRef, 'age', snapshot.data().age + 1); - * }); - * ``` - * - * @param documentRef A reference to the document to be updated. - * @param field The first field to update. - * @param value The first value. - * @param moreFieldsAndValues Additional key/value pairs. - */ - update( - documentRef: DocumentReference, - field: string | FieldPath, - value: any, - ...moreFieldsAndValues: any[] - ): Transaction; -} - -/** - * A write batch, used to perform multiple writes as a single atomic unit. - * - * A WriteBatch object can be acquired by calling `firestore.batch()`. It provides methods for adding - * writes to the write batch. None of the writes will be committed (or visible locally) until - * `WriteBatch.commit()` is called. - * - * Unlike transactions, write batches are persisted offline and therefore are preferable when you don't need to - * condition your writes on read data. - */ -export interface WriteBatch { - /** - * Commits all of the writes in this write batch as a single atomic unit. - * - * Returns a Promise resolved once all of the writes in the batch have been successfully written - * to the backend as an atomic unit. Note that it won't resolve while you're offline. - * - * #### Example - * - * ```js - * const batch = firebase.firestore().batch(); - * - * // Perform batch operations... - * - * await batch.commit(); - * ``` - */ - commit(): Promise; - - /** - * Deletes the document referred to by the provided `DocumentReference`. - * - * #### Example - * - * ```js - * const batch = firebase.firestore().batch(); - * const docRef = firebase.firestore().doc('users/alovelace'); - * - * batch.delete(docRef); - * ``` - * - * @param documentRef A reference to the document to be deleted. - */ - delete(documentRef: DocumentReference): WriteBatch; - - /** - * Writes to the document referred to by the provided DocumentReference. If the document does - * not exist yet, it will be created. If you pass SetOptions, the provided data can be merged - * into the existing document. - * - * #### Example - * - * ```js - * const batch = firebase.firestore().batch(); - * const docRef = firebase.firestore().doc('users/dsmith'); - * - * batch.set(docRef, { - * name: 'David Smith', - * age: 25, - * }); - * ``` - * - * @param documentRef A reference to the document to be set. - * @param data An object of the fields and values for the document. - * @param options An object to configure the set behavior. - */ - set(documentRef: DocumentReference, data: { [key]: value }, options?: SetOptions): WriteBatch; - - /** - * Updates fields in the document referred to by the provided DocumentReference. The update will fail if applied to a document that does not exist. - * - * #### Example - * - * ```js - * const batch = firebase.firestore().batch(); - * const docRef = firebase.firestore().doc('users/alovelace'); - * - * batch.update(docRef, { - * city: 'SF', - * }); - * ``` - * - * @param documentRef A reference to the document to be updated. - * @param data An object containing the fields and values with which to update the document. Fields can contain dots to reference nested fields within the document. - */ - update(documentRef: DocumentReference, data: { [key]: value }): WriteBatch; - - /** - * Updates fields in the document referred to by this DocumentReference. The update will fail if applied to a document that does not exist. - * - * Nested fields can be update by providing dot-separated field path strings or by providing FieldPath objects. - * - * #### Example - * - * ```js - * const batch = firebase.firestore().batch(); - * const docRef = firebase.firestore().doc('users/alovelace'); - * - * batch.update(docRef, 'city', 'SF', 'age', 31); - * ``` - * - * @param documentRef A reference to the document to be updated. - * @param field The first field to update. - * @param value The first value. - * @param moreFieldAndValues Additional key value pairs. - */ - update( - documentRef: DocumentReference, - field: string | FieldPath, - value: any, - ...moreFieldAndValues: any[] - ): WriteBatch; -} - -export interface Statics { - /** - * Returns the `Blob` class. - */ - Blob: Blob; - - /** - * Returns the `FieldPath` class. - */ - FieldPath: FieldPath; - - /** - * Returns the `FieldValue` class. - */ - FieldValue: FieldValue; - - /** - * Returns the `GeoPoint` class. - */ - GeoPoint: GeoPoint; - - /** - * Returns the `Timestamp` class. - */ - Timestamp: Timestamp; - - /** - * Used to set the cache size to unlimited when passing to `cacheSizeBytes` in - * `firebase.firestore().settings()`. - */ - CACHE_SIZE_UNLIMITED: number; - - /** - * Sets the verbosity of Cloud Firestore native device logs (debug, error, or silent). - * - * - `debug`: the most verbose logging level, primarily for debugging. - * - `error`: logs only error events. - * - `silent`: turn off logging. - * - * #### Example - * - * ```js - * firebase.firestore.setLogLevel('silent'); - * ``` - * - * @param logLevel The verbosity you set for activity and error logging. - */ - setLogLevel(logLevel: 'debug' | 'error' | 'silent'): void; -} - -/** - * The Firebase Cloud Firestore service is available for the default app or a given app. - * - * #### Example 1 - * - * Get the firestore instance for the **default app**: - * - * ```js - * const firestoreForDefaultApp = firebase.firestore(); - * ``` - * - * #### Example 2 - * - * Get the firestore instance for a **secondary app**: - * - * ```js - * const otherApp = firebase.app('otherApp'); - * const firestoreForOtherApp = firebase.firestore(otherApp); - * ``` - * - */ -export interface Module extends ReactNativeFirebaseModule { - /** - * Creates a write batch, used for performing multiple writes as a single atomic operation. - * The maximum number of writes allowed in a single WriteBatch is 500, but note that each usage - * of `FieldValue.serverTimestamp()`, `FieldValue.arrayUnion()`, `FieldValue.arrayRemove()`, or `FieldValue.increment()` - * inside a WriteBatch counts as an additional write. - * - * #### Example - * - * ```js - * const batch = firebase.firestore().batch(); - * batch.delete(...); - * ``` - */ - batch(): WriteBatch; - - /** - * Gets a `CollectionReference` instance that refers to the collection at the specified path. - * - * #### Example - * - * ```js - * const collectionReference = firebase.firestore().collection('users'); - * ``` - * - * @param collectionPath A slash-separated path to a collection. - */ - collection(collectionPath: string): CollectionReference; - - /** - * Creates and returns a new Query that includes all documents in the database that are contained - * in a collection or subcollection with the given collectionId. - * - * #### Example - * - * ```js - * const collectionGroup = firebase.firestore().collection('orders'); - * ``` - * - * @param collectionId Identifies the collections to query over. Every collection or subcollection with this ID as the last segment of its path will be included. Cannot contain a slash. - */ - collectionGroup(collectionId: string): Query; - - /** - * Disables network usage for this instance. It can be re-enabled via `enableNetwork()`. While the - * network is disabled, any snapshot listeners or get() calls will return results from cache, and any - * write operations will be queued until the network is restored. - * - * Returns a promise that is resolved once the network has been disabled. - * - * #### Example - * - * ```js - * await firebase.firestore().disableNetwork(); - * ``` - */ - disableNetwork(): Promise; - - /** - * Gets a `DocumentReference` instance that refers to the document at the specified path. - * - * #### Example - * - * ```js - * const documentReference = firebase.firestore().doc('users/alovelace'); - * ``` - * - * @param documentPath A slash-separated path to a document. - */ - doc(documentPath: string): DocumentReference; - - /** - * Re-enables use of the network for this Firestore instance after a prior call to `disableNetwork()`. - */ - enableNetwork(): Promise; - - /** - * Executes the given `updateFunction` and then attempts to commit the changes applied within the transaction. - * If any document read within the transaction has changed, Cloud Firestore retries the `updateFunction`. - * If it fails to commit after 5 attempts, the transaction fails. - * - * The maximum number of writes allowed in a single transaction is 500, but note that each usage of - * `FieldValue.serverTimestamp()`, `FieldValue.arrayUnion()`, `FieldValue.arrayRemove()`, or `FieldValue.increment()` - * inside a transaction counts as an additional write. - * - * #### Example - * - * ```js - * const cityRef = firebase.firestore().doc('cities/SF'); - * - * await firebase.firestore() - * .runTransaction(async (transaction) => { - * const snapshot = await transaction.get(cityRef); - * await transaction.update(cityRef, { - * population: snapshot.data().population + 1, - * }); - * }); - * ``` - */ - runTransaction(updateFunction: (transaction: Transaction) => Promise): Promise; - - /** - * Specifies custom settings to be used to configure the Firestore instance. Must be set before invoking any other methods. - * - * #### Example - * - * ```js - * const settings = { - * cacheSizeBytes: firebase.firestore.CACHE_SIZE_UNLIMITED, - * }; - * - * await firebase.firestore().settings(settings); - * ``` - * - * @param settings A `Settings` object. - */ - settings(settings: Settings): Promise; -} - -declare module '@react-native-firebase/firestore' { - import type { - ReactNativeFirebaseNamespace, - ReactNativeFirebaseModuleAndStatics, - } from '@react-native-firebase/app-types/index.js.flow'; - /** - * @example - * ```js - * import { firebase } from '@react-native-firebase/firestore'; - * firebase.firestore().X(...); - * ``` - */ - declare export var firebase: {} & ReactNativeFirebaseNamespace; - - /** - * @example - * ```js - * import firestore from '@react-native-firebase/firestore'; - * firestore().X(...); - * ``` - */ - declare export default ReactNativeFirebaseModuleAndStatics; -} - -/** - * Attach namespace to `firebase.` and `FirebaseApp.`. - */ -declare module '@react-native-firebase/app-types' { - import type { ReactNativeFirebaseModuleAndStatics } from '@react-native-firebase/app-types/index.js.flow'; - - declare interface ReactNativeFirebaseNamespace { - /** - * Firestore - */ - firestore: ReactNativeFirebaseModuleAndStatics; - } - - declare interface FirebaseApp { - /** - * Firestore - */ - firestore(): Module; - } -} diff --git a/packages/functions/lib/index.js.flow b/packages/functions/lib/index.js.flow deleted file mode 100644 index 46ddd02609..0000000000 --- a/packages/functions/lib/index.js.flow +++ /dev/null @@ -1,316 +0,0 @@ -/* - * Copyright (c) 2016-present Invertase Limited & Contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this library except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -import { ReactNativeFirebaseModule } from '@react-native-firebase/app-types/index.js.flow'; - -/** - * The set of Firebase Functions status codes. - * - * The codes are the same at the ones exposed by [gRPC](https://github.com/grpc/grpc/blob/master/doc/statuscodes.md). - * - * Possible values: - * - `cancelled`: The operation was cancelled (typically by the caller). - * - `unknown`: Unknown error or an error from a different error domain. - * - `invalid-argument`: Client specified an invalid argument. Note that this - * differs from `failed-precondition`. `invalid-argument` indicates - * arguments that are problematic regardless of the state of the system - * (e.g. an invalid field name). - * - `deadline-exceeded`: Deadline expired before operation could complete. - * For operations that change the state of the system, this error may be - * returned even if the operation has completed successfully. For example, - * a successful response from a server could have been delayed long enough - * for the deadline to expire. - * - `not-found`: Some requested document was not found. - * - `already-exists`: Some document that we attempted to create already - * exists. - * - `permission-denied`: The caller does not have permission to execute the - * specified operation. - * - `resource-exhausted`: Some resource has been exhausted, perhaps a - * per-user quota, or perhaps the entire file system is out of space. - * - `failed-precondition`: Operation was rejected because the system is not - * in a state required for the operation's execution. - * - `aborted`: The operation was aborted, typically due to a concurrency - * issue like transaction aborts, etc. - * - `out-of-range`: Operation was attempted past the valid range. - * - `unimplemented`: Operation is not implemented or not supported/enabled. - * - `internal`: Internal errors. Means some invariants expected by - * underlying system has been broken. If you see one of these errors, - * something is very broken. - * - `unavailable`: The service is currently unavailable. This is most likely - * a transient condition and may be corrected by retrying with a backoff. - * - `data-loss`: Unrecoverable data loss or corruption. - * - `unauthenticated`: The request does not have valid authentication - * credentials for the operation. - */ -export type FunctionsErrorCode = - | 'ok' - | 'cancelled' - | 'unknown' - | 'invalid-argument' - | 'deadline-exceeded' - | 'not-found' - | 'already-exists' - | 'permission-denied' - | 'resource-exhausted' - | 'failed-precondition' - | 'aborted' - | 'out-of-range' - | 'unimplemented' - | 'internal' - | 'unavailable' - | 'data-loss' - | 'unauthenticated'; - -/** - * An HttpsCallableResult wraps a single result from a function call. - */ -export interface HttpsCallableResult { - data: any; -} - -/** - * An HttpsCallable is a reference to a "callable" http trigger in - * Google Cloud Functions. - * - * #### Example - * - * ```js - * // Create a HttpsCallable instance - * const instance = functions().httpsCallable('order'); - * - * try { - * const response = await instance({ - * id: '12345', - * }); - * } catch (e) { - * console.error(e); - * } - * ``` - */ -export interface HttpsCallable { - (data?: any): Promise; -} - -/** - * An HttpsError wraps a single error from a function call. - * - * #### Example - * - * ```js - * try { - * await functions().httpsCallable('order')(); - * } catch (httpsError) { - * console.log('Message', httpsError.message); - * - * // Check code - * if (httpsError.code === firebase.functions.HttpsErrorCode.NOT_FOUND) { - * console.error('Functions endpoint "order" not found'); - * } - * } - * ``` - */ -export interface HttpsError extends Error { - /** - * A standard error code that will be returned to the client. This also - * determines the HTTP status code of the response, as defined in code.proto. - * - * #### Example - * - * ```js - * try { - * await functions().httpsCallable('order')(); - * } catch (httpsError) { - * console.error(httpsError.code); - * } - * ``` - */ - code: FunctionsErrorCode; - /** - * Extra data to be converted to JSON and included in the error response. - * - * ```js - * try { - * await functions().httpsCallable('order')(); - * } catch (httpsError) { - * if (httpsError.details) { - * console.error(httpsError.details); - * } - * } - * ``` - */ - details?: any; -} - -/** - * The HttpsErrorCode interface provides access to all FunctionsErrorCode - * type aliases. - * - * #### Example - * - * ```js - * try { - * await functions().httpsCallable('order')(); - * } catch (httpsError) { - * switch(httpsError.code) { - * case firebase.functions.HttpsErrorCode.NOT_FOUND: - * console.error('Functions endpoint not found'); - * break; - * case firebase.functions.HttpsErrorCode.CANCELLED: - * console.error('The operation was cancelled'); - * break; - * default: - * console.error('An error occurred'); - * break; - * } - * } - * ``` - */ -interface HttpsErrorCode { - OK: 'ok'; - CANCELLED: 'cancelled'; - UNKNOWN: 'unknown'; - INVALID_ARGUMENT: 'invalid-argument'; - DEADLINE_EXCEEDED: 'deadline-exceeded'; - NOT_FOUND: 'not-found'; - ALREADY_EXISTS: 'already-exists'; - PERMISSION_DENIED: 'permission-denied'; - UNAUTHENTICATED: 'unauthenticated'; - RESOURCE_EXHAUSTED: 'resource-exhausted'; - FAILED_PRECONDITION: 'failed-precondition'; - ABORTED: 'aborted'; - OUT_OF_RANGE: 'out-of-range'; - UNIMPLEMENTED: 'unimplemented'; - INTERNAL: 'internal'; - UNAVAILABLE: 'unavailable'; - DATA_LOSS: 'data-loss'; -} - -/** - * firebase.functions.X - */ -export interface Statics { - /** - * Uppercase + underscored variables of @Functions.FunctionsErrorCode - * - * #### Example - * - * ```js - * firebase.functions.HttpsErrorCode.OK; - * ``` - */ - HttpsErrorCode: {} & HttpsErrorCode; -} - -/** - * firebase.functions().X - */ -interface Module extends ReactNativeFirebaseModule { - /** - * Gets an `HttpsCallable` instance that refers to the function with the given - * name. - * - * #### Example - * - * ```js - * const instance = functions().httpsCallable('order'); - * - * try { - * const response = await instance({ - * id: '12345', - * }); - * } catch (e) { - * console.error(e); - * } - * ``` - * - * @param name The name of the https callable function. - * @return The `HttpsCallable` instance. - */ - httpsCallable(name: string): HttpsCallable; - - /** - * Changes this instance to point to a Cloud Functions emulator running - * locally. - * - * See https://firebase.google.com/docs/functions/local-emulator - * - * #### Example - * - * ```js - * if (__DEV__) { - * functions().useFunctionsEmulator('http://10.0.0.8:1337'); - * } - * ``` - * - * @param origin The origin string of the local emulator started via firebase tools - * "http://10.0.0.8:1337". - */ - useFunctionsEmulator(origin: string): void; -} - -declare module '@react-native-firebase/functions' { - import type { - ReactNativeFirebaseNamespace, - ReactNativeFirebaseModuleAndStaticsWithApp, - } from '@react-native-firebase/app-types/index.js.flow'; - - declare export var HttpsErrorCode: {} & HttpsErrorCode; - - /** - * @example - * ```js - * import { firebase } from '@react-native-firebase/functions'; - * firebase.functions().httpsCallable(...); - * ``` - */ - declare export var firebase: {} & ReactNativeFirebaseNamespace; - - declare var FunctionsDefaultExport: ReactNativeFirebaseModuleAndStaticsWithApp; - /** - * @example - * ```js - * import functions from '@react-native-firebase/functions'; - * functions().httpsCallable(...); - * ``` - */ - declare export default FunctionsDefaultExport; -} - -/** - * Attach namespace to `firebase.` and `FirebaseApp.`. - */ -declare module '@react-native-firebase/app-types' { - declare interface ReactNativeFirebaseNamespace { - /** - * The Cloud Functions for Firebase client SDKs let you call functions - * directly from a Firebase app. To call a function from your app in this way, - * write and deploy an HTTPS Callable function in Cloud Functions, - * and then add client logic to call the function from your app. - */ - functions: ReactNativeFirebaseModuleAndStaticsWithApp; - } - - declare interface FirebaseApp { - /** - * The Cloud Functions for Firebase client SDKs let you call functions - * directly from a Firebase app. To call a function from your app in this way, - * write and deploy an HTTPS Callable function in Cloud Functions, - * and then add client logic to call the function from your app. - */ - functions(region?: string): Module; - } -} diff --git a/packages/iid/lib/index.js.flow b/packages/iid/lib/index.js.flow deleted file mode 100644 index 402cca8ab5..0000000000 --- a/packages/iid/lib/index.js.flow +++ /dev/null @@ -1,136 +0,0 @@ -/* eslint-disable import/no-duplicates */ -/* - * Copyright (c) 2016-present Invertase Limited & Contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this library except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -import type { ReactNativeFirebaseModule } from '@react-native-firebase/app-types/index.js.flow'; - -export interface Statics {} - -export interface Module extends ReactNativeFirebaseModule { - /** - * Returns a identifier that uniquely identifies the app instance. - * - * Once an Instance ID is generated, Firebase periodically sends information about the application - * and the device it's running on to the Firebase backend. To stop this, see `delete()`. - * - * #### Example - * - * ```js - * const id = firebase.iid().get(); - * ``` - */ - get(): Promise; - - /** - * Delete the Instance ID and all data associated with it. This stops the periodic sending of data to the Firebase - * backend that was started when the Instance ID was generated. - * - * A new Instance ID is asynchronously generated unless auto initialisation is turned off. - * - * #### Example - * - * ```js - * await firebase.iid().delete(); - * ``` - */ - delete(): Promise; - - /** - * Returns a token that authorizes an Entity to perform an action on behalf of the application. - * - * #### Example - * - * ```js - * const token = await firebase.iid().getToken(firebase.app().options.storageBucket, '*'); - * ``` - * - * @param authorizedEntity Entity authorized by the token. Defaults to the apps `messagingSenderId` option. - * @param scope Action authorized for authorizedEntity. Defaults to '*'. - */ - getToken(authorizedEntity?: string, scope?: string): Promise; - - /** - * Revokes access to a scope for an entity previously authorized by `getToken()`. - * - * #### Example - * - * ```js - * await firebase.iid().deleteToken(firebase.app().options.storageBucket, '*'); - * ``` - * - * @param authorizedEntity Entity authorized by the token. Defaults to the apps' `messagingSenderId` option. - * @param scope Action authorized for authorizedEntity. Defaults to '*'. - */ - deleteToken(authorizedEntity?: string, scope?: string): Promise; -} - -declare module '@react-native-firebase/iid' { - import type { - ReactNativeFirebaseNamespace, - ReactNativeFirebaseModuleAndStaticsWithApp, - } from '@react-native-firebase/app-types/index.js.flow'; - /** - * @example - * ```js - * import { firebase } from '@react-native-firebase/iid'; - * firebase.iid().X(...); - * ``` - */ - declare export var firebase: {} & ReactNativeFirebaseNamespace; - - /** - * @example - * ```js - * import iid from '@react-native-firebase/iid'; - * iid().X(...); - * ``` - */ - declare export default ReactNativeFirebaseModuleAndStaticsWithApp; -} - -/** - * Attach namespace to `firebase.` and `FirebaseApp.`. - */ -declare module '@react-native-firebase/app-types' { - import type { ReactNativeFirebaseModuleAndStaticsWithApp } from '@react-native-firebase/app-types/index.js.flow'; - - declare interface ReactNativeFirebaseNamespace { - /** - * Firebase Instance ID provides a unique identifier for each instance of your app and a mechanism to authenticate - * and authorize actions for it (for example: sending FCM messages). - * - * An Instance ID is long lived except when you call delete, the app is restored on a new device, the user - * uninstalls/reinstall the app or the user clears the app data (clearing data applies to Android only). - * - * @firebase iid - */ - iid: ReactNativeFirebaseModuleAndStaticsWithApp; - } - - declare interface FirebaseApp { - /** - * Firebase Instance ID provides a unique identifier for each instance of your app and a mechanism to authenticate - * and authorize actions for it (for example: sending FCM messages). - * - * An Instance ID is long lived except when you call delete, the app is restored on a new device, the user - * uninstalls/reinstall the app or the user clears the app data (clearing data applies to Android only). - * - * @firebase iid - */ - iid(): Module; - } -} diff --git a/packages/in-app-messaging/lib/index.js.flow b/packages/in-app-messaging/lib/index.js.flow deleted file mode 100644 index d3bfb489b7..0000000000 --- a/packages/in-app-messaging/lib/index.js.flow +++ /dev/null @@ -1,130 +0,0 @@ -/* eslint-disable import/no-duplicates */ -/* - * Copyright (c) 2016-present Invertase Limited & Contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this library except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -import type { ReactNativeFirebaseModule } from '@react-native-firebase/app-types/index.js.flow'; - -export interface Statics {} - -export interface Module extends ReactNativeFirebaseModule { - /** - * Determines whether messages are suppressed or not. - * - * #### Example - * - * ```js - * const isSuppressed = firebase.inAppMessaging().isMessagesDisplaySuppressed; - * ``` - */ - isMessagesDisplaySuppressed: boolean; - - /** - * Enable or disable suppression of Firebase In App Messaging messages. - * - * When enabled, no in app messages will be rendered until either you disable suppression, or the app restarts. - * This state is not persisted between app restarts. - * - * #### Example - * - * ```js - * // Suppress messages - * await firebase.inAppMessaging().setMessagesDisplaySuppressed(true); - * ``` - * - * @param enabled Whether messages should be suppressed. - */ - setMessagesDisplaySuppressed(enabled: boolean): Promise; - - /** - * Determines whether automatic data collection is enabled or not. - * - * #### Example - * - * ```js - * const isDataCollectionEnabled = firebase.inAppMessaging().isAutomaticDataCollectionEnabled; - * ``` - */ - isAutomaticDataCollectionEnabled: boolean; - - /** - * Enable or disable automatic data collection for Firebase In-App Messaging. - * - * When enabled, generates a registration token on app startup if there is no valid one and generates a new token - * when it is deleted (which prevents deleteInstanceId() from stopping the periodic sending of data). - * - * This setting is persisted across app restarts and overrides the setting specified in your manifest/plist file. - * - * #### Example - * - * ```js - * // Disable data collection - * firebase.inAppMessaging().setAutomaticDataCollectionEnabled(false); - * ``` - * - * @param enabled Whether automatic data collection is enabled. - */ - setAutomaticDataCollectionEnabled(enabled: boolean): Promise; -} - -declare module '@react-native-firebase/in-app-messaging' { - import type { - ReactNativeFirebaseNamespace, - ReactNativeFirebaseModuleAndStatics, - } from '@react-native-firebase/app-types/index.js.flow'; - /** - * @example - * ```js - * import { firebase } from '@react-native-firebase/in-app-messaging'; - * firebase.inAppMessaging().X(...); - * ``` - */ - declare export var firebase: {} & ReactNativeFirebaseNamespace; - - /** - * @example - * ```js - * import inAppMessaging from '@react-native-firebase/in-app-messaging'; - * inAppMessaging().X(...); - * ``` - */ - declare export default ReactNativeFirebaseModuleAndStatics; -} - -/** - * Attach namespace to `firebase.` and `FirebaseApp.`. - */ -declare module '@react-native-firebase/app-types' { - import type { ReactNativeFirebaseModuleAndStatics } from '@react-native-firebase/app-types/index.js.flow'; - - declare interface ReactNativeFirebaseNamespace { - /** - * Firebase In-App Messaging helps you engage users who are actively using your app by sending - * them targeted and contextual messages that nudge them to complete key in-app actions - like - * beating a game level, buying an item, or subscribing to content. - */ - inAppMessaging: ReactNativeFirebaseModuleAndStatics; - } - - declare interface FirebaseApp { - /** - * Firebase In-App Messaging helps you engage users who are actively using your app by sending - * them targeted and contextual messages that nudge them to complete key in-app actions - like - * beating a game level, buying an item, or subscribing to content. - */ - inAppMessaging(): Module; - } -} diff --git a/packages/messaging/lib/index.js.flow b/packages/messaging/lib/index.js.flow deleted file mode 100644 index 353afa48b3..0000000000 --- a/packages/messaging/lib/index.js.flow +++ /dev/null @@ -1,68 +0,0 @@ -/* eslint-disable import/no-duplicates */ -/* - * Copyright (c) 2016-present Invertase Limited & Contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this library except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -import type { ReactNativeFirebaseModule } from '@react-native-firebase/app-types/index.js.flow'; - -export interface Statics {} - -export interface Module extends ReactNativeFirebaseModule {} - -declare module '@react-native-firebase/messaging' { - import type { - ReactNativeFirebaseNamespace, - ReactNativeFirebaseModuleAndStatics, - } from '@react-native-firebase/app-types/index.js.flow'; - /** - * @example - * ```js - * import { firebase } from '@react-native-firebase/messaging'; - * firebase.messaging().X(...); - * ``` - */ - declare export var firebase: {} & ReactNativeFirebaseNamespace; - - /** - * @example - * ```js - * import messaging from '@react-native-firebase/messaging'; - * messaging().X(...); - * ``` - */ - declare export default ReactNativeFirebaseModuleAndStatics; -} - -/** - * Attach namespace to `firebase.` and `FirebaseApp.`. - */ -declare module '@react-native-firebase/app-types' { - import type { ReactNativeFirebaseModuleAndStatics } from '@react-native-firebase/app-types/index.js.flow'; - - declare interface ReactNativeFirebaseNamespace { - /** - * Messaging - */ - messaging: ReactNativeFirebaseModuleAndStatics; - } - - declare interface FirebaseApp { - /** - * Messaging - */ - messaging(): Module; - } -} diff --git a/packages/ml-natural-language/lib/index.js.flow b/packages/ml-natural-language/lib/index.js.flow deleted file mode 100644 index f73518eba8..0000000000 --- a/packages/ml-natural-language/lib/index.js.flow +++ /dev/null @@ -1,213 +0,0 @@ -/* eslint-disable import/no-duplicates */ -/* - * Copyright (c) 2016-present Invertase Limited & Contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this library except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -import type { ReactNativeFirebaseModule } from '@react-native-firebase/app-types/index.js.flow'; - -export interface Statics {} - -/** - * An interface representing the language identification options to be used with the - * `identifyLanguage` and `identifyPossibleLanguages` methods. - */ -export interface LanguageIdentificationOptions { - /** - * The confidence threshold for language identification. The identified languages will have a - * confidence higher or equal to the confidence threshold. The value should be between 0 and 1, e.g. 0.5. - * - * If no value is set, a default value is used instead. - * - */ - confidenceThreshold?: number; -} - -/** - * An identified language for the given input text. Returned as an Array of IdentifiedLanguage from - * `identifyPossibleLanguages`. - */ -export interface IdentifiedLanguage { - /** - * The [BCP-47 language code](https://en.wikipedia.org/wiki/IETF_language_tag) for the language, e.g. 'en'. - */ - language: string; - - /** - * The confidence score of the language. A float value between 0 and 1. - */ - confidence: number; -} - -/** - * An interface representing a suggest reply, an array of these are returned from `suggestReplies` - */ -export interface SuggestedReply { - /** - * The smart reply text. - */ - text: string; -} - -/** - * A `TextMessage` interface provided to `suggestReplies()`. - */ -export interface TextMessage { - /** - * The message text. - * - * This is required and must not be an empty string. - */ - text: string; - - /** - * Whether the message is a local user. If false, a `userId` must be provided for the message. - * - * Defaults to true. - */ - isLocalUser?: boolean; - - /** - * A user ID of a remote user. - * - * Used to help better identify users to provide more accurate replies. - */ - userId?: string; - - /** - * The timestamp of the message in milliseconds. - * - * Defaults to now (`Date.now()`). - */ - timestamp?: number; -} - -/** - * The Firebase ML Kit service interface. - * - * > This module is available for the default app only. - * - * #### Example - * - * Get the ML Kit service for the default app: - * - * ```js - * const defaultAppMLKit = firebase.naturalLanguage(); - * ``` - */ -export interface Module extends ReactNativeFirebaseModule { - /** - * Identifies the main language for the given text. - * - * Returns a promise that resolves with a [BCP-47 language code](https://en.wikipedia.org/wiki/IETF_language_tag) of the detected language. - * - * If the language was undetected or unknown the code returned is `und`. - * - * #### Example - * - * ```js - * const language = await firebase.naturalLanguage().identifyLanguage('Hello there. General Kenobi.'); - * console.warn(language); // en - * - * const unknownLanguage = await firebase.naturalLanguage().identifyLanguage('foo bar baz', { confidenceThreshold: 0.9 }); - * console.warn(language); // und - * ``` - * - * @param text The input text to use for identifying the language. Inputs longer than 200 characters are truncated to 200 characters, as longer input does not improve the detection accuracy. - * @param options See `LanguageIdentificationOptions`. - */ - identifyLanguage(text: string, options?: LanguageIdentificationOptions): Promise; - - /** - * Identifies possible languages for the given text. - * - * #### Example - * - * ```js - * const identifiedLanguages = firebase.naturalLanguage().identifyPossibleLanguages('hello world'); - * console.warn(identifiedLanguages[0].language); // en - * ``` - * - * @param text The input text to use for identifying the language. Inputs longer than 200 characters are truncated to 200 characters, as longer input does not improve the detection accuracy. - * @param options See `LanguageIdentificationOptions`. - */ - identifyPossibleLanguages( - text: string, - options?: LanguageIdentificationOptions, - ): Promise; - - /** - * Returns suggested replies for a conversation. - * - * #### Example - * - * ```js - * const replies = await firebase.naturalLanguage().suggestReplies([ - * { text: "Hey, long time no speak!", }, - * { text: 'I know right, it has been a while..', userId: 'xxxx', isLocalUser: false }, - * { text: 'We should catch up sometime' }, - * { text: 'Definitely, how about we go for lunch this week?', userId: 'xxxx', isLocalUser: false }, - * ]); - * ``` - * - * @param messages An array of `TextMessage` interfaces. - */ - suggestReplies(messages: TextMessage[]): Promise; -} - -declare module '@react-native-firebase/ml-natural-language' { - import type { - ReactNativeFirebaseNamespace, - ReactNativeFirebaseModuleAndStatics, - } from '@react-native-firebase/app-types/index.js.flow'; - /** - * @example - * ```js - * import { firebase } from '@react-native-firebase/ml-natural-language'; - * firebase.naturalLanguage().X(...); - * ``` - */ - declare export var firebase: {} & ReactNativeFirebaseNamespace; - - /** - * @example - * ```js - * import naturalLanguage from '@react-native-firebase/ml-natural-language'; - * naturalLanguage().X(...); - * ``` - */ - declare export default ReactNativeFirebaseModuleAndStatics; -} - -/** - * Attach namespace to `firebase.` and `FirebaseApp.`. - */ -declare module '@react-native-firebase/app-types' { - import type { ReactNativeFirebaseModuleAndStatics } from '@react-native-firebase/app-types/index.js.flow'; - - declare interface ReactNativeFirebaseNamespace { - /** - * ML Kit Natural Language - */ - naturalLanguage: ReactNativeFirebaseModuleAndStatics; - } - - declare interface FirebaseApp { - /** - * ML Kit Natural Language - */ - naturalLanguage(): Module; - } -} diff --git a/packages/ml-vision/lib/index.js.flow b/packages/ml-vision/lib/index.js.flow deleted file mode 100644 index d0d8ea4e14..0000000000 --- a/packages/ml-vision/lib/index.js.flow +++ /dev/null @@ -1,68 +0,0 @@ -/* eslint-disable import/no-duplicates */ -/* - * Copyright (c) 2016-present Invertase Limited & Contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this library except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -import type { ReactNativeFirebaseModule } from '@react-native-firebase/app-types/index.js.flow'; - -export interface Statics {} - -export interface Module extends ReactNativeFirebaseModule {} - -declare module '@react-native-firebase/mlkit' { - import type { - ReactNativeFirebaseNamespace, - ReactNativeFirebaseModuleAndStatics, - } from '@react-native-firebase/app-types/index.js.flow'; - /** - * @example - * ```js - * import { firebase } from '@react-native-firebase/mlkit'; - * firebase.mlkit().X(...); - * ``` - */ - declare export var firebase: {} & ReactNativeFirebaseNamespace; - - /** - * @example - * ```js - * import mlkit from '@react-native-firebase/mlkit'; - * mlkit().X(...); - * ``` - */ - declare export default ReactNativeFirebaseModuleAndStatics; -} - -/** - * Attach namespace to `firebase.` and `FirebaseApp.`. - */ -declare module '@react-native-firebase/app-types' { - import type { ReactNativeFirebaseModuleAndStatics } from '@react-native-firebase/app-types/index.js.flow'; - - declare interface ReactNativeFirebaseNamespace { - /** - * Mlkit - */ - mlkit: ReactNativeFirebaseModuleAndStatics; - } - - declare interface FirebaseApp { - /** - * Mlkit - */ - mlkit(): Module; - } -} diff --git a/packages/perf/lib/index.js.flow b/packages/perf/lib/index.js.flow deleted file mode 100644 index 7e0175d826..0000000000 --- a/packages/perf/lib/index.js.flow +++ /dev/null @@ -1,432 +0,0 @@ -/* eslint-disable import/no-duplicates */ -/* - * Copyright (c) 2016-present Invertase Limited & Contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this library except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -import type { ReactNativeFirebaseModule } from '@react-native-firebase/app-types/index.js.flow'; - -export interface Statics {} - -/** - * Type alias describing the valid HTTP methods accepted when creating a new {@link perf.HttpMetric} instance. - * - * #### Example - * - * ```js - * const metric = firebase.perf().newHttpMetric('https://api.com/user', 'PATCH'); - * ``` - */ -export type HttpMethod = - | 'GET' - | 'HEAD' - | 'PUT' - | 'POST' - | 'PATCH' - | 'TRACE' - | 'DELETE' - | 'CONNECT' - | 'OPTIONS'; - -/** - * Trace allows you to time the beginning to end of a certain action in your app with additional metric values and attributes. - */ -export interface Trace { - /** - * Returns the value of an attribute. Returns null if it does not exist. - * - * #### Example - * - * ```js - * const attribute = trace.getAttribute('userId'); - * ``` - * - * @param attribute Name of the attribute to fetch the value of. - */ - getAttribute(attribute: string): string | null; - - /** - * Sets a String value for the specified attribute. Updates the value of the attribute if it already exists. - * The maximum number of attributes that can be added is 5. - * - * #### Example - * - * ```js - * trace.putAttribute('userId', '123456789'); - * ``` - * - * @param attribute Name of the attribute. Max length is 40 chars. - * @param value Value of the attribute. Max length is 100 chars. - */ - putAttribute(attribute: string, value: string): void; - - /** - * Gets the value of the metric with the given name in the current trace. If the metric - * doesn't exist, it will not be created and a 0 is returned. - * - * #### Example - * - * ```js - * const metric = trace.getMetric('hits'); - * ``` - * - * @param metricName Name of the metric to get. - */ - getMetric(metricName: string): number; - - /** - * Returns an object of all the currently added metrics and their number values. - * - * #### Example - * - * ```js - * const metrics = trace.getMetrics(); - * - * metrics.forEach(($) => { - * console.log($); - * }); - * ``` - */ - getMetrics(): { [key: string]: number }; - - /** - * Sets the value of the named metric with the provided number. - * - * If a metric with the given name exists it will be overwritten. - * If a metric with the given name doesn't exist, a new one will be created. - * - * #### Example - * - * ```js - * trace.putMetric('hits', 1); - * ``` - * - * @param metricName Name of the metric to set. Must not have a leading or trailing whitespace, no leading underscore '_' character and have a max length of 32 characters. - * @param value The value the metric should be set to. - */ - putMetric(metricName: string, value: number): void; - - /** - * Increments the named metric by the `incrementBy` value. - * - * If a metric with the given name doesn't exist, a new one will be created starting with the value of `incrementBy`. - * - * ```js - * trace.incrementMetric('hits', 1); - * ``` - * - * @param metricName Name of the metric to increment. Must not have a leading or trailing whitespace, no leading underscore '_' character and have a max length of 32 characters. - * @param incrementBy The value the metric should be incremented by. - */ - incrementMetric(metricName: string, incrementBy: number): void; - - /** - * Removes a metric by name if it exists. - * - * #### Example - * - * ```js - * trace.removeMetric('hits'); - * ``` - * - * @param metricName Name of the metric to remove. - */ - removeMetric(metricName: string): void; - - /** - * Marks the start time of the trace. Does nothing if already started. - * - * #### Example - * - * ```js - * const trace = firebase.perf().newTrace('example'); - * await trace.start(); - * ``` - */ - start(): Promise; - - /** - * Marks the end time of the trace and queues the metric on the device for transmission. Does nothing if already stopped. - * - * * #### Example - * - * ```js - * const trace = firebase.perf().newTrace('example'); - * await trace.start(); - * trace.putMetric('hits', 1); - * await trace.stop(); - * ``` - */ - stop(): Promise; -} - -/** - * Metric used to collect data for network requests/responses. A new instance must be used for every request/response. - */ -export interface HttpMetric { - /** - * Returns the value of an attribute. Returns null if it does not exist. - * - * #### Example - * - * ```js - * const attribute = metric.getAttribute('user_role'); - * ``` - * - * @param attribute Name of the attribute to fetch the value of - */ - getAttribute(attribute: string): string | null; - - /** - * Returns an object of all the currently added attributes. - * - * #### Example - * - * ```js - * const attributes = metric.getAttributes(); - * - * attributes.forEach(($) => { - * console.log($); - * }); - * ``` - */ - getAttributes(): { [key: string]: string }; - - /** - * Sets a String value for the specified attribute. Updates the value of the attribute if it already exists. - * The maximum number of attributes that can be added is 5. - * - * #### Example - * - * ```js - * metric.putAttribute('user_role', 'admin'); - * ``` - * - * @param attribute Name of the attribute. Max length is 40 chars. - * @param value Value of the attribute. Max length is 100 chars. - */ - putAttribute(attribute: string, value: string): void; - - /** - * Removes an already added attribute. Does nothing if attribute does not exist. - * - * #### Example - * - * ```js - * metric.removeAttribute('user_role'); - * ``` - * - * @param attribute Name of the attribute to be removed. - */ - removeAttribute(attribute: string): void; - - /** - * Sets the httpResponse code of the request. - * - * #### Example - * - * ```js - * const response = await fetch(url); - * metric.setHttpResponseCode(response.status); - * ``` - * > This is required for every request, if you do not provide this your metric will not be captured. - * - * @param code Value must be greater than 0. Set to null to remove. Invalid usage will be logged natively. - */ - setHttpResponseCode(code: number | null): void; - - /** - * Sets the size of the request payload. - * - * #### Example - * - * ```js - * const response = await fetch(url); - * metric.setRequestPayloadSize(response.headers.get('Content-Type')); - * ``` - * - * @param bytes Value must be greater than 0. Set to null to remove. Invalid usage will be logged natively. - */ - setRequestPayloadSize(bytes: number | null): void; - - /** - * Sets the size of the response payload. - * - * #### Example - * - * ```js - * const response = await fetch(url); - * metric.setResponsePayloadSize(response.headers.get('Content-Length')); - * ``` - * - * @param bytes Value must be greater than 0. Set to null to remove. Invalid usage will be logged natively. - */ - setResponsePayloadSize(bytes: number | null): void; - - /** - * Content type of the response e.g. `text/html` or `application/json`. - * - * #### Example - * - * ```js - * const response = await fetch(url); - * metric.setResponsePayloadSize(response.headers.get('Content-Type')); - * ``` - * - * @param contentType Valid string of MIME type. Set to null to remove. Invalid usage will be logged natively. - */ - setResponseContentType(contentType: string | null): void; - - /** - * Marks the start time of the request. Does nothing if already started. - * - * #### Example - * - * ```js - * const metric = firebase.perf().newHttpMetric('https://api.com/login', 'POST'); - * await metric.start(); - * ``` - */ - start(): Promise; - - /** - * Marks the end time of the response and queues the network request metric on the device for transmission. Does nothing if already stopped. - * - * #### Example - * - * ```js - * const metric = firebase.perf().newHttpMetric('https://api.com/login', 'POST'); - * await metric.start(); - * metric.putAttribute('user_role', 'admin'); - * await metric.stop(); - * ``` - */ - stop(): Promise; -} - -export interface Module extends ReactNativeFirebaseModule { - /** - * Determines whether performance monitoring is enabled or disabled. - * - * #### Example - * - * ```js - * const isEnabled = firebase.perf().isPerformanceCollectionEnabled; - * console.log('Performance collection enabled: ', isEnabled); - * ``` - */ - isPerformanceCollectionEnabled: boolean; - - /** - * Enables or disables performance monitoring. - * - * #### Example - * - * ```js - * // Disable performance monitoring collection - * await firebase.perf().setPerformanceCollectionEnabled(false); - * ``` - * - * @param enabled Should performance monitoring be enabled - */ - setPerformanceCollectionEnabled(enabled: boolean): Promise; - - /** - * Creates a Trace instance with the given identifier. - * - * #### Example - * - * ```js - * const trace = firebase.perf().newTrace('user_profile'); - * await trace.start(); - * ``` - * - * @param identifier Name of the trace, no leading or trailing whitespace allowed, no leading underscore '_' character allowed, max length is 100. - */ - newTrace(identifier: string): Trace; - - /** - * Creates a Trace instance with the given identifier and immediately starts it. - * - * #### Example - * - * ```js - * const trace = await firebase.perf().startTrace('user_profile'); - * ``` - * - * @param identifier Name of the trace, no leading or trailing whitespace allowed, no leading underscore '_' character allowed, max length is 100. - */ - startTrace(identifier: string): Promise; - - /** - * Creates a HttpMetric instance for collecting network performance data for a single request/response - * - * #### Example - * - * ```js - * const metric = firebase.perf().newHttpMetric('https://api.com/user/1', 'GET'); - * await metric.start(); - * ``` - * - * @param url A valid url String, cannot be empty - * @param httpMethod One of the values GET, PUT, POST, DELETE, HEAD, PATCH, OPTIONS, TRACE, or CONNECT - */ - newHttpMetric(url: string, httpMethod: HttpMethod): HttpMetric; -} - -declare module '@react-native-firebase/perf' { - import type { - ReactNativeFirebaseNamespace, - ReactNativeFirebaseModuleAndStatics, - } from '@react-native-firebase/app-types/index.js.flow'; - /** - * @example - * ```js - * import { firebase } from '@react-native-firebase/perf'; - * firebase.perf().X(...); - * ``` - */ - declare export var firebase: {} & ReactNativeFirebaseNamespace; - - /** - * @example - * ```js - * import perf from '@react-native-firebase/perf'; - * perf().X(...); - * ``` - */ - declare export default ReactNativeFirebaseModuleAndStatics; -} - -/** - * Attach namespace to `firebase.` and `FirebaseApp.`. - */ -declare module '@react-native-firebase/app-types' { - import type { ReactNativeFirebaseModuleAndStatics } from '@react-native-firebase/app-types/index.js.flow'; - - declare interface ReactNativeFirebaseNamespace { - /** - * Perf - */ - perf: ReactNativeFirebaseModuleAndStatics; - } - - declare interface FirebaseApp { - /** - * Perf - */ - perf(): Module; - } -} diff --git a/packages/remote-config/lib/index.js.flow b/packages/remote-config/lib/index.js.flow deleted file mode 100644 index e0d2e82393..0000000000 --- a/packages/remote-config/lib/index.js.flow +++ /dev/null @@ -1,434 +0,0 @@ -/* eslint-disable import/no-duplicates */ -/* - * Copyright (c) 2016-present Invertase Limited & Contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this library except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -import type { ReactNativeFirebaseModule } from '@react-native-firebase/app-types/index.js.flow'; - -/** - * A pseudo-enum for usage with ConfigSettingsRead.lastFetchStatus to determine the last fetch status. - * - * #### Example - * - * ```js - * firebase.remoteConfig.LastFetchStatus; - * ``` - */ -export interface LastFetchStatus { - /** - * A value indicating that the last fetch was successful. - * - * ```js - * firebase.remoteConfig.LastFetchStatus.SUCCESS; - * ``` - */ - SUCCESS: 'success'; - - /** - * A value indicating that the last fetch failed. - * - * ```js - * firebase.remoteConfig.LastFetchStatus.FAILURE; - * ``` - */ - FAILURE: 'failure'; - - /** - * A value indicating that the last fetch was throttled. - * - * This usually occurs when calling fetch often with a low expiration duration. - * - * ```js - * firebase.remoteConfig.LastFetchStatus.THROTTLED; - * ``` - */ - THROTTLED: 'throttled'; - - /** - * A value indicating that no fetches have occurred yet. - * - * This usually means you've not called fetch yet. - * - * ```js - * firebase.remoteConfig.LastFetchStatus.NO_FETCH_YET; - * ``` - */ - NO_FETCH_YET: 'no_fetch_yet'; -} - -/** - * A pseudo-enum for usage with ConfigValue.source to determine the value source. - * - * #### Example - * - * ```js - * firebase.remoteConfig.ValueSource; - * ``` - */ -export interface ValueSource { - /** - * If the value was retrieved from the server. - * - * ```js - * firebase.remoteConfig.ValueSource.REMOTE; - * ``` - */ - REMOTE: 'remote'; - /** - * If the value was set as a default value. - * - * ```js - * firebase.remoteConfig.ValueSource.DEFAULT; - * ``` - */ - DEFAULT: 'default'; - /** - * If no value was found and a static default value was returned instead. - * - * ```js - * firebase.remoteConfig.ValueSource.STATIC; - * ``` - */ - STATIC: 'static'; -} - -/** - * Firebase Remote RemoteConfig statics. - * - * ```js - * firebase.remoteConfig; - * ``` - */ -export interface Statics { - /** - * A pseudo-enum for usage with ConfigValue.source to determine the value source. - * - * #### Example - * - * ```js - * firebase.remoteConfig.ValueSource; - * ``` - */ - ValueSource: ValueSource; - - /** - * A pseudo-enum for usage with `firebase.remoteConfig().lastFetchStatus` to determine the last fetch status. - * - * #### Example - * - * ```js - * firebase.remoteConfig.LastFetchStatus; - * ``` - */ - LastFetchStatus: LastFetchStatus; -} - -/** - * An Interface representing a Remote RemoteConfig value. - */ -export interface ConfigValue { - /** - * Where the value was retrieved from. - * - * - `remote`: If the value was retrieved from the server. - * - `default`: If the value was set as a default value. - * - `static`: If no value was found and a static default value was returned instead. - * - * See the `ValueSource` statics definition. - * - * #### Example - * - * ```js - * const configValue = firebase.remoteConfig().getValue('beta_enabled'); - * console.log('Value source: ', configValue.source); - * ``` - */ - source: 'remote' | 'default' | 'static'; - - /** - * The returned value. - * - * #### Example - * - * ```js - * const configValue = firebase.remoteConfig().getValue('beta_enabled'); - * console.log('Value: ', configValue.value); - * ``` - */ - value: undefined | number | boolean | string; -} - -/** - * An Interface representing multiple RemoteConfig Values. - * - * #### Example - * - * ```js - * const values = firebase.remoteConfig().getAll(); - * ``` - */ -export interface ConfigValues { - [key: string]: ConfigValue; -} - -/** - * An Interface representing settable config settings. - * - * #### Example - * - * The example below makes use of the React Native `__DEV__` global JavaScript variable which - * is exposed. - * - * ```js - * await firebase.remoteConfig().setConfigSettings({ - * isDeveloperModeEnabled: __DEV__, - * }); - * ``` - */ -export interface ConfigSettings { - /** - * If enabled, default behaviour such as caching is disabled for a better debugging - * experience. - */ - isDeveloperModeEnabled: boolean; - /** - * The time that remote config should cache flags for. - */ - minimumFetchInterval?: number; -} - -/** - * An Interface representing a RemoteConfig Defaults object. - * - * #### Example - * - * ```js - * await firebase.remoteConfig().setDefaults({ - * experiment_enabled: false, - * }); - * ``` - */ -export interface ConfigDefaults { - [key: string]: number | string | boolean; -} - -/** - * The Firebase Remote RemoteConfig service interface. - * - * > This module is available for the default app only. - * - * #### Example - * - * Get the Remote RemoteConfig service for the default app: - * - * ```js - * const defaultAppRemoteConfig = firebase.remoteConfig(); - * ``` - */ -export interface Module extends ReactNativeFirebaseModule { - /** - * The number of milliseconds since the last Remote RemoteConfig fetch was performed. - */ - lastFetchTime: number; - /** - * Whether developer mode is enabled. This is set manually via {@link config#setConfigSettings} - */ - isDeveloperModeEnabled: boolean; - /** - * The status of the latest Remote RemoteConfig fetch action. - * - * See the `LastFetchStatus` statics definition. - */ - lastFetchStatus: 'success' | 'failure' | 'no_fetch_yet' | 'throttled'; - - /** - * Moves fetched data to the apps active config. - * Resolves with a boolean value of whether the fetched config was moved successfully. - * - * #### Example - * - * ```js - * // Fetch values - * await firebase.remoteConfig().fetch(); - * const activated = await firebase.remoteConfig().activate(); - * - * if (activated) { - * console.log('Fetched values successfully activated.'); - * } else { - * console.log('Fetched values failed to activate.'); - * } - * ``` - */ - activate(): Promise; - - /** - * Fetches the remote config data from Firebase, as defined in the dashboard. If duration is defined (seconds), data will be locally cached for this duration. - * - * #### Example - * - * ```js - * // Fetch and cache for 5 minutes - * await firebase.remoteConfig().fetch(300); - * ``` - * - * @param expirationDurationSeconds Duration in seconds to cache the data for. To skip cache, use a duration of 0. - */ - fetch(expirationDurationSeconds?: number): Promise; - - /** - * Fetches the remote config data from Firebase, as defined in the dashboard. If duration is defined (seconds), data will be locally cached for this duration. - * - * Once fetching is complete this method immediately calls activate and returns a boolean value of the activation status. - * - * #### Example - * - * ```js - * // Fetch, cache for 5 minutes and activate - * const activated = await firebase.remoteConfig().fetchAndActivate(300); - * - * if (activated) { - * console.log('Fetched values successfully activated.'); - * } else { - * console.log('Fetched values failed to activate.'); - * } - * ``` - * - * @param expirationDurationSeconds Duration in seconds to cache the data for. To skip cache use a duration of 0. - */ - fetchAndActivate(expirationDurationSeconds?: number): Promise; - - /** - * Returns all available config values. - * - * #### Example - * - * ```js - * const values = firebase.remoteConfig().getAll(); - * - * Object.entries(values).forEach(($) => { - * const [key, entry] = $; - * console.log('Key: ', key); - * console.log('Source: ', entry.source); - * console.log('Value: ', entry.value); - * }); - * ``` - * - */ - getAll(): ConfigValues; - - /** - * Gets a ConfigValue by key. - * - * #### Example - * - * ```js - * const configValue = firebase.remoteConfig().getValue('experiment'); - * console.log('Source: ', configValue.source); - * console.log('Value: ', configValue.value); - * ``` - * - * @param key A key used to retrieve a specific value. - */ - getValue(key: string): ConfigValue; - - /** - * Set the Remote RemoteConfig settings, specifically the `isDeveloperModeEnabled` flag. - * - * #### Example - * - * ```js - * await firebase.remoteConfig().setConfigSettings({ - * isDeveloperModeEnabled: __DEV__, - * }); - * ``` - * - * @param configSettings A ConfigSettingsWrite instance used to set Remote RemoteConfig settings. - */ - setConfigSettings(configSettings: ConfigSettings): Promise; - - /** - * Sets default values for the app to use when accessing values. - * Any data fetched and activated will override any default values. Any values in the defaults but not on Firebase will be untouched. - * - * #### Example - * - * ```js - * await firebase.remoteConfig().setDefaults({ - * experiment_enabled: false, - * }); - * ``` - * - * @param defaults A ConfigDefaults instance used to set default values. - */ - setDefaults(defaults: ConfigDefaults): Promise; - - /** - * Sets the default values from a resource file. - * On iOS this is a plist file and on Android this is an XML defaultsMap file. - * - * ```js - * // TODO @ehesp - * ``` - * - * @param resourceName The plist/xml file name with no extension. - */ - setDefaultsFromResource(resourceName: string): Promise; -} - -declare module '@react-native-firebase/remote-config' { - import type { - ReactNativeFirebaseNamespace, - ReactNativeFirebaseModuleAndStatics, - } from '@react-native-firebase/app-types/index.js.flow'; - /** - * @example - * ```js - * import { firebase } from '@react-native-firebase/remote-config'; - * firebase.remoteConfig().X(...); - * ``` - */ - declare export var firebase: {} & ReactNativeFirebaseNamespace; - - /** - * @example - * ```js - * import remoteConfig from '@react-native-firebase/remote-config'; - * remoteConfig().X(...); - * ``` - */ - declare export default ReactNativeFirebaseModuleAndStatics; -} - -/** - * Attach namespace to `firebase.` and `FirebaseApp.`. - */ -declare module '@react-native-firebase/app-types' { - import type { ReactNativeFirebaseModuleAndStatics } from '@react-native-firebase/app-types/index.js.flow'; - - declare interface ReactNativeFirebaseNamespace { - /** - * RemoteConfig - */ - remoteConfig: ReactNativeFirebaseModuleAndStatics; - } - - declare interface FirebaseApp { - /** - * RemoteConfig - */ - remoteConfig(): Module; - } -} diff --git a/packages/storage/lib/index.js.flow b/packages/storage/lib/index.js.flow deleted file mode 100644 index fe1e04018b..0000000000 --- a/packages/storage/lib/index.js.flow +++ /dev/null @@ -1,1164 +0,0 @@ -/* eslint-disable import/no-duplicates */ -/* - * Copyright (c) 2016-present Invertase Limited & Contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this library except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -import type { ReactNativeFirebaseModule } from '@react-native-firebase/app-types/index.js.flow'; -import { NativeFirebaseError } from '@react-native-firebase/app-types'; - -/** - * Possible string formats used for uploading via `StorageReference.putString()` - * - * ```js - * firebase.storage.StringFormat; - * ``` - */ -export interface StringFormat { - /** - * Raw string format. - * - * #### Usage - * - * ```js - * firebase.storage.StringFormat.RAW; - * ``` - * - * #### Example String Format - * - * ```js - * const sampleString = ''; - * ``` - */ - RAW: 'raw'; - - /** - * Base64 string format. - * - * Learn more about Base64 [on the Mozilla Web Docs](https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding) - * - * #### Usage - * - * ```js - * firebase.storage.StringFormat.BASE64; - * ``` - * - * #### Example String Format - * - * ```js - * const sampleString = 'PEZvbyBCYXI+'; - * ``` - * - */ - BASE64: 'base64'; - - /** - * Base64Url string format. - * - * #### Usage - * - * ```js - * firebase.storage.StringFormat.BASE64URL; - * ``` - * - * #### Example String Format - * - * ```js - * const sampleString = 'PEZvbyBCYXI-'; - * ``` - * - */ - BASE64URL: 'base64url'; - - /** - * Data URL string format. - * - * #### Usage - * - * ```js - * firebase.storage.StringFormat.DATA_URL; - * ``` - * - * #### Example String Format - * - * ```js - * const sampleString = 'data:text/plain;base64,PEZvbyBCYXI+'; - * ``` - */ - DATA_URL: 'data_url'; -} - -/** - * An event to subscribe to that is triggered on a Upload or Download task. - * - * Event subscription is created via `StorageTask.on()`. - * - * ```js - * firebase.storage.TaskEvent; - * ``` - */ -export interface TaskEvent { - /** - * An event that indicates that the tasks state has changed. - * - * ```js - * firebase.storage.TaskEvent.STATE_CHANGED; - * ``` - */ - STATE_CHANGED: 'state_changed'; -} - -/** - * A collection of properties that indicates the current tasks state. - * - * An event subscription is created via `StorageTask.on()`. - * - * ```js - * firebase.storage.TaskEvent; - * ``` - */ -export interface TaskState { - /** - * Task has been cancelled by the user. - */ - CANCELLED: 'cancelled'; - - /** - * An Error occurred, see TaskSnapshot.error for details. - */ - ERROR: 'error'; - - /** - * Task has been paused. Resume the task via `StorageTask.resume()`. - */ - PAUSED: 'paused'; - - /** - * Task is running. Pause the task via `StorageTask.pause()` - */ - RUNNING: 'running'; - - /** - * Task has completed successfully. - */ - SUCCESS: 'success'; -} - -/** - * A collection of native device file paths to aid in the usage of file path based storage methods. - * - * Concatenate a file path with your target file name when using `putFile` or `getFile`. - * - * ```js - * firebase.storage.Path; - * ``` - */ -export interface Path { - /** - * Returns an absolute path to the applications main bundle. - * - * ```js - * firebase.storage.Path.MainBundle; - * ``` - * - * @ios iOS only - */ - MainBundle: string; - - /** - * Returns an absolute path to the application specific cache directory on the filesystem. - * - * The system will automatically delete files in this directory when disk space is needed elsewhere on the device, starting with the oldest files first. - * - * ```js - * firebase.storage.Path.CachesDirectory; - * ``` - */ - CachesDirectory: string; - - /** - * Returns an absolute path to the users Documents directory. - * - * Use this directory to place documents that have been created by the user. - * - * ```js - * firebase.storage.Path.DocumentDirectory; - * ``` - */ - DocumentDirectory: string; - - /** - * Returns an absolute path to a temporary directory. - * - * Use this directory to create temporary files. The system will automatically delete files in this directory when disk space is needed elsewhere on the device, starting with the oldest files first. - * - * ```js - * firebase.storage.Path.TempDirectory; - * ``` - */ - TempDirectory: string; - - /** - * Returns an absolute path to the apps library/resources directory. - * - * E.g. this can be used for things like documentation, support files, and configuration files and generic resources. - * - * ```js - * firebase.storage.Path.LibraryDirectory; - * ``` - */ - LibraryDirectory: string; - - /** - * Returns an absolute path to the directory on the primary shared/external storage device. - * - * Here your application can place persistent files it owns. These files are internal to the application, and not typically visible to the user as media. - * - * Returns null if no external storage directory found, e.g. removable media has been ejected by the user. - * - * ```js - * firebase.storage.Path.ExternalDirectory; - * ``` - * - * @android Android only - iOS returns null - */ - ExternalDirectory: string | null; - - /** - * Returns an absolute path to the primary shared/external storage directory. - * - * Traditionally this is an SD card, but it may also be implemented as built-in storage on a device. - * - * Returns null if no external storage directory found, e.g. removable media has been ejected by the user. - * - * ```js - * firebase.storage.Path.ExternalStorageDirectory; - * ``` - * - * @android Android only - iOS returns null - */ - ExternalStorageDirectory: string | null; - - /** - * Returns an absolute path to a directory in which to place pictures that are available to the user. - * - * ```js - * firebase.storage.Path.PicturesDirectory; - * ``` - */ - PicturesDirectory: string; - - /** - * Returns an absolute path to a directory in which to place movies that are available to the user. - * - * ```js - * firebase.storage.Path.MoviesDirectory; - * ``` - */ - MoviesDirectory: string; -} - -/** - * Cloud Storage statics. - * - * #### Example - * - * ```js - * firebase.storage; - * ``` - */ -export interface Statics { - /** - * Possible string formats used for uploading via `StorageReference.putString()` - * - * #### Example - * - * ```js - * firebase.storage.StringFormat; - * ``` - */ - StringFormat: StringFormat; - - /** - * A collection of properties that indicates the current tasks state. - * - * #### Example - * - * ```js - * firebase.storage.TaskState; - * ``` - */ - TaskState: TaskState; - - /** - * An event to subscribe to that is triggered on a Upload or Download task. - * - * #### Example - * - * ```js - * firebase.storage.TaskEvent; - * ``` - */ - TaskEvent: TaskEvent; - - /** - * A collection of native device file paths to aid in the usage of file path based storage methods. - * - * #### Example - * - * ```js - * firebase.storage.Path; - * ``` - */ - Path: Path; -} - -/** - * An interface representing all the metadata properties that can be set. - * - * This is used in updateMetadata, put, putString & putFile. - */ -export interface SettableMetadata { - /** - * The 'Cache-Control' HTTP header that will be set on the storage object when it's requested. - * - * #### Example 1 - * - * To turn off caching, you can set the following cacheControl value. - * - * ```js - * { - * cacheControl: 'no-store', - * } - * ``` - * - * #### Example 2 - * - * To aggressively cache an object, e.g. static assets, you can set the following cacheControl value. - * - * ```js - * { - * cacheControl: 'public, max-age=31536000', - * } - * ``` - * - * [Learn more about this header on Mozilla.](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition) - */ - cacheControl?: string | null; - - /** - * The 'Content-Disposition' HTTP header that will be set on the storage object when it's requested. - * - * [Learn more about this header on Mozilla.](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition) - */ - contentDisposition?: string | null; - - /** - * The 'Content-Encoding' HTTP header that will be used on the storage object when it's requested. - * - * [Learn more about this header on Mozilla.](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding) - */ - contentEncoding?: string | null; - - /** - * The 'Content-Language' HTTP header that will be set on the storage object when it's requested. - * - * [Learn more about this header on Mozilla.](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Language) - */ - contentLanguage?: string | null; - - /** - * The 'Content-Type' HTTP header that will be set on the object when it's requested. - * - * This is used to indicate the media type (or MIME type) of the object. When uploading a file - * Firebase Cloud Storage for React Native will attempt to automatically detect this if `contentType` - * is not already set, if it fails to detect a media type it will default to `application/octet-stream`. - * - * For `DATA_URL` string formats uploaded via `putString` this will also be automatically extracted if available. - * - * #### Example - * - * Setting the content type as JSON, e.g. for when uploading a JSON string via `putString`. - * - * ```js - * { - * contentType: 'application/json', - * } - * ``` - * - * [Learn more about this header on Mozilla.](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type) - */ - contentType?: string | null; - - /** - * Additional user-defined custom metadata for this storage object. - * - * String values only are supported for custom metadata property values. - * - * #### Example - * - * Adding a user controlled NSFW meta data field. - * - * ```js - * { - * customMetadata: { - * 'nsfw': 'true' - * }, - * } - */ - customMetadata?: { - [key: string]: string, - } | null; -} - -/** - * The full readable metadata returned by `TaskSnapshot.metadata` or `StorageReference.getMetadata()`. - */ -export interface FullMetadata extends SettableMetadata { - /** - * A Base64-encoded MD5 hash of the storage object being uploaded. - */ - md5Hash: string | null; - - /** - * The bucket this storage object is contained in. - * - * #### Example Value - * - * ``` - * gs://my-project-storage-bucket - * ``` - */ - bucket: string; - - /** - * The full path to this storage object in its bucket. - * - * #### Example Value - * - * ``` - * invertase/logo.png - * ``` - */ - fullPath: string; - - /** - * Storage object generation values enable users to uniquely identify data resources, e.g. object versioning. - * - * Read more on generation on the [Google Cloud Storage documentation](https://cloud.google.com/storage/docs/generations-preconditions). - */ - generation: string; - - /** - * Storage object metageneration values enable users to uniquely identify data resources, e.g. object versioning. - * - * Read more on metageneration on the [Google Cloud Storage documentation](https://cloud.google.com/storage/docs/generations-preconditions). - */ - metageneration: string; - - /** - * The short name of storage object in its bucket, e.g. it's file name. - * - * #### Example Value - * - * ``` - * logo.png - * ``` - */ - name: string; - - /** - * The size of this storage object in bytes. - */ - size: number; - - /** - * A date string representing when this storage object was created. - * - * #### Example Value - * - * ``` - * 2019-05-02T00:34:56.264Z - * ``` - */ - timeCreated: string; - - /** - * A date string representing when this storage object was last updated. - * - * #### Example Value - * - * ``` - * 2019-05-02T00:35:56.264Z - * ``` - */ - updated: string; -} - -/** - * The options `list()` accepts. - */ -export interface ListOptions { - /** - * If set, limits the total number of `prefixes` and `items` to return. The default and maximum maxResults is 1000. - */ - maxResults?: number; - - /** - * The `nextPageToken` from a previous call to `list()`. If provided, listing is resumed from the previous position. - */ - pageToken?: string; -} - -/** - * Result returned by `list()`. - */ -export interface ListResult { - /** - * Objects in this directory. You can call `getMetadate()` and `getDownloadUrl()` on them. - */ - items: Reference[]; - - /** - * If set, there might be more results for this list. Use this token to resume the list. - */ - nextPageToken: string | null; - - /** - * References to prefixes (sub-folders). You can call `list()` on them to get its contents. - * - * Folders are implicit based on '/' in the object paths. For example, if a bucket has two objects '/a/b/1' and '/a/b/2', list('/a') will return '/a/b' as a prefix. - */ - prefixes: Reference[]; -} - -/** - * Represents a reference to a Google Cloud Storage object in React Native Firebase. - * - * A reference can be used to upload and download storage objects, get/set storage object metadata, retrieve storage object download urls and delete storage objects. - * - * #### Example 1 - * - * Get a reference to a specific storage path. - * - * ```js - * const ref = firebase.storage().ref('invertase/logo.png'); - * ``` - * - * #### Example 2 - * - * Get a reference to a specific storage path on another bucket in the same firebase project. - * - * ```js - * const ref = firebase.storage().refFromURL('gs://other-bucket/invertase/logo.png'); - * ``` - */ -export interface Reference { - /** - * The name of the bucket containing this reference's object. - */ - bucket: string; - /** - * A reference pointing to the parent location of this reference, or null if this reference is the root. - */ - parent: Reference | null; - /** - * The full path of this object. - */ - fullPath: string; - /** - * The short name of this object, which is the last component of the full path. For example, - * if fullPath is 'full/path/image.png', name is 'image.png'. - */ - name: string; - /** - * A reference to the root of this reference's bucket. - */ - root: Reference; - /** - * The storage service associated with this reference. - */ - storage: Module; - - /** - * Returns a gs:// URL for this object in the form `gs://///`. - * - * #### Example - * - * ```js - * const ref = firebase.storage().ref('invertase/logo.png'); - * console.log('Full path: ', ref.toString()); // gs://invertase.io/invertase/logo.png - * ``` - */ - toString(): string; - - /** - * Returns a reference to a relative path from this reference. - * - * #### Example - * - * ```js - * const parent = firebase.storage().ref('invertase'); - * const ref = parent.child('logo.png'); - * ``` - * - * @param path The relative path from this reference. Leading, trailing, and consecutive slashes are removed. - */ - child(path: string): Reference; - - /** - * Deletes the object at this reference's location. - * - * #### Example - * - * ```js - * const ref = firebase.storage().ref('invertase/logo.png'); - * await ref.delete(); - * ``` - */ - delete(): Promise; - - /** - * Fetches a long lived download URL for this object. - * - * #### Example - * - * ```js - * const ref = firebase.storage().ref('invertase/logo.png'); - * const url = await ref.getDownloadURL(); - * ``` - */ - getDownloadURL(): Promise; - - /** - * Fetches metadata for the object at this location, if one exists. - * - * #### Example - * - * ```js - * const ref = firebase.storage().ref('invertase/logo.png'); - * const metadata = await ref.getMetadata(); - * console.log('Cache control: ', metadata.cacheControl); - * ``` - */ - getMetadata(): Promise; - - /** - * List items (files) and prefixes (folders) under this storage reference. - * - * List API is only available for Firebase Rules Version 2. - * - * GCS is a key-blob store. Firebase Storage imposes the semantic of '/' delimited folder structure. - * Refer to GCS's List API if you want to learn more. - * - * To adhere to Firebase Rules's Semantics, Firebase Storage does not support objects whose paths - * end with "/" or contain two consecutive "/"s. Firebase Storage List API will filter these unsupported objects. - * list() may fail if there are too many unsupported objects in the bucket. - * - * #### Example - * - * ```js - * const ref = firebase.storage().ref('/'); - * const results = await ref.list({ - * maxResults: 30, - * }); - * ``` - * - * @param options An optional ListOptions interface. - */ - list(options?: ListOptions): Promise; - - /** - * List all items (files) and prefixes (folders) under this storage reference. - * - * This is a helper method for calling list() repeatedly until there are no more results. The default pagination size is 1000. - * - * Note: The results may not be consistent if objects are changed while this operation is running. - * - * Warning: `listAll` may potentially consume too many resources if there are too many results. - * - * #### Example - * - * ```js - * const ref = firebase.storage().ref('/'); - * const results = await ref.listAll(); - * ``` - */ - listAll(): Promise; - - /** - * Puts a file from local disk onto the storage bucket. - * - * #### Example - * - * ```js - * const ref = firebase.storage().ref('invertase/new-logo.png'); - * const path = `${firebase.utils.FilePath.DOCUMENT_DIRECTORY}/new-logo.png`; - * const task = ref.putFile(path, { - * cacheControl: 'no-store', // disable caching - * }); - * ``` - * - * @param localFilePath The local file path to upload to the bucket at the reference location. - * @param metadata Any additional `SettableMetadata` for this task. - */ - putFile(localFilePath: string, metadata?: SettableMetadata): Task; - - /** - * Downloads a file to the specified local file path on the device. - * - * #### Example - * - * Get a Download Storage task to download a file: - * - * ```js - * const downloadTo = `${firebase.utils.FilePath.DOCUMENT_DIRECTORY}/foobar.json`; - * - * const task = firebase.storage().ref('/foo/bar.json').writeToFile(downloadTo); - * ``` - * @param localFilePath - */ - writeToFile(localFilePath: string): Task; - - /** - * Puts data onto the storage bucket. - * - * #### Example - * - * ```js - * const ref = firebase.storage().ref('invertase/new-logo.png'); - * const task = ref.put(BLOB, { - * cacheControl: 'no-store', // disable caching - * }); - * ``` - * - * @param data The data to upload to the storage bucket at the reference location. - * @param metadata - */ - put(data: Blob | Uint8Array | ArrayBuffer, metadata?: SettableMetadata): Task; - - /** - * Puts a string on the storage bucket. Depending on the string type, set a {@link storage.StringFormat} type. - * - * #### Example - * - * ```js - * const ref = firebase.storage().ref('invertase/new-logo.png'); - * const task = ref.putString('PEZvbyBCYXI+', firebase.storage.StringFormat.BASE64, { - * cacheControl: 'no-store', // disable caching - * }); - * ``` - * - * @param data The string data, must match the format provided. - * @param format The format type of the string, e.g. a Base64 format string. - * @param metadata Any additional `SettableMetadata` for this task. - */ - putString( - data: string, - format?: 'raw' | 'base64' | 'base64url' | 'data_url', - metadata?: SettableMetadata, - ): Task; - - /** - * Updates the metadata for this reference object on the storage bucket. - * - * #### Example - * - * ```js - * const ref = firebase.storage().ref('invertase/nsfw-logo.png'); - * const updatedMetadata = await ref.updateMetadata({ - * customMetadata: { - * 'nsfw': 'true', - * } - * }); - * ``` - * - * @param metadata A `SettableMetadata` instance to update. - */ - updateMetadata(metadata: SettableMetadata): Promise; -} - -export interface TaskSnapshotObserver { - next: (taskSnapshot: TaskSnapshot) => void; - - error: (error: Error) => void; - - complete: () => void; -} - -/** - * Storage Task used for Uploading or Downloading files. - * - * #### Example 1 - * - * Get a Upload Storage task to upload a string: - * - * ```js - * const string = '{ "foo": 1 }'; - * const task = firebase - * .storage() - * .ref('/foo/bar.json') - * .putString(string); - * ``` - * - * #### Example 2 - * - * Get a Download Storage task to download a file: - * - * ```js - * const string = '{ "foo": 1 }'; - * const downloadTo = `${firebase.storage.Path.DocumentDirectory}/bar.json`; - * - * const task = firebase - * .storage() - * .ref('/foo/bar.json') - * .writeToFile(downloadTo); - * ``` - */ -export interface Task { - /** - * Pause the current Download or Upload task. - * - * #### Example - * - * Pause a running task inside a state changed listener: - * - * ```js - * task.on('state_changed', taskSnapshot => { - * if (taskSnapshot.state === firebase.storage.TaskState.RUNNING) { - * console.log('Pausing my task!'); - * task.pause(); - * } - * }); - * ``` - * - */ - pause(): Promise; - - /** - * Resume the current Download or Upload task. - * - * #### Example - * - * Resume a previously paused task inside a state changed listener: - * - * ```js - * task.on('state_changed', taskSnapshot => { - * // ... pause me ... - * if (taskSnapshot.state === firebase.storage.TaskState.PAUSED) { - * console.log('Resuming my task!'); - * task.resume(); - * } - * }); - * ``` - * - */ - resume(): Promise; - - /** - * Cancel the current Download or Upload task. - * - * - * #### Example - * - * Cancel a task inside a state changed listener: - * - * ```js - * task.on('state_changed', taskSnapshot => { - * console.log('Cancelling my task!'); - * task.cancel(); - * }); - * ``` - * - */ - cancel(): Promise; - - /** - * - * @param event - * @param nextOrObserver - * @param error - * @param complete - */ - on( - event: 'state_changed', - nextOrObserver?: TaskSnapshotObserver | null | ((a: TaskSnapshot) => any), - error?: ((a: Error) => any) | null, - complete?: (() => void) | null, - ): Function; - - // /** - // * @ignore May not exist in RN JS Environment yet so we'll hide from docs. - // */ - // finally(onFinally?: (() => void) | undefined | null): Promise; - - then( - onFulfilled?: ((a: TaskSnapshot) => any) | null, - onRejected?: ((a: Error) => any) | null, - ): Promise; - - catch(onRejected: (a: Error) => any): Promise; -} - -/** - * A TaskSnapshot provides information about a storage tasks state. - * - * #### Example 1 - * - * ``` - * firebase - * .storage() - * .ref('/foo/bar.json') - * .putString(JSON.stringify({ foo: 'bar' })) - * .then((taskSnapshot) => { - * if (taskSnapshot.state === firebase.storage.TaskState.SUCCESS) { - * console.log('Total bytes uploaded: ', taskSnapshot.totalBytes); - * } - * }); - * ``` - * - * #### Example 2 - * - * ``` - * const task = firebase - * .storage() - * .ref('/foo/bar.json') - * .putString(JSON.stringify({ foo: 'bar' })); - * - * task.on('state_changed', taskSnapshot => { - * if (taskSnapshot.state === firebase.storage.TaskState.PAUSED) { - * console.log('Resuming my task!'); - * task.resume(); - * } - * }); - * ``` - */ -export interface TaskSnapshot { - /** - * The number of bytes currently transferred. - */ - bytesTransferred: number; - - /** - * The metadata of the tasks via a {@link storage.FullMetadata} interface. - */ - metadata: FullMetadata; - - /** - * The {@link storage.Reference} of the task. - */ - ref: Reference; - - /** - * The current state of the task snapshot. - */ - state: 'cancelled' | 'error' | 'paused' | 'running' | 'success'; - - /** - * The parent {@link storage.Task} of this snapshot. - */ - task: Task; - - /** - * The total amount of bytes for this task. - */ - totalBytes: number; - - /** - * If the {@link storage.TaskSnapshot#state} is `error`, returns a JavaScript error of the - * current task snapshot. - */ - error?: NativeFirebaseError; -} - -/** - * The Cloud Storage service is available for the default app, a given app or a specific storage bucket. - * - * #### Example 1 - * - * Get the storage instance for the **default app**: - * - * ```js - * const storageForDefaultApp = firebase.storage(); - * ``` - * - * #### Example 2 - * - * Get the storage instance for a **secondary app**: - * - * ```js - * const otherApp = firebase.app('otherApp'); - * const storageForOtherApp = firebase.storage(otherApp); - * ``` - * - * #### Example 3 - * - * Get the storage instance for a **specific storage bucket**: - * - * ```js - * const defaultApp = firebase.app(); - * const storageForBucket = defaultApp.storage('gs://another-bucket-url'); - * - * const otherApp = firebase.app('otherApp'); - * const storageForOtherAppBucket = otherApp.storage('gs://another-bucket-url'); - * ``` - * - */ -export interface Module extends ReactNativeFirebaseModule { - /** - * TODO. - * - * #### Example - * - * ```js - * const uploadRetryTime = firebase.storage().maxUploadRetryTime; - * ``` - */ - maxUploadRetryTime: number; - - /** - * TODO. - * - * #### Example - * - * ```js - * await firebase.storage().setMaxUploadRetryTime(5000); - * ``` - * - * @param time Number of milliseconds.... TODO - */ - setMaxUploadRetryTime(time: number): Promise; - - /** - * TODO. - * - * #### Example - * - * ```js - * const downloadRetryTime = firebase.storage().maxUploadRetryTime; - * ``` - */ - maxDownloadRetryTime: number; - - /** - * TODO. - * - * #### Example - * - * ```js - * await firebase.storage().setMaxDownloadRetryTime(5000); - * ``` - * - * @param time Number of miliseconds.... TODO - */ - setMaxDownloadRetryTime(time: number): Promise; - - /** - * TODO. - * - * #### Example - * - * ```js - * const maxOperationRetryTime = firebase.storage().maxOperationRetryTime; - * ``` - */ - maxOperationRetryTime: number; - - /** - * TODO. - * - * #### Example - * - * ```js - * await firebase.storage().setMaxOperationRetryTime(5000); - * ``` - * - * @param time Number of miliseconds.... TODO - */ - setMaxOperationRetryTime(time: number): Promise; - - /** - * Returns a new {@link storage.Reference} instance. - * - * #### Example - * - * ```js - * const maxOperationRetryTime = firebase.storage().maxOperationRetryTime; - * ``` - * - * @param path An optional string pointing to a location on the storage bucket. If no path - * is provided, the returned reference will be the bucket root path. - */ - ref(path?: string): Reference; - - /** - * Returns a new {@link storage.Reference} instance from a storage bucket URL. - * - * #### Example - * - * ```js - * const maxOperationRetryTime = firebase.storage().maxOperationRetryTime; - * ``` - * - * @param url A storage bucket URL pointing to a single file or location. Must start with `gs://`, - * e.g. `gs://assets/logo.png` or `gs://assets`. - */ - refFromURL(url: string): Reference; -} - -declare module '@react-native-firebase/storage' { - import type { - ReactNativeFirebaseNamespace, - ReactNativeFirebaseModuleAndStatics, - } from '@react-native-firebase/app-types/index.js.flow'; - /** - * @example - * ```js - * import { firebase } from '@react-native-firebase/storage'; - * firebase.storage().X(...); - * ``` - */ - declare export var firebase: {} & ReactNativeFirebaseNamespace; - - /** - * @example - * ```js - * import storage from '@react-native-firebase/storage'; - * storage().X(...); - * ``` - */ - declare export default ReactNativeFirebaseModuleAndStatics; -} - -/** - * Attach namespace to `firebase.` and `FirebaseApp.`. - */ -declare module '@react-native-firebase/app-types' { - import type { ReactNativeFirebaseModuleAndStatics } from '@react-native-firebase/app-types/index.js.flow'; - - declare interface ReactNativeFirebaseNamespace { - /** - * Storage - */ - storage: ReactNativeFirebaseModuleAndStatics; - } - - declare interface FirebaseApp { - /** - * Storage - */ - storage(): Module; - } -} diff --git a/scripts/_TEMPLATE_/lib/index.js.flow b/scripts/_TEMPLATE_/lib/index.js.flow deleted file mode 100644 index 5a892da274..0000000000 --- a/scripts/_TEMPLATE_/lib/index.js.flow +++ /dev/null @@ -1,70 +0,0 @@ -/* eslint-disable import/no-duplicates */ -/* - * Copyright (c) 2016-present Invertase Limited & Contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this library except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -import type { ReactNativeFirebaseModule } from '@react-native-firebase/app-types/index.js.flow'; - -export interface Statics {} - -export interface Module extends ReactNativeFirebaseModule { - -} - -declare module '@react-native-firebase/_template_' { - import type { - ReactNativeFirebaseNamespace, - ReactNativeFirebaseModuleAndStatics, - } from '@react-native-firebase/app-types/index.js.flow'; - /** - * @example - * ```js - * import { firebase } from '@react-native-firebase/_template_'; - * firebase._template_().X(...); - * ``` - */ - declare export var firebase: {} & ReactNativeFirebaseNamespace; - - /** - * @example - * ```js - * import _template_ from '@react-native-firebase/_template_'; - * _template_().X(...); - * ``` - */ - declare export default ReactNativeFirebaseModuleAndStatics; -} - -/** - * Attach namespace to `firebase.` and `FirebaseApp.`. - */ -declare module '@react-native-firebase/app-types' { - import type { ReactNativeFirebaseModuleAndStatics } from '@react-native-firebase/app-types/index.js.flow'; - - declare interface ReactNativeFirebaseNamespace { - /** - * _Template_ - */ - _template_: ReactNativeFirebaseModuleAndStatics; - } - - declare interface FirebaseApp { - /** - * _Template_ - */ - _template_(): Module; - } -}