Network Node Running Again

This commit is contained in:
Luis Fernando Molina committed 2021-11-24 19:41:10 +01:00
1 parent 8557b7b02e
commit 541a269f80
28 files changed
+220 -130

No files matched your search

@@ -150,7 +150,7 @@ exports.newAlgorithmicTradingBotModulesSnapshots = function(processIndex) {
}
/* Now we go down through all this node children */
let schemaDocument = TS.projects.foundations.globals.taskConstants.APP_SCHEMA_MAP.get(node.project + '-' + node.type)
let schemaDocument = SA.projects.foundations.globals.schemas.APP_SCHEMA_MAP.get(node.project + '-' + node.type)
if (schemaDocument === undefined) { return }
if (schemaDocument.childrenNodesProperties !== undefined) {
@@ -112,7 +112,7 @@ exports.newAlgorithmicTradingBotModulesTradingEngine = function (processIndex) {
destinationNode.value = originNode.value
/* Now we go down through all the children of the origin node, assuming the destination node has the same children structure*/
let schemaDocument = TS.projects.foundations.globals.taskConstants.APP_SCHEMA_MAP.get(originNode.project + '-' + originNode.type)
let schemaDocument = SA.projects.foundations.globals.schemas.APP_SCHEMA_MAP.get(originNode.project + '-' + originNode.type)
if (schemaDocument === undefined) { return }
if (schemaDocument.childrenNodesProperties !== undefined) {
@@ -151,7 +151,7 @@ exports.newAlgorithmicTradingBotModulesTradingEngine = function (processIndex) {
nodesMap.set(node.id, node)
/* Now we go down through all this node children */
let schemaDocument = TS.projects.foundations.globals.taskConstants.APP_SCHEMA_MAP.get(node.project + '-' + node.type)
let schemaDocument = SA.projects.foundations.globals.schemas.APP_SCHEMA_MAP.get(node.project + '-' + node.type)
if (schemaDocument === undefined) { return }
if (schemaDocument.childrenNodesProperties !== undefined) {
@@ -194,7 +194,7 @@ exports.newAlgorithmicTradingBotModulesTradingEngine = function (processIndex) {
}
/* Now we go down through all this node children */
let schemaDocument = TS.projects.foundations.globals.taskConstants.APP_SCHEMA_MAP.get(node.project + '-' + node.type)
let schemaDocument = SA.projects.foundations.globals.schemas.APP_SCHEMA_MAP.get(node.project + '-' + node.type)
if (schemaDocument === undefined) { return }
if (schemaDocument.childrenNodesProperties !== undefined) {
@@ -31,7 +31,7 @@ exports.newAlgorithmicTradingBotModulesTradingOutput = function (processIndex) {
/* Preparing everything for the Simulation */
let tradingSimulationModuleObject = TS.projects.algorithmicTrading.botModules.tradingSimulation.newAlgorithmicTradingBotModulesTradingSimulation(processIndex)
let outputDatasets = TS.projects.visualScripting.utilities.nodeFunctions.nodeBranchToArray(TS.projects.foundations.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.processOutput, 'Output Dataset')
let outputDatasets = SA.projects.visualScripting.utilities.nodeFunctions.nodeBranchToArray(TS.projects.foundations.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.processOutput, 'Output Dataset')
let outputDatasetsMap = new Map()
await TS.projects.foundations.functionLibraries.outputManagementFunctions.readFiles(
@@ -37,7 +37,7 @@ exports.newAlgorithmicTradingBotModulesTradingRecords = function (processIndex)
we have a pointer to the node that have the information we need to extract.
Later, based on the product record definition we will extract each individual value.
*/
let outputDatasets = TS.projects.visualScripting.utilities.nodeFunctions.nodeBranchToArray(TS.projects.foundations.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.processOutput, 'Output Dataset')
let outputDatasets = SA.projects.visualScripting.utilities.nodeFunctions.nodeBranchToArray(TS.projects.foundations.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.processOutput, 'Output Dataset')
for (let i = 0; i < outputDatasets.length; i++) {
let outputDatasetNode = outputDatasets[i]
@@ -372,8 +372,8 @@ exports.newAlgorithmicTradingBotModulesTradingSimulation = function (processInde
}
function positionChart(chart) {
let dataDependencies = TS.projects.visualScripting.utilities.nodeFunctions.nodeBranchToArray(TS.projects.foundations.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.processDependencies, 'Data Dependency')
dataDependencies = TS.projects.visualScripting.utilities.nodeFunctions.filterOutNodeWihtoutReferenceParentFromNodeArray(dataDependencies)
let dataDependencies = SA.projects.visualScripting.utilities.nodeFunctions.nodeBranchToArray(TS.projects.foundations.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.processDependencies, 'Data Dependency')
dataDependencies = SA.projects.visualScripting.utilities.nodeFunctions.filterOutNodeWihtoutReferenceParentFromNodeArray(dataDependencies)
/* Finding the Current Element on Daily Files */
if (TS.projects.foundations.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).TRADING_PROCESSING_DAILY_FILES) {
@@ -272,7 +272,7 @@ exports.newAlgorithmicTradingBotModulesTradingSystem = function (processIndex) {
}
/* Now we go down through all this node children */
let schemaDocument = TS.projects.foundations.globals.taskConstants.APP_SCHEMA_MAP.get(node.project + '-' + node.type)
let schemaDocument = SA.projects.foundations.globals.schemas.APP_SCHEMA_MAP.get(node.project + '-' + node.type)
if (schemaDocument === undefined) { return }
if (schemaDocument.childrenNodesProperties !== undefined) {
@@ -201,7 +201,7 @@ exports.newDataMiningBotModulesFetchingProcess = function (processIndex) {
if (recordProperty.apiResponseFieldReference !== undefined) {
if (recordProperty.apiResponseFieldReference.referenceParent !== undefined) {
let apiResponseField = recordProperty.apiResponseFieldReference.referenceParent
let endpointNodeFound = TS.projects.visualScripting.utilities.nodeFunctions.findNodeInNodeMesh(apiResponseField, 'API Endpoint')
let endpointNodeFound = SA.projects.visualScripting.utilities.nodeFunctions.findNodeInNodeMesh(apiResponseField, 'API Endpoint')
/*
Every Record Property with an apiResponseFieldReference must be on the path
to a certain endpoint.
@@ -52,13 +52,13 @@
}
/* The first phase here is about checking that we have everything we need at the definition level. */
let dataDependencies = TS.projects.visualScripting.utilities.nodeFunctions.nodeBranchToArray(
let dataDependencies = SA.projects.visualScripting.utilities.nodeFunctions.nodeBranchToArray(
TS.projects.foundations.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.processDependencies, 'Data Dependency'
)
if (TS.projects.foundations.functionLibraries.singleMarketFunctions.validateDataDependencies(processIndex, dataDependencies, callBackFunction) !== true) { return }
let outputDatasets = TS.projects.visualScripting.utilities.nodeFunctions.nodeBranchToArray(
let outputDatasets = SA.projects.visualScripting.utilities.nodeFunctions.nodeBranchToArray(
TS.projects.foundations.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.processOutput, 'Output Dataset'
)
if (TS.projects.foundations.functionLibraries.singleMarketFunctions.validateOutputDatasets(processIndex, outputDatasets, callBackFunction) !== true) { return }
@@ -138,9 +138,9 @@
contextSummary.dataset = outputDatasetNode.referenceParent.config.codeName
contextSummary.product = outputDatasetNode.referenceParent.parentNode.config.codeName
let botNode = TS.projects.visualScripting.utilities.nodeFunctions.findNodeInNodeMesh(outputDatasetNode, 'Indicator Bot')
let botNode = SA.projects.visualScripting.utilities.nodeFunctions.findNodeInNodeMesh(outputDatasetNode, 'Indicator Bot')
contextSummary.bot = botNode.config.codeName
let dataMineNode = TS.projects.visualScripting.utilities.nodeFunctions.findNodeInNodeMesh(outputDatasetNode, 'Data Mine')
let dataMineNode = SA.projects.visualScripting.utilities.nodeFunctions.findNodeInNodeMesh(outputDatasetNode, 'Data Mine')
contextSummary.dataMine = dataMineNode.config.codeName
contextSummary.mineType = dataMineNode.type.replace(' ', '-')
contextSummary.project = dataMineNode.project
@@ -513,7 +513,7 @@
}
function writeDataRanges(callBack) {
let outputDatasets = TS.projects.visualScripting.utilities.nodeFunctions.nodeBranchToArray(
let outputDatasets = SA.projects.visualScripting.utilities.nodeFunctions.nodeBranchToArray(
TS.projects.foundations.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.processOutput, 'Output Dataset')
let outputDatasetIndex = -1;
controlLoop()
@@ -151,7 +151,7 @@
function writeTimeFramesFiles(callBack) {
let outputDatasets =
TS.projects.visualScripting.utilities.nodeFunctions.nodeBranchToArray(TS.projects.foundations.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.processOutput, 'Output Dataset')
SA.projects.visualScripting.utilities.nodeFunctions.nodeBranchToArray(TS.projects.foundations.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.processOutput, 'Output Dataset')
let outputDatasetIndex = -1;
controlLoop()
@@ -0,0 +1,8 @@
exports.newFoundationsGlobalsSchemas = function () {
let thisObject = {
APP_SCHEMA_MAP: new Map()
}
return thisObject
}
@@ -375,14 +375,14 @@ exports.newFoundationsFunctionLibrariesDataDependenciesFunctions = function () {
THe first thing we do is to build an array of all the
declared dependencies of the Bot Process.
*/
let dataDependencies = TS.projects.visualScripting.utilities.nodeFunctions.nodeBranchToArray(TS.projects.foundations.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.processDependencies, 'Data Dependency')
let dataDependencies = SA.projects.visualScripting.utilities.nodeFunctions.nodeBranchToArray(TS.projects.foundations.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.processDependencies, 'Data Dependency')
/*
Then we will filter out declared dependencies that are
not referencing nodes currently present at the workspace.
This will allow the user to have less Data Mines loaded at
the workspace that the ones that a the Bot process depends on.
*/
dataDependencies = TS.projects.visualScripting.utilities.nodeFunctions.filterOutNodeWihtoutReferenceParentFromNodeArray(dataDependencies)
dataDependencies = SA.projects.visualScripting.utilities.nodeFunctions.filterOutNodeWihtoutReferenceParentFromNodeArray(dataDependencies)
/*
We will run some validations to prevent starting the process
if all needed config and nodes are not present.
@@ -394,7 +394,7 @@ exports.newFoundationsFunctionLibrariesDataDependenciesFunctions = function () {
we do it just to be able to validate that all nodes and config
are ok before letting this process run too far.
*/
let outputDatasets = TS.projects.visualScripting.utilities.nodeFunctions.nodeBranchToArray(TS.projects.foundations.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.processOutput, 'Output Dataset')
let outputDatasets = SA.projects.visualScripting.utilities.nodeFunctions.nodeBranchToArray(TS.projects.foundations.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.processOutput, 'Output Dataset')
/*
Here we check that all output datasets configs are ok.
*/
@@ -48,7 +48,7 @@ exports.newFoundationsFunctionLibrariesFromOneMinToMultiTimeFrameFunctions = fun
node.dataDependency = dataDependenciesModule.curatedDependencyNodeArray[0]
}
let outputDatasets = TS.projects.visualScripting.utilities.nodeFunctions.nodeBranchToArray(
let outputDatasets = SA.projects.visualScripting.utilities.nodeFunctions.nodeBranchToArray(
TS.projects.foundations.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.processOutput, 'Output Dataset'
)
@@ -123,7 +123,7 @@ exports.newFoundationsFunctionLibrariesProcessFilesFunctions = function () {
async function writeProcessFiles(processIndex, contextVariables, currentTimeFrame, processDate, statusDependencies) {
let fileStorage = TS.projects.foundations.taskModules.fileStorage.newFileStorage(processIndex)
let outputDatasets = TS.projects.visualScripting.utilities.nodeFunctions.nodeBranchToArray(TS.projects.foundations.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.processOutput, 'Output Dataset')
let outputDatasets = SA.projects.visualScripting.utilities.nodeFunctions.nodeBranchToArray(TS.projects.foundations.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.processOutput, 'Output Dataset')
await writeTimeFramesFiles()
await writeDataRanges()
@@ -91,12 +91,12 @@
return
}
let botNode = TS.projects.visualScripting.utilities.nodeFunctions.findNodeInNodeMesh(outputDatasetNode, 'Indicator Bot')
let botNode = SA.projects.visualScripting.utilities.nodeFunctions.findNodeInNodeMesh(outputDatasetNode, 'Indicator Bot')
if (botNode === undefined) {
botNode = TS.projects.visualScripting.utilities.nodeFunctions.findNodeInNodeMesh(outputDatasetNode, 'Trading Bot')
botNode = SA.projects.visualScripting.utilities.nodeFunctions.findNodeInNodeMesh(outputDatasetNode, 'Trading Bot')
}
if (botNode === undefined) {
botNode = TS.projects.visualScripting.utilities.nodeFunctions.findNodeInNodeMesh(outputDatasetNode, 'Learning Bot')
botNode = SA.projects.visualScripting.utilities.nodeFunctions.findNodeInNodeMesh(outputDatasetNode, 'Learning Bot')
}
if (botNode === undefined) {
TS.projects.foundations.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, "[ERROR] start -> Product Definition not attached to a Bot. ");
@@ -110,11 +110,11 @@
return
}
let dataMineNode = TS.projects.visualScripting.utilities.nodeFunctions.findNodeInNodeMesh(outputDatasetNode, 'Data Mine')
let dataMineNode = SA.projects.visualScripting.utilities.nodeFunctions.findNodeInNodeMesh(outputDatasetNode, 'Data Mine')
if (dataMineNode === undefined) {
let tradingMineNode = TS.projects.visualScripting.utilities.nodeFunctions.findNodeInNodeMesh(outputDatasetNode, 'Trading Mine')
let tradingMineNode = SA.projects.visualScripting.utilities.nodeFunctions.findNodeInNodeMesh(outputDatasetNode, 'Trading Mine')
if (tradingMineNode === undefined) {
let learningMineNode = TS.projects.visualScripting.utilities.nodeFunctions.findNodeInNodeMesh(outputDatasetNode, 'Learning Mine')
let learningMineNode = SA.projects.visualScripting.utilities.nodeFunctions.findNodeInNodeMesh(outputDatasetNode, 'Learning Mine')
if (learningMineNode === undefined) {
TS.projects.foundations.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, "[ERROR] start -> Bot not attached to a Data Mine, Trading Mine or Learning Mine.");
callBackFunction(TS.projects.foundations.globals.standardResponses.DEFAULT_FAIL_RESPONSE);
@@ -8,7 +8,6 @@ exports.newFoundationsGlobalsTaskConstants = function () {
NETWORK_NODE: undefined,
PROJECT_DEFINITION_NODE: undefined,
PROJECTS_SCHEMA: undefined,
APP_SCHEMA_MAP: new Map(),
EVENT_SERVER_CLIENT_MODULE_OBJECT: undefined, // This is an instance of the Event Server Client pointing to the localhost server
TASK_HEARTBEAT_INTERVAL_HANDLER: undefined
}
@@ -50,7 +50,7 @@
/*
First we will get all the data dependencies of the bot, as defined at the Trading Mine.
*/
thisObject.curatedDependencyNodeArray = TS.projects.visualScripting.utilities.nodeFunctions.nodeBranchToArray(TS.projects.foundations.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.processDependencies, 'Data Dependency')
thisObject.curatedDependencyNodeArray = SA.projects.visualScripting.utilities.nodeFunctions.nodeBranchToArray(TS.projects.foundations.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.processDependencies, 'Data Dependency')
if (thisObject.curatedDependencyNodeArray.length === 0) {
TS.projects.foundations.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, "[ERROR] initialize -> onInitilized -> It is not possible to not have data dependencies at all.")
callBackFunction(TS.projects.foundations.globals.standardResponses.DEFAULT_FAIL_RESPONSE)
@@ -61,7 +61,7 @@
This will allow the user to have less Data Mines loaded at the workspace
that the ones that a Trading Mine depends on.
*/
thisObject.curatedDependencyNodeArray = TS.projects.visualScripting.utilities.nodeFunctions.filterOutNodeWihtoutReferenceParentFromNodeArray(thisObject.curatedDependencyNodeArray)
thisObject.curatedDependencyNodeArray = SA.projects.visualScripting.utilities.nodeFunctions.filterOutNodeWihtoutReferenceParentFromNodeArray(thisObject.curatedDependencyNodeArray)
} else {
TS.projects.foundations.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, "[ERROR] initialize -> onInitilized -> It is not possible not to have process dependencies, which means not data dependencies.")
@@ -222,7 +222,7 @@ exports.newFoundationsProcessModulesDataset = function (processIndex) {
function scanNodeMesh(startingNode) {
if (startingNode === undefined) { return }
let schemaDocument = TS.projects.foundations.globals.taskConstants.APP_SCHEMA_MAP.get(startingNode.project + '-' + startingNode.type)
let schemaDocument = SA.projects.foundations.globals.schemas.APP_SCHEMA_MAP.get(startingNode.project + '-' + startingNode.type)
if (schemaDocument === undefined) { return }
if (startingNode.id === productDefinition.id) {
@@ -18,23 +18,23 @@
/* We will raise the events for the datasets impacted by the process that just finished. */
if (TS.projects.foundations.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.processOutput !== undefined) {
let outputDatasets = TS.projects.visualScripting.utilities.nodeFunctions.nodeBranchToArray(TS.projects.foundations.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.processOutput, 'Output Dataset')
let outputDatasets = SA.projects.visualScripting.utilities.nodeFunctions.nodeBranchToArray(TS.projects.foundations.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.processOutput, 'Output Dataset')
for (let j = 0; j < outputDatasets.length; j++) {
let outputDataset = outputDatasets[j]
let botNode = TS.projects.visualScripting.utilities.nodeFunctions.findNodeInNodeMesh(outputDataset, 'Indicator Bot')
let botNode = SA.projects.visualScripting.utilities.nodeFunctions.findNodeInNodeMesh(outputDataset, 'Indicator Bot')
if (botNode === undefined) {
botNode = TS.projects.visualScripting.utilities.nodeFunctions.findNodeInNodeMesh(outputDataset, 'Trading Bot')
botNode = SA.projects.visualScripting.utilities.nodeFunctions.findNodeInNodeMesh(outputDataset, 'Trading Bot')
}
if (botNode === undefined) {
botNode = TS.projects.visualScripting.utilities.nodeFunctions.findNodeInNodeMesh(outputDataset, 'Sensor Bot')
botNode = SA.projects.visualScripting.utilities.nodeFunctions.findNodeInNodeMesh(outputDataset, 'Sensor Bot')
}
if (botNode === undefined) {
botNode = TS.projects.visualScripting.utilities.nodeFunctions.findNodeInNodeMesh(outputDataset, 'API Data Fetcher Bot')
botNode = SA.projects.visualScripting.utilities.nodeFunctions.findNodeInNodeMesh(outputDataset, 'API Data Fetcher Bot')
}
if (botNode === undefined) {
botNode = TS.projects.visualScripting.utilities.nodeFunctions.findNodeInNodeMesh(outputDataset, 'Learning Bot')
botNode = SA.projects.visualScripting.utilities.nodeFunctions.findNodeInNodeMesh(outputDataset, 'Learning Bot')
}
/* Some validations to verify that everything is in place. */
@@ -112,23 +112,23 @@
function asyncRaiseEvents(lastFile, timeFrames) {
if (TS.projects.foundations.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.processOutput !== undefined) {
let outputDatasets = TS.projects.visualScripting.utilities.nodeFunctions.nodeBranchToArray(TS.projects.foundations.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.processOutput, 'Output Dataset')
let outputDatasets = SA.projects.visualScripting.utilities.nodeFunctions.nodeBranchToArray(TS.projects.foundations.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.processOutput, 'Output Dataset')
for (let j = 0; j < outputDatasets.length; j++) {
let outputDataset = outputDatasets[j]
let botNode = TS.projects.visualScripting.utilities.nodeFunctions.findNodeInNodeMesh(outputDataset, 'Indicator Bot')
let botNode = SA.projects.visualScripting.utilities.nodeFunctions.findNodeInNodeMesh(outputDataset, 'Indicator Bot')
if (botNode === undefined) {
botNode = TS.projects.visualScripting.utilities.nodeFunctions.findNodeInNodeMesh(outputDataset, 'Trading Bot')
botNode = SA.projects.visualScripting.utilities.nodeFunctions.findNodeInNodeMesh(outputDataset, 'Trading Bot')
}
if (botNode === undefined) {
botNode = TS.projects.visualScripting.utilities.nodeFunctions.findNodeInNodeMesh(outputDataset, 'Sensor Bot')
botNode = SA.projects.visualScripting.utilities.nodeFunctions.findNodeInNodeMesh(outputDataset, 'Sensor Bot')
}
if (botNode === undefined) {
botNode = TS.projects.visualScripting.utilities.nodeFunctions.findNodeInNodeMesh(outputDataset, 'API Data Fetcher Bot')
botNode = SA.projects.visualScripting.utilities.nodeFunctions.findNodeInNodeMesh(outputDataset, 'API Data Fetcher Bot')
}
if (botNode === undefined) {
botNode = TS.projects.visualScripting.utilities.nodeFunctions.findNodeInNodeMesh(outputDataset, 'Learning Bot')
botNode = SA.projects.visualScripting.utilities.nodeFunctions.findNodeInNodeMesh(outputDataset, 'Learning Bot')
}
/* Some validations to verify that everything is in place. */
@@ -111,7 +111,7 @@ exports.newMachineLearningBotModulesLearningEngine = function (processIndex) {
destinationNode.value = originNode.value
/* Now we go down through all the children of the origin node, assuming the destination node has the same children structure*/
let schemaDocument = TS.projects.foundations.globals.taskConstants.APP_SCHEMA_MAP.get(originNode.project + '-' + originNode.type)
let schemaDocument = SA.projects.foundations.globals.schemas.APP_SCHEMA_MAP.get(originNode.project + '-' + originNode.type)
if (schemaDocument === undefined) { return }
if (schemaDocument.childrenNodesProperties !== undefined) {
@@ -150,7 +150,7 @@ exports.newMachineLearningBotModulesLearningEngine = function (processIndex) {
nodesMap.set(node.id, node)
/* Now we go down through all this node children */
let schemaDocument = TS.projects.foundations.globals.taskConstants.APP_SCHEMA_MAP.get(node.project + '-' + node.type)
let schemaDocument = SA.projects.foundations.globals.schemas.APP_SCHEMA_MAP.get(node.project + '-' + node.type)
if (schemaDocument === undefined) { return }
if (schemaDocument.childrenNodesProperties !== undefined) {
@@ -193,7 +193,7 @@ exports.newMachineLearningBotModulesLearningEngine = function (processIndex) {
}
/* Now we go down through all this node children */
let schemaDocument = TS.projects.foundations.globals.taskConstants.APP_SCHEMA_MAP.get(node.project + '-' + node.type)
let schemaDocument = SA.projects.foundations.globals.schemas.APP_SCHEMA_MAP.get(node.project + '-' + node.type)
if (schemaDocument === undefined) { return }
if (schemaDocument.childrenNodesProperties !== undefined) {
@@ -31,7 +31,7 @@ exports.newMachineLearningBotModulesLearningOutput = function (processIndex) {
/* Preparing everything for the Simulation */
let learningSimulationModuleObject = TS.projects.machineLearning.botModules.learningSimulation.newMachineLearningBotModulesLearningSimulation(processIndex)
let outputDatasets = TS.projects.visualScripting.utilities.nodeFunctions.nodeBranchToArray(TS.projects.foundations.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.processOutput, 'Output Dataset')
let outputDatasets = SA.projects.visualScripting.utilities.nodeFunctions.nodeBranchToArray(TS.projects.foundations.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.processOutput, 'Output Dataset')
let outputDatasetsMap = new Map()
await TS.projects.foundations.functionLibraries.outputManagementFunctions.readFiles(
@@ -37,7 +37,7 @@ exports.newMachineLearningBotModulesLearningRecords = function (processIndex) {
we have a pointer to the node that have the information we need to extract.
Later, based on the product record definition we will extract each individual value.
*/
let outputDatasets = TS.projects.visualScripting.utilities.nodeFunctions.nodeBranchToArray(TS.projects.foundations.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.processOutput, 'Output Dataset')
let outputDatasets = SA.projects.visualScripting.utilities.nodeFunctions.nodeBranchToArray(TS.projects.foundations.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.processOutput, 'Output Dataset')
for (let i = 0; i < outputDatasets.length; i++) {
let outputDatasetNode = outputDatasets[i]
@@ -381,8 +381,8 @@ exports.newMachineLearningBotModulesLearningSimulation = function (processIndex)
}
function positionChart(chart) {
let dataDependencies = TS.projects.visualScripting.utilities.nodeFunctions.nodeBranchToArray(TS.projects.foundations.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.processDependencies, 'Data Dependency')
dataDependencies = TS.projects.visualScripting.utilities.nodeFunctions.filterOutNodeWihtoutReferenceParentFromNodeArray(dataDependencies)
let dataDependencies = SA.projects.visualScripting.utilities.nodeFunctions.nodeBranchToArray(TS.projects.foundations.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.processDependencies, 'Data Dependency')
dataDependencies = SA.projects.visualScripting.utilities.nodeFunctions.filterOutNodeWihtoutReferenceParentFromNodeArray(dataDependencies)
/* Finding the Current Element on Market Files */
if (TS.projects.foundations.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).TRADING_PROCESSING_DAILY_FILES) {
@@ -292,7 +292,7 @@ exports.newMachineLearningBotModulesLearningSystem = function (processIndex) {
}
/* Now we go down through all this node children */
let schemaDocument = TS.projects.foundations.globals.taskConstants.APP_SCHEMA_MAP.get(node.project + '-' + node.type)
let schemaDocument = SA.projects.foundations.globals.schemas.APP_SCHEMA_MAP.get(node.project + '-' + node.type)
if (schemaDocument === undefined) { return }
if (schemaDocument.childrenNodesProperties !== undefined) {
+146 -73
View File
@@ -20,88 +20,161 @@ exports.newNetworkModulesUserProfiles = function newNetworkModulesUserProfiles()
async function initialize(nodeCodeName, p2pNetworkIdentity) {
let pluginFileNames = await SA.projects.communityPlugins.utilities.plugins.getPluginFileNames(
'Governance',
'User-Profiles'
)
await loadAppSchemas()
await loadProfiles()
for (let i = 0; i < pluginFileNames.length; i++) {
let pluginFileName = pluginFileNames[i]
async function loadAppSchemas() {
let pluginFileContent = await SA.projects.communityPlugins.utilities.plugins.getPluginFileContent(
'Governance',
'User-Profiles',
pluginFileName
)
let promise = new Promise((resolve, reject) => {
let userProfilePlugin = JSON.parse(pluginFileContent)
let config = JSON.parse(userProfilePlugin.config)
let signatureObject = config.signature
let web3 = new SA.nodeModules.web3()
let blockchainAccount = web3.eth.accounts.recover(signatureObject)
let ranking = 0 // TODO: read the blockchain balance and transactions from the Treasury Account to calculate the profile ranking.
let userProfileId = userProfilePlugin.id
let userHandle = config.signature.message
let project = 'Governance'
let filePath = global.env.PATH_TO_PROJECTS + '/' + project + '/Schemas/'
let folder = 'App-Schema'
let userProfile = SA.projects.socialTrading.modules.socialGraphUserProfile.newSocialTradingModulesSocialGraphUserProfile()
userProfile.initialize(
userProfileId,
userHandle,
blockchainAccount,
ranking
)
SA.projects.foundations.utilities.filesAndDirectories.getAllFilesInDirectoryAndSubdirectories(filePath + folder, onFilesReady)
SA.projects.network.globals.memory.maps.USER_PROFILES_BY_ID.set(userProfileId, userProfile)
SA.projects.network.globals.memory.maps.USER_PROFILES_BY_HANDLE.set(userHandle, userProfile)
SA.projects.network.globals.memory.maps.USER_PROFILES_BY_BLOKCHAIN_ACCOUNT.set(blockchainAccount, userProfile)
/*
Each User Profile might have Signing Accounts, meaning
accounts that can sign on behalf of the User Profile.
*/
if (userProfilePlugin.signingAccounts !== undefined) {
for (let j = 0; j < userProfilePlugin.signingAccounts.signingAccounts.length; j++) {
let signingAccount = userProfilePlugin.signingAccounts.signingAccounts[j]
let config = JSON.parse(signingAccount.config)
let signatureObject = config.signature
let web3 = new SA.nodeModules.web3()
let blockchainAccount = web3.eth.accounts.recover(signatureObject)
SA.projects.network.globals.memory.maps.USER_PROFILES_BY_BLOKCHAIN_ACCOUNT.set(blockchainAccount, userProfile)
/*
If the Signing Account is for a P2P node, we will add the node to the array of available nodes at the p2p network.
*/
if (
signingAccount.referenceParent !== undefined &&
signingAccount.referenceParent.type === "P2P Network Node" &&
signingAccount.referenceParent.config !== undefined
) {
let config
function onFilesReady(files) {
for (let k = 0; k < files.length; k++) {
let name = files[k]
let nameSplitted = name.split(folder)
let fileName = nameSplitted[1]
for (let i = 0; i < 10; i++) {
fileName = fileName.replace('\\', '/')
}
let fileToRead = filePath + folder + fileName
let fileContent = SA.nodeModules.fs.readFileSync(fileToRead)
let schemaDocument
try {
config = JSON.parse(signingAccount.referenceParent.config)
schemaDocument = JSON.parse(fileContent)
SA.projects.foundations.globals.schemas.APP_SCHEMA_MAP.set(project + '-' + schemaDocument.type, schemaDocument)
} catch (err) {
console.log('P2P Network Node Config not in JSON format. userProfileHandle = ' + userHandle + ' NodeId = ' + signingAccount.referenceParent.id)
continue
console.log('[WARN] loadAppSchemas -> Error Parsing JSON File: ' + fileToRead + '. Error = ' + err.stack)
return
}
if (config.host === undefined) {
continue
}
if (config.webSocketsPort === undefined) {
continue
}
let p2pNetworkNode = SA.projects.network.modules.p2pNetworkNode.newNetworkModulesP2PNetworkNode()
p2pNetworkNode.initialize(signingAccount.referenceParent, userProfile, blockchainAccount)
SA.projects.network.globals.memory.arrays.P2P_NETWORK_NODES.push(p2pNetworkNode)
}
/*
Now, we will extract the information from the User Profile, specifically of our identity at the p2p network.
*/
if (
signingAccount.referenceParent !== undefined &&
signingAccount.referenceParent.id === SA.secrets.map.get(nodeCodeName).nodeId
) {
p2pNetworkIdentity.node = signingAccount.referenceParent
p2pNetworkIdentity.blockchainAccount = blockchainAccount
p2pNetworkIdentity.userProfile = userProfile
resolve()
}
}
)
return promise
}
async function loadProfiles() {
let pluginFileNames = await SA.projects.communityPlugins.utilities.plugins.getPluginFileNames(
'Governance',
'User-Profiles'
)
for (let i = 0; i < pluginFileNames.length; i++) {
let pluginFileName = pluginFileNames[i]
let pluginFileContent = await SA.projects.communityPlugins.utilities.plugins.getPluginFileContent(
'Governance',
'User-Profiles',
pluginFileName
)
let userProfilePlugin = JSON.parse(pluginFileContent)
let config = JSON.parse(userProfilePlugin.config)
let signatureObject = config.signature
let web3 = new SA.nodeModules.web3()
let blockchainAccount = web3.eth.accounts.recover(signatureObject)
let ranking = 0 // TODO: read the blockchain balance and transactions from the Treasury Account to calculate the profile ranking.
let userProfileId = userProfilePlugin.id
let userHandle = config.signature.message
let userProfile = SA.projects.socialTrading.modules.socialGraphUserProfile.newSocialTradingModulesSocialGraphUserProfile()
userProfile.initialize(
userProfileId,
userHandle,
blockchainAccount,
ranking
)
SA.projects.network.globals.memory.maps.USER_PROFILES_BY_ID.set(userProfileId, userProfile)
SA.projects.network.globals.memory.maps.USER_PROFILES_BY_HANDLE.set(userHandle, userProfile)
SA.projects.network.globals.memory.maps.USER_PROFILES_BY_BLOKCHAIN_ACCOUNT.set(blockchainAccount, userProfile)
/*
Each User Profile might have Signing Accounts, meaning
accounts that can sign on behalf of the User Profile.
*/
if (userProfilePlugin.signingAccounts !== undefined) {
let algoTradersPlatform = SA.projects.visualScripting.utilities.nodeFunctions.nodeBranchToArray(userProfilePlugin.userApps, 'Algo Traders Platform')
let socialTradingDesktopApp = SA.projects.visualScripting.utilities.nodeFunctions.nodeBranchToArray(userProfilePlugin.userApps, 'Social Trading Desktop App')
let socialTradingMobileApp = SA.projects.visualScripting.utilities.nodeFunctions.nodeBranchToArray(userProfilePlugin.userApps, 'Social Trading Mobile App')
let socialTradingServerApp = SA.projects.visualScripting.utilities.nodeFunctions.nodeBranchToArray(userProfilePlugin.userApps, 'Social Trading Server App')
let socialTradingBots = SA.projects.visualScripting.utilities.nodeFunctions.nodeBranchToArray(userProfilePlugin.userBots, 'Social Trading Bot')
let socialPersonas = SA.projects.visualScripting.utilities.nodeFunctions.nodeBranchToArray(userProfilePlugin.socialPersonas, 'Social Persona')
let p2pNetworkNodes = SA.projects.visualScripting.utilities.nodeFunctions.nodeBranchToArray(userProfilePlugin.p2pNetworkNodes, 'P2P Network Node')
let networkClientsMap = new Map()
addToNetworkClientMap(algoTradersPlatform, 'Algo Traders Platform')
addToNetworkClientMap(socialTradingDesktopApp, 'Social Trading Desktop App')
addToNetworkClientMap(socialTradingMobileApp, 'Social Trading Mobile App')
addToNetworkClientMap(socialTradingServerApp, 'Social Trading Server App')
addToNetworkClientMap(socialTradingBots, 'Social Trading Bot')
addToNetworkClientMap(socialPersonas, 'Social Persona')
addToNetworkClientMap(p2pNetworkNodes, 'P2P Network Node')
function addToNetworkClientMap(nodeArray) {
for (let i = 0; i < nodeArray.length; i++) {
let currentNode = nodeArray[i]
networkClientsMap.set(currentNode.id, currentNode)
}
}
for (let j = 0; j < userProfilePlugin.signingAccounts.signingAccounts.length; j++) {
let signingAccount = userProfilePlugin.signingAccounts.signingAccounts[j]
let config = JSON.parse(signingAccount.config)
let signatureObject = config.signature
let web3 = new SA.nodeModules.web3()
let blockchainAccount = web3.eth.accounts.recover(signatureObject)
SA.projects.network.globals.memory.maps.USER_PROFILES_BY_BLOKCHAIN_ACCOUNT.set(blockchainAccount, userProfile)
/*
If the Signing Account is for a P2P node, we will add the node to the array of available nodes at the p2p network.
*/
if (signingAccount.savedPayload === undefined) { continue }
if (signingAccount.savedPayload.referenceParent === undefined) { continue }
signingAccount.referenceParent = networkClientsMap.get(signingAccount.savedPayload.referenceParent.id)
if (
signingAccount.referenceParent !== undefined &&
signingAccount.referenceParent.type === "P2P Network Node" &&
signingAccount.referenceParent.config !== undefined
) {
let config
try {
config = JSON.parse(signingAccount.referenceParent.config)
} catch (err) {
console.log('P2P Network Node Config not in JSON format. userProfileHandle = ' + userHandle + ' NodeId = ' + signingAccount.referenceParent.id)
continue
}
if (config.host === undefined) {
continue
}
if (config.webSocketsPort === undefined) {
continue
}
let p2pNetworkNode = SA.projects.network.modules.p2pNetworkNode.newNetworkModulesP2PNetworkNode()
p2pNetworkNode.initialize(signingAccount.referenceParent, userProfile, blockchainAccount)
SA.projects.network.globals.memory.arrays.P2P_NETWORK_NODES.push(p2pNetworkNode)
}
/*
Now, we will extract the information from the User Profile, specifically of our identity at the p2p network.
*/
if (
signingAccount.referenceParent !== undefined &&
signingAccount.referenceParent.id === SA.secrets.map.get(nodeCodeName).nodeId
) {
p2pNetworkIdentity.node = signingAccount.referenceParent
p2pNetworkIdentity.blockchainAccount = blockchainAccount
p2pNetworkIdentity.userProfile = userProfile
}
}
}
}
+7 -1
View File
@@ -329,7 +329,7 @@
}
]
},
"TS": {
"SA": {
"utilities": [
{
"name": "Node Functions",
@@ -795,6 +795,12 @@
"propertyName": "timeConstants",
"functionName": "newFoundationsGlobalsTimeConstants",
"fileName": "TimeConstants.js"
},
{
"name": "Schemas",
"propertyName": "schemas",
"functionName": "newFoundationsGlobalsSchemas",
"fileName": "Schemas.js"
}
],
"utilities": [
@@ -16,7 +16,11 @@ exports.newVisualScriptingUtilitiesNodeFunctions = function () {
return resultArray
function scanNodeBranch(startingNode) {
let schemaDocument = TS.projects.foundations.globals.taskConstants.APP_SCHEMA_MAP.get(startingNode.project + '-' + startingNode.type)
if (startingNode === undefined) {
return
}
let schemaDocument = SA.projects.foundations.globals.schemas.APP_SCHEMA_MAP.get(startingNode.project + '-' + startingNode.type)
if (schemaDocument === undefined) { return }
if (startingNode.type === nodeType) {
@@ -60,7 +64,7 @@ exports.newVisualScriptingUtilitiesNodeFunctions = function () {
if (startingNode === undefined) { return }
if (nodeFound !== undefined) { return }
let schemaDocument = TS.projects.foundations.globals.taskConstants.APP_SCHEMA_MAP.get(startingNode.project + '-' + startingNode.type)
let schemaDocument = SA.projects.foundations.globals.schemas.APP_SCHEMA_MAP.get(startingNode.project + '-' + startingNode.type)
if (schemaDocument === undefined) { return }
if (startingNode.type === nodeType) {
@@ -114,7 +118,7 @@ exports.newVisualScriptingUtilitiesNodeFunctions = function () {
function scanNodeMesh(startingNode) {
if (startingNode === undefined) { return }
let schemaDocument = TS.projects.foundations.globals.taskConstants.APP_SCHEMA_MAP.get(startingNode.project + '-' + startingNode.type)
let schemaDocument = SA.projects.foundations.globals.schemas.APP_SCHEMA_MAP.get(startingNode.project + '-' + startingNode.type)
if (schemaDocument === undefined) { return }
if (startingNode.id === nodeId) {
+2 -2
View File
@@ -76,7 +76,7 @@ exports.newTaskServer = function newTaskServer() {
for (let j = 0; j < project.schema.length; j++) {
let schemaDocument = project.schema[j]
let key = project.name + '-' + schemaDocument.type
TS.projects.foundations.globals.taskConstants.APP_SCHEMA_MAP.set(key, schemaDocument)
SA.projects.foundations.globals.schemas.APP_SCHEMA_MAP.set(key, schemaDocument)
}
}
}
@@ -88,7 +88,7 @@ exports.newTaskServer = function newTaskServer() {
setupTaskHeartbeats()
function initializeProjectDefinitionNode() {
TS.projects.foundations.globals.taskConstants.PROJECT_DEFINITION_NODE = TS.projects.visualScripting.utilities.nodeFunctions.findNodeInNodeMesh(TS.projects.foundations.globals.taskConstants.TASK_NODE, 'Project Definition')
TS.projects.foundations.globals.taskConstants.PROJECT_DEFINITION_NODE = SA.projects.visualScripting.utilities.nodeFunctions.findNodeInNodeMesh(TS.projects.foundations.globals.taskConstants.TASK_NODE, 'Project Definition')
if (TS.projects.foundations.globals.taskConstants.PROJECT_DEFINITION_NODE === undefined) {
console.log("[ERROR] Task Server -> Task -> bootingProcess -> Project Definition not found. ")
TS.projects.foundations.globals.taskVariables.FATAL_ERROR_MESSAGE = 'Project Definition not found. Fatal Error, can not continue. Fix the problem and try again.'