"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

function _bluebird() {
  const data = require("bluebird");

  _bluebird = function () {
    return data;
  };

  return data;
}

function _index() {
  const data = require("./api/consumer/index");

  _index = function () {
    return data;
  };

  return data;
}

function _index2() {
  const data = require("./api/scope/index");

  _index2 = function () {
    return data;
  };

  return data;
}

function _extension() {
  const data = _interopRequireDefault(require("./extensions/extension"));

  _extension = function () {
    return data;
  };

  return data;
}

function _hooks() {
  const data = _interopRequireDefault(require("./hooks"));

  _hooks = function () {
    return data;
  };

  return data;
}

_hooks().default.init();

module.exports = {
  show: (scopePath, id, opts) => (0, _index().getScopeComponent)({
    scopePath,
    id,
    allVersions: opts && opts.versions
  }).then(c => {
    if (Array.isArray(c)) {
      return c.map(v => v.toObject());
    }

    return c.toObject();
  }),
  list: scopePath => (0, _index2().scopeList)(scopePath).then(listScopeResult => listScopeResult.map(result => result.id.toString())),
  addMany: function () {
    var _ref = (0, _bluebird().coroutine)(function* (components, alternateCwd) {
      return (0, _index().addMany)(components, alternateCwd);
    });

    return function addMany(_x, _x2) {
      return _ref.apply(this, arguments);
    };
  }(),

  /**
   * Load extension programmatically
   */
  loadExtension: function () {
    var _ref2 = (0, _bluebird().coroutine)(function* (args) {
      const extension = yield _extension().default.load(args);
      return Promise.resolve(extension);
    });

    return function loadExtension(_x3) {
      return _ref2.apply(this, arguments);
    };
  }()
};