
import * as localforage from 'localforage'

import { Provider } from '../../../@utility/data-structures/provider'
import { PROVIDER_TYPE_DATABASE } from '../../../@utility/constants/provider'

import { PREPARE_PROVIDER_FOR_USE } from '../algorithms/PREPARE_PROVIDER_FOR_USE'
import { createItem } from '../algorithms/create-item'
import { createItemId } from '../algorithms/create-item-id'
import { createItemStore } from '../algorithms/create-item-store'
import { deleteItem } from '../algorithms/delete-item'
import { doesExistItem } from '../algorithms/does-exist-item'
import { getItem } from '../algorithms/get-item'
import { getItemList } from '../algorithms/get-item-list'
import { updateItem } from '../algorithms/update-item'

const LOCALFORAGE: Provider = new Provider({
  nameVersionId: 'localforage@default',
  type: PROVIDER_TYPE_DATABASE,
  hasOfflineSupport: true,
  nameDescription: 'Browser Storage - localForage',
  websiteURL: 'https://github.com/localForage/localForage',
  iconImageURL: 'http://cdn.onlinewebfonts.com/svg/img_164815.png',
  textDescriptionShort: `localForage is a fast and simple storage library for JavaScript.
  localForage improves the offline experience of your web app by using asynchronous storage (IndexedDB or WebSQL) with a simple, localStorage-like API.`,
  providerImport: localforage,
  functionTable: {
    PREPARE_PROVIDER_FOR_USE,
    createItem,
    createItemId,
    createItemStore,
    deleteItem,
    doesExistItem,
    getItem,
    getItemList,
    updateItem
  }
})

export {
  LOCALFORAGE
}