@ospin/fct-graph
Advanced tools
Comparing version 6.0.7 to 6.1.0
{ | ||
"name": "@ospin/fct-graph", | ||
"author": "OSPIN webapp team", | ||
"version": "6.0.7", | ||
"version": "6.1.0", | ||
"description": "Graph data structure with conditional edges via 'slots' on nodes. Intended to represent physical and virtual functionalities on a device.", | ||
@@ -6,0 +6,0 @@ "main": "index.js", |
@@ -27,6 +27,11 @@ const Joi = require('joi') | ||
const connectsFct = (dataStream, fctId) => ( | ||
dataStream.sourceFctId === fctId || dataStream.sinkFctId === fctId | ||
) | ||
module.exports = { | ||
SCHEMA, | ||
create, | ||
connectsFct, | ||
connectsToFctSlot, | ||
} |
@@ -6,2 +6,3 @@ const Joi = require('joi') | ||
const Slot = require('../slots/Slot') | ||
const DataStream = require('../dataStreams/DataStream') | ||
const RegexUtils = require('../utils/RegexUtils') | ||
@@ -331,2 +332,29 @@ | ||
const removeFunctionality = (fctGraph, fctId) => { | ||
const graphWithoutFct = update(fctGraph, { | ||
functionalities: fctGraph.functionalities.filter(fct => fct.id !== fctId), | ||
}) | ||
/* removing all connections to that fct */ | ||
return update(graphWithoutFct, { | ||
functionalities: graphWithoutFct.functionalities.map(fct => ({ | ||
...fct, | ||
slots: fct.slots.map(slot => ({ | ||
...slot, | ||
dataStreams: slot.dataStreams.filter(ds => !DataStream.connectsFct(ds, fctId)), | ||
})), | ||
})), | ||
}) | ||
} | ||
const removeIntervalOutNode = (fctGraph, fctId, slotName) => { | ||
const intervalOutFctId = getReporterFctIdForSlot(fctGraph, fctId, slotName) | ||
return removeFunctionality(fctGraph, intervalOutFctId) | ||
} | ||
const removePushInNode = (fctGraph, fctId, slotName) => { | ||
const pushInFctId = getInputNodeFctIdForSlot(fctGraph, fctId, slotName) | ||
return removeFunctionality(fctGraph, pushInFctId) | ||
} | ||
module.exports = { | ||
@@ -364,2 +392,5 @@ SCHEMA, | ||
fctsDeepEquals, | ||
removeFunctionality, | ||
removeIntervalOutNode, | ||
removePushInNode, | ||
} |
73219
1097