Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
@skava/graphql / dist / deps / transformRequestProxy.js
Size: Mime:
"use strict";
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
    result["default"] = mod;
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const exotic_1 = require("exotic");
const config = __importStar(require("../bootstrapper/api/config"));
const STREAMDAO_1 = require("../bootstrapper/api/STREAMDAO");
const config_1 = require("../bootstrapper/api/config");
// const cookieJar = new CookieJar()
// @TODO change the base url & config ^
// @NOTE we would want the proxies if we want the production
// so when we merge into master or when we have the flag
// then test on real api responses - best of both
// if (!ENV_TEST || ENV_API_PROD) {
//   // change the config
// }
const { clientDomain, clientVersion, cookieConfig } = config;
const apiConfig = { clientDomain, clientVersion };
exports.apiConfig = apiConfig;
const https = 'http';
exports.https = https;
const baseUrlPrefix = config_1.STREAM_API_LAYER !== config_1.API_LAYER_ENV
    ? `${https}://${clientDomain}`
    : `${https}://${clientDomain}/skavastream`;
exports.baseUrlPrefix = baseUrlPrefix;
const getBaseTargetURL = objectDAO => {
    /* @TODO Sort this out properly as proxy is broken  */
    let targetUrl = '';
    console.log('API_LAYER_ENV', config_1.API_LAYER_ENV);
    const version = objectDAO.clientVersion
        ? objectDAO.clientVersion
        : apiConfig.clientVersion;
    if (objectDAO.isAbsoluteUrl) {
        targetUrl = objectDAO['absoluteUrl'];
    }
    else if (config_1.STREAM_API_LAYER !== config_1.API_LAYER_ENV) {
        const orchestrationService = objectDAO.orchestrationService
            ? objectDAO.orchestrationService
            : '';
        const orchestrationServiceType = objectDAO.orchestrationServiceType
            ? objectDAO.orchestrationServiceType
            : '';
        const pathParams = objectDAO.pathParams ? objectDAO.pathParams : '';
        targetUrl = `${baseUrlPrefix}${orchestrationService}${orchestrationServiceType}${pathParams}`;
    }
    else {
        targetUrl = `${baseUrlPrefix}/${objectDAO.type}/${version}/${objectDAO.partner}`;
    }
    console.log('transformproxy', targetUrl);
    return targetUrl || 'https://@@FAIL';
};
exports.getBaseTargetURL = getBaseTargetURL;
const getURL = (route, callType) => {
    // const type = route.replace('/', '')
    if (route) {
        // const type = route.substring(route.lastIndexOf("/") + 1, route.length)
        //Todo @anto this needs to be optimized in better way
        //spliting api's like /api/payment/add and reusing the same stream dao
        const types = route.split('api/')[1];
        const type = types ? types.split('/')[0] : '';
        const objectDAO = STREAMDAO_1.getStreamDataAccessObjType(types);
        let apiObjectDAO = objectDAO;
        if (!objectDAO.type) {
            apiObjectDAO = STREAMDAO_1.getStreamDataAccessObjType(type);
        }
        if (!exotic_1.isEmpty(type)) {
            const target = getBaseTargetURL(apiObjectDAO);
            let targetUrl = `${target}/${types}`;
            if (config_1.STREAM_API_LAYER !== config_1.API_LAYER_ENV) {
                targetUrl = `${target}`;
            }
            return targetUrl;
        }
        else {
            return route;
        }
    }
    else {
        return route;
    }
};
exports.getURL = getURL;
const endpoints = [
    '/productlist',
    '/category',
    '/product',
    '/viewbag',
    '/getlists',
    '/profile',
    '/search',
    '/reviews',
    '/getstores',
    '/register',
    '/createlist',
    '/additem',
    '/deleteitem',
    '/getitems',
    '/login',
    '/profile',
    '/logout',
    '/setshippingaddress/update',
    '/setpaymentmethod',
    '/deletecard',
    '/submitreview',
    '/resetpassword',
    '/orderdetails',
    '/submitorder/return',
    '/submitorder/cancel',
    '/addtobag',
    '/deletefrombag',
    '/estimate',
    '/updatebag',
    '/updateshippingmethods',
    '/payment',
    '/submitorder',
    '/setshippingaddress',
    '/searchsuggestion',
    '/updatepassword',
    '/getsecurityquestion',
    '/suspendcart',
    '/user',
    '/getCatalog',
    '/getPages',
    '/getKeyForToken',
    '/loyalty',
    '/checkoutauth',
    '/token/create',
    '/resetByMailUrl',
    '/validateresetpassword',
    '/resetpasswordbysecurityquestion',
    '/resetpasswordbyemail',
    '/useraddresses',
    '/useractivation',
    '/accountinvite',
    '/accountprofile',
    '/accountregister',
];
exports.endpoints = endpoints;
const callDetails = {
    '/productlist': 'GET',
    '/category': 'GET',
    '/product': 'GET',
    '/viewbag': 'GET',
    '/getlists': 'POST',
    '/profile': 'POST',
    '/search': 'GET',
    '/reviews': 'POST',
    '/submitreview': 'POST',
    '/getstores': 'POST',
    '/register': 'POST',
    '/additem': 'POST',
    '/deleteitem': 'POST',
    '/getitems': 'POST',
    '/login': 'POST',
    '/logout': 'POST',
    '/setshippingaddress/update': 'POST',
    '/setpaymentmethod': 'POST',
    '/deletecard': 'DELETE',
    '/resetpassword': 'POST',
    '/orderdetails': 'POST',
    '/submitorder/return': 'POST',
    '/submitorder/cancel': 'POST',
    '/addtobag': 'POST',
    '/deletefrombag': 'POST',
    '/estimate': 'POST',
    '/updatebag': 'POST',
    '/updateshippingmethods': 'POST',
    '/payment': 'POST',
    '/submitorder': 'POST',
    '/setshippingaddress': 'POST',
    '/searchsuggestion': 'GET',
    '/suspendcart': 'POST',
    '/user': 'GET',
    '/getCatalog': 'GET',
    '/getPages': 'GET',
    '/getKeyForToken': 'GET',
    '/loyalty': 'POST',
    '/checkoutauth': 'POST',
    '/token/create': 'POST',
    '/resetByMailUrl': 'POST',
    '/validateresetpassword': 'POST',
    '/resetpasswordbysecurityquestion': 'POST',
    '/resetpasswordbyemail': 'POST',
    '/useractivation': 'PATCH',
    '/accountinvite': 'PATCH',
    '/accountprofile': 'GET',
    '/accountregister': 'POST',
};
exports.callDetails = callDetails;
Object.freeze(endpoints);
Object.freeze(callDetails);
//# sourceMappingURL=transformRequestProxy.js.map