<commit_before>'use strict';
import InsalesApi from 'insales';
import { createDir } from './file-system/dir';
import { _watch,
         watcher } from './file-system/watch';
import { getAsset,
         getAssets,
         upadeteAssets,
         uploadAsset,
         removeAsset,
         editAsset } from './request/asset';
import { instance } from './instance';

class InSalesUploader {
  constructor(options){
    const self = this;
    self.options = options || {};
    if (!self.options.id) throw new Error('Missing app id');
    if (!self.options.token) throw new Error('Missing app token');
    if (!self.options.url) throw new Error('Missing app url');
    self.options.protocol = (self.options.http) ? 'http://' : 'https://';

    self.instance = instance(self)

    self.assets = {};
    self.state = {};
    self.downloadList = [];

    self.insales = InsalesApi({
      id: this.options.id,
      secret: this.options.token,
      http: this.options.http
    });
  }


  createDir(owner, action) {
    return createDir(this, action);
  }

  getAsset(owner,_asset) {
    return getAsset(this, _asset);
  }

  getAssets(owner, action) {
    return getAssets(this, action);
  }

  upadeteAssets(owner) {
    return upadeteAssets(this);
  }

  uploadAsset(owner, _asset, _path) {
    return uploadAsset(this, _asset, _path);
  }

  removeAsset(owner, _assetId, _path, _name) {
    return removeAsset(this, _assetId, _path, _name);
  }

  editAsset(owner, _asset, assetId, path) {
    return editAsset(this, _asset, assetId, path);
  }

  watcher(owner) {
    return watcher(this);
  }

  _watch(owner, event, path) {
    return _watch(this, event, path);
  }

  _download () {
    var self = this;
    return new Promise(function (resolve, reject) {
      var action = {
        method: 'download'
      }
      self.createDir(self, action);
      self.upadeteAssets(self).then(function() {
        getAssets(self, action).then(function() {
          resolve()
        });
      });
    });
  }

  download () {
    return Promise.all([
      this._download()
    ])
  }

  _backup () {
    var self = this;
    return new Promise(function (resolve, reject) {
      var action = {
        method: 'backup'
      }
      self.createDir(self, action);
      self.upadeteAssets(self).then(function() {
        getAssets(self, action).then(function() {
          resolve()
          return;
        });
      });
    });
  }<commit_msg>Update app.js<commit_after>'use strict';
import InsalesApi from 'insales';
import { createDir } from './file-system/dir';
import { _watch,
         watcher } from './file-system/watch';
import { getAsset,
         getAssets,
         upadeteAssets,
         uploadAsset,
         removeAsset,
         editAsset } from './request/asset';
import { instance } from './instance';

class InSalesUploader {
  constructor(options){
    const self = this;
    self.options = options || {};
    if (!self.options.id) throw new Error('Missing app id');
    if (!self.options.token) throw new Error('Missing app token');
    if (!self.options.url) throw new Error('Missing app url');
    self.options.protocol = (self.options.http) ? 'http://' : 'https://';

    self.instance = instance(self)

    self.assets = {};
    self.state = {};
    self.downloadList = [];

    self.insales = InsalesApi({
      id: this.options.id,
      secret: this.options.token,
      http: this.options.http
    });
  }


  createDir(owner, action) {
    return Promise.all([createDir(this, action)]);
  }

  getAsset(owner,_asset) {
    return getAsset(this, _asset);
  }

  getAssets(owner, action) {
    return getAssets(this, action);
  }

  upadeteAssets(owner) {
    return upadeteAssets(this);
  }

  uploadAsset(owner, _asset, _path) {
    return uploadAsset(this, _asset, _path);
  }

  removeAsset(owner, _assetId, _path, _name) {
    return removeAsset(this, _assetId, _path, _name);
  }

  editAsset(owner, _asset, assetId, path) {
    return editAsset(this, _asset, assetId, path);
  }

  watcher(owner) {
    return watcher(this);
  }

  _watch(owner, event, path) {
    return _watch(this, event, path);
  }

  _download () {
    var self = this;
    return new Promise(function (resolve, reject) {
      var action = {
        method: 'download'
      }
      self.createDir(self, action).then(function() {
        self.upadeteAssets(self).then(function() {
          getAssets(self, action).then(function() {
            resolve()
          });
        });
      });
    });
  }

  download () {
    return Promise.all([
      this._download()
    ])
  }

  _backup () {
    var self = this;
    return new Promise(function (resolve, reject) {
      var action = {
        method: 'backup'
      }
      self.createDir(self, action).then(function() {
        self.upadeteAssets(self).then(function() {
          getAssets(self, action).then(function() {
            resolve()
            return;
          });
        });
      });
    });
  }
{'fraction_non_alphanumeric': 0.14437965011059722, 'fraction_numerical': 0.0, 'mean_word_length': 2.4831932773109244, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6043431', 'n_tokens_mistral': 1597, 'n_tokens_neox': 1561, 'n_words': 339}