Merge branch 'Superalgos:develop' into develop

This commit is contained in:
B Harrell authored and GitHub committed 2021-09-05 07:24:53 -05:00
commit 75dadff4bc
373 files changed
+20242 -11268

No files matched your search

+1
View File
@@ -12,3 +12,4 @@ Projects/Foundations/Icons/Thumbs.db
*.exe
node_modules
launch.json
.idea
+10
View File
@@ -0,0 +1,10 @@
{
"folders": [
{
"path": "C:\\Superalgos"
}
],
"settings": {
"search.maintainFileSearchCache": true
}
}
+10
View File
@@ -0,0 +1,10 @@
{
"folders": [
{
"path": "C:\\Superalgos"
}
],
"settings": {
"search.maintainFileSearchCache": true
}
}
+10
View File
@@ -0,0 +1,10 @@
{
"folders": [
{
"path": "C:\\Superalgos"
}
],
"settings": {
"search.maintainFileSearchCache": true
}
}
+1
View File
@@ -10,6 +10,7 @@
"**/Data-Storage": true,
"**/Documentation": true,
"**/Log-Files": true,
"**/node_modules": true,
"**/Deprecated-Code": true
},
"search.maintainFileSearchCache": true
-72
View File
@@ -1,72 +0,0 @@
exports.newMultiProject = function () {
let thisObject = {
initialize: initialize
}
return thisObject;
function initialize() {
/*
First thing is to load the project schema file.
*/
let PROJECTS_SCHEMA = require(global.env.PATH_TO_PROJECTS_REQUIRED + '/' + 'ProjectsSchema.json')
/*
Here we will setup the CL object, with all the
projects and modules that will have inside.
*/
CL.projects = {}
for (let i = 0; i < PROJECTS_SCHEMA.length; i++) {
let projectDefinition = PROJECTS_SCHEMA[i]
global.CL.projects[projectDefinition.propertyName] = {}
let projectInstance = global.CL.projects[projectDefinition.propertyName]
projectInstance.utilities = {}
projectInstance.globals = {}
projectInstance.functionLibraries = {}
projectInstance.taskModules = {}
projectInstance.processModules = {}
projectInstance.botModules = {}
if (projectDefinition.CL === undefined) { continue }
/* Set up Utilities of this Project */
if (projectDefinition.CL.utilities !== undefined) {
for (let j = 0; j < projectDefinition.CL.utilities.length; j++) {
let utilityDefinition = projectDefinition.CL.utilities[j]
let path = global.env.PATH_TO_PROJECTS_REQUIRED + '/' + projectDefinition.name + '/' + 'CL' + '/' + 'Utilities' + '/' + utilityDefinition.fileName
let requiredObject = require(path)
let requiredFunction = requiredObject[utilityDefinition.functionName]
projectInstance.utilities[utilityDefinition.propertyName] = requiredFunction.call()
}
}
/* Set up Globals of this Project */
if (projectDefinition.CL.globals !== undefined) {
for (let j = 0; j < projectDefinition.CL.globals.length; j++) {
let globalDefinition = projectDefinition.CL.globals[j]
let path = global.env.PATH_TO_PROJECTS_REQUIRED + '/' + projectDefinition.name + '/' + 'CL' + '/' + 'Globals' + '/' + globalDefinition.fileName
let requiredObject = require(path)
let requiredFunction = requiredObject[globalDefinition.functionName]
projectInstance.globals[globalDefinition.propertyName] = requiredFunction.call()
}
}
/* Set up Function Libraries of this Project */
if (projectDefinition.CL.functionLibraries !== undefined) {
for (let j = 0; j < projectDefinition.CL.functionLibraries.length; j++) {
let functionLibraryDefinition = projectDefinition.CL.functionLibraries[j]
let path = global.env.PATH_TO_PROJECTS_REQUIRED + '/' + projectDefinition.name + '/' + 'CL' + '/' + 'Function-Libraries' + '/' + functionLibraryDefinition.fileName
let requiredObject = require(path)
let requiredFunction = requiredObject[functionLibraryDefinition.functionName]
projectInstance.functionLibraries[functionLibraryDefinition.propertyName] = requiredFunction.call()
}
}
}
}
}
-54
View File
@@ -1,54 +0,0 @@
<h2 id="trading-engine">Trading Engine</h2>
<table class="definitionTable"><tr><td>
<img src="images/icons/nodes/png150/trading-engine.png" />
</td><td>
<strong>The trading engine hierarchy is the data structure used by the trading bot to keep runtime information highly accessible and exposed to others.</strong>
</td></tr></table>
<p>You will use this hierarchy for two main purposes:</p>
<p>The hierarchy exposes—literally—all the information processed by the trading bot, providing a comprehensive feedback loop to trading systems and analysis capabilities to users. The hierarchy exposes—literally—all the information processed by the trading bot, providing a comprehensive feedback loop to trading systems and analysis capabilities to users.</p>
<ul>
<li>
<p><strong>To let your trading systems:</strong> This allows strategies to keep track of and react to current and past events—including those involving the exchange, such as orders placed or filled—as the bot is running.</p>
</li>
<li>
<p><strong>To keep track of the actions:</strong> By analyzing runtime information, you may gain a detailed understanding of what happens, when, and why, throughout a trading session.</p>
</li>
</ul>
<p>The hierarchy exposes—literally—all the information processed by the trading bot, providing a comprehensive feedback loop to trading systems and analysis capabilities to users.</p>
<div class="bs-callout bs-callout-success">Este callout se usa para resaltar una idea particularmente importante. Algo se sobresale, como una conclusion, o algo por el estilo.</div>
<p>The hierarchy exposes all the information processed by the trading bot, providing a comprehensive feedback loop to trading systems and analysis capabilities to users. The hierarchy exposes all the information processed by the trading bot, providing a comprehensive feedback loop to trading systems and analysis capabilities to users.</p>
<div class="alert alert-info" role="alert"><i class="fa fa-info-circle"></i> <b>Note:</b> Esto es una nota, algo noteworthy.</div>
<div class="alert alert-success" role="alert"><i class="fa fa-check-square-o"></i> <b>Tip:</b> Esto es un tip.</div>
<div class="alert alert-warning" role="alert"><i class="fa fa-warning"></i> <b>Important:</b> Esto es algo importante.</div>
<div class="alert alert-danger" role="alert"><i class="fa fa-exclamation-circle"></i> <b>Warning:</b> Esto es una aviso de alerta.</div>
<h4 id="adding-a-trading-engine-node">Adding a Trading Engine Node</h4>
<p>Calculo que con este segundo nivel de titulo alcanza.</p>
<h4 id="este-es-otro-formato-tipico-de-la-doc--trading-engine">Este es otro formato tipico de la doc: Trading Engine</h4>
<table class="definitionTable"><tr><td>
<img src="images/icons/nodes/png50/trading-engine.png" />
</td><td>
The trading engine hierarchy is the data structure used by the trading bot to keep runtime information highly accessible and exposed to others.
</td></tr></table>
File diff suppressed because it is too large. Load diff
-3552
View File
File diff suppressed because it is too large. Load diff
+125
View File
@@ -0,0 +1,125 @@
exports.newDesktopApp = function newDesktopApp() {
let thisObject = {
run: run
}
return thisObject
async function run() {
/*
let socialGraphService = NT.projects.network.modules.socialGraph.newSocialGraph()
await socialGraphService.initialize()
*/
/*
This is the Web Sockets client that interacts with the Superalgos Network.
*/
//DK.webSocketsClient = SA.projects.network.modules.webSocketsClient.newNetworkModulesWebSocketsClient()
//await DK.webSocketsClient.initialize()
/* These are the Network Interfaces by which the UI interacts with the Desktop App.*/
//let WEB_SOCKETS_INTERFACE = require('./webSocketsInterface.js')
let HTTP_INTERFACE = require('./httpInterface.js')
/*
WEB_SOCKETS_INTERFACE = WEB_SOCKETS_INTERFACE.newWebSocketsInterface()
WEB_SOCKETS_INTERFACE.initialize()
console.log('Web Sockets Interface ....................................... Listening at port ' + global.env.CLIENT_WEB_SOCKETS_INTERFACE_PORT)
*/
HTTP_INTERFACE = HTTP_INTERFACE.newHttpInterface()
HTTP_INTERFACE.initialize()
console.log('Http Interface .............................................. Listening at port ' + global.env.DESKTOP_HTTP_INTERFACE_PORT)
return
let queryMessage
let query
/*
Test Query User Profiles.
*/
queryMessage = {
queryType: SA.projects.socialTrading.globals.queryTypes.USER_PROFILES,
emitterUserProfileId: DK.TEST_NETWORK_CLIENT_USER_PROFILE_ID,
initialIndex: 'Last',
amountRequested: 10,
direction: 'Past'
}
query = {
requestType: 'Query',
queryMessage: JSON.stringify(queryMessage)
}
await DK.webSocketsClient.sendMessage(
JSON.stringify(query)
)
.then(showProfiles)
.catch(onError)
async function showProfiles(profiles) {
console.log(profiles)
for (let i = 0; i < profiles.length; i++) {
let profile = profiles[i]
/*
Test Following Profiles.
*/
let eventMessage = {
eventId: SA.projects.foundations.utilities.miscellaneousFunctions.genereteUniqueId(),
eventType: SA.projects.socialTrading.globals.eventTypes.FOLLOW_USER_PROFILE,
emitterUserProfileId: DK.TEST_NETWORK_CLIENT_USER_PROFILE_ID,
targetUserProfileId: profile.userProfileId
}
let event = {
requestType: 'Event',
eventMessage: JSON.stringify(eventMessage)
}
await DK.webSocketsClient.sendMessage(
JSON.stringify(event)
)
.then(followAdded)
.catch(onError)
function followAdded() {
console.log("User Profile " + profile.userProfileHandle + " followed.")
}
}
}
/*
Test Query User Profile Stats.
*/
queryMessage = {
queryType: SA.projects.socialTrading.globals.queryTypes.USER_PROFILE_STATS,
emitterUserProfileId: DK.TEST_NETWORK_CLIENT_USER_PROFILE_ID,
targetUserProfileId: DK.TEST_NETWORK_CLIENT_USER_PROFILE_ID
}
query = {
requestType: 'Query',
queryMessage: JSON.stringify(queryMessage)
}
await DK.webSocketsClient.sendMessage(
JSON.stringify(query)
)
.then(showProfilesStats)
.catch(onError)
function showProfilesStats(profile) {
console.log(profile)
}
/*
Error Handling
*/
function onError(errorMessage) {
console.log('[ERROR] Query not executed. ' + errorMessage)
}
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+34
View File
@@ -0,0 +1,34 @@
/* latin */
@font-face {
font-family: 'Saira';
font-style: normal;
font-weight: 300;
src: local('Saira Light'), local('Saira-Light'), url(Fonts/Saira.woff2) format('woff2');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* latin */
@font-face {
font-family: 'Saira Condensed';
font-style: normal;
font-weight: 300;
src: local('Saira Condensed Light'), local('SairaCondensed-Light'), url(Fonts/Saira-Condensed.woff2) format('woff2');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
font-family: segoeui;
src: url(Fonts/segoeui.woff) format('woff');
font-weight: normal;
font-style: normal;
}
kbd {
padding: 2px 8px;
font-size: 125%;
font-weight: 500;
color: #000;
background-color: #bcd643;
border-radius: 5px;
border-style: outset;
border-width: 1px;
}
+52
View File
@@ -0,0 +1,52 @@
<html lang="en">
<head>
<meta charset="utf-8">
<title>Superalgos Desktop</title>
<meta name="description" content="Free and Open Source Crypto Social Trading">
<link rel="stylesheet" href="main.css" type="text/css" charset="utf-8" />
<link rel="shortcut icon" type="image/png/ico" href="Images/favicon.ico" />
<script type="text/javascript" src="WebServer/require.js"></script>
<script type="text/javascript" src="AppPreLoader.js"></script>
<script type="text/javascript">
function loadApp() {
// Prevent click-jacking
try {
if (window == window.top || window.chrome && chrome.app && chrome.app.window) {
document.documentElement.style.display = 'block'
} else {
top.location = self.location
}
} catch (e) { console.error('CJ protection', e) }
try {
loadSuperalgos()
} catch (err) {
console.log("[ERROR] UI can not be started. Please check that WebServer is running.", err);
}
}
function onResize() {
try {
if (page === undefined) { return }
if (page.eventHandler === undefined) { return }
if (DISABLE_BROWSER_RESIZE_EVENT === true) { return }
page.eventHandler.raiseEvent('Browser Resized')
} catch (err) {
console.log('Error Resizing. ' + err.stack)
}
}
</script>
</head>
<body id="body" onload="loadApp()"
onresize="onResize()">
Hello World!
<div id="masterApp"></div>
<div id="canvasApp"></div>
</body>
</html>
File renamed without changes.
+68
View File
@@ -0,0 +1,68 @@
exports.newHttpInterface = function newHttpInterface() {
/*
This module represent the HTTP API of the
Desktop App. All HTTP request are processed
by this module.
*/
let thisObject = {
initialize: initialize,
finalize: finalize
}
return thisObject
function finalize() {
}
function initialize() {
/*
We will create an HTTP Server and leave it running forever.
*/
SA.nodeModules.http.createServer(onHttpRequest).listen(global.env.DESKTOP_HTTP_INTERFACE_PORT)
/* Starting the browser now is optional */
if (process.argv.includes("noBrowser")) {
//Running Client only with no UI.
} else {
SA.nodeModules.open('http://localhost:' + global.env.DESKTOP_HTTP_INTERFACE_PORT)
}
}
function onHttpRequest(httpRequest, httpResponse) {
try {
let requestPathAndParameters = httpRequest.url.split('?') // Remove version information
let requestPath = requestPathAndParameters[0].split('/')
let endpointOrFile = requestPath[1]
switch (endpointOrFile) {
case 'Images': // This means the Images folder.
{
let path = global.env.PATH_TO_CLIENT + '/WebServer/Images/' + requestPath[2]
if (requestPath[3] !== undefined) {
path = path + '/' + requestPath[3]
}
if (requestPath[4] !== undefined) {
path = path + '/' + requestPath[4]
}
if (requestPath[5] !== undefined) {
path = path + '/' + requestPath[5]
}
path = unescape(path)
SA.projects.foundations.utilities.httpResponses.respondWithImage(path, httpResponse)
}
break
default:
{
SA.projects.foundations.utilities.httpResponses.respondWithWebFile(httpResponse, endpointOrFile, global.env.PATH_TO_DESKTOP)
}
}
} catch (err) {
console.log(err.stack)
}
}
}
+6 -7
View File
@@ -2,19 +2,18 @@ exports.newEnvironment = function () {
let thisObject = {
WEB_SERVER_URL: 'localhost',
WEB_SOCKETS_INTERFACE_PORT: 18041,
HTTP_INTERFACE_PORT: 34248,
CLIENT_WEB_SOCKETS_INTERFACE_PORT: 18041,
CLIENT_HTTP_INTERFACE_PORT: 34248,
PATH_TO_TASK_SERVER: './TaskServer',
PATH_TO_DATA_STORAGE: './Data-Storage',
PATH_TO_PROJECTS: './Projects',
PATH_TO_LOG_FILES: './Log-Files',
PATH_TO_PROJECTS_REQUIRED: '../Projects',
PATH_TO_UI: './UI',
PATH_TO_DATA_FILES: './UI/Data-Files/src',
PATH_TO_CLIENT: './Client/',
PATH_TO_PROJECTS_REQUIRED: './Projects',
PATH_TO_PROJECT_SCHEMA: '../Projects/ProjectsSchema.json',
PATH_TO_CLIENT: './Platform',
PATH_TO_DEFAULT_WORKSPACE: './Projects/Foundations/Plugins/Workspaces',
PATH_TO_MY_WORKSPACES: './My-Workspaces',
PATH_TO_FONTS: './Client/WebServer/Fonts'
PATH_TO_FONTS: './Platform/WebServer/Fonts'
}
return thisObject
+23
View File
@@ -0,0 +1,23 @@
exports.newEnvironment = function () {
let thisObject = {
WEB_SERVER_URL: 'localhost',
CLIENT_WEB_SOCKETS_INTERFACE_PORT: 18041,
NETWORK_WEB_SOCKETS_INTERFACE_PORT: 18042,
CLIENT_HTTP_INTERFACE_PORT: 34248,
DESKTOP_HTTP_INTERFACE_PORT: 34249,
PATH_TO_TASK_SERVER: './TaskServer',
PATH_TO_DATA_STORAGE: './Data-Storage',
PATH_TO_PROJECTS: './Projects',
PATH_TO_LOG_FILES: './Log-Files',
PATH_TO_PROJECTS_REQUIRED: './Projects',
PATH_TO_PROJECT_SCHEMA: './Projects/ProjectsSchema.json',
PATH_TO_CLIENT: './Platform',
PATH_TO_DESKTOP: './Desktop',
PATH_TO_DEFAULT_WORKSPACE: './Projects/Foundations/Plugins/Workspaces',
PATH_TO_MY_WORKSPACES: './My-Workspaces',
PATH_TO_FONTS: './Platform/WebServer/Fonts'
}
return thisObject
}
+116
View File
@@ -0,0 +1,116 @@
exports.newMultiProject = function () {
let thisObject = {
initialize: initialize
}
return thisObject;
function initialize(rootObject, rootObjectName) {
/*
Here we will setup the rootObject object, with all the
projects and modules that will have inside.
*/
rootObject.projects = {}
for (let i = 0; i < PROJECTS_SCHEMA.length; i++) {
let projectDefinition = PROJECTS_SCHEMA[i]
global[rootObjectName].projects[projectDefinition.propertyName] = {}
let projectInstance = global[rootObjectName].projects[projectDefinition.propertyName]
projectInstance.utilities = {}
projectInstance.globals = {}
projectInstance.functionLibraries = {}
projectInstance.modules = {}
projectInstance.taskModules = {}
projectInstance.processModules = {}
projectInstance.botModules = {}
if (projectDefinition[rootObjectName] === undefined) { continue }
/* Set up Utilities of this Project */
if (projectDefinition[rootObjectName].utilities !== undefined) {
for (let j = 0; j < projectDefinition[rootObjectName].utilities.length; j++) {
let utilityDefinition = projectDefinition[rootObjectName].utilities[j]
let path = global.env.PATH_TO_PROJECTS_REQUIRED + '/' + projectDefinition.name + '/' + rootObjectName + '/' + 'Utilities' + '/' + utilityDefinition.fileName
let requiredObject = require(path)
let requiredFunction = requiredObject[utilityDefinition.functionName]
projectInstance.utilities[utilityDefinition.propertyName] = requiredFunction.call()
}
}
/* Set up Globals of this Project */
if (projectDefinition[rootObjectName].globals !== undefined) {
for (let j = 0; j < projectDefinition[rootObjectName].globals.length; j++) {
let globalDefinition = projectDefinition[rootObjectName].globals[j]
let path = global.env.PATH_TO_PROJECTS_REQUIRED + '/' + projectDefinition.name + '/' + rootObjectName + '/' + 'Globals' + '/' + globalDefinition.fileName
let requiredObject = require(path)
let requiredFunction = requiredObject[globalDefinition.functionName]
projectInstance.globals[globalDefinition.propertyName] = requiredFunction.call()
}
}
/* Set up Function Libraries of this Project */
if (projectDefinition[rootObjectName].functionLibraries !== undefined) {
for (let j = 0; j < projectDefinition[rootObjectName].functionLibraries.length; j++) {
let functionLibraryDefinition = projectDefinition[rootObjectName].functionLibraries[j]
let path = global.env.PATH_TO_PROJECTS_REQUIRED + '/' + projectDefinition.name + '/' + rootObjectName + '/' + 'Function-Libraries' + '/' + functionLibraryDefinition.fileName
let requiredObject = require(path)
let requiredFunction = requiredObject[functionLibraryDefinition.functionName]
projectInstance.functionLibraries[functionLibraryDefinition.propertyName] = requiredFunction.call()
}
}
/*
From here we will require and get the modules, but without instantiation thisObject.
*/
/* Set up Modules for this Project */
if (projectDefinition[rootObjectName].modules !== undefined) {
for (let j = 0; j < projectDefinition[rootObjectName].modules.length; j++) {
let taskModuleDefinition = projectDefinition[rootObjectName].modules[j]
let path = global.env.PATH_TO_PROJECTS_REQUIRED + '/' + projectDefinition.name + '/' + rootObjectName + '/' + 'Modules' + '/' + taskModuleDefinition.fileName
let requiredObject = require(path)
projectInstance.modules[taskModuleDefinition.propertyName] = requiredObject
}
}
/* Set up Task Modules for this Project */
if (projectDefinition[rootObjectName].taskModules !== undefined) {
for (let j = 0; j < projectDefinition[rootObjectName].taskModules.length; j++) {
let taskModuleDefinition = projectDefinition[rootObjectName].taskModules[j]
let path = global.env.PATH_TO_PROJECTS_REQUIRED + '/' + projectDefinition.name + '/' + rootObjectName + '/' + 'Task-Modules' + '/' + taskModuleDefinition.fileName
let requiredObject = require(path)
projectInstance.taskModules[taskModuleDefinition.propertyName] = requiredObject
}
}
/* Set up Process Modules for this Project */
if (projectDefinition[rootObjectName].processModules !== undefined) {
for (let j = 0; j < projectDefinition[rootObjectName].processModules.length; j++) {
let processModuleDefinition = projectDefinition[rootObjectName].processModules[j]
let path = global.env.PATH_TO_PROJECTS_REQUIRED + '/' + projectDefinition.name + '/' + rootObjectName + '/' + 'Process-Modules' + '/' + processModuleDefinition.fileName
let requiredObject = require(path)
projectInstance.processModules[processModuleDefinition.propertyName] = requiredObject
}
}
/* Set up Bot Modules for this Project */
if (projectDefinition[rootObjectName].botModules !== undefined) {
for (let j = 0; j < projectDefinition[rootObjectName].botModules.length; j++) {
let botModuleDefinition = projectDefinition[rootObjectName].botModules[j]
let path = global.env.PATH_TO_PROJECTS_REQUIRED + '/' + projectDefinition.name + '/' + rootObjectName + '/' + 'Bot-Modules' + '/' + botModuleDefinition.folderName + '/' + botModuleDefinition.fileName
let requiredObject = require(path)
projectInstance.botModules[botModuleDefinition.propertyName] = requiredObject
}
}
}
}
}
+14
View File
@@ -0,0 +1,14 @@
{
"folders": [
{
"path": "C:\\Superalgos\\Network"
},
{
"path": "C:\\Superalgos\\Projects\\Network"
},
{
"path": "C:\\Superalgos\\Projects\\Social-Trading"
}
],
"settings": {}
}
+17
View File
@@ -0,0 +1,17 @@
{
"files.exclude": {
"**/Data-Storage": true,
"**/Documentation": true,
"**/Log-Files": true,
"**/node_modules": true,
"**/Deprecated-Code": true
},
"search.exclude": {
"**/Data-Storage": true,
"**/Documentation": true,
"**/Log-Files": true,
"**/node_modules": true,
"**/Deprecated-Code": true
},
"search.maintainFileSearchCache": true
}
+22 -26
View File
@@ -1,28 +1,24 @@
exports.newNetworkNode = function newNetworkNode() {
global.NT = {
memory: {
maps: {
USER_PROFILES_BY_ID: new Map(), // Here we will store the user profiles by User Profile Id.
USER_PROFILES_BY_HANDLE: new Map(), // Here we will store the user profiles by User Profile Handle.
POSTS: new Map(), // This are all the posts we are keeping track of.
EVENTS: new Map(), // This is the registry of all events received that prevents processing them more than once.
},
arrays: {
EVENTS: [], // A time ordered list of events.
NETWORK_CLIENTS: [], // These are the Network Clients connected to this Network Node ordered by Ranking.
NETWORK_PEERS: [], // These are the Network Peers connected to this Network Node ordered by Ranking.
}
},
modules: {
USER_PROFILE: require('./UserProfile.js'),
BOT: require('./BotProfile.js'),
EVENT: require('./Event.js'),
POST: require('./Post.js'),
QUERY: require('./Query.js'),
QUERY_PROFILE_STATS: require('./Queries/ProfileStats.js'),
QUERY_PROFILE_POSTS: require('./Queries/ProfilePosts.js'),
QUERY_POST_REPLIES: require('./Queries/ProfileReplies.js'),
QUERY_EVENTS: require('./Queries/Events.js')
let thisObject = {
run: run
}
}
return thisObject
function run() {
/*
Let's start the Network Interfaces
*/
NT.webSocketsInterface = NT.projects.network.modules.webSocketsInterface.newNetworkModulesWebSocketsInterface()
NT.webSocketsInterface.initialize()
start()
async function start() {
let socialGraphService = NT.projects.socialTrading.modules.socialGraph.newSocialGraph()
await socialGraphService.initialize()
}
}
}
-245
View File
@@ -1,245 +0,0 @@
exports.newEvents = function newEvents() {
let thisObject = {
profile: undefined,
initialIndex: undefined,
amountRequested: undefined,
direction: undefined,
execute: execute,
initialize: initialize,
finalize: finalize
}
const INITIAL_EVENT_INDEX_FIRST = 'First'
const INITIAL_EVENT_INDEX_LAST = 'Last'
const MIN_AMOUNT_REQUESTED = 1
const MAX_AMOUNT_REQUESTED = 100
const DIRECTION_FUTURE = 'Future'
const DIRECTION_PAST = 'Past'
return thisObject
function finalize() {
thisObject.profile = undefined
}
function initialize(queryReceived) {
/*
Validate User Profile
*/
if (queryReceived.emitterUserProfileId !== undefined) {
thisObject.profile = NT.memory.maps.USER_PROFILES_BY_ID.get(queryReceived.emitterUserProfileId)
} else {
thisObject.profile = NT.memory.maps.USER_PROFILES_BY_HANDLE.get(queryReceived.emitterUserProfileHandle)
}
if (thisObject.profile === undefined) {
throw ('Emitter User Profile Not Found.')
}
/*
Validate Initial Index
*/
if (queryReceived.initialIndex === undefined) {
throw ('Initial Index Undefined.')
}
if (queryReceived.initialIndex === INITIAL_EVENT_INDEX_LAST) {
queryReceived.initialIndex = thisObject.profile.posts.length - 1
}
if (queryReceived.initialIndex === INITIAL_EVENT_INDEX_FIRST) {
queryReceived.initialIndex = 0
}
if (isNaN(queryReceived.initialIndex) === true) {
throw ('Initial Event Is Not a Number.')
}
thisObject.initialIndex = queryReceived.initialIndex
/*
Validate Amount Requested
*/
if (queryReceived.amountRequested === undefined) {
throw ('Amount Requested Undefined.')
}
if (isNaN(queryReceived.amountRequested) === true) {
throw ('Amount Requested Is Not a Number.')
}
if (queryReceived.amountRequested < MIN_AMOUNT_REQUESTED) {
throw ('Amount Requested Below Min.')
}
if (queryReceived.amountRequested > MAX_AMOUNT_REQUESTED) {
throw ('Amount Requested Above Max.')
}
/*
Validate Direction
*/
if (queryReceived.direction === undefined) {
throw ('Direction Undefined.')
}
if (queryReceived.direction !== DIRECTION_FUTURE && queryReceived.direction !== DIRECTION_PAST) {
throw ('Direction Not Supported.')
}
thisObject.direction = queryReceived.direction
}
function execute() {
let response = []
switch (thisObject.direction) {
case DIRECTION_FUTURE: {
for (let i = thisObject.initialIndex; i < thisObject.initialIndex + thisObject.amountRequested; i++) {
let event = NT.memory.arrays.EVENTS[i]
if (event === undefined) { break }
checkEventContext(event)
}
break
}
case DIRECTION_PAST: {
for (let i = thisObject.initialIndex; i > thisObject.initialIndex - thisObject.amountRequested; i--) {
let event = NT.memory.arrays.EVENTS[i]
if (event === undefined) { break }
checkEventContext(event)
}
break
}
}
return response
function checkEventContext(event) {
/*
For an event to be returned at the response of this query, it needs to be related
to the profile making the query. How it can be related?
1. The Emitter or Target profile must be the same as the Query Profile.
2. The Emitter or Traget profile must be at the Following map of the Query Profile.
3. The Emmiter or Target post must be belong to any profile at the Following of the Query Profile.
Any of the above happening, means that indeed it is related.
*/
let emitterUserProfile = NT.memory.maps.USER_PROFILES_BY_ID.get(eventReceived.emitterUserProfileId)
let targetUserProfile = NT.memory.maps.USER_PROFILES_BY_ID.get(eventReceived.targetUserProfileId)
let emitterPost = NT.memory.maps.POSTS.get(eventReceived.emitterPostHash)
let targetPost = NT.memory.maps.POSTS.get(eventReceived.targetPostHash)
/*
Test #1 : The Emitter or Target profile must be the same as the Query Profile.
*/
if (emitterUserProfile !== undefined) {
if (emitterUserProfile.userProfieId === thisObject.profile.userProfieId) {
addToResponse(event)
return
}
}
if (targetUserProfile !== undefined) {
if (targetUserProfile.userProfieId === thisObject.profile.userProfieId) {
addToResponse(event)
return
}
}
/*
Test #2 : The Emitter or Traget profile must be at the Following map of the Query Profile.
*/
if (emitterUserProfile !== undefined) {
if (thisObject.profile.following.get(emitterUserProfile.userProfieId) !== undefined) {
addToResponse(event)
return
}
}
if (targetUserProfile !== undefined) {
if (thisObject.profile.following.get(targetUserProfile.userProfieId) !== undefined) {
addToResponse(event)
return
}
}
/*
Test #3 : The Emmiter or Target post must be belong to any profile at the Following of the Query Profile.
*/
if (emitterPost !== undefined) {
if (thisObject.profile.following.get(emitterPost.emitterUserProfileId) !== undefined) {
addToResponse(event)
return
}
}
if (emitterPost !== undefined) {
if (thisObject.profile.following.get(emitterPost.targetUserProfileId) !== undefined) {
addToResponse(event)
return
}
}
if (targetPost !== undefined) {
if (thisObject.profile.following.get(targetPost.emitterUserProfileId) !== undefined) {
addToResponse(event)
return
}
}
if (targetPost !== undefined) {
if (thisObject.profile.following.get(targetPost.targetUserProfileId) !== undefined) {
addToResponse(event)
return
}
}
function addToResponse(event) {
let eventResponse = {
eventId: event.eventId,
eventType: event.eventType,
emitterUserProfileId: event.emitterUserProfileId,
targetUserProfileId: event.targetUserProfileId,
emitterPostHash: event.emitterPostHash,
targetPostHash: event.targetPostHash,
timestamp: event.timestamp,
botId: event.botId,
botAsset: event.botAsset,
botExchange: event.botExchange
}
if (emitterUserProfile !== undefined) {
let query = NT.modules.QUERY_PROFILE_STATS.newProfileStats()
query.initialize({ targetUserProfileId: event.emitterUserProfileId })
eventResponse.emitterUserProfile = query.execute()
}
if (targetUserProfile !== undefined) {
let query = NT.modules.QUERY_PROFILE_STATS.newProfileStats()
query.initialize({ targetUserProfileId: event.targetUserProfileId })
eventResponse.targetUserProfile = query.execute()
}
if (emitterPost !== undefined) {
eventResponse.emitterPost = addPost(emitterPost)
}
if (targetPost !== undefined) {
eventResponse.targetPost = addPost(targetPost)
}
response.push(eventResponse)
function addPost(post) {
let postResponse = {
emitterUserProfileId: post.emitterUserProfileId,
targetUserProfileId: post.targetUserProfileId,
emitterPostHash: post.emitterPostHash,
targetPostHash: post.targetPostHash,
postType: post.postType,
timestamp: post.timestamp,
repliesCount: post.replies.length,
reactionsCount: []
}
for (let i = 0; i < post.reactionTypesCount; i++) {
postResponse.reactionsCount.push(post.reactionsCount.get(i))
}
return postResponse
}
}
}
}
}
-129
View File
@@ -1,129 +0,0 @@
exports.newPostReplies = function newPostReplies() {
let thisObject = {
post: undefined,
initialIndex: undefined,
amountRequested: undefined,
direction: undefined,
execute: execute,
initialize: initialize,
finalize: finalize
}
const INITIAL_REPLY_INDEX_FIRST = 'First'
const INITIAL_REPLY_INDEX_LAST = 'Last'
const MIN_AMOUNT_REQUESTED = 1
const MAX_AMOUNT_REQUESTED = 100
const DIRECTION_FUTURE = 'Future'
const DIRECTION_PAST = 'Past'
return thisObject
function finalize() {
thisObject.post = undefined
}
function initialize(queryReceived) {
/*
Validate Post
*/
thisObject.post = NT.memory.maps.POSTS.get(queryReceived.targetPostHash)
if (thisObject.post === undefined) {
throw ('Target Post Not Found.')
}
/*
Validate Initial Index
*/
if (queryReceived.initialIndex === undefined) {
throw ('Initial Index Undefined.')
}
if (queryReceived.initialIndex === INITIAL_REPLY_INDEX_LAST) {
queryReceived.initialIndex = thisObject.poat.replies.length - 1
}
if (queryReceived.initialIndex === INITIAL_REPLY_INDEX_FIRST) {
queryReceived.initialIndex = 0
}
if (isNaN(queryReceived.initialIndex) === true) {
throw ('Initial Reply Is Not a Number.')
}
thisObject.initialIndex = queryReceived.initialIndex
/*
Validate Amount Requested
*/
if (queryReceived.amountRequested === undefined) {
throw ('Amount Requested Undefined.')
}
if (isNaN(queryReceived.amountRequested) === true) {
throw ('Amount Requested Is Not a Number.')
}
if (queryReceived.amountRequested < MIN_AMOUNT_REQUESTED) {
throw ('Amount Requested Below Min.')
}
if (queryReceived.amountRequested > MAX_AMOUNT_REQUESTED) {
throw ('Amount Requested Above Max.')
}
/*
Validate Direction
*/
if (queryReceived.direction === undefined) {
throw ('Direction Undefined.')
}
if (queryReceived.direction !== DIRECTION_FUTURE && queryReceived.direction !== DIRECTION_PAST) {
throw ('Direction Not Supported.')
}
thisObject.direction = queryReceived.direction
}
function execute() {
let response = []
switch (thisObject.direction) {
case DIRECTION_FUTURE: {
for (let i = thisObject.initialIndex; i < thisObject.initialIndex + thisObject.amountRequested; i++) {
let post = thisObject.post.replies[i]
if (post === undefined) { break }
addToResponse(post)
}
break
}
case DIRECTION_PAST: {
for (let i = thisObject.initialIndex; i > thisObject.initialIndex - thisObject.amountRequested; i--) {
let post = thisObject.post.replies[i]
if (post === undefined) { break }
addToResponse(post)
}
break
}
}
return response
function addToResponse(post) {
let postResponse = {
emitterUserProfileId: post.emitterUserProfileId,
targetUserProfileId: post.targetUserProfileId,
emitterPostHash: post.emitterPostHash,
targetPostHash: post.targetPostHash,
postType: post.postType,
timestamp: post.timestamp,
repliesCount: post.replies.length,
reactionsCount: []
}
for (let i = 0; i < post.reactionTypesCount; i++) {
postResponse.reactionsCount.push(post.reactionsCount.get(i))
}
response.push(postResponse)
}
}
}
-133
View File
@@ -1,133 +0,0 @@
exports.newProfilePosts = function newProfilePosts() {
let thisObject = {
profile: undefined,
initialIndex: undefined,
amountRequested: undefined,
direction: undefined,
execute: execute,
initialize: initialize,
finalize: finalize
}
const INITIAL_POST_INDEX_FIRST = 'First'
const INITIAL_POST_INDEX_LAST = 'Last'
const MIN_AMOUNT_REQUESTED = 1
const MAX_AMOUNT_REQUESTED = 100
const DIRECTION_FUTURE = 'Future'
const DIRECTION_PAST = 'Past'
return thisObject
function finalize() {
thisObject.profile = undefined
}
function initialize(queryReceived) {
/*
Validate User Profile
*/
if (queryReceived.targetUserProfileId !== undefined) {
thisObject.profile = NT.memory.maps.USER_PROFILES_BY_ID.get(queryReceived.targetUserProfileId)
} else {
thisObject.profile = NT.memory.maps.USER_PROFILES_BY_HANDLE.get(queryReceived.targetUserProfileHandle)
}
if (thisObject.profile === undefined) {
throw ('Target User Profile Not Found.')
}
/*
Validate Initial Index
*/
if (queryReceived.initialIndex === undefined) {
throw ('Initial Index Undefined.')
}
if (queryReceived.initialIndex === INITIAL_POST_INDEX_LAST) {
queryReceived.initialIndex = thisObject.profile.posts.length - 1
}
if (queryReceived.initialIndex === INITIAL_POST_INDEX_FIRST) {
queryReceived.initialIndex = 0
}
if (isNaN(queryReceived.initialIndex) === true) {
throw ('Initial Post Is Not a Number.')
}
thisObject.initialIndex = queryReceived.initialIndex
/*
Validate Amount Requested
*/
if (queryReceived.amountRequested === undefined) {
throw ('Amount Requested Undefined.')
}
if (isNaN(queryReceived.amountRequested) === true) {
throw ('Amount Requested Is Not a Number.')
}
if (queryReceived.amountRequested < MIN_AMOUNT_REQUESTED) {
throw ('Amount Requested Below Min.')
}
if (queryReceived.amountRequested > MAX_AMOUNT_REQUESTED) {
throw ('Amount Requested Above Max.')
}
/*
Validate Direction
*/
if (queryReceived.direction === undefined) {
throw ('Direction Undefined.')
}
if (queryReceived.direction !== DIRECTION_FUTURE && queryReceived.direction !== DIRECTION_PAST) {
throw ('Direction Not Supported.')
}
thisObject.direction = queryReceived.direction
}
function execute() {
let response = []
switch (thisObject.direction) {
case DIRECTION_FUTURE: {
for (let i = thisObject.initialIndex; i < thisObject.initialIndex + thisObject.amountRequested; i++) {
let post = thisObject.profile.posts[i]
if (post === undefined) { break }
addToResponse(post)
}
break
}
case DIRECTION_PAST: {
for (let i = thisObject.initialIndex; i > thisObject.initialIndex - thisObject.amountRequested; i--) {
let post = thisObject.profile.posts[i]
if (post === undefined) { break }
addToResponse(post)
}
break
}
}
return response
function addToResponse(post) {
let postResponse = {
emitterUserProfileId: post.emitterUserProfileId,
targetUserProfileId: post.targetUserProfileId,
emitterPostHash: post.emitterPostHash,
targetPostHash: post.targetPostHash,
postType: post.postType,
timestamp: post.timestamp,
repliesCount: post.replies.length,
reactionsCount: []
}
for (let i = 0; i < post.reactionTypesCount; i++) {
postResponse.reactionsCount.push(post.reactionsCount.get(i))
}
response.push(postResponse)
}
}
}
-63
View File
@@ -1,63 +0,0 @@
exports.newQuery = function newQuery() {
let thisObject = {
query: undefined,
queryType: undefined,
execute: execute,
initialize: initialize,
finalize: finalize
}
const QUERY_TYPES = {
PROFILE_STATS: 0,
PROFILE_POSTS: 1,
POST_REPLIES: 2,
EVENTS: 3
}
return thisObject
function finalize() {
thisObject.query = undefined
thisObject.queryType = undefined
}
function initialize(queryReceived) {
thisObject.queryType = queryReceived.queryType
switch (thisObject.queryType) {
case QUERY_TYPES.PROFILE_STATS: {
thisObject.query = NT.modules.QUERY_PROFILE_STATS.newProfileStats()
query.initialize(queryReceived)
break
}
case QUERY_TYPES.PROFILE_POSTS: {
thisObject.query = NT.modules.QUERY_PROFILE_POSTS.newProfilePosts()
query.initialize(queryReceived)
break
}
case QUERY_TYPES.POST_REPLIES: {
thisObject.query = NT.modules.QUERY_POST_REPLIES.newPostReplies()
query.initialize(queryReceived)
break
}
case QUERY_TYPES.maps.EVENTS: {
thisObject.query = NT.modules.QUERY_EVENTS.newEvents()
query.initialize(queryReceived)
break
}
default: throw('Query Type Not Supported.')
}
}
function execute() {
return thisObject.query.execute()
}
}
-137
View File
@@ -1,137 +0,0 @@
exports.newUserProfile = function newUserProfile() {
let thisObject = {
botProfileId: undefined,
botProfileHandle: undefined,
botAsset: undefined,
botExchange: undefined,
enabled: undefined,
following: undefined,
followers: undefined,
followingCount: undefined,
followersCount: undefined,
emitterEventsCount: undefined,
targetEventsCount: undefined,
postsCount: undefined,
posts: undefined,
addPost: addPost,
removePost: removePost,
addFollowing: addFollowing,
removeFollowing: removeFollowing,
addFollower: addFollower,
removeFollower: removeFollower,
initialize: initialize,
finalize: finalize
}
return thisObject
function finalize() {
thisObject.following = undefined
thisObject.followers = undefined
thisObject.posts = undefined
}
function initialize() {
thisObject.following = new Map()
thisObject.followers = new Map()
thisObject.followingCount = 0
thisObject.followersCount = 0
thisObject.emitterEventsCount = 0
thisObject.targetEventsCount = 0
thisObject.postsCount = 0
thisObject.posts = []
}
function addPost(
emitterUserProfileId,
targetUserProfileId,
emitterBotProfileId,
targetBotProfileId,
emitterPostHash,
targetPostHash,
postType,
timestamp
) {
if (NT.memory.maps.POSTS.get(emitterPostHash) !== undefined) {
throw ('Post Already Exists.')
}
let post = NT.modules.POST.newPost()
post.initialize(
emitterUserProfileId,
targetUserProfileId,
emitterBotProfileId,
targetBotProfileId,
emitterPostHash,
targetPostHash,
postType,
timestamp
)
thisObject.posts.push(post)
NT.memory.maps.POSTS.set(emitterPostHash, post)
thisObject.postsCount++
}
function removePost(
emitterPostHash
) {
if (NT.memory.maps.POSTS.get(emitterPostHash) === undefined) {
throw ('Post Does Not Exist.')
}
let post = thisObject.posts.get(emitterPostHash)
post.finalize()
for (let i = thisObject.posts.length - 1; i >= 0; i--) {
if (thisObject.posts[i].emitterPostHash === emitterPostHash) {
thisObject.posts.splice(i, 1)
break
}
}
NT.memory.maps.POSTS.delete(emitterPostHash)
thisObject.postsCount--
}
function addFollowing(
botProfile
) {
if (thisObject.following.get(botProfile.id) === undefined) {
thisObject.following.set(botProfile.id, botProfile)
thisObject.followingCount++
}
}
function removeFollowing(
botProfile
) {
if (thisObject.following.get(botProfile.id) !== undefined) {
thisObject.following.delete(botProfile.id)
thisObject.followingCount--
}
}
function addFollower(
botProfile
) {
if (thisObject.followers.get(botProfile.id) === undefined) {
thisObject.followers.set(botProfile.id, botProfile)
thisObject.followersCount++
}
}
function removeFollower(
botProfile
) {
if (thisObject.followers.get(botProfile.id) !== undefined) {
thisObject.followers.delete(botProfile.id)
thisObject.followersCount--
}
}
}
-76
View File
@@ -1,76 +0,0 @@
exports.newClientInterface = function newClientInterface() {
let thisObject = {
eventReceived: eventReceived,
queryReceived: queryReceived,
initialize: initialize,
finalize: finalize
}
return thisObject
function finalize() {
}
function initialize() {
}
function eventReceived(eventMessage) {
/*
We expect here a JSON string with the following properties:
{
"eventId": "a8de78f0-c3e4-4a2a-b7e8-f659073969db",
"eventType": 10,
"emitterUserProfileId": "a8de78f0-c3e4-4a2a-b7e8-f659073969db",
"targetUserProfileId": "a8de78f0-c3e4-4a2a-b7e8-f659073969db",
"emitterPostHash": "a8de78f0-c3e4-4a2a-b7e8-f659073969db",
"targetPostHash": "a8de78f0-c3e4-4a2a-b7e8-f659073969db",
"timestamp": 124234234234,
"botId": "a8de78f0-c3e4-4a2a-b7e8-f659073969db",
"botAsset": "BTC",
"botExchange": "Binance"
}
*/
let eventReceived = JSON.parse(eventMessage)
if (NT.memory.maps.EVENTS.get(eventReceived.eventId) !== undefined) {
throw ('Event Already Exists.')
}
let event = NT.modules.EVENT.newEvent()
event.initialize(eventReceived)
NT.memory.maps.EVENTS.set(eventReceived.eventId, event)
}
function queryReceived(queryMessage) {
/*
We expect here a JSON string with the following properties:
{
"equeryId": "a8de78f0-c3e4-4a2a-b7e8-f659073969db",
"queryType": 10,
"emitterUserProfileId": "a8de78f0-c3e4-4a2a-b7e8-f659073969db",
"targetUserProfileId": "a8de78f0-c3e4-4a2a-b7e8-f659073969db",
"emitterUserProfileHandle": "Luis-Fernando-Molina",
"targetUserProfileHandle": "Luis-Fernando-Molina",
"emitterPostHash": "a8de78f0-c3e4-4a2a-b7e8-f659073969db",
"targetPostHash": "a8de78f0-c3e4-4a2a-b7e8-f659073969db",
"timestamp": 124234234234,
"botId": "a8de78f0-c3e4-4a2a-b7e8-f659073969db",
"botAsset": "BTC",
"botExchange": "Binance",
"initialIndex": 35,
"amountRequested": 50,
"direction": "Past"
}
*/
let queryReceived = JSON.parse(queryMessage)
let query = NT.modules.QUERY.newQuery()
query.initialize(queryReceived)
return query.execute()
}
}
-321
View File
@@ -1,321 +0,0 @@
exports.newEvent = function newEvent() {
let thisObject = {
eventId: undefined,
emitterUserProfileId: undefined,
targetUserProfileId: undefined,
emitterBotProfileId: undefined,
targetBotProfileId: undefined,
emitterPostHash: undefined,
targetPostHash: undefined,
timestamp: undefined,
botId: undefined,
botAsset: undefined,
botExchange: undefined,
initialize: initialize,
finalize: finalize
}
const EVENT_TYPES = {
NEW_USER_POST: 10,
REPLY_TO_USER_POST: 11,
REPOST_USER_POST: 12,
QUOTE_REPOST_USER_POST: 13,
REMOVE_USER_POST: 14,
FOLLOW_USER_PROFILE: 15,
UNFOLLOW_USER_PROFILE: 16,
NEW_BOT_POST: 20,
REPLY_TO_BOT_POST: 21,
REPOST_BOT_POST: 22,
QUOTE_REPOST_BOT_POST: 23,
REMOVE_BOT_POST: 24,
FOLLOW_BOT_PROFILE: 25,
UNFOLLOW_BOT_PROFILE: 26,
ADD_BOT: 50,
REMOVE_BOT: 51,
ENABLE_BOT: 52,
DISABLE_BOT: 53,
ADD_REACTION_LIKE: 100,
ADD_REACTION_LOVE: 101,
ADD_REACTION_HAHA: 102,
ADD_REACTION_WOW: 103,
ADD_REACTION_SAD: 104,
ADD_REACTION_ANGRY: 105,
ADD_REACTION_HUG: 106,
REMOVE_REACTION_LIKE: 200,
REMOVE_REACTION_LOVE: 201,
REMOVE_REACTION_HAHA: 202,
REMOVE_REACTION_WOW: 203,
REMOVE_REACTION_SAD: 204,
REMOVE_REACTION_ANGRY: 205,
REMOVE_REACTION_HUG: 206
}
return thisObject
function finalize() {
emitterUserProfile = undefined
targetUserProfile = undefined
}
function initialize(eventReceived) {
/*
Store the message properties into this object properties.
*/
thisObject.eventId = eventReceived.eventId
thisObject.emitterUserProfileId = eventReceived.emitterUserProfileId
thisObject.targetUserProfileId = eventReceived.targetUserProfileId
thisObject.emitterBotProfileId = eventReceived.emitterBotProfileId
thisObject.targetBotProfileId = eventReceived.targetBotProfileId
thisObject.emitterPostHash = eventReceived.emitterPostHash
thisObject.targetPostHash = eventReceived.targetPostHash
thisObject.timestamp = eventReceived.timestamp
thisObject.botId = eventReceived.botId
thisObject.botAsset = eventReceived.botAsset
thisObject.botExchange = eventReceived.botExchange
/*
Validate Emitter User Profile.
*/
let emitterUserProfile = NT.memory.maps.USER_PROFILES_BY_ID.get(thisObject.emitterUserProfileId)
if (emitterUserProfile === undefined) {
throw ('Emitter User Profile Not Found.')
}
emitterUserProfile.emitterEventsCount++
/*
Validate Target User Profile.
*/
let targetUserProfile = NT.memory.maps.USER_PROFILES_BY_ID.get(thisObject.targetUserProfileId)
if (targetUserProfile === undefined) {
/* We thow an exception when it does not have a target user profile and is required*/
if (
thisObject.eventType !== EVENT_TYPES.NEW_USER_POST &&
thisObject.eventType !== EVENT_TYPES.NEW_BOT_POST
) {
throw ('Target User Profile Not Found.')
}
} else {
targetUserProfile.targetEventsCount++
}
/*
Validate Emitter Bot Profile.
*/
if (emitterBotProfileId !== undefined) {
let botProfile = emitterUserProfile.bots.get(emitterBotProfileId)
if (
emitterBotProfile === undefined
) {
throw ('Emitter BOt Profile Not Found.')
}
}
/*
Is is related to Posting?
*/
if (
thisObject.eventType === EVENT_TYPES.NEW_USER_POST ||
thisObject.eventType === EVENT_TYPES.REPLY_TO_USER_POST ||
thisObject.eventType === EVENT_TYPES.REPOST_USER_POST ||
thisObject.eventType === EVENT_TYPES.QUOTE_REPOST_USER_POST ||
thisObject.eventType === EVENT_TYPES.NEW_BOT_POST ||
thisObject.eventType === EVENT_TYPES.REPLY_TO_BOT_POST ||
thisObject.eventType === EVENT_TYPES.REPOST_BOT_POST ||
thisObject.eventType === EVENT_TYPES.QUOTE_REPOST_BOT_POST
) {
/*
New User Post
*/
if (
thisObject.eventType === EVENT_TYPES.NEW_USER_POST ||
thisObject.eventType === EVENT_TYPES.REPLY_TO_USER_POST ||
thisObject.eventType === EVENT_TYPES.REPOST_USER_POST ||
thisObject.eventType === EVENT_TYPES.QUOTE_REPOST_USER_POST
) {
emitterUserProfile.addPost(
thisObject.emitterUserProfileId,
thisObject.targetUserProfileId,
thisObject.emitterBotProfileId,
thisObject.targetBotProfileId,
thisObject.emitterPostHash,
thisObject.targetPostHash,
thisObject.eventType - 10,
thisObject.timestamp
)
return
}
/*
New Bot Post
*/
if (
thisObject.eventType === EVENT_TYPES.NEW_BOT_POST ||
thisObject.eventType === EVENT_TYPES.REPLY_TO_BOT_POST ||
thisObject.eventType === EVENT_TYPES.REPOST_BOT_POST ||
thisObject.eventType === EVENT_TYPES.QUOTE_REPOST_BOT_POST
) {
emitterBotProfile.addPost(
thisObject.emitterUserProfileId,
thisObject.targetUserProfileId,
thisObject.emitterBotProfileId,
thisObject.targetBotProfileId,
thisObject.emitterPostHash,
thisObject.targetPostHash,
thisObject.eventType - 20,
thisObject.timestamp
)
return
}
/*
Remove User Post
*/
if (
thisObject.eventType === EVENT_TYPES.REMOVE_USER_POST
) {
emitterUserProfile.removePost(
thisObject.emitterPostHash
)
return
}
/*
Remove Bot Post
*/
if (
thisObject.eventType === EVENT_TYPES.REMOVE_USER_POST
) {
emitterBotProfile.removePost(
thisObject.emitterPostHash
)
return
}
}
/*
Is is a following?
*/
if (
thisObject.eventType === EVENT_TYPES.FOLLOW_USER_PROFILE ||
thisObject.eventType === EVENT_TYPES.UNFOLLOW_USER_PROFILE ||
thisObject.eventType === EVENT_TYPES.FOLLOW_BOT_PROFILE ||
thisObject.eventType === EVENT_TYPES.UNFOLLOW_BOT_PROFILE
) {
switch (thisObject.eventType) {
case EVENT_TYPES.FOLLOW_USER_PROFILE: {
emitterUserProfile.addFollowing(
targetUserProfile
)
targetUserProfile.addFollower(
emitterUserProfile
)
break
}
case EVENT_TYPES.UNFOLLOW_USER_PROFILE: {
emitterUserProfile.removeFollowing(
targetUserProfile
)
targetUserProfile.removeFollower(
emitterUserProfile
)
break
}
case EVENT_TYPES.FOLLOW_BOT_PROFILE: {
emitterUserProfile.addTradePostsFollowing(
targetUserProfile
)
targetUserProfile.addTradePostsFollower(
emitterUserProfile
)
break
}
case EVENT_TYPES.UNFOLLOW_BOT_PROFILE: {
emitterUserProfile.removeTradePostsFollowing(
targetUserProfile
)
targetUserProfile.removeTradePostsFollower(
emitterUserProfile
)
break
}
}
return
}
/*
Is is a Reaction?
*/
if (
thisObject.eventType === EVENT_TYPES.ADD_REACTION_LIKE ||
thisObject.eventType === EVENT_TYPES.ADD_REACTION_LOVE ||
thisObject.eventType === EVENT_TYPES.ADD_REACTION_HAHA ||
thisObject.eventType === EVENT_TYPES.ADD_REACTION_WOW ||
thisObject.eventType === EVENT_TYPES.ADD_REACTION_SAD ||
thisObject.eventType === EVENT_TYPES.ADD_REACTION_ANGRY ||
thisObject.eventType === EVENT_TYPES.ADD_REACTION_HUG
) {
let targetPost = NT.memory.maps.POSTS.get(thisObject.targetPostHash)
if (targetPost === undefined) {
throw ('Target Post Not Found')
}
targetPost.addReaction(thisObject.eventType - 100)
return
}
if (
thisObject.eventType === EVENT_TYPES.REMOVE_REACTION_LIKE ||
thisObject.eventType === EVENT_TYPES.REMOVE_REACTION_LOVE ||
thisObject.eventType === EVENT_TYPES.REMOVE_REACTION_HAHA ||
thisObject.eventType === EVENT_TYPES.REMOVE_REACTION_WOW ||
thisObject.eventType === EVENT_TYPES.REMOVE_REACTION_SAD ||
thisObject.eventType === EVENT_TYPES.REMOVE_REACTION_ANGRY ||
thisObject.eventType === EVENT_TYPES.REMOVE_REACTION_HUG
) {
let targetPost = NT.memory.maps.POSTS.get(thisObject.targetPostHash)
if (targetPost === undefined) {
throw ('Target Post Not Found')
}
targetPost.removeReaction(thisObject.eventType - 200)
return
}
/*
Is is a Bot?
*/
if (
thisObject.eventType === EVENT_TYPES.ADD_BOT ||
thisObject.eventType === EVENT_TYPES.REMOVE_BOT ||
thisObject.eventType === EVENT_TYPES.ENABLE_BOT ||
thisObject.eventType === EVENT_TYPES.DISABLE_BOT
) {
switch (thisObject.eventType) {
case EVENT_TYPES.ADD_BOT: {
emitterUserProfile.addBot(
thisObject.botId,
thisObject.botAsset,
thisObject.botExchange
)
break
}
case EVENT_TYPES.REMOVE_BOT: {
emitterUserProfile.removeBot(
thisObject.botId
)
break
}
case EVENT_TYPES.ENABLE_BOT: {
emitterUserProfile.enableBot(
thisObject.botId
)
break
}
case EVENT_TYPES.DISABLE_BOT: {
emitterUserProfile.disableBot(
thisObject.botId
)
break
}
}
return
}
}
}
-129
View File
@@ -1,129 +0,0 @@
exports.newPost = function newPost() {
let thisObject = {
emitterUserProfileId: undefined,
targetUserProfileId: undefined,
emitterBotProfileId: undefined,
targetBotProfileId: undefined,
emitterPostHash: undefined,
targetPostHash: undefined,
postType: undefined,
timestamp: undefined,
replies: undefined,
reactionsCount: undefined,
reactionTypesCount: undefined,
addReaction: addReaction,
removeReactions: removeReaction,
initialize: initialize,
finalize: finalize
}
const POST_TYPES = {
NEW_POST: 0,
REPLY_TO_POST: 1,
REPOST_: 2,
QUOTE_REPOST_: 3
}
const REACTION_TYPES = {
REACTION_LIKE: 0,
REACTION_LOVE: 1,
REACTION_HAHA: 2,
REACTION_WOW: 3,
REACTION_SAD: 4,
REACTION_ANGRY: 5,
REACTION_HUG: 6
}
thisObject.reactionTypesCount = 7
thisObject.reactionsCount = new Map()
thisObject.reactionsCount.set(REACTION_TYPES.REACTION_LIKE, 0)
thisObject.reactionsCount.set(REACTION_TYPES.REACTION_LOVE, 0)
thisObject.reactionsCount.set(REACTION_TYPES.REACTION_HAHA, 0)
thisObject.reactionsCount.set(REACTION_TYPES.REACTION_WOW, 0)
thisObject.reactionsCount.set(REACTION_TYPES.REACTION_SAD, 0)
thisObject.reactionsCount.set(REACTION_TYPES.REACTION_ANGRY, 0)
thisObject.reactionsCount.set(REACTION_TYPES.REACTION_HUG, 0)
return thisObject
function finalize() {
thisObject.emitterUserProfileId = undefined
thisObject.targetUserProfileId = undefined
thisObject.emitterBotProfileId = undefined
thisObject.targetBotProfileId = undefined
thisObject.emitterPostHash = undefined
thisObject.targetPostHash = undefined
thisObject.postType = undefined
thisObject.timestamp = undefined
thisObject.replies = undefined
}
function initialize(
emitterUserProfileId,
targetUserProfileId,
emitterBotProfileId,
targetBotProfileId,
emitterPostHash,
targetPostHash,
postType,
timestamp
) {
thisObject.emitterUserProfileId = emitterUserProfileId
thisObject.targetUserProfileId = targetUserProfileId
thisObject.emitterBotProfileId = emitterBotProfileId
thisObject.targetBotProfileId = targetBotProfileId
thisObject.emitterPostHash = emitterPostHash
thisObject.targetPostHash = targetPostHash
thisObject.postType = postType
thisObject.timestamp = timestamp
thisObject.replies = []
/*
Let's find the Target Post
*/
let targetPost
if (
thisObject.postType === POST_TYPES.REPLY_TO_POST ||
thisObject.postType === POST_TYPES.REPOST_ ||
thisObject.postType === POST_TYPES.QUOTE_REPOST_
) {
targetPost = NT.memory.maps.POSTS.get(thisObject.targetPostHash)
if (targetPost === undefined) {
throw ('Target Post Not Found.')
}
}
/*
Let's add this post to the replies of the Target Post
*/
if (
thisObject.postType === POST_TYPES.REPLY_TO_POST
) {
targetPost.replies.push(thisObject)
}
}
function addReaction(reactionType) {
let reactionCount = thisObject.reactionsCount.get(reactionType)
if (reactionCount === undefined) {
throw ('Reaction Type Not Supported.')
}
thisObject.reactionsCount.set(reactionType, reactionsCount + 1)
}
function removeReaction(reactionType) {
let reactionCount = thisObject.reactionsCount.get(reactionType)
if (reactionCount === undefined) {
throw ('Reaction Type Not Supported.')
}
thisObject.reactionsCount.set(reactionType, reactionsCount - 1)
}
}
-203
View File
@@ -1,203 +0,0 @@
exports.newUserProfile = function newUserProfile() {
let thisObject = {
userProfieId: undefined,
userProfileHandle: undefined,
blockchainAccount: undefined,
ranking: undefined,
following: undefined,
followers: undefined,
followingCount: undefined,
followersCount: undefined,
emitterEventsCount: undefined,
targetEventsCount: undefined,
postsCount: undefined,
botsCount: undefined,
bots: undefined,
posts: undefined,
addPost: addPost,
removePost: removePost,
addFollowing: addFollowing,
removeFollowing: removeFollowing,
addFollower: addFollower,
removeFollower: removeFollower,
addBot: addBot,
removeBot: removeBot,
enableBot: enableBot,
disableBot: disableBot,
initialize: initialize,
finalize: finalize
}
return thisObject
function finalize() {
thisObject.following = undefined
thisObject.followers = undefined
thisObject.posts = undefined
thisObject.bots = undefined
}
function initialize() {
thisObject.following = new Map()
thisObject.followers = new Map()
thisObject.followingCount = 0
thisObject.followersCount = 0
thisObject.emitterEventsCount = 0
thisObject.targetEventsCount = 0
thisObject.postsCount = 0
thisObject.botsCount = 0
thisObject.posts = []
thisObject.bots = []
}
function addPost(
emitterUserProfileId,
targetUserProfileId,
emitterPostHash,
targetPostHash,
postType,
timestamp
) {
if (NT.memory.maps.POSTS.get(emitterPostHash) !== undefined) {
throw ('Post Already Exists.')
}
let post = NT.modules.POST.newPost()
post.initialize(
emitterUserProfileId,
targetUserProfileId,
undefined,
undefined,
emitterPostHash,
targetPostHash,
postType,
timestamp
)
thisObject.posts.push(post)
NT.memory.maps.POSTS.set(emitterPostHash, post)
thisObject.postsCount++
}
function removePost(
emitterPostHash
) {
if (NT.memory.maps.POSTS.get(emitterPostHash) === undefined) {
throw ('Post Does Not Exist.')
}
let post = thisObject.posts.get(emitterPostHash)
post.finalize()
for (let i = thisObject.posts.length - 1; i >= 0; i--) {
if (thisObject.posts[i].emitterPostHash === emitterPostHash) {
thisObject.posts.splice(i, 1)
break
}
}
NT.memory.maps.POSTS.delete(emitterPostHash)
thisObject.postsCount--
}
function addFollowing(
userProfile
) {
if (thisObject.following.get(userProfile.id) === undefined) {
thisObject.following.set(userProfile.id, userProfile)
thisObject.followingCount++
}
}
function removeFollowing(
userProfile
) {
if (thisObject.following.get(userProfile.id) !== undefined) {
thisObject.following.delete(userProfile.id)
thisObject.followingCount--
}
}
function addFollower(
userProfile
) {
if (thisObject.followers.get(userProfile.id) === undefined) {
thisObject.followers.set(userProfile.id, userProfile)
thisObject.followersCount++
}
}
function removeFollower(
userProfile
) {
if (thisObject.followers.get(userProfile.id) !== undefined) {
thisObject.followers.delete(userProfile.id)
thisObject.followersCount--
}
}
function addBot(
botId,
botAsset,
botExchange
) {
if (thisObject.bots.get(botId) !== undefined) {
throw ('Bot Already Exists.')
}
let bot = NT.modules.BOTS.newBot()
bot.initialize(
botId,
botAsset,
botExchange
)
thisObject.bots.set(botId, bot)
thisObject.botsCount++
}
function removeBot(
botId
) {
if (thisObject.bots.get(botId) === undefined) {
throw ('Bot Does Not Exist.')
}
thisObject.bots.get(botId).finalize()
thisObject.bots.delete(botId)
thisObject.botsCount--
}
function enableBot(
botId
) {
let bot = thisObject.bots.get(botId)
if (bot === undefined) {
throw ('Bot Does Not Exist.')
}
if (bot.enabled === true) {
throw ('Bot Already Enabled.')
}
bot.enabled = true
}
function disableBot(
botId
) {
let bot = thisObject.bots.get(botId)
if (bot === undefined) {
throw ('Bot Does Not Exist.')
}
if (bot.enabled === false) {
throw ('Bot Already Disabled.')
}
bot.enabled = false
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -472,14 +472,14 @@ exports.newGithubServer = function newGithubServer() {
unless the existing one belongs to the same Github username.
*/
let userProfileIdMap = new Map()
let pluginFileNames = await CL.projects.foundations.utilities.plugins.getPluginFileNames(
let pluginFileNames = await SA.projects.foundations.utilities.plugins.getPluginFileNames(
'Governance',
'User-Profiles'
)
for (let i = 0; i < pluginFileNames.length; i++) {
let pluginFileName = pluginFileNames[i]
let pluginFileContent = await CL.projects.foundations.utilities.plugins.getPluginFileContent(
let pluginFileContent = await SA.projects.foundations.utilities.plugins.getPluginFileContent(
'Governance',
'User-Profiles',
pluginFileName
@@ -522,13 +522,13 @@ exports.newGithubServer = function newGithubServer() {
unless the existing one belongs to the same Github username.
*/
let userProfileIdMap = new Map()
let pluginFileNames = await CL.projects.foundations.utilities.plugins.getPluginFileNames(
let pluginFileNames = await SA.projects.foundations.utilities.plugins.getPluginFileNames(
'Governance',
'User-Profiles'
)
for (let i = 0; i < pluginFileNames.length; i++) {
let pluginFileName = pluginFileNames[i]
let pluginFileContent = await CL.projects.foundations.utilities.plugins.getPluginFileContent(
let pluginFileContent = await SA.projects.foundations.utilities.plugins.getPluginFileContent(
'Governance',
'User-Profiles',
pluginFileName
File diff suppressed because it is too large. Load diff
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -4,26 +4,21 @@
let thisObject = {
initialize: initialize,
finalize: finalize,
run: run
finalize: finalize
}
const WEB_SOCKET = require('ws')
let socketServer
let port = global.env.WEB_SOCKETS_INTERFACE_PORT
let port = global.env.CLIENT_WEB_SOCKETS_INTERFACE_PORT
return thisObject
function finalize() {
socketServer = undefined
}
function initialize() {
}
function run() {
setUpWebSocketServer()
setUpWebSocketServer()
}
function setUpWebSocketServer() {
@@ -47,8 +42,8 @@
if (LOG_INFO === true) {
console.log('Message Received: ' + message.substring(0, 1000))
}
let messageArray = message.split('|*|')
let messageArray = message.toString().split('|*|')
let origin = messageArray[0]
let nonce = messageArray[1]
+79 -66
View File
@@ -6,92 +6,107 @@ global.env = ENVIRONMENT_MODULE
process.on('uncaughtException', function (err) {
if (err.message && err.message.indexOf("EADDRINUSE") > 0) {
console.log("A Superalgos Client cannot be started. Reason: the port configured migth be being used by another application.")
console.log("The Superalgos Platform Client cannot be started. Reason: the port configured migth be being used by another application, or Superalgos Platform Client might be already running.")
return
}
console.log('[ERROR] Client -> client-> uncaughtException -> err.message = ' + err.message)
console.log('[ERROR] Client -> client-> uncaughtException -> err.stack = ' + err.stack)
console.log('[ERROR] Client -> client-> uncaughtException -> err = ' + err)
console.log('[ERROR] Platform App -> uncaughtException -> err.message = ' + err.message)
console.log('[ERROR] Platform App -> uncaughtException -> err.stack = ' + err.stack)
console.log('[ERROR] Platform App -> uncaughtException -> err = ' + err)
process.exit(1)
})
process.on('unhandledRejection', (reason, p) => {
// Signal user that a necissary node module is missing
if (reason.code == 'MODULE_NOT_FOUND') {
console.log("[ERROR] Dependency library not found. Please try running the 'node setup' command and then restart the Client.")
console.log('[ERROR] Client -> client-> reason = ' + JSON.stringify(reason))
console.log("[ERROR] Dependency library not found. Please try running the 'node setup' command and then restart the Superalgos Platform Client.")
console.log('[ERROR] Platform App -> reason = ' + JSON.stringify(reason))
process.exit(1)
}
console.log('[ERROR] Client -> client-> unhandledRejection -> reason = ' + JSON.stringify(reason))
console.log('[ERROR] Client -> client-> unhandledRejection -> p = ' + JSON.stringify(p))
console.log('[ERROR] Platform App -> unhandledRejection -> reason = ' + JSON.stringify(reason))
console.log('[ERROR] Platform App -> unhandledRejection -> p = ' + JSON.stringify(p))
process.exit(1)
})
/* Callbacks default responses. */
global.DEFAULT_OK_RESPONSE = {
result: "Ok",
message: "Operation Succeeded"
};
global.DEFAULT_FAIL_RESPONSE = {
result: "Fail",
message: "Operation Failed"
};
global.DEFAULT_RETRY_RESPONSE = {
result: 'Retry',
message: 'Retry Later'
}
global.CUSTOM_OK_RESPONSE = {
result: 'Ok, but check Message',
message: 'Custom Message'
}
global.CUSTOM_FAIL_RESPONSE = {
result: 'Fail Because',
message: 'Custom Message'
}
/* The CL object is accesible everywhere at the Superalgos Client */
global.CL = {}
/* Servers */
let WEB_SERVER = require('./webServer.js')
let DATA_FILE_SERVER = require('./dataFileServer.js')
let PROJECT_FILE_SERVER = require('./projectFileServer.js')
let UI_FILE_SERVER = require('./uiFileServer.js')
let PLUGIN_SERVER = require('./pluginServer.js')
let EVENT_SERVER = require('./eventServer.js')
let TASK_MANAGER_SERVER = require('./taskManagerServer.js')
let CCXT_SERVER = require('./ccxtServer.js')
let WEB3_SERVER = require('./web3Server.js')
let GITHUB_SERVER = require('./githubServer.js')
/* Network Interfaces */
let WEB_SOCKETS_INTERFACE = require('./webSocketsInterface.js')
let HTTP_INTERFACE = require('./httpInterface.js')
try {
/* Callbacks default responses. */
global.DEFAULT_OK_RESPONSE = {
result: "Ok",
message: "Operation Succeeded"
};
global.DEFAULT_FAIL_RESPONSE = {
result: "Fail",
message: "Operation Failed"
};
global.DEFAULT_RETRY_RESPONSE = {
result: 'Retry',
message: 'Retry Later'
}
global.CUSTOM_OK_RESPONSE = {
result: 'Ok, but check Message',
message: 'Custom Message'
}
global.CUSTOM_FAIL_RESPONSE = {
result: 'Fail Because',
message: 'Custom Message'
}
/* Servers */
let WEB_SERVER = require('./Client/webServer.js')
let DATA_FILE_SERVER = require('./Client/dataFileServer.js')
let PROJECT_FILE_SERVER = require('./Client/projectFileServer.js')
let UI_FILE_SERVER = require('./Client/uiFileServer.js')
let PLUGIN_SERVER = require('./Client/pluginServer.js')
let EVENT_SERVER = require('./Client/eventServer.js')
let TASK_MANAGER_SERVER = require('./Client/taskManagerServer.js')
let CCXT_SERVER = require('./Client/ccxtServer.js')
let WEB3_SERVER = require('./Client/web3Server.js')
let GITHUB_SERVER = require('./Client/githubServer.js')
/* Network Interfaces */
let WEB_SOCKETS_INTERFACE = require('./Client/webSocketsInterface.js')
let HTTP_INTERFACE = require('./Client/httpInterface.js')
/*
The CL object is accesible everywhere at the Superalgos Client.
It provides access to all modules built for this Client.
*/
global.CL = {}
/*
The SA object is accesible everywhere at the Superalgos Client.
It provides access to all modules built for Superalgos in general.
*/
global.SA = {}
/*
First thing is to load the project schema file.
*/
global.PROJECTS_SCHEMA = require(global.env.PATH_TO_PROJECT_SCHEMA)
/*
Setting up the modules that will be available for the Servers Running inside this Client
*/
let MULTI_PROJECT = require('./MultiProject.js');
let MULTI_PROJECT = require('../MultiProject.js');
let MULTI_PROJECT_MODULE = MULTI_PROJECT.newMultiProject()
MULTI_PROJECT_MODULE.initialize()
MULTI_PROJECT_MODULE.initialize(CL, 'CL')
MULTI_PROJECT_MODULE.initialize(SA, 'SA')
/*
Setting up external dependencies.
*/
CL.nodeModules = {
SA.nodeModules = {
fs: require('fs'),
nodeFetch: require('node-fetch')
nodeFetch: require('node-fetch'),
open: require('open'),
http: require('http'),
ccxt: require('ccxt')
}
/*
Setting up servers running inside this Client.
*/
CL.servers = {}
console.log('CLIENT SERVERS:')
console.log('SUPERALGOS PLATFORM CLIENT SERVERS:')
console.log('')
CL.servers.WEB_SERVER = WEB_SERVER.newWebServer()
@@ -145,18 +160,16 @@ try {
console.log('Github Server ............................................... Started')
console.log('')
console.log('CLIENT INTERFACES:')
console.log('SUPERALGOS PLATFORM CLIENT INTERFACES:')
console.log('')
WEB_SOCKETS_INTERFACE = WEB_SOCKETS_INTERFACE.newWebSocketsInterface()
WEB_SOCKETS_INTERFACE.initialize()
WEB_SOCKETS_INTERFACE.run()
console.log('Web Sockets Interface ....................................... Listening at port ' + global.env.WEB_SOCKETS_INTERFACE_PORT)
console.log('Web Sockets Interface ....................................... Listening at port ' + global.env.CLIENT_WEB_SOCKETS_INTERFACE_PORT)
HTTP_INTERFACE = HTTP_INTERFACE.newHttpInterface()
HTTP_INTERFACE.initialize()
HTTP_INTERFACE.run()
console.log('Http Interface .............................................. Listening at port ' + global.env.HTTP_INTERFACE_PORT)
console.log('Http Interface .............................................. Listening at port ' + global.env.CLIENT_HTTP_INTERFACE_PORT)
console.log('')
console.log("You are running Superalgos Beta 11")
@@ -176,6 +189,6 @@ try {
console.log('')
} catch (err) {
console.log('[ERROR] Client -> Error = ' + err.stack)
console.log('[ERROR] Platform App -> Error = ' + err.stack)
}
File renamed without changes.
File renamed without changes.
+190
View File
@@ -0,0 +1,190 @@
let postLoader
function newAppLoader() {
const MODULE_NAME = 'App Loader'
const INFO_LOG = false
const ERROR_LOG = true
const logger = newWebDebugLog()
let thisObject = {
loadModules: loadModules
}
return thisObject
async function loadModules() {
try {
if (INFO_LOG === true) { logger.write('[INFO] loadModules -> Entering function.') }
let plotters
let modulesArray = []
plotters = defaultPlotters()
modulesArray = modulesArray.concat([
'Globals.js',
'Workspace.js',
'Files/SingleFile.js',
'Files/FileCloud.js',
'Files/MarketFiles.js',
'Files/DailyFiles.js',
'Files/FileCursor.js',
'Files/FileSequence.js',
'Files/FileStorage.js',
'EventsServerClient.js',
'LegacyPlotter.js',
'PlotterPanel.js',
'VideoRecorder.js',
'ProductStorage.js',
'Canvas.js',
'EventHandler.js',
'Frame.js',
'Animation.js',
'Container.js',
'Utilities.js',
'AppPostLoader.js'
])
modulesArray = modulesArray.concat(plotters)
functionLibraries()
function functionLibraries() {
let url = 'ListFunctionLibraries'
httpRequest(undefined, url, onResponse)
function onResponse(err, fileList) {
let urlArray = []
let fileArray = JSON.parse(fileList)
for (let i = 0; i < fileArray.length; i++) {
let item = fileArray[i]
project = item[0]
fileName = item[1]
urlArray.push('Projects' + '/' + project + '/' + 'UI' + '/' + 'Function-Libraries' + '/' + fileName)
}
modulesArray = modulesArray.concat(urlArray)
utilities()
}
}
function utilities() {
let url = 'ListUtilitiesFiles'
httpRequest(undefined, url, onResponse)
function onResponse(err, fileList) {
let urlArray = []
let fileArray = JSON.parse(fileList)
for (let i = 0; i < fileArray.length; i++) {
let item = fileArray[i]
project = item[0]
fileName = item[1]
urlArray.push('Projects' + '/' + project + '/' + 'UI' + '/' + 'Utilities' + '/' + fileName)
}
modulesArray = modulesArray.concat(urlArray)
globals()
}
}
function globals() {
let url = 'ListGlobalFiles'
httpRequest(undefined, url, onResponse)
function onResponse(err, fileList) {
let urlArray = []
let fileArray = JSON.parse(fileList)
for (let i = 0; i < fileArray.length; i++) {
let item = fileArray[i]
project = item[0]
fileName = item[1]
urlArray.push('Projects' + '/' + project + '/' + 'UI' + '/' + 'Globals' + '/' + fileName)
}
modulesArray = modulesArray.concat(urlArray)
spaces()
}
}
function spaces() {
let url = 'ListSpaceFiles'
httpRequest(undefined, url, onResponse)
function onResponse(err, fileList) {
let urlArray = []
let fileArray = JSON.parse(fileList)
for (let i = 0; i < fileArray.length; i++) {
let path = fileArray[i]
urlArray.push('Projects' + '/' + path)
}
modulesArray = modulesArray.concat(urlArray)
downloadIncludedFiles()
}
}
function downloadIncludedFiles() {
let downloadedCounter = 0
for (let i = 0; i < modulesArray.length; i++) {
let path = modulesArray[i]
REQUIREJS([path], onRequired)
if (INFO_LOG === true) { logger.write('[INFO] loadModules -> Module Requested.') }
if (INFO_LOG === true) { logger.write('[INFO] loadModules -> path = ' + path) }
if (INFO_LOG === true) { logger.write('[INFO] loadModules -> total requested = ' + (i + 1)) }
function onRequired(pModule) {
try {
if (INFO_LOG === true) { logger.write('[INFO] loadModules -> onRequired -> Entering function.') }
if (INFO_LOG === true) { logger.write('[INFO] loadModules -> onRequired -> Module Downloaded.') }
if (INFO_LOG === true) { logger.write('[INFO] loadModules -> onRequired -> path = ' + path) }
downloadedCounter++
if (INFO_LOG === true) { logger.write('[INFO] loadModules -> onRequired -> downloadedCounter = ' + downloadedCounter) }
if (downloadedCounter === modulesArray.length) {
if (INFO_LOG === true) { logger.write('[INFO] loadModules -> onRequired -> Starting Advanced Algos Platform.') }
setTimeout(() => {
postLoader = newAppPostLoader()
postLoader.start()
}, 500)
}
} catch (err) {
if (ERROR_LOG === true) { logger.write('[ERROR] loadModules -> onRequired -> err = ' + err.stack) }
}
}
}
}
} catch (err) {
if (ERROR_LOG === true) { logger.write('[ERROR] loadModules -> err = ' + err.stack) }
}
}
function defaultPlotters() {
return [
'Plotters/Foundations/Candles/Plotters-Candles-Volumes/Candles.js',
'Plotters/Foundations/Candles/Plotters-Candles-Volumes/CandlePanel.js',
'Plotters/Foundations/Candles/Plotters-Candles-Volumes/Volumes.js',
'Plotters/Foundations/Candles/Plotters-Candles-Volumes/VolumePanel.js',
'Plotters/Foundations/Bollinger/Plotters-Bollinger-Bands/BollingerBands.js',
'Plotters/Foundations/Bollinger/Plotters-Bollinger-Bands/BollingerBandsPanel.js',
'Plotters/Foundations/Bollinger/Plotters-Bollinger-Bands/PercentageBandwidth.js'
]
}
}
File renamed without changes.
File renamed without changes.
+10
View File
@@ -121,6 +121,8 @@ function newCanvas() {
let spaceAnimationDrawMap = new Map()
let spaceDefinitionDrawMap = new Map()
if (projectDefinition.UI === undefined) { continue }
/* Set up Globals of this Project */
if (projectDefinition.UI.globals !== undefined) {
for (let j = 0; j < projectDefinition.UI.globals.length; j++) {
@@ -742,6 +744,8 @@ function newCanvas() {
let projectInstance = UI.projects[projectDefinition.propertyName]
if (projectInstance === undefined) { continue }
if (projectDefinition.UI === undefined) { continue }
if (projectDefinition.UI.spaces === undefined) { continue }
for (let j = 0; j < projectDefinition.UI.spaces.length; j++) {
let spaceInstance = projectInstance.events.onMouseDownMap.get(j)
if (spaceInstance === undefined) { continue }
@@ -850,6 +854,8 @@ function newCanvas() {
let projectInstance = UI.projects[projectDefinition.propertyName]
if (projectInstance === undefined) { continue }
if (projectDefinition.UI === undefined) { continue }
if (projectDefinition.UI.spaces === undefined) { continue }
for (let j = 0; j < projectDefinition.UI.spaces.length; j++) {
let spaceInstance = projectInstance.events.onMouseClickMap.get(j)
if (spaceInstance === undefined) { continue }
@@ -966,6 +972,8 @@ function newCanvas() {
let projectInstance = UI.projects[projectDefinition.propertyName]
if (projectInstance === undefined) { continue }
if (projectDefinition.UI === undefined) { continue }
if (projectDefinition.UI.spaces === undefined) { continue }
for (let j = 0; j < projectDefinition.UI.spaces.length; j++) {
let spaceInstance = projectInstance.events.onMouseOverMap.get(j)
if (spaceInstance === undefined) { continue }
@@ -1028,6 +1036,8 @@ function newCanvas() {
let projectInstance = UI.projects[projectDefinition.propertyName]
if (projectInstance === undefined) { continue }
if (projectDefinition.UI === undefined) { continue }
if (projectDefinition.UI.spaces === undefined) { continue }
for (let j = 0; j < projectDefinition.UI.spaces.length; j++) {
let spaceInstance = projectInstance.events.onMouseWheelMap.get(j)
if (spaceInstance === undefined) { continue }
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

File renamed without changes.
File renamed without changes.
Loaded 100 of 373 files, more files were not shown because too many files have changed in this diff. Show more