<commit_before>/* global fetch */
import 'babel-polyfill'

import {unpromiser, retry, warn} from './utils'
import {LocalStorage, MemoryStorage} from './auth_storage'
import {AppToken as AppTokenV2, getAppToken as getAppTokenV2} from './auth_v2'
import * as auth from './auth_v3'
import * as data from './data'
import * as mango from './mango'
import * as files from './files'
import * as offline from './offline'
import * as settings from './settings'
import * as relations from './relations'

const {
  AppToken: AppTokenV3,
  AccessToken: AccessTokenV3,
  Client: ClientV3
} = auth

const AuthNone = 0
const AuthRunning = 1
const AuthError = 2
const AuthOK = 3

const defaultClientParams = {
  softwareID: 'github.com/cozy/cozy-client-js'
}

const dataProto = {
  create: data.create,
  find: data.find,
  update: data.update,
  delete: data._delete,
  updateAttributes: data.updateAttributes,
  changesFeed: data.changesFeed,
  defineIndex: mango.defineIndex,
  query: mango.query,
  addReferencedFiles: relations.addReferencedFiles,
  listReferencedFiles: relations.listReferencedFiles,
  destroy: function (...args) {
    warn('destroy is deprecated, use cozy.data.delete instead.')
    return data._delete(...args)
  }
}

const authProto = {
  client: auth.client,
  registerClient: auth.registerClient,
  updateClient: auth.updateClient,
  unregisterClient: auth.unregisterClient,
  getClient: auth.getClient,
  getAuthCodeURL: auth.getAuthCodeURL,
  getAccessToken: auth.getAccessToken,
  refreshToken: auth.refreshToken
}

const filesProto = {
  create: files.create,
  createDirectory: files.createDirectory,
  updateById: files.updateById,
  updateAttributesById: files.updateAttributesById,
  updateAttributesByPath: files.updateAttributesByPath,
  trashById: files.trashById,
  statById: files.statById,
  statByPath: files.statByPath,
  downloadById: files.downloadById,
  downloadByPath: files.downloadByPath,
  getDownloadLinkById: files.getDownloadLinkById,
  getDownloadLinkByPath: files.getDownloadLinkByPath,
  getArchiveLink: files.getArchiveLink,
  getFilePath: files.getFilePath,
  listTrash: files.listTrash,
  clearTrash: files.clearTrash,
  restoreById: files.restoreById,
  destroyById: files.destroyById
}

const offlineProto = {
  init: offline.init,
  getDoctypes: offline.getDoctypes,
  // database
  hasDatabase: offline.hasDatabase,
  getDatabase: offline.getDatabase,
  createDatabase: offline.createDatabase,
  destroyDatabase: offline.destroyDatabase,
  destroyAllDatabase: offline.destroyAllDatabase,
  // replication
  hasReplication: offline.hasReplication,<commit_msg>[fix] Get back previous function name for getDownloadLink (should be removed later)<commit_after>/* global fetch */
import 'babel-polyfill'

import {unpromiser, retry, warn} from './utils'
import {LocalStorage, MemoryStorage} from './auth_storage'
import {AppToken as AppTokenV2, getAppToken as getAppTokenV2} from './auth_v2'
import * as auth from './auth_v3'
import * as data from './data'
import * as mango from './mango'
import * as files from './files'
import * as offline from './offline'
import * as settings from './settings'
import * as relations from './relations'

const {
  AppToken: AppTokenV3,
  AccessToken: AccessTokenV3,
  Client: ClientV3
} = auth

const AuthNone = 0
const AuthRunning = 1
const AuthError = 2
const AuthOK = 3

const defaultClientParams = {
  softwareID: 'github.com/cozy/cozy-client-js'
}

const dataProto = {
  create: data.create,
  find: data.find,
  update: data.update,
  delete: data._delete,
  updateAttributes: data.updateAttributes,
  changesFeed: data.changesFeed,
  defineIndex: mango.defineIndex,
  query: mango.query,
  addReferencedFiles: relations.addReferencedFiles,
  listReferencedFiles: relations.listReferencedFiles,
  destroy: function (...args) {
    warn('destroy is deprecated, use cozy.data.delete instead.')
    return data._delete(...args)
  }
}

const authProto = {
  client: auth.client,
  registerClient: auth.registerClient,
  updateClient: auth.updateClient,
  unregisterClient: auth.unregisterClient,
  getClient: auth.getClient,
  getAuthCodeURL: auth.getAuthCodeURL,
  getAccessToken: auth.getAccessToken,
  refreshToken: auth.refreshToken
}

const filesProto = {
  create: files.create,
  createDirectory: files.createDirectory,
  updateById: files.updateById,
  updateAttributesById: files.updateAttributesById,
  updateAttributesByPath: files.updateAttributesByPath,
  trashById: files.trashById,
  statById: files.statById,
  statByPath: files.statByPath,
  downloadById: files.downloadById,
  downloadByPath: files.downloadByPath,
  getDownloadLinkById: files.getDownloadLinkById,
  getDownloadLink: files.getDownloadLinkByPath, // DEPRECATED, should be removed very soon
  getDownloadLinkByPath: files.getDownloadLinkByPath,
  getArchiveLink: files.getArchiveLink,
  getFilePath: files.getFilePath,
  listTrash: files.listTrash,
  clearTrash: files.clearTrash,
  restoreById: files.restoreById,
  destroyById: files.destroyById
}

const offlineProto = {
  init: offline.init,
  getDoctypes: offline.getDoctypes,
  // database
  hasDatabase: offline.hasDatabase,
  getDatabase: offline.getDatabase,
  createDatabase: offline.createDatabase,
  destroyDatabase: offline.destroyDatabase,
  destroyAllDatabase: offline.destroyAllDatabase,
  // replication
  hasReplication: offline.hasReplication,
{'fraction_non_alphanumeric': 0.09745211084247722, 'fraction_numerical': 0.004091500836897899, 'mean_word_length': 5.056306306306307, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 19, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3893374', 'n_tokens_mistral': 1681, 'n_tokens_neox': 1636, 'n_words': 404}