diff --git a/.gitignore b/.gitignore index d9043d22a..7ab8c3a90 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ configs/Email.Config.json configs/User.Profile.json configs/Execution.Config.json configs/Secret.Keys.json +.env diff --git a/Assistant.js b/Assistant.js index 301130f36..232e61610 100644 --- a/Assistant.js +++ b/Assistant.js @@ -982,8 +982,8 @@ if (pRate !== marketRate) { - logger.write(MODULE_NAME, "[ERROR] putPosition -> Input Validations -> putPosition Rate can not be different to marketRate while in Backtesting Mode. "); - onResponse(global.DEFAULT_FAIL_RESPONSE, positionId); + logger.write(MODULE_NAME, "[WARNING] putPosition -> Input Validations -> putPosition Rate can is different to marketRate while in Backtesting Mode. "); + //onResponse(global.DEFAULT_FAIL_RESPONSE, positionId); } let positionId = Math.trunc(Math.random(1) * 1000000); diff --git a/Context.js b/Context.js index c834d8d1a..df5cd196f 100644 --- a/Context.js +++ b/Context.js @@ -169,7 +169,6 @@ } catch (err) { logger.write(MODULE_NAME, "[ERROR] initialize -> getStatusReport -> err = " + err.message); - logger.write(MODULE_NAME, "[ERROR] initialize -> getStatusReport -> key = " + key); callBack(global.DEFAULT_FAIL_RESPONSE); } } diff --git a/ExtractionBotProcessMainLoop.js b/ExtractionBotProcessMainLoop.js index 235f07587..9802d27c4 100644 --- a/ExtractionBotProcessMainLoop.js +++ b/ExtractionBotProcessMainLoop.js @@ -50,7 +50,11 @@ switch (global.CURRENT_EXECUTION_AT) { // This is what determines if the bot is loaded from the devTeam or an endUser copy. case "Cloud": { - filePath = global.DEV_TEAM + "/" + "bots" + "/" + bot.repo + "/" + pProcessConfig.name; // DevTeams bots only are run at the cloud. + if (global.RUN_AS_TEAM) { + filePath = global.DEV_TEAM + "/" + "bots" + "/" + bot.repo + "/" + pProcessConfig.name; // DevTeams bots only are run at the cloud. + } else { + filePath = global.DEV_TEAM + "/" + "members" + "/" + global.USER_LOGGED_IN + "/" + global.CURRENT_BOT_REPO + "/" + pProcessConfig.name; // DevTeam Members bots only are run at the browser. + } break; } case "Browser": { @@ -154,8 +158,6 @@ return str.length < max ? pad(" " + str, max) : str; } - console.log(new Date().toISOString() + " " + pad(bot.codeName, 20) + " " + pad(bot.process, 30) + " " + pad(pMonth, 2) + "/" + pad(pYear, 4) + " Entered into Main Loop # " + pad(Number(bot.loopCounter) + 1, 8)); - /* For each loop we want to create a new log file. */ logger = DEBUG_MODULE.newDebugLog(); @@ -178,6 +180,10 @@ bot.processDatetime = new Date(); // This will be considered the process date and time, so as to have it consistenly all over the execution. + /* High level log entry */ + + console.log(processDatetime.toISOString() + " " + pad(bot.codeName, 20) + " " + pad(bot.process, 30) + " " + pad(pMonth, 2) + "/" + pad(pYear, 4) + " Entered into Main Loop # " + pad(Number(bot.loopCounter), 8)); + /* We will prepare first the infraestructure needed for the bot to run. There are 3 modules we need to sucessfullly initialize first. */ let userBot; diff --git a/IndicatorBotProcessMainLoop.js b/IndicatorBotProcessMainLoop.js index 9cd328bf9..8248487dd 100644 --- a/IndicatorBotProcessMainLoop.js +++ b/IndicatorBotProcessMainLoop.js @@ -50,7 +50,11 @@ switch (global.CURRENT_EXECUTION_AT) { // This is what determines if the bot is loaded from the devTeam or an endUser copy. case "Cloud": { - filePath = global.DEV_TEAM + "/" + "bots" + "/" + bot.repo + "/" + pProcessConfig.name; // DevTeams bots only are run at the cloud. + if (global.RUN_AS_TEAM) { + filePath = global.DEV_TEAM + "/" + "bots" + "/" + bot.repo + "/" + pProcessConfig.name; // DevTeams bots only are run at the cloud. + } else { + filePath = global.DEV_TEAM + "/" + "members" + "/" + global.USER_LOGGED_IN + "/" + global.CURRENT_BOT_REPO + "/" + pProcessConfig.name; // DevTeam Members bots only are run at the browser. + } break; } case "Browser": { @@ -155,8 +159,6 @@ return str.length < max ? pad(" " + str, max) : str; } - console.log(new Date().toISOString() + " " + pad(bot.codeName, 20) + " " + pad(bot.process, 30) + " " + pad(pMonth, 2) + "/" + pad(pYear, 4) + " Entered into Main Loop # " + pad(Number(bot.loopCounter) + 1, 8 )); - /* For each loop we want to create a new log file. */ logger = DEBUG_MODULE.newDebugLog(); @@ -178,6 +180,10 @@ bot.processDatetime = new Date(); // This will be considered the process date and time, so as to have it consistenly all over the execution. + /* High level log entry */ + + console.log(bot.processDatetime.toISOString() + " " + pad(bot.codeName, 20) + " " + pad(bot.process, 30) + " " + pad(pMonth, 2) + "/" + pad(pYear, 4) + " Entered into Main Loop # " + pad(Number(bot.loopCounter), 8)); + /* We will prepare first the infraestructure needed for the bot to run. There are 3 modules we need to sucessfullly initialize first. */ let userBot; diff --git a/Integrations/OperationsModuleIntegration.js b/Integrations/OperationsModuleIntegration.js new file mode 100644 index 000000000..41c4642c7 --- /dev/null +++ b/Integrations/OperationsModuleIntegration.js @@ -0,0 +1,59 @@ +const axios = require('axios') +const appRoot = require('app-root-path') +const { logger } = require(`${appRoot}/utils/logger`) +const auth = require(`${appRoot}/utils/auth`) + +exports.updateExecutionResults = async function (summaryDate, buyAverage, sellAverage, + marketRate, combinedProfitsA, combinedProfitsB) { + + logger.debug('updateExecutionResults -> Entering Function.') + + try { + + const authResponse = await auth.authenticate() + + const operationsResponse = await axios({ + url: process.env.GATEWAY_ENDPOINT, + method: 'post', + data: { + query: ` + mutation($id: ID!, $summaryDate: Int!, $buyAverage: Float!, $sellAverage: Float!, + $marketRate: Float!, $combinedProfitsA: Float!, $combinedProfitsB: Float!, + $assetA: String!, $assetB: String!){ + operations_UpdateExecutionSummary( + id: $id, + summaryDate: $summaryDate, + buyAverage: $buyAverage, + sellAverage: $sellAverage, + marketRate: $marketRate, + combinedProfitsA: $combinedProfitsA, + combinedProfitsB: $combinedProfitsB, + assetA: $assetA, + assetB: $assetB + ) + } + `, + variables: { + id: process.env.CLONE_ID, + summaryDate: summaryDate, + buyAverage: buyAverage, + sellAverage: sellAverage, + marketRate: marketRate, + combinedProfitsA: combinedProfitsA, + combinedProfitsB: combinedProfitsB, + assetA: global.MARKET.assetA, + assetB: global.MARKET.assetB + }, + }, + headers: { + authorization: 'Bearer ' + authResponse.data.access_token + } + }) + + logger.debug('updateExecutionResults -> Operations Module Response: %s', operationsResponse.data.data.operations_UpdateExecutionSummary) + + } catch (error) { + logger.error('updateExecutionResults -> Error: ' + error.stack) + throw new Error('There has been an error updating the execution report: ' + error) + } +} \ No newline at end of file diff --git a/Project.njsproj b/Project.njsproj index c6a345349..c8f20791c 100644 --- a/Project.njsproj +++ b/Project.njsproj @@ -33,6 +33,12 @@ Code + + Code + + + Code + Code @@ -45,6 +51,9 @@ + + Code + Code @@ -76,13 +85,17 @@ + + + + diff --git a/Root.js b/Root.js index 5fcf14cf8..92ac034fc 100644 --- a/Root.js +++ b/Root.js @@ -1,4 +1,5 @@ - +const appRoot = require('app-root-path') +const operationsIntegration = require(`${appRoot}/Integrations/OperationsModuleIntegration`) exports.newRoot = function newRoot() { @@ -218,14 +219,13 @@ exports.newRoot = function newRoot() { Here we check that the local configuration for the execution exist, if it doesn't exist we will take the one on the server. */ - let executionListItem; if (global.EXECUTION_CONFIG === undefined) { - executionListItem = listItem; + listItem = PLATFORM_CONFIG.executionList[p]; } else { - executionListItem = global.EXECUTION_CONFIG.executionList[p]; + listItem = global.EXECUTION_CONFIG.executionList[p]; } - if (listItem.enabled !== "true" || executionListItem.enabled !== "true") { + if (listItem.enabled !== "true") { console.log(logDisplace + "Root : [INFO] start -> Skipping process for being disabled."); console.log(logDisplace + "Root : [INFO] start -> listItem.process = " + listItem.process); @@ -344,7 +344,7 @@ exports.newRoot = function newRoot() { if (FULL_LOG === true) { console.log(logDisplace + "Root : [INFO] start -> findProcess -> Process found at the bot configuration file. -> listItem.process = " + listItem.process); } let processConfig = botConfig.processes[i]; - + processConfig.startMode = global.EXECUTION_CONFIG.startMode // Override file storage configuration try { /* @@ -888,7 +888,7 @@ exports.newRoot = function newRoot() { tradingBotMainLoop.run(pGenes, pTotalInstances, whenRunFinishes); - function whenRunFinishes(err) { + function whenRunFinishes(err, context) { pBotConfig.loopCounter = 0; @@ -914,6 +914,20 @@ exports.newRoot = function newRoot() { console.log(logDisplace + "Root : [ERROR] start -> findProcess -> runTradingBot -> createBotInstance -> onInitializeReady -> whenStartFinishes -> Bot execution finished with errors. Please check the logs."); logger.persist(); } + + // Update operations module with latest context + if (context !== undefined) { + let lastExecution = context.executionHistory[context.executionHistory.length - 1] + let date = lastExecution[0] / 1000 | 0 + let buyAvgRate = lastExecution[1] + let sellAvgRate = lastExecution[2] + let marketRate = lastExecution[7] + let combinedProfitsA = lastExecution[13] + let combinedProfitsB = lastExecution[14] + + operationsIntegration.updateExecutionResults(date, buyAvgRate, sellAvgRate, + marketRate, combinedProfitsA, combinedProfitsB) + } } } else { diff --git a/Run.js b/Run.js index 18b7b7cca..747440525 100644 --- a/Run.js +++ b/Run.js @@ -1,8 +1,10 @@ require('dotenv').config() -global.CURRENT_ENVIRONMENT = "Develop"; -global.CURRENT_EXECUTION_AT = "Cloud"; + +global.CURRENT_ENVIRONMENT = "Develop"; +global.CURRENT_EXECUTION_AT = "Cloud"; global.SHALL_BOT_STOP = false; global.AT_BREAKPOINT = false; // This is used only when running at the browser. +global.RUN_AS_TEAM = false; /* Default parameters can be changed by the execution configuration */ global.EXCHANGE_NAME = "Poloniex"; @@ -13,6 +15,7 @@ global.MARKET = { process.on('uncaughtException', function (err) { console.log('[INFO] Run -> uncaughtException -> err.message = ' + err.message); + console.log('[INFO] Run -> uncaughtException -> err.stack = ', err.stack); return; }); @@ -40,22 +43,31 @@ function readExecutionConfiguration() { try { console.log("[INFO] Run -> readExecutionConfiguration -> Entering function. "); + global.CURRENT_ENVIRONMENT = process.env.PLATFORM_ENVIRONMENT global.DEV_TEAM = process.env.DEV_TEAM; + global.RUN_AS_TEAM = (process.env.RUN_AS_TEAM === "true"); + global.GATEWAY_ENDPOINT = process.env.GATEWAY_ENDPOINT; + global.STORAGE_URL = process.env.STORAGE_URL; + global.USER_LOGGED_IN = process.env.USER_LOGGED_IN; + global.CURRENT_BOT_REPO = process.env.BOT + "-" + process.env.TYPE + "-Bot"; let executionList = [{ - enabled: "true", - devTeam: process.env.DEV_TEAM, - bot: process.env.BOT, - process: process.env.PROCESS + enabled: "true", + devTeam: process.env.DEV_TEAM, + bot: process.env.BOT, + process: process.env.PROCESS, + repo: global.CURRENT_BOT_REPO }] - // TODO Improve this by changing Root.js let mode = - '{ "run":"false",' + - '"resumeExecution":' + process.env.RESUME_EXECUTION + + '{ "run": "false",' + + '"resumeExecution": "' + process.env.RESUME_EXECUTION + '",' + + '"beginDatetime": "' + process.env.BEGIN_DATE_TIME + '",' + + '"endDatetime": "' + process.env.END_DATE_TIME + '",' + + '"waitTime": "' + process.env.WAIT_TIME + '"' + '}' let startMode = JSON.parse('{ "live": ' + mode +', "backtest": '+mode+', "competition": '+mode+'}') - startMode[process.env.START_MODE].run="true" + startMode[process.env.START_MODE].run = "true" global.EXECUTION_CONFIG = { executionList: executionList, @@ -64,6 +76,7 @@ function readExecutionConfiguration() { readStoragePermissions(); } + catch (err) { console.log("[ERROR] readExecutionConfiguration -> err = " + err.message); console.log("[ERROR] readExecutionConfiguration -> err = " + err.stack); @@ -76,17 +89,14 @@ function readStoragePermissions() { try { console.log( "[INFO] Run -> readStoragePermissions -> Entering function. "); - let fs = require('fs'); - filePath = './' + 'configs' + '/' + 'User.Profile.json'; - global.USER_PROFILE = JSON.parse(fs.readFileSync(filePath, 'utf8')); - /* Dinamically generating the azure storage permissions for the bot to run */ - + global.STORAGE_BASE_URL = process.env.STORAGE_BASE_URL + global.USER_PROFILE = {} const MAX_STORAGE_PERMISSION_DAYS = 10; const STORAGE_ACCESS_MANAGER = require('./StorageAccessManager'); storageAccessManager = STORAGE_ACCESS_MANAGER.newStorageAccessManager(); - storageAccessManager.initialize(global.USER_PROFILE.connectionString, onInitialized); + storageAccessManager.initialize(process.env.STORAGE_CONNECTION_STRING, onInitialized); function onInitialized() { diff --git a/StorageAccessManager.js b/StorageAccessManager.js index ed6794ced..9a36d9d25 100644 --- a/StorageAccessManager.js +++ b/StorageAccessManager.js @@ -56,8 +56,7 @@ let sasToken = blobService.generateSharedAccessSignature(pContainer, blobName, sharedAccessPolicy); - return "BlobEndpoint=https://aadevelop.blob.core.windows.net;SharedAccessSignature=" + sasToken + ""; - //return "BlobEndpoint=https://aaproduction.blob.core.windows.net;SharedAccessSignature=" + sasToken + ""; + return "BlobEndpoint=" + global.STORAGE_BASE_URL + ";SharedAccessSignature=" + sasToken + ""; } } diff --git a/TradingBotProcessMainLoop.js b/TradingBotProcessMainLoop.js index 877150c6b..3c39c5660 100644 --- a/TradingBotProcessMainLoop.js +++ b/TradingBotProcessMainLoop.js @@ -52,7 +52,12 @@ switch (global.CURRENT_EXECUTION_AT) { // This is what determines if the bot is loaded from the devTeam or an endUser copy. case "Cloud": { - filePath = global.DEV_TEAM + "/" + "bots" + "/" + bot.repo + "/" + pProcessConfig.name; // DevTeams bots only are run at the cloud. + if (global.RUN_AS_TEAM) { + filePath = global.DEV_TEAM + "/" + "bots" + "/" + bot.repo + "/" + pProcessConfig.name; // DevTeams bots only are run at the cloud. + } else { + filePath = global.DEV_TEAM + "/" + "members" + "/" + global.USER_LOGGED_IN + "/" + global.CURRENT_BOT_REPO + "/" + pProcessConfig.name; // DevTeam Members bots only are run at the browser. + } + break; } case "Browser": { @@ -134,6 +139,8 @@ function run(pGenes, pTotalAlgobots, callBackFunction) { + let context; + try { if (FULL_LOG === true) { parentLogger.write(MODULE_NAME, "[INFO] run -> Entering function."); } @@ -160,8 +167,6 @@ return str.length < max ? pad(" " + str, max) : str; } - console.log(new Date().toISOString() + " " + pad(bot.codeName, 20) + " " + pad(bot.instance, 20) + " " + pad(bot.process, 30) + " Entered into Main Loop # " + pad(Number(bot.loopCounter) + 1, 8)); - /* For each loop we want to create a new log file. */ logger = DEBUG_MODULE.newDebugLog(); @@ -289,7 +294,7 @@ clearTimeout(nextLoopTimeoutHandle); clearTimeout(checkLoopHealthHandle); bot.enableCheckLoopHealth = false; - callBackFunction(global.DEFAULT_OK_RESPONSE); + callBackFunction(global.DEFAULT_OK_RESPONSE, context); return; } } @@ -341,7 +346,7 @@ clearTimeout(nextLoopTimeoutHandle); clearTimeout(checkLoopHealthHandle); bot.enableCheckLoopHealth = false; - callBackFunction(global.DEFAULT_OK_RESPONSE); + callBackFunction(global.DEFAULT_OK_RESPONSE, context); return; } } @@ -369,9 +374,12 @@ } - /* We will prepare first the infraestructure needed for the bot to run. There are 3 modules we need to sucessfullly initialize first. */ + /* High level log entry */ - let context; + console.log(bot.processDatetime.toISOString() + " " + pad(bot.codeName, 20) + " " + pad(bot.devTeam, 20) + " " + pad(bot.process, 30) + " " + bot.startMode + " Entered into Main Loop # " + pad(Number(bot.loopCounter), 8)); + + /* We will prepare first the infraestructure needed for the bot to run. There are 3 modules we need to sucessfullly initialize first. */ + let exchangeAPI; let assistant; let userBot; @@ -994,7 +1002,7 @@ clearTimeout(nextLoopTimeoutHandle); clearTimeout(checkLoopHealthHandle); bot.enableCheckLoopHealth = false; - callBackFunction(global.DEFAULT_OK_RESPONSE); + callBackFunction(global.DEFAULT_OK_RESPONSE, context); return; } @@ -1184,6 +1192,7 @@ callBackFunction(err); } } + } catch (err) { diff --git a/exchange/ExchangeAPI.js b/exchange/ExchangeAPI.js index 0c1559768..a2d728c97 100644 --- a/exchange/ExchangeAPI.js +++ b/exchange/ExchangeAPI.js @@ -5,12 +5,12 @@ This module allows trading bots to connect to the exchange and do trading operations on it. So far it can only work with Poloniex. */ - const _ = require('lodash'); - const isValidOrder = require('./exchangeUtils').isValidOrder; + const _ = require('lodash') + const isValidOrder = require('./exchangeUtils').isValidOrder const graphqlClient = require('graphql-client') - const request = require('request') - const authOptions = require('./Auth0') - + const appRoot = require('app-root-path') + const auth = require(`${appRoot}/utils/auth`) + let MODULE_NAME = "Exchange API"; let thisObject = { @@ -29,7 +29,7 @@ return thisObject; - function initialize(callBackFunction) { + async function initialize(callBackFunction) { try { if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write(MODULE_NAME, "[INFO] initialize -> Entering function."); } @@ -38,27 +38,16 @@ let botExchange = 'Poloniex'; let exchange = botExchange.toLowerCase() + 'Client.js'; let api = require('./wrappers/' + exchange); - - request(authOptions, onTokenResponse); - function onTokenResponse(error, response, body) { - if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write(MODULE_NAME, "[INFO] onTokenResponse -> Entering function."); } + const authResponse = await auth.authenticate() - if (error) { - logger.write(MODULE_NAME, "[ERROR] onTokenResponse -> err = " + error.message); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); - } else { - if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write(MODULE_NAME, "[INFO] onTokenResponse -> Token Received."); } - let response = JSON.parse(body) - let authToken = response.access_token - let keyVaultAPI = createKeyVaultAPIClient(authToken) - apiClient = api.newAPIClient(keyVaultAPI, logger); + let keyVaultAPI = createKeyVaultAPIClient(authResponse.data.access_token) + apiClient = api.newAPIClient(keyVaultAPI, logger); + + callBackFunction(global.DEFAULT_OK_RESPONSE); - callBackFunction(global.DEFAULT_OK_RESPONSE); - } - } } catch (err) { - logger.write(MODULE_NAME, "[ERROR] initialize -> err = " + err.message); + logger.write(MODULE_NAME, "[ERROR] initialize -> err = " + err.stack); callBackFunction(global.DEFAULT_FAIL_RESPONSE); } } @@ -67,8 +56,7 @@ if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write(MODULE_NAME, "[INFO] createKeyVaultAPIClient -> Entering function."); } const keyVaultAPI = graphqlClient({ - //url: 'https://platform-api.advancedalgos.net/graphql', - url: 'https://platform-dev-api.advancedalgos.net/graphql', + url: global.GATEWAY_ENDPOINT, headers: { Authorization: 'Bearer ' + authToken } diff --git a/package-lock.json b/package-lock.json index ef0cf5a63..d98bbf8d0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20,10 +20,10 @@ "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.2.tgz", "integrity": "sha1-c7Xuyj+rZT49P5Qis0GtQiBdyWU=", "requires": { - "co": "4.6.0", - "fast-deep-equal": "1.1.0", - "fast-json-stable-stringify": "2.0.0", - "json-schema-traverse": "0.3.1" + "co": "^4.6.0", + "fast-deep-equal": "^1.0.0", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.3.0" } }, "apollo-boost": { @@ -31,14 +31,14 @@ "resolved": "https://registry.npmjs.org/apollo-boost/-/apollo-boost-0.1.16.tgz", "integrity": "sha512-ppnQr90n2cn0ZMveEbqxW6NxmskIpThiLziLlRpRLy4keoAICg1NZecxJQmeaBLMtyhf5UholAjpS2SLmEJeHg==", "requires": { - "apollo-cache": "1.1.17", - "apollo-cache-inmemory": "1.2.10", - "apollo-client": "2.4.2", - "apollo-link": "1.2.3", - "apollo-link-error": "1.1.1", - "apollo-link-http": "1.5.5", - "apollo-link-state": "0.4.2", - "graphql-tag": "2.10.0" + "apollo-cache": "^1.1.17", + "apollo-cache-inmemory": "^1.2.10", + "apollo-client": "^2.4.2", + "apollo-link": "^1.0.6", + "apollo-link-error": "^1.0.3", + "apollo-link-http": "^1.3.1", + "apollo-link-state": "^0.4.0", + "graphql-tag": "^2.4.2" } }, "apollo-cache": { @@ -46,7 +46,7 @@ "resolved": "https://registry.npmjs.org/apollo-cache/-/apollo-cache-1.1.17.tgz", "integrity": "sha512-7sp24n2HZO4vXgTaKNomLyIfGxG4gDdDkBB0jkRzRi7HhnKmfwhiF/RCiKNbgLdrPX151INdls0KwIVliD0dHQ==", "requires": { - "apollo-utilities": "1.0.21" + "apollo-utilities": "^1.0.21" } }, "apollo-cache-inmemory": { @@ -54,9 +54,9 @@ "resolved": "https://registry.npmjs.org/apollo-cache-inmemory/-/apollo-cache-inmemory-1.2.10.tgz", "integrity": "sha512-eBusPFVtYIuo+PIfJdAwUCQ4cs7AJ4mB7sTdXxNQCXToYw8mzE6EfHnV37kdVfBXSaa82BzE2rb/YUq/duuamw==", "requires": { - "apollo-cache": "1.1.17", - "apollo-utilities": "1.0.21", - "graphql-anywhere": "4.1.19" + "apollo-cache": "^1.1.17", + "apollo-utilities": "^1.0.21", + "graphql-anywhere": "^4.1.19" } }, "apollo-client": { @@ -65,13 +65,13 @@ "integrity": "sha512-g1z23umaVSoKLj9xNl0aAnk2KBF4JeBi7MeKFc9CGTixH7TkqeQUQtxcjrC7j2h4KmDbuhOAHOFUGf8YshN+ag==", "requires": { "@types/async": "2.0.49", - "@types/zen-observable": "0.8.0", + "@types/zen-observable": "^0.8.0", "apollo-cache": "1.1.17", - "apollo-link": "1.2.3", - "apollo-link-dedup": "1.0.10", + "apollo-link": "^1.0.0", + "apollo-link-dedup": "^1.0.0", "apollo-utilities": "1.0.21", - "symbol-observable": "1.2.0", - "zen-observable": "0.8.9" + "symbol-observable": "^1.0.2", + "zen-observable": "^0.8.0" } }, "apollo-link": { @@ -79,8 +79,8 @@ "resolved": "https://registry.npmjs.org/apollo-link/-/apollo-link-1.2.3.tgz", "integrity": "sha512-iL9yS2OfxYhigme5bpTbmRyC+Htt6tyo2fRMHT3K1XRL/C5IQDDz37OjpPy4ndx7WInSvfSZaaOTKFja9VWqSw==", "requires": { - "apollo-utilities": "1.0.21", - "zen-observable-ts": "0.8.10" + "apollo-utilities": "^1.0.0", + "zen-observable-ts": "^0.8.10" } }, "apollo-link-dedup": { @@ -88,7 +88,7 @@ "resolved": "https://registry.npmjs.org/apollo-link-dedup/-/apollo-link-dedup-1.0.10.tgz", "integrity": "sha512-tpUI9lMZsidxdNygSY1FxflXEkUZnvKRkMUsXXuQUNoSLeNtEvUX7QtKRAl4k9ubLl8JKKc9X3L3onAFeGTK8w==", "requires": { - "apollo-link": "1.2.3" + "apollo-link": "^1.2.3" } }, "apollo-link-error": { @@ -96,7 +96,7 @@ "resolved": "https://registry.npmjs.org/apollo-link-error/-/apollo-link-error-1.1.1.tgz", "integrity": "sha512-/yPcaQWcBdB94vpJ4FsiCJt1dAGGRm+6Tsj3wKwP+72taBH+UsGRQQZk7U/1cpZwl1yqhHZn+ZNhVOebpPcIlA==", "requires": { - "apollo-link": "1.2.3" + "apollo-link": "^1.2.3" } }, "apollo-link-http": { @@ -104,8 +104,8 @@ "resolved": "https://registry.npmjs.org/apollo-link-http/-/apollo-link-http-1.5.5.tgz", "integrity": "sha512-C5N6N/mRwmepvtzO27dgMEU3MMtRKSqcljBkYNZmWwH11BxkUQ5imBLPM3V4QJXNE7NFuAQAB5PeUd4ligivTQ==", "requires": { - "apollo-link": "1.2.3", - "apollo-link-http-common": "0.2.5" + "apollo-link": "^1.2.3", + "apollo-link-http-common": "^0.2.5" } }, "apollo-link-http-common": { @@ -113,7 +113,7 @@ "resolved": "https://registry.npmjs.org/apollo-link-http-common/-/apollo-link-http-common-0.2.5.tgz", "integrity": "sha512-6FV1wr5AqAyJ64Em1dq5hhGgiyxZE383VJQmhIoDVc3MyNcFL92TkhxREOs4rnH2a9X2iJMko7nodHSGLC6d8w==", "requires": { - "apollo-link": "1.2.3" + "apollo-link": "^1.2.3" } }, "apollo-link-state": { @@ -121,8 +121,8 @@ "resolved": "https://registry.npmjs.org/apollo-link-state/-/apollo-link-state-0.4.2.tgz", "integrity": "sha512-xMPcAfuiPVYXaLwC6oJFIZrKgV3GmdO31Ag2eufRoXpvT0AfJZjdaPB4450Nu9TslHRePN9A3quxNueILlQxlw==", "requires": { - "apollo-utilities": "1.0.21", - "graphql-anywhere": "4.1.19" + "apollo-utilities": "^1.0.8", + "graphql-anywhere": "^4.1.0-alpha.0" } }, "apollo-utilities": { @@ -130,16 +130,21 @@ "resolved": "https://registry.npmjs.org/apollo-utilities/-/apollo-utilities-1.0.21.tgz", "integrity": "sha512-ZcxELlEl+sDCYBgEMdNXJAsZtRVm8wk4HIA58bMsqYfd1DSAJQEtZ93F0GZgYNAGy3QyaoBeZtbb0/01++G8JQ==", "requires": { - "fast-json-stable-stringify": "2.0.0", - "fclone": "1.0.11" + "fast-json-stable-stringify": "^2.0.0", + "fclone": "^1.0.11" } }, + "app-root-path": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/app-root-path/-/app-root-path-2.1.0.tgz", + "integrity": "sha1-mL9lmTJ+zqGZMJhm6BQDaP0uZGo=" + }, "asn1": { "version": "0.2.4", "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz", "integrity": "sha512-jxwzQpLQjSmWXgwaCZE9Nz+glAG01yF1QnWgbhGwHI5A6FRIEY6IVqtHhIepHqI7/kyEyQEagBC5mBEFlIYvdg==", "requires": { - "safer-buffer": "2.1.2" + "safer-buffer": "~2.1.0" } }, "assert": { @@ -155,6 +160,14 @@ "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=" }, + "async": { + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/async/-/async-2.6.1.tgz", + "integrity": "sha512-fNEiL2+AZt6AlAw/29Cr0UDe4sRAHCpEHh54WMz+Bb7QfNcFw4h3loofyJpLeQs4Yx7yuqu/2dLgM5hKOs6HlQ==", + "requires": { + "lodash": "^4.17.10" + } + }, "asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", @@ -170,22 +183,31 @@ "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.8.0.tgz", "integrity": "sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ==" }, + "axios": { + "version": "0.18.0", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.18.0.tgz", + "integrity": "sha1-MtU+SFHv3AoRmTts0AB4nXDAUQI=", + "requires": { + "follow-redirects": "^1.3.0", + "is-buffer": "^1.1.5" + } + }, "azure-storage": { "version": "2.10.2", "resolved": "https://registry.npmjs.org/azure-storage/-/azure-storage-2.10.2.tgz", "integrity": "sha512-pOyGPya9+NDpAfm5YcFfklo57HfjDbYLXxs4lomPwvRxmb0Di/A+a+RkUmEFzaQ8S13CqxK40bRRB0sjj2ZQxA==", "requires": { - "browserify-mime": "1.2.9", - "extend": "3.0.2", + "browserify-mime": "~1.2.9", + "extend": "^3.0.2", "json-edm-parser": "0.1.2", "md5.js": "1.3.4", - "readable-stream": "2.0.6", - "request": "2.88.0", - "underscore": "1.8.3", - "uuid": "3.3.2", - "validator": "9.4.1", + "readable-stream": "~2.0.0", + "request": "^2.86.0", + "underscore": "~1.8.3", + "uuid": "^3.0.0", + "validator": "~9.4.1", "xml2js": "0.2.8", - "xmlbuilder": "9.0.7" + "xmlbuilder": "^9.0.7" }, "dependencies": { "underscore": { @@ -201,7 +223,7 @@ "integrity": "sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4=", "optional": true, "requires": { - "tweetnacl": "0.14.5" + "tweetnacl": "^0.14.3" } }, "browserify-mime": { @@ -219,12 +241,62 @@ "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=" }, + "color": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/color/-/color-3.0.0.tgz", + "integrity": "sha512-jCpd5+s0s0t7p3pHQKpnJ0TpQKKdleP71LWcA0aqiljpiuAkOSUFN/dyH8ZwF0hRmFlrIuRhufds1QyEP9EB+w==", + "requires": { + "color-convert": "^1.9.1", + "color-string": "^1.5.2" + } + }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=" + }, + "color-string": { + "version": "1.5.3", + "resolved": "https://registry.npmjs.org/color-string/-/color-string-1.5.3.tgz", + "integrity": "sha512-dC2C5qeWoYkxki5UAXapdjqO672AM4vZuPGRQfO8b5HKuKGBbKWpITyDYN7TOFKvRW7kOgAn3746clDBMDJyQw==", + "requires": { + "color-name": "^1.0.0", + "simple-swizzle": "^0.2.2" + } + }, + "colornames": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/colornames/-/colornames-1.1.1.tgz", + "integrity": "sha1-+IiQMGhcfE/54qVZ9Qd+t2qBb5Y=" + }, + "colors": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/colors/-/colors-1.3.3.tgz", + "integrity": "sha512-mmGt/1pZqYRjMxB1axhTo16/snVZ5krrKkcmMeVKxzECMMXoCgnvTPp10QgHfcbQZw8Dq2jMNG6je4JlWU0gWg==" + }, + "colorspace": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/colorspace/-/colorspace-1.1.1.tgz", + "integrity": "sha512-pI3btWyiuz7Ken0BWh9Elzsmv2bM9AhA7psXib4anUXy/orfZ/E0MbQwhSOG/9L8hLlalqrU0UhOuqxW1YjmVw==", + "requires": { + "color": "3.0.x", + "text-hex": "1.0.x" + } + }, "combined-stream": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.7.tgz", "integrity": "sha512-brWl9y6vOB1xYPZcpZde3N9zDByXTosAeMDo4p1wzo6UMOX4vumB+TP1RZ76sfE6Md68Q0NJSrE/gbezd4Ul+w==", "requires": { - "delayed-stream": "1.0.0" + "delayed-stream": "~1.0.0" } }, "core-util-is": { @@ -237,7 +309,15 @@ "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=", "requires": { - "assert-plus": "1.0.0" + "assert-plus": "^1.0.0" + } + }, + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "requires": { + "ms": "2.0.0" } }, "delayed-stream": { @@ -245,6 +325,16 @@ "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" }, + "diagnostics": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/diagnostics/-/diagnostics-1.1.1.tgz", + "integrity": "sha512-8wn1PmdunLJ9Tqbx+Fx/ZEuHfJf4NKSN2ZBj7SJC/OWRWha843+WsTjqMe1B5E3p28jqBlp+mJ2fPVxPyNgYKQ==", + "requires": { + "colorspace": "1.1.x", + "enabled": "1.0.x", + "kuler": "1.0.x" + } + }, "dotenv": { "version": "6.2.0", "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-6.2.0.tgz", @@ -256,8 +346,16 @@ "integrity": "sha1-OoOpBOVDUyh4dMVkt1SThoSamMk=", "optional": true, "requires": { - "jsbn": "0.1.1", - "safer-buffer": "2.1.2" + "jsbn": "~0.1.0", + "safer-buffer": "^2.1.0" + } + }, + "enabled": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/enabled/-/enabled-1.0.2.tgz", + "integrity": "sha1-ll9lE9LC0cX0ZStkouM5ZGf8L5M=", + "requires": { + "env-variable": "0.0.x" } }, "encoding": { @@ -265,9 +363,14 @@ "resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.12.tgz", "integrity": "sha1-U4tm8+5izRq1HsMjgp0flIDHS+s=", "requires": { - "iconv-lite": "0.4.24" + "iconv-lite": "~0.4.13" } }, + "env-variable": { + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/env-variable/-/env-variable-0.0.5.tgz", + "integrity": "sha512-zoB603vQReOFvTg5xMl9I1P2PnHsHQQKTEowsKKD7nseUfJq6UWzK+4YtlWUO1nhiQUxe6XMkk+JleSZD1NZFA==" + }, "extend": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", @@ -288,11 +391,29 @@ "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz", "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=" }, + "fast-safe-stringify": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.0.6.tgz", + "integrity": "sha512-q8BZ89jjc+mz08rSxROs8VsrBBcn1SIw1kq9NjolL509tkABRk9io01RAjSaEv1Xb2uFLt8VtRiZbGp5H8iDtg==" + }, "fclone": { "version": "1.0.11", "resolved": "https://registry.npmjs.org/fclone/-/fclone-1.0.11.tgz", "integrity": "sha1-EOhdo4v+p/xZk0HClu4ddyZu5kA=" }, + "fecha": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fecha/-/fecha-2.3.3.tgz", + "integrity": "sha512-lUGBnIamTAwk4znq5BcqsDaxSmZ9nDVJaij6NvRt/Tg4R69gERA+otPKbS86ROw9nxVMw2/mp1fnaiWqbs6Sdg==" + }, + "follow-redirects": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.6.1.tgz", + "integrity": "sha512-t2JCjbzxQpWvbhts3l6SH1DKzSrx8a+SsaVf4h6bG4kOXUuPYS/kg2Lr4gQSb7eemaHqJkOThF1BGyjlUkO1GQ==", + "requires": { + "debug": "=3.1.0" + } + }, "forever-agent": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", @@ -303,9 +424,9 @@ "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.2.tgz", "integrity": "sha1-SXBJi+YEwgwAXU9cI67NIda0kJk=", "requires": { - "asynckit": "0.4.0", + "asynckit": "^0.4.0", "combined-stream": "1.0.6", - "mime-types": "2.1.20" + "mime-types": "^2.1.12" }, "dependencies": { "combined-stream": { @@ -313,7 +434,7 @@ "resolved": "http://registry.npmjs.org/combined-stream/-/combined-stream-1.0.6.tgz", "integrity": "sha1-cj599ugBrFYTETp+RFqbactjKBg=", "requires": { - "delayed-stream": "1.0.0" + "delayed-stream": "~1.0.0" } } } @@ -323,7 +444,7 @@ "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=", "requires": { - "assert-plus": "1.0.0" + "assert-plus": "^1.0.0" } }, "graphql": { @@ -331,7 +452,7 @@ "resolved": "https://registry.npmjs.org/graphql/-/graphql-14.0.2.tgz", "integrity": "sha512-gUC4YYsaiSJT1h40krG3J+USGlwhzNTXSb4IOZljn9ag5Tj+RkoXrWp+Kh7WyE3t1NCfab5kzCuxBIvOMERMXw==", "requires": { - "iterall": "1.2.2" + "iterall": "^1.2.2" } }, "graphql-anywhere": { @@ -339,7 +460,7 @@ "resolved": "https://registry.npmjs.org/graphql-anywhere/-/graphql-anywhere-4.1.19.tgz", "integrity": "sha512-mQlvbECzYPBcgBC9JsdM4v+DSvNmcIP+8Vwr+ij3gktbaLSE0Iza30mztuz40Jlf7ooMs+0emBZucNjLzqz7tA==", "requires": { - "apollo-utilities": "1.0.21" + "apollo-utilities": "^1.0.21" } }, "graphql-client": { @@ -347,7 +468,7 @@ "resolved": "https://registry.npmjs.org/graphql-client/-/graphql-client-2.0.1.tgz", "integrity": "sha512-XXdjUD3mwsBDcUB7g+iXQeRt+3gmIbvA/Yx1nE5aq2RQmaJwiH4hEoYw27AW8cDR90pCrPlHJAb1jJq3zUMbZA==", "requires": { - "isomorphic-fetch": "2.2.1" + "isomorphic-fetch": "^2.2.1" } }, "graphql-tag": { @@ -365,8 +486,8 @@ "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.1.0.tgz", "integrity": "sha512-+qnmNjI4OfH2ipQ9VQOw23bBd/ibtfbVdK2fYbY4acTDqKTW/YDp9McimZdDbG8iV9fZizUqQMD5xvriB146TA==", "requires": { - "ajv": "5.5.2", - "har-schema": "2.0.0" + "ajv": "^5.3.0", + "har-schema": "^2.0.0" } }, "hash-base": { @@ -374,8 +495,8 @@ "resolved": "https://registry.npmjs.org/hash-base/-/hash-base-3.0.4.tgz", "integrity": "sha1-X8hoaEfs1zSZQDMZprCj8/auSRg=", "requires": { - "inherits": "2.0.1", - "safe-buffer": "5.1.2" + "inherits": "^2.0.1", + "safe-buffer": "^5.0.1" } }, "http-signature": { @@ -383,9 +504,9 @@ "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", "integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=", "requires": { - "assert-plus": "1.0.0", - "jsprim": "1.4.1", - "sshpk": "1.14.2" + "assert-plus": "^1.0.0", + "jsprim": "^1.2.2", + "sshpk": "^1.7.0" } }, "iconv-lite": { @@ -393,7 +514,7 @@ "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", "requires": { - "safer-buffer": "2.1.2" + "safer-buffer": ">= 2.1.2 < 3" } }, "inherits": { @@ -401,6 +522,16 @@ "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz", "integrity": "sha1-sX0I0ya0Qj5Wjv9xn5GwscvfafE=" }, + "is-arrayish": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.3.2.tgz", + "integrity": "sha512-eVRqCvVlZbuw3GrM63ovNSNAeA1K16kaR/LRY/92w0zxQ5/1YzwblUX652i4Xs9RwAGjW9d9y6X88t8OaAJfWQ==" + }, + "is-buffer": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==" + }, "is-stream": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", @@ -421,8 +552,8 @@ "resolved": "https://registry.npmjs.org/isomorphic-fetch/-/isomorphic-fetch-2.2.1.tgz", "integrity": "sha1-YRrhrPFPXoH3KVB0coGf6XM1WKk=", "requires": { - "node-fetch": "1.7.3", - "whatwg-fetch": "3.0.0" + "node-fetch": "^1.0.1", + "whatwg-fetch": ">=0.10.0" } }, "isstream": { @@ -446,7 +577,7 @@ "resolved": "https://registry.npmjs.org/json-edm-parser/-/json-edm-parser-0.1.2.tgz", "integrity": "sha1-HmCw/vG8CvZ7wNFG393lSGzWFbQ=", "requires": { - "jsonparse": "1.2.0" + "jsonparse": "~1.2.0" } }, "json-schema": { @@ -480,18 +611,45 @@ "verror": "1.10.0" } }, + "kuler": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/kuler/-/kuler-1.0.1.tgz", + "integrity": "sha512-J9nVUucG1p/skKul6DU3PUZrhs0LPulNaeUOox0IyXDi8S4CztTHs1gQphhuZmzXG7VOQSf6NJfKuzteQLv9gQ==", + "requires": { + "colornames": "^1.1.1" + } + }, "lodash": { "version": "4.17.11", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==" }, + "logform": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/logform/-/logform-1.10.0.tgz", + "integrity": "sha512-em5ojIhU18fIMOw/333mD+ZLE2fis0EzXl1ZwHx4iQzmpQi6odNiY/t+ITNr33JZhT9/KEaH+UPIipr6a9EjWg==", + "requires": { + "colors": "^1.2.1", + "fast-safe-stringify": "^2.0.4", + "fecha": "^2.3.3", + "ms": "^2.1.1", + "triple-beam": "^1.2.0" + }, + "dependencies": { + "ms": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", + "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==" + } + } + }, "md5.js": { "version": "1.3.4", "resolved": "http://registry.npmjs.org/md5.js/-/md5.js-1.3.4.tgz", "integrity": "sha1-6b296UogpawYsENA/Fdk1bCdkB0=", "requires": { - "hash-base": "3.0.4", - "inherits": "2.0.1" + "hash-base": "^3.0.0", + "inherits": "^2.0.1" } }, "mime-db": { @@ -504,16 +662,21 @@ "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.20.tgz", "integrity": "sha512-HrkrPaP9vGuWbLK1B1FfgAkbqNjIuy4eHlIYnFi7kamZyLLrGlo2mpcx0bBmNpKqBtYtAfGbodDddIgddSJC2A==", "requires": { - "mime-db": "1.36.0" + "mime-db": "~1.36.0" } }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + }, "node-fetch": { "version": "1.7.3", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-1.7.3.tgz", "integrity": "sha512-NhZ4CsKx7cYm2vSrBAr2PvFOe6sWDf0UYLRqA6svUYg7+/TSfVAu49jYC4BvQ4Sms9SZgdqGBgroqfDhJdTyKQ==", "requires": { - "encoding": "0.1.12", - "is-stream": "1.1.0" + "encoding": "^0.1.11", + "is-stream": "^1.0.1" } }, "nodemailer": { @@ -531,6 +694,11 @@ "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==" }, + "one-time": { + "version": "0.0.4", + "resolved": "https://registry.npmjs.org/one-time/-/one-time-0.0.4.tgz", + "integrity": "sha1-+M33eISCb+Tf+T46nMN7HkSAdC4=" + }, "performance-now": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", @@ -566,12 +734,12 @@ "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.0.6.tgz", "integrity": "sha1-j5A0HmilPMySh4jaz80Rs265t44=", "requires": { - "core-util-is": "1.0.2", - "inherits": "2.0.1", - "isarray": "1.0.0", - "process-nextick-args": "1.0.7", - "string_decoder": "0.10.31", - "util-deprecate": "1.0.2" + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", + "isarray": "~1.0.0", + "process-nextick-args": "~1.0.6", + "string_decoder": "~0.10.x", + "util-deprecate": "~1.0.1" } }, "request": { @@ -579,26 +747,26 @@ "resolved": "https://registry.npmjs.org/request/-/request-2.88.0.tgz", "integrity": "sha512-NAqBSrijGLZdM0WZNsInLJpkJokL72XYjUpnB0iwsRgxh7dB6COrHnTBNwN0E+lHDAJzu7kLAkDeY08z2/A0hg==", "requires": { - "aws-sign2": "0.7.0", - "aws4": "1.8.0", - "caseless": "0.12.0", - "combined-stream": "1.0.7", - "extend": "3.0.2", - "forever-agent": "0.6.1", - "form-data": "2.3.2", - "har-validator": "5.1.0", - "http-signature": "1.2.0", - "is-typedarray": "1.0.0", - "isstream": "0.1.2", - "json-stringify-safe": "5.0.1", - "mime-types": "2.1.20", - "oauth-sign": "0.9.0", - "performance-now": "2.1.0", - "qs": "6.5.2", - "safe-buffer": "5.1.2", - "tough-cookie": "2.4.3", - "tunnel-agent": "0.6.0", - "uuid": "3.3.2" + "aws-sign2": "~0.7.0", + "aws4": "^1.8.0", + "caseless": "~0.12.0", + "combined-stream": "~1.0.6", + "extend": "~3.0.2", + "forever-agent": "~0.6.1", + "form-data": "~2.3.2", + "har-validator": "~5.1.0", + "http-signature": "~1.2.0", + "is-typedarray": "~1.0.0", + "isstream": "~0.1.2", + "json-stringify-safe": "~5.0.1", + "mime-types": "~2.1.19", + "oauth-sign": "~0.9.0", + "performance-now": "^2.1.0", + "qs": "~6.5.2", + "safe-buffer": "^5.1.2", + "tough-cookie": "~2.4.3", + "tunnel-agent": "^0.6.0", + "uuid": "^3.3.2" } }, "retry": { @@ -621,22 +789,35 @@ "resolved": "http://registry.npmjs.org/sax/-/sax-0.5.8.tgz", "integrity": "sha1-1HLbIo6zMcJQaw6MFVJK25OdEsE=" }, + "simple-swizzle": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/simple-swizzle/-/simple-swizzle-0.2.2.tgz", + "integrity": "sha1-pNprY1/8zMoz9w0Xy5JZLeleVXo=", + "requires": { + "is-arrayish": "^0.3.1" + } + }, "sshpk": { "version": "1.14.2", "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.14.2.tgz", "integrity": "sha1-xvxhZIo9nE52T9P8306hBeSSupg=", "requires": { - "asn1": "0.2.4", - "assert-plus": "1.0.0", - "bcrypt-pbkdf": "1.0.2", - "dashdash": "1.14.1", - "ecc-jsbn": "0.1.2", - "getpass": "0.1.7", - "jsbn": "0.1.1", - "safer-buffer": "2.1.2", - "tweetnacl": "0.14.5" + "asn1": "~0.2.3", + "assert-plus": "^1.0.0", + "bcrypt-pbkdf": "^1.0.0", + "dashdash": "^1.12.0", + "ecc-jsbn": "~0.1.1", + "getpass": "^0.1.1", + "jsbn": "~0.1.0", + "safer-buffer": "^2.0.2", + "tweetnacl": "~0.14.0" } }, + "stack-trace": { + "version": "0.0.10", + "resolved": "https://registry.npmjs.org/stack-trace/-/stack-trace-0.0.10.tgz", + "integrity": "sha1-VHxws0fo0ytOEI6hoqFZ5f3eGcA=" + }, "string_decoder": { "version": "0.10.31", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", @@ -647,21 +828,31 @@ "resolved": "https://registry.npmjs.org/symbol-observable/-/symbol-observable-1.2.0.tgz", "integrity": "sha512-e900nM8RRtGhlV36KGEU9k65K3mPb1WV70OdjfxlG2EAuM1noi/E/BaW/uMhL7bPEssK8QV57vN3esixjUvcXQ==" }, + "text-hex": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/text-hex/-/text-hex-1.0.0.tgz", + "integrity": "sha512-uuVGNWzgJ4yhRaNSiubPY7OjISw4sw4E5Uv0wbjp+OzcbmVU/rsT8ujgcXJhn9ypzsgr5vlzpPqP+MBBKcGvbg==" + }, "tough-cookie": { "version": "2.4.3", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.4.3.tgz", "integrity": "sha512-Q5srk/4vDM54WJsJio3XNn6K2sCG+CQ8G5Wz6bZhRZoAe/+TxjWB/GlFAnYEbkYVlON9FMk/fE3h2RLpPXo4lQ==", "requires": { - "psl": "1.1.29", - "punycode": "1.4.1" + "psl": "^1.1.24", + "punycode": "^1.4.1" } }, + "triple-beam": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/triple-beam/-/triple-beam-1.3.0.tgz", + "integrity": "sha512-XrHUvV5HpdLmIj4uVMxHggLbFSZYIn7HEWsqePZcI50pco+MPqJ50wMGY794X7AOOhxOBAjbkqfAbEe/QMp2Lw==" + }, "tunnel-agent": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", "requires": { - "safe-buffer": "5.1.2" + "safe-buffer": "^5.0.1" } }, "tweetnacl": { @@ -703,9 +894,9 @@ "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", "integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=", "requires": { - "assert-plus": "1.0.0", + "assert-plus": "^1.0.0", "core-util-is": "1.0.2", - "extsprintf": "1.3.0" + "extsprintf": "^1.2.0" } }, "whatwg-fetch": { @@ -713,12 +904,105 @@ "resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-3.0.0.tgz", "integrity": "sha512-9GSJUgz1D4MfyKU7KRqwOjXCXTqWdFNvEr7eUBYchQiVc744mqK/MzXPNR2WsPkmkOa4ywfg8C2n8h+13Bey1Q==" }, + "winston": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/winston/-/winston-3.1.0.tgz", + "integrity": "sha512-FsQfEE+8YIEeuZEYhHDk5cILo1HOcWkGwvoidLrDgPog0r4bser1lEIOco2dN9zpDJ1M88hfDgZvxe5z4xNcwg==", + "requires": { + "async": "^2.6.0", + "diagnostics": "^1.1.1", + "is-stream": "^1.1.0", + "logform": "^1.9.1", + "one-time": "0.0.4", + "readable-stream": "^2.3.6", + "stack-trace": "0.0.x", + "triple-beam": "^1.3.0", + "winston-transport": "^4.2.0" + }, + "dependencies": { + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" + }, + "process-nextick-args": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", + "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==" + }, + "readable-stream": { + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "requires": { + "safe-buffer": "~5.1.0" + } + } + } + }, + "winston-transport": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/winston-transport/-/winston-transport-4.3.0.tgz", + "integrity": "sha512-B2wPuwUi3vhzn/51Uukcao4dIduEiPOcOt9HJ3QeaXgkJ5Z7UwpBzxS4ZGNHtrxrUvTwemsQiSys0ihOf8Mp1A==", + "requires": { + "readable-stream": "^2.3.6", + "triple-beam": "^1.2.0" + }, + "dependencies": { + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" + }, + "process-nextick-args": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", + "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==" + }, + "readable-stream": { + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "requires": { + "safe-buffer": "~5.1.0" + } + } + } + }, "xml2js": { "version": "0.2.8", "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.2.8.tgz", "integrity": "sha1-m4FpCTFjH/CdGVdUn69U9PmAs8I=", "requires": { - "sax": "0.5.8" + "sax": "0.5.x" } }, "xmlbuilder": { @@ -736,7 +1020,7 @@ "resolved": "https://registry.npmjs.org/zen-observable-ts/-/zen-observable-ts-0.8.10.tgz", "integrity": "sha512-5vqMtRggU/2GhePC9OU4sYEWOdvmayp2k3gjPf4F0mXwB3CSbbNznfDUvDJx9O2ZTa1EIXdJhPchQveFKwNXPQ==", "requires": { - "zen-observable": "0.8.9" + "zen-observable": "^0.8.0" } } } diff --git a/package.json b/package.json index a91b814fd..8b4027f28 100644 --- a/package.json +++ b/package.json @@ -10,17 +10,19 @@ "license": "ISC", "dependencies": { "apollo-boost": "^0.1.16", + "app-root-path": "^2.1.0", "assert": "^1.4.1", + "axios": "^0.18.0", + "azure-storage": "^2.8.2", + "dotenv": "^6.0.0", "graphql": "^14.0.2", "graphql-client": "^2.0.1", "lodash": "^4.17.11", "nodemailer": "^4.6.8", "nonce": "^1.0.4", "querystring": "^0.2.0", - "request": "^2.88.0", "retry": "^0.12.0", "underscore": "^1.9.1", - "azure-storage": "^2.8.2", - "dotenv": "^6.0.0" + "winston": "^3.1.0" } } diff --git a/utils/auth.js b/utils/auth.js new file mode 100644 index 000000000..114a25e9e --- /dev/null +++ b/utils/auth.js @@ -0,0 +1,25 @@ +const axios = require('axios') +const appRoot = require('app-root-path') +const { logger } = require(`${appRoot}/utils/logger`) + +exports.authenticate = function () { + try { + logger.debug('authenticate -> Entering Function.') + + const authBody = '{"client_id":"' + process.env.AUTH_CLIENT_ID + + '","client_secret": "' + process.env.AUTH_CLIENT_SECRET + + '","audience":"' + process.env.AUTH_AUDIENCE + + '","grant_type":"client_credentials"}' + + return axios({ + url: process.env.AUTH_URL, + method: 'post', + data: authBody, + headers: { 'content-type': 'application/json' } + }) + + } catch (error) { + logger.error('authenticate -> Error: ' + error.stack) + throw new Error('There has been an error on the authentication: ' + error) + } +} \ No newline at end of file diff --git a/utils/logger.js b/utils/logger.js new file mode 100644 index 000000000..1cc942d0c --- /dev/null +++ b/utils/logger.js @@ -0,0 +1,40 @@ +const winston = require('winston') +const appRoot = require('app-root-path') +const util = require('util') + +const options = { + file: { + level: 'info', + filename: `${appRoot}/logs/app.log`, + handleExceptions: true, + json: true, + maxsize: 5242880, // 5MB + maxFiles: 5, + colorize: false, + timestamp: true + }, + console: { + level: 'debug', + handleExceptions: true, + json: false, + colorize: true, + timestamp: true + } +} + +exports.logger = winston.createLogger({ + level: 'info', + format: winston.format.combine( + winston.format.colorize(), + winston.format.splat(), + winston.format.timestamp({ format: 'YY/MM/DD HH:mm' }), + winston.format.printf( + info => `${info.timestamp} - ${info.level}: ${JSON.parse(JSON.stringify(util.inspect(info.message)))}` + ) + ), + transports: [ + new winston.transports.File(options.file), + new winston.transports.Console(options.console) + ], + exitOnError: false // do not exit on handled exceptions +}) \ No newline at end of file