import formGlobal from "./global/formGlobal";
import formPlugin from "./global/formPlugin";
import cacheGlobal from "./global/cacheGlobal";
import dataGlobal from "./global/dataGlobal";
import formResourceGlobal from "./global/formResourceGlobal";
import formUserGlobal from "./global/formUserGlobal";
import apiForm from "./api/apiForm";
import apiOutAdmin from "./api/apiOutAdmin";
import {registerAxiosFormData} from "sasp-base";

const install = function (Vue, opts = {}) {
    apiForm.init(opts.SERVICE_URL);
    if(opts.ADMIN_URL){
        apiOutAdmin.init(opts.ADMIN_URL);
    }
    registerAxiosFormData(opts.SERVICE_URL);

    Vue.use(formUserGlobal,opts);
    Vue.use(formGlobal,opts);
    Vue.use(dataGlobal,opts);
    Vue.use(formResourceGlobal,opts);
    Vue.use(cacheGlobal,opts);
    Vue.prototype.FORM_GLOBAL = formGlobal;
    Vue.prototype.FORM_RES_GLOBAL = formResourceGlobal;
    Vue.prototype.FORM_PLUGIN = formPlugin;
    Vue.prototype.CACHE_GLOBAL = cacheGlobal;
    Vue.prototype.FORM_USER_GLOBAL = formUserGlobal;
    Object.assign(Vue.prototype.api, apiForm.apis, apiOutAdmin.apis);
}

export default {
    install
};