function buildTxMetadata (bookmarks, txConfig, database, mode, impersonatedUser, notificationFilter, functions = {}) {
  const metadata = {}
  if (!bookmarks.isEmpty()) {
    metadata.bookmarks = bookmarks.values()
  }
  if (txConfig.timeout !== null) {
    metadata.tx_timeout = txConfig.timeout
  }
  if (txConfig.metadata) {
    metadata.tx_metadata = txConfig.metadata
  }
  if (database) {
    metadata.db = assertString(database, 'database')
  }
  if (impersonatedUser) {
    metadata.imp_user = assertString(impersonatedUser, 'impersonatedUser')
  }
  if (mode === ACCESS_MODE_READ) {
    metadata.mode = READ_MODE
  }

  const appendNotificationFilter = functions.appendNotificationFilter ?? appendLegacyNotificationFilterToMetadata
  appendNotificationFilter(metadata, notificationFilter)
  return metadata
}
Create an object that represent transaction metadata.
@param {Bookmarks} bookmarks the bookmarks.
@param {TxConfig} txConfig the configuration.
@param {string} database the database name.
@param {string} mode the access mode.
@param {string} impersonatedUser the impersonated user mode.
@param {notificationFilter} notificationFilter the notification filter
@param {Object} functions Transformation functions applied to metadata
@param {function(metadata,notificationFilter):void} functions.appendNotificationFilter Changes metadata by appending the Notification Filter to it.
@return {Object} a metadata object.