Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add toJSON() support for Firestore classes #4298

Merged
merged 6 commits into from
Jan 26, 2021
Merged

Add toJSON() support for Firestore classes #4298

merged 6 commits into from
Jan 26, 2021

Conversation

thebrianchen
Copy link

Fixes #4258.

Adding toJSON() on the Firebase instance breaks the circular reference between firebase.app.container and the Firestore instance. Similarly, adding toJSON() to the AsyncQueue and ExponentialBackoff allows them to be serialized despite the circular references.

Some questions:

  1. Should I include my Firebase changes in app-compat?
  2. Should the firebase packages also get the same patch message, or should there be a separate patch message for them?
  3. Should we add more precise return types for toJSON()? I'm afraid of locking them in and causing a breaking change if we ever want to change them in the future.

@changeset-bot
Copy link

changeset-bot bot commented Jan 15, 2021

🦋 Changeset detected

Latest commit: 0a9f5bd

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Contributor

github-actions bot commented Jan 15, 2021

Changeset File Check ⚠️

  • Changeset formatting error in following file:
    Package "firebase-exp" must depend on the current version of "@firebase/database": "0.9.0" vs "0.8.3"
    Package "firebase-exp" must depend on the current version of "@firebase/database": "0.9.0" vs "0.8.3"
    Error: Found mixed changeset clean-meals-double
    Found ignored packages: @firebase/app-compat
    Found not ignored packages: @firebase/app @firebase/firestore
    Mixed changesets that contain both ignored and not ignored packages are not allowed
        at Object.getReleasePlan [as default] (/home/runner/work/firebase-js-sdk/firebase-js-sdk/node_modules/@changesets/get-release-plan/dist/get-release-plan.cjs.dev.js:24:10)
    

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Jan 15, 2021

Size Analysis Report

Affected Products

  • @firebase/analytics-exp

    • getAnalytics

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size
      ?
      9.01 kB
      ? (?)
      size-with-ext-deps
      ?
      26.3 kB
      ? (?)

      Dependency Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      functions
      ?

      22 dependencies

      attemptFetchDynamicConfigWithRetry
      factory
      fetchDynamicConfig
      fetchDynamicConfigWithRetry
      findGtagScriptOnPage
      getAnalytics
      getHeaders
      getOrCreateDataLayer
      gtagOnConfig
      gtagOnEvent
      initializeAnalytics
      insertScriptTag
      isRetriableError
      logEvent
      logEvent$1
      promiseAllSettled
      registerAnalytics
      setAbortableTimeout
      validateIndexedDB
      warnOnBrowserContextMismatch
      wrapGtag
      wrapOrCreateGtag
      

      ?
      classes
      ?

      AnalyticsAbortSignal
      AnalyticsService
      RetryData
      

      ?
      variables
      ?

      22 dependencies

      ANALYTICS_TYPE
      BASE_INTERVAL_MILLIS
      DYNAMIC_CONFIG_URL
      ERRORS
      ERROR_FACTORY
      FETCH_TIMEOUT_MILLIS
      GA_FID_KEY
      GTAG_URL
      LONG_RETRY_FACTOR
      ORIGIN_KEY
      dataLayerName
      defaultRetryData
      dynamicConfigPromisesList
      globalInitDone
      gtagCoreFunction
      gtagName
      initializationPromisesMap
      logger
      measurementIdToAppId
      name
      version
      wrappedGtagFunction
      

      ?
      enums
      ?
      ?

      External Dependency Table

      ModuleBase (6ac66ba)Head (01616e5)Diff
      @firebase/app-exp
      ?

      _getProvider
      _registerComponent
      registerVersion
      

      ?
      @firebase/logger
      ?

      Logger
      

      ?
      @firebase/util
      ?

      ErrorFactory
      FirebaseError
      areCookiesEnabled
      calculateBackoffMillis
      isBrowserExtension
      isIndexedDBAvailable
      validateIndexedDBOpenable
      

      ?
      @firebase/component
      ?

      Component
      

      ?
    • isSupported

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size
      ?
      9.07 kB
      ? (?)
      size-with-ext-deps
      ?
      26.4 kB
      ? (?)

      Dependency Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      functions
      ?

      22 dependencies

      attemptFetchDynamicConfigWithRetry
      factory
      fetchDynamicConfig
      fetchDynamicConfigWithRetry
      findGtagScriptOnPage
      getHeaders
      getOrCreateDataLayer
      gtagOnConfig
      gtagOnEvent
      initializeAnalytics
      insertScriptTag
      isRetriableError
      isSupported
      logEvent
      logEvent$1
      promiseAllSettled
      registerAnalytics
      setAbortableTimeout
      validateIndexedDB
      warnOnBrowserContextMismatch
      wrapGtag
      wrapOrCreateGtag
      

      ?
      classes
      ?

      AnalyticsAbortSignal
      AnalyticsService
      RetryData
      

      ?
      variables
      ?

      22 dependencies

      ANALYTICS_TYPE
      BASE_INTERVAL_MILLIS
      DYNAMIC_CONFIG_URL
      ERRORS
      ERROR_FACTORY
      FETCH_TIMEOUT_MILLIS
      GA_FID_KEY
      GTAG_URL
      LONG_RETRY_FACTOR
      ORIGIN_KEY
      dataLayerName
      defaultRetryData
      dynamicConfigPromisesList
      globalInitDone
      gtagCoreFunction
      gtagName
      initializationPromisesMap
      logger
      measurementIdToAppId
      name
      version
      wrappedGtagFunction
      

      ?
      enums
      ?
      ?

      External Dependency Table

      ModuleBase (6ac66ba)Head (01616e5)Diff
      @firebase/app-exp
      ?

      _registerComponent
      registerVersion
      

      ?
      @firebase/logger
      ?

      Logger
      

      ?
      @firebase/util
      ?

      ErrorFactory
      FirebaseError
      areCookiesEnabled
      calculateBackoffMillis
      isBrowserExtension
      isIndexedDBAvailable
      validateIndexedDBOpenable
      

      ?
      @firebase/component
      ?

      Component
      

      ?
    • logEvent

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size
      ?
      8.93 kB
      ? (?)
      size-with-ext-deps
      ?
      26.3 kB
      ? (?)

      Dependency Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      functions
      ?

      20 dependencies

      attemptFetchDynamicConfigWithRetry
      factory
      fetchDynamicConfig
      fetchDynamicConfigWithRetry
      findGtagScriptOnPage
      getHeaders
      getOrCreateDataLayer
      gtagOnConfig
      gtagOnEvent
      initializeAnalytics
      insertScriptTag
      isRetriableError
      logEvent
      promiseAllSettled
      registerAnalytics
      setAbortableTimeout
      validateIndexedDB
      warnOnBrowserContextMismatch
      wrapGtag
      wrapOrCreateGtag
      

      ?
      classes
      ?

      AnalyticsAbortSignal
      AnalyticsService
      RetryData
      

      ?
      variables
      ?

      22 dependencies

      ANALYTICS_TYPE
      BASE_INTERVAL_MILLIS
      DYNAMIC_CONFIG_URL
      ERRORS
      ERROR_FACTORY
      FETCH_TIMEOUT_MILLIS
      GA_FID_KEY
      GTAG_URL
      LONG_RETRY_FACTOR
      ORIGIN_KEY
      dataLayerName
      defaultRetryData
      dynamicConfigPromisesList
      globalInitDone
      gtagCoreFunction
      gtagName
      initializationPromisesMap
      logger
      measurementIdToAppId
      name
      version
      wrappedGtagFunction
      

      ?
      enums
      ?
      ?

      External Dependency Table

      ModuleBase (6ac66ba)Head (01616e5)Diff
      @firebase/app-exp
      ?

      _registerComponent
      registerVersion
      

      ?
      @firebase/logger
      ?

      Logger
      

      ?
      @firebase/util
      ?

      ErrorFactory
      FirebaseError
      areCookiesEnabled
      calculateBackoffMillis
      isBrowserExtension
      isIndexedDBAvailable
      validateIndexedDBOpenable
      

      ?
      @firebase/component
      ?

      Component
      

      ?
    • setAnalyticsCollectionEnabled

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size
      ?
      9.08 kB
      ? (?)
      size-with-ext-deps
      ?
      26.4 kB
      ? (?)

      Dependency Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      functions
      ?

      22 dependencies

      attemptFetchDynamicConfigWithRetry
      factory
      fetchDynamicConfig
      fetchDynamicConfigWithRetry
      findGtagScriptOnPage
      getHeaders
      getOrCreateDataLayer
      gtagOnConfig
      gtagOnEvent
      initializeAnalytics
      insertScriptTag
      isRetriableError
      logEvent
      logEvent$1
      promiseAllSettled
      registerAnalytics
      setAbortableTimeout
      setAnalyticsCollectionEnabled
      validateIndexedDB
      warnOnBrowserContextMismatch
      wrapGtag
      wrapOrCreateGtag
      

      ?
      classes
      ?

      AnalyticsAbortSignal
      AnalyticsService
      RetryData
      

      ?
      variables
      ?

      22 dependencies

      ANALYTICS_TYPE
      BASE_INTERVAL_MILLIS
      DYNAMIC_CONFIG_URL
      ERRORS
      ERROR_FACTORY
      FETCH_TIMEOUT_MILLIS
      GA_FID_KEY
      GTAG_URL
      LONG_RETRY_FACTOR
      ORIGIN_KEY
      dataLayerName
      defaultRetryData
      dynamicConfigPromisesList
      globalInitDone
      gtagCoreFunction
      gtagName
      initializationPromisesMap
      logger
      measurementIdToAppId
      name
      version
      wrappedGtagFunction
      

      ?
      enums
      ?
      ?

      External Dependency Table

      ModuleBase (6ac66ba)Head (01616e5)Diff
      @firebase/app-exp
      ?

      _registerComponent
      registerVersion
      

      ?
      @firebase/logger
      ?

      Logger
      

      ?
      @firebase/util
      ?

      ErrorFactory
      FirebaseError
      areCookiesEnabled
      calculateBackoffMillis
      isBrowserExtension
      isIndexedDBAvailable
      validateIndexedDBOpenable
      

      ?
      @firebase/component
      ?

      Component
      

      ?
    • setCurrentScreen

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size
      ?
      9.17 kB
      ? (?)
      size-with-ext-deps
      ?
      26.5 kB
      ? (?)

      Dependency Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      functions
      ?

      22 dependencies

      attemptFetchDynamicConfigWithRetry
      factory
      fetchDynamicConfig
      fetchDynamicConfigWithRetry
      findGtagScriptOnPage
      getHeaders
      getOrCreateDataLayer
      gtagOnConfig
      gtagOnEvent
      initializeAnalytics
      insertScriptTag
      isRetriableError
      logEvent
      logEvent$1
      promiseAllSettled
      registerAnalytics
      setAbortableTimeout
      setCurrentScreen
      validateIndexedDB
      warnOnBrowserContextMismatch
      wrapGtag
      wrapOrCreateGtag
      

      ?
      classes
      ?

      AnalyticsAbortSignal
      AnalyticsService
      RetryData
      

      ?
      variables
      ?

      22 dependencies

      ANALYTICS_TYPE
      BASE_INTERVAL_MILLIS
      DYNAMIC_CONFIG_URL
      ERRORS
      ERROR_FACTORY
      FETCH_TIMEOUT_MILLIS
      GA_FID_KEY
      GTAG_URL
      LONG_RETRY_FACTOR
      ORIGIN_KEY
      dataLayerName
      defaultRetryData
      dynamicConfigPromisesList
      globalInitDone
      gtagCoreFunction
      gtagName
      initializationPromisesMap
      logger
      measurementIdToAppId
      name
      version
      wrappedGtagFunction
      

      ?
      enums
      ?
      ?

      External Dependency Table

      ModuleBase (6ac66ba)Head (01616e5)Diff
      @firebase/app-exp
      ?

      _registerComponent
      registerVersion
      

      ?
      @firebase/logger
      ?

      Logger
      

      ?
      @firebase/util
      ?

      ErrorFactory
      FirebaseError
      areCookiesEnabled
      calculateBackoffMillis
      isBrowserExtension
      isIndexedDBAvailable
      validateIndexedDBOpenable
      

      ?
      @firebase/component
      ?

      Component
      

      ?
    • setUserId

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size
      ?
      9.15 kB
      ? (?)
      size-with-ext-deps
      ?
      26.5 kB
      ? (?)

      Dependency Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      functions
      ?

      22 dependencies

      attemptFetchDynamicConfigWithRetry
      factory
      fetchDynamicConfig
      fetchDynamicConfigWithRetry
      findGtagScriptOnPage
      getHeaders
      getOrCreateDataLayer
      gtagOnConfig
      gtagOnEvent
      initializeAnalytics
      insertScriptTag
      isRetriableError
      logEvent
      logEvent$1
      promiseAllSettled
      registerAnalytics
      setAbortableTimeout
      setUserId
      validateIndexedDB
      warnOnBrowserContextMismatch
      wrapGtag
      wrapOrCreateGtag
      

      ?
      classes
      ?

      AnalyticsAbortSignal
      AnalyticsService
      RetryData
      

      ?
      variables
      ?

      22 dependencies

      ANALYTICS_TYPE
      BASE_INTERVAL_MILLIS
      DYNAMIC_CONFIG_URL
      ERRORS
      ERROR_FACTORY
      FETCH_TIMEOUT_MILLIS
      GA_FID_KEY
      GTAG_URL
      LONG_RETRY_FACTOR
      ORIGIN_KEY
      dataLayerName
      defaultRetryData
      dynamicConfigPromisesList
      globalInitDone
      gtagCoreFunction
      gtagName
      initializationPromisesMap
      logger
      measurementIdToAppId
      name
      version
      wrappedGtagFunction
      

      ?
      enums
      ?
      ?

      External Dependency Table

      ModuleBase (6ac66ba)Head (01616e5)Diff
      @firebase/app-exp
      ?

      _registerComponent
      registerVersion
      

      ?
      @firebase/logger
      ?

      Logger
      

      ?
      @firebase/util
      ?

      ErrorFactory
      FirebaseError
      areCookiesEnabled
      calculateBackoffMillis
      isBrowserExtension
      isIndexedDBAvailable
      validateIndexedDBOpenable
      

      ?
      @firebase/component
      ?

      Component
      

      ?
    • setUserProperties

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size
      ?
      9.23 kB
      ? (?)
      size-with-ext-deps
      ?
      26.6 kB
      ? (?)

      Dependency Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      functions
      ?

      22 dependencies

      attemptFetchDynamicConfigWithRetry
      factory
      fetchDynamicConfig
      fetchDynamicConfigWithRetry
      findGtagScriptOnPage
      getHeaders
      getOrCreateDataLayer
      gtagOnConfig
      gtagOnEvent
      initializeAnalytics
      insertScriptTag
      isRetriableError
      logEvent
      logEvent$1
      promiseAllSettled
      registerAnalytics
      setAbortableTimeout
      setUserProperties
      validateIndexedDB
      warnOnBrowserContextMismatch
      wrapGtag
      wrapOrCreateGtag
      

      ?
      classes
      ?

      AnalyticsAbortSignal
      AnalyticsService
      RetryData
      

      ?
      variables
      ?

      22 dependencies

      ANALYTICS_TYPE
      BASE_INTERVAL_MILLIS
      DYNAMIC_CONFIG_URL
      ERRORS
      ERROR_FACTORY
      FETCH_TIMEOUT_MILLIS
      GA_FID_KEY
      GTAG_URL
      LONG_RETRY_FACTOR
      ORIGIN_KEY
      dataLayerName
      defaultRetryData
      dynamicConfigPromisesList
      globalInitDone
      gtagCoreFunction
      gtagName
      initializationPromisesMap
      logger
      measurementIdToAppId
      name
      version
      wrappedGtagFunction
      

      ?
      enums
      ?
      ?

      External Dependency Table

      ModuleBase (6ac66ba)Head (01616e5)Diff
      @firebase/app-exp
      ?

      _registerComponent
      registerVersion
      

      ?
      @firebase/logger
      ?

      Logger
      

      ?
      @firebase/util
      ?

      ErrorFactory
      FirebaseError
      areCookiesEnabled
      calculateBackoffMillis
      isBrowserExtension
      isIndexedDBAvailable
      validateIndexedDBOpenable
      

      ?
      @firebase/component
      ?

      Component
      

      ?
    • settings

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size
      ?
      9.05 kB
      ? (?)
      size-with-ext-deps
      ?
      26.4 kB
      ? (?)

      Dependency Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      functions
      ?

      22 dependencies

      attemptFetchDynamicConfigWithRetry
      factory
      fetchDynamicConfig
      fetchDynamicConfigWithRetry
      findGtagScriptOnPage
      getHeaders
      getOrCreateDataLayer
      gtagOnConfig
      gtagOnEvent
      initializeAnalytics
      insertScriptTag
      isRetriableError
      logEvent
      logEvent$1
      promiseAllSettled
      registerAnalytics
      setAbortableTimeout
      settings
      validateIndexedDB
      warnOnBrowserContextMismatch
      wrapGtag
      wrapOrCreateGtag
      

      ?
      classes
      ?

      AnalyticsAbortSignal
      AnalyticsService
      RetryData
      

      ?
      variables
      ?

      22 dependencies

      ANALYTICS_TYPE
      BASE_INTERVAL_MILLIS
      DYNAMIC_CONFIG_URL
      ERRORS
      ERROR_FACTORY
      FETCH_TIMEOUT_MILLIS
      GA_FID_KEY
      GTAG_URL
      LONG_RETRY_FACTOR
      ORIGIN_KEY
      dataLayerName
      defaultRetryData
      dynamicConfigPromisesList
      globalInitDone
      gtagCoreFunction
      gtagName
      initializationPromisesMap
      logger
      measurementIdToAppId
      name
      version
      wrappedGtagFunction
      

      ?
      enums
      ?
      ?

      External Dependency Table

      ModuleBase (6ac66ba)Head (01616e5)Diff
      @firebase/app-exp
      ?

      _registerComponent
      registerVersion
      

      ?
      @firebase/logger
      ?

      Logger
      

      ?
      @firebase/util
      ?

      ErrorFactory
      FirebaseError
      areCookiesEnabled
      calculateBackoffMillis
      isBrowserExtension
      isIndexedDBAvailable
      validateIndexedDBOpenable
      

      ?
      @firebase/component
      ?

      Component
      

      ?
  • @firebase/app-exp

    • SDK_VERSION

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size
      2.70 kB
      2.70 kB
      +1 B (+0.0%)
      size-with-ext-deps
      4.12 kB
      4.12 kB
      +1 B (+0.0%)
  • @firebase/auth-exp

    • ActionCodeURL

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      40.0 kB
      40.0 kB
      +1 B (+0.0%)
    • AuthCredential

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      39.2 kB
      39.2 kB
      +1 B (+0.0%)
    • EmailAuthCredential

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      41.0 kB
      41.0 kB
      +1 B (+0.0%)
    • EmailAuthProvider

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      42.3 kB
      42.3 kB
      +1 B (+0.0%)
    • FacebookAuthProvider

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      42.8 kB
      42.8 kB
      +1 B (+0.0%)
    • GithubAuthProvider

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      42.8 kB
      42.8 kB
      +1 B (+0.0%)
    • GoogleAuthProvider

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      42.8 kB
      42.8 kB
      +1 B (+0.0%)
    • OAuthCredential

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      41.0 kB
      41.0 kB
      +1 B (+0.0%)
    • OAuthProvider

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      42.2 kB
      42.2 kB
      +1 B (+0.0%)
    • PhoneAuthCredential

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      41.0 kB
      41.0 kB
      +1 B (+0.0%)
    • PhoneAuthProvider

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      42.6 kB
      42.6 kB
      +1 B (+0.0%)
    • PhoneMultiFactorGenerator

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      39.9 kB
      39.9 kB
      +1 B (+0.0%)
    • RecaptchaVerifier

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      45.2 kB
      45.2 kB
      +1 B (+0.0%)
    • TwitterAuthProvider

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      42.8 kB
      42.8 kB
      +1 B (+0.0%)
    • applyActionCode

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      39.1 kB
      39.1 kB
      +1 B (+0.0%)
    • checkActionCode

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      40.0 kB
      40.0 kB
      +1 B (+0.0%)
    • confirmPasswordReset

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      39.1 kB
      39.1 kB
      +1 B (+0.0%)
    • createUserWithEmailAndPassword

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      40.0 kB
      40.0 kB
      +1 B (+0.0%)
    • deleteUser

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      39.0 kB
      39.0 kB
      +1 B (+0.0%)
    • fetchSignInMethodsForEmail

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      39.3 kB
      39.3 kB
      +1 B (+0.0%)
    • getAdditionalUserInfo

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      40.3 kB
      40.3 kB
      +1 B (+0.0%)
    • getAuth

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      66.6 kB
      66.6 kB
      +1 B (+0.0%)
    • getIdToken

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      39.0 kB
      39.0 kB
      +1 B (+0.0%)
    • getIdTokenResult

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      39.0 kB
      39.0 kB
      +1 B (+0.0%)
    • getMultiFactorResolver

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      41.7 kB
      41.7 kB
      +1 B (+0.0%)
    • getRedirectResult

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      44.6 kB
      44.6 kB
      +1 B (+0.0%)
    • initializeAuth

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      39.3 kB
      39.3 kB
      +1 B (+0.0%)
    • isSignInWithEmailLink

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      40.1 kB
      40.1 kB
      +1 B (+0.0%)
    • linkWithCredential

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      40.0 kB
      40.0 kB
      +1 B (+0.0%)
    • linkWithPhoneNumber

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      43.5 kB
      43.5 kB
      +1 B (+0.0%)
    • linkWithPopup

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      47.9 kB
      47.9 kB
      +1 B (+0.0%)
    • linkWithRedirect

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      42.9 kB
      42.9 kB
      +1 B (+0.0%)
    • multiFactor

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      41.1 kB
      41.1 kB
      +1 B (+0.0%)
    • onAuthStateChanged

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      39.0 kB
      39.0 kB
      +1 B (+0.0%)
    • onIdTokenChanged

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      39.0 kB
      39.0 kB
      +1 B (+0.0%)
    • parseActionCodeURL

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      40.0 kB
      40.0 kB
      +1 B (+0.0%)
    • reauthenticateWithCredential

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      40.6 kB
      40.6 kB
      +1 B (+0.0%)
    • reauthenticateWithPhoneNumber

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      44.1 kB
      44.1 kB
      +1 B (+0.0%)
    • reauthenticateWithPopup

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      47.9 kB
      47.9 kB
      +1 B (+0.0%)
    • reauthenticateWithRedirect

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      42.7 kB
      42.7 kB
      +1 B (+0.0%)
    • reload

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      38.9 kB
      38.9 kB
      +1 B (+0.0%)
    • sendEmailVerification

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      39.9 kB
      39.9 kB
      +1 B (+0.0%)
    • sendPasswordResetEmail

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      39.8 kB
      39.8 kB
      +1 B (+0.0%)
    • sendSignInLinkToEmail

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      39.9 kB
      39.9 kB
      +1 B (+0.0%)
    • setPersistence

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      39.0 kB
      39.0 kB
      +1 B (+0.0%)
    • signInAnonymously

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      40.1 kB
      40.1 kB
      +1 B (+0.0%)
    • signInWithCredential

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      40.4 kB
      40.4 kB
      +1 B (+0.0%)
    • signInWithCustomToken

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      40.0 kB
      40.0 kB
      +1 B (+0.0%)
    • signInWithEmailAndPassword

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      43.8 kB
      43.8 kB
      +1 B (+0.0%)
    • signInWithEmailLink

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      44.0 kB
      44.0 kB
      +1 B (+0.0%)
    • signInWithPhoneNumber

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      43.8 kB
      43.8 kB
      +1 B (+0.0%)
    • signInWithPopup

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      47.9 kB
      47.9 kB
      +1 B (+0.0%)
    • signInWithRedirect

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      42.4 kB
      42.4 kB
      +1 B (+0.0%)
    • signOut

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      39.0 kB
      39.0 kB
      +1 B (+0.0%)
    • unlink

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      39.5 kB
      39.6 kB
      +1 B (+0.0%)
    • updateCurrentUser

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      39.0 kB
      39.0 kB
      +1 B (+0.0%)
    • updateEmail

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      39.3 kB
      39.3 kB
      +1 B (+0.0%)
    • updatePassword

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      39.3 kB
      39.3 kB
      +1 B (+0.0%)
    • updatePhoneNumber

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      39.7 kB
      39.7 kB
      +1 B (+0.0%)
    • updateProfile

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      39.5 kB
      39.5 kB
      +1 B (+0.0%)
    • useDeviceLanguage

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      39.0 kB
      39.0 kB
      +1 B (+0.0%)
    • verifyBeforeUpdateEmail

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      39.9 kB
      39.9 kB
      +1 B (+0.0%)
    • verifyPasswordResetCode

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      40.1 kB
      40.1 kB
      +1 B (+0.0%)
    • browserLocalPersistence

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      42.0 kB
      42.0 kB
      +1 B (+0.0%)
    • browserPopupRedirectResolver

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      56.4 kB
      56.4 kB
      +1 B (+0.0%)
    • browserSessionPersistence

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      39.6 kB
      39.6 kB
      +1 B (+0.0%)
    • debugErrorMap

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      49.5 kB
      49.5 kB
      +1 B (+0.0%)
    • inMemoryPersistence

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      39.0 kB
      39.0 kB
      +1 B (+0.0%)
    • indexedDBLocalPersistence

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      46.3 kB
      46.3 kB
      +1 B (+0.0%)
    • prodErrorMap

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      39.0 kB
      39.0 kB
      +1 B (+0.0%)
  • @firebase/messaging-exp

    • deleteToken

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size
      7.52 kB
      7.51 kB
      -11 B (-0.1%)
      size-with-ext-deps
      24.2 kB
      24.2 kB
      +7 B (+0.0%)
    • getToken

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size
      12.0 kB
      12.0 kB
      -17 B (-0.1%)
      size-with-ext-deps
      28.7 kB
      28.7 kB
      +7 B (+0.0%)
  • @firebase/remote-config-exp

    • activate

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      27.0 kB
      27.0 kB
      +1 B (+0.0%)
    • ensureInitialized

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      26.7 kB
      26.7 kB
      +1 B (+0.0%)
    • fetchAndActivate

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      27.7 kB
      27.7 kB
      +1 B (+0.0%)
    • fetchConfig

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      27.3 kB
      27.3 kB
      +1 B (+0.0%)
    • getAll

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      27.9 kB
      27.9 kB
      +1 B (+0.0%)
    • getBoolean

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      27.8 kB
      27.8 kB
      +1 B (+0.0%)
    • getNumber

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      27.8 kB
      27.8 kB
      +1 B (+0.0%)
    • getRemoteConfig

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      26.8 kB
      26.8 kB
      +1 B (+0.0%)
    • getString

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      27.8 kB
      27.8 kB
      +1 B (+0.0%)
    • getValue

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      27.7 kB
      27.7 kB
      +1 B (+0.0%)
    • setLogLevel

      Size Table

      TypeBase (6ac66ba)Head (01616e5)Diff
      size-with-ext-deps
      26.9 kB
      26.9 kB
      +1 B (+0.0%)

Copy link
Contributor

@schmidt-sebastian schmidt-sebastian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the code change is fine but I disagree a bit with the direction (but can certainly be convinced). We have our own internal data structures, and we shouldn't make an effort to make the "consumable" by our users. This makes our life more complicated and gives off the impression that we will support the output format going forward. It also convolutes the returned data, with very little additional benefit to the user.

Consider this: What does the user want when they call toJSON on a DocumentReference? They probably would prefer something like:

{ 
 path: 'coll/doc',
 firestore: {project: 'foo', database: '(default)'}
 converter: null
 }

over

{ 
 path: 'coll/doc',
 firestore: {project: 'foo', database: '(default)', asyncQueue: {...}, firestoreClient: {...} }
 converter: null
}

The first one is more concise, provides the information the user likely needs, and is less likely to change over time.

In case you are wondering where my argument is going (and if it is going anywhere): I think we should just implement toJSON on FirebaseFirestore and call it a day. The toJSON should have enough information to help the developer distinguish it from other instances, that is - database ID and FirebaseApp (and maybe others, but select instance members).

And yes, this should also work for Firbease@exp.

FWIW, the change to FirebaseApp already follows this pattern.

Let me know if you want to talk about this more.

@thebrianchen
Copy link
Author

@schmidt-sebastian Thanks for the suggestion -- your proposal creates a much more simplified API surface and doesn't require us to maintain a bunch of toJSON() fields. I ended up only including the databaseId and settings, since the project/database fields are not available by default. I'm not sure if I should expand the individual fields or add a return type. WDYT?

Copy link
Contributor

@schmidt-sebastian schmidt-sebastian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should add app to Firebase.toJSON as well, but otherwise this LGTM. You might want to verify that you are on the right prettier before submitting (but you might be and the code style may be outdated)

Comment on lines 85 to 88
JSON.stringify(documentSnapshot('foo/bar', { a: 1 }, true));
JSON.stringify(documentSnapshot('foo/bar', { a: 1 }, false));
JSON.stringify(documentSnapshot('foo/bar', null, true));
JSON.stringify(documentSnapshot('foo/bar', null, false));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do these four cases test different paths in a toJSON call?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not anymore, removed.

@@ -134,6 +134,13 @@ export class FirebaseFirestore implements FirestoreService {
return this._terminateTask;
}

toJSON(): object {
return {
databaseId: this._databaseId,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we include the app as well? I think the developers might want to see the app name here, since it acts as the main identifier for all Firebase components.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added app.name to the JSON.

@@ -112,6 +112,8 @@ export interface FirebaseNamespace {
// Sets log handler for all Firebase components.
onLog(logCallback: LogCallback, options?: LogOptions): void;

toJSON(): object;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should also modify the Firestore and the Firebase types if you modify this (firestore-types/index.d.ts and firebase/index.d.ts)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

Copy link
Member

@Feiyang1 Feiyang1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Can you please add a test for toJSON() in @firebase/app?

@thebrianchen
Copy link
Author

LGTM. Can you please add a test for toJSON() in @firebase/app?

@Feiyang1 Done. Also added support for toJSON() in FirebaseAppLite.

@thebrianchen thebrianchen merged commit 749c7f3 into master Jan 26, 2021
@thebrianchen thebrianchen deleted the bc/json-fun branch January 26, 2021 22:06
@google-oss-bot google-oss-bot mentioned this pull request Jan 26, 2021
@firebase firebase locked and limited conversation to collaborators Feb 26, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enumerable circular references in many firestore objects
4 participants