in source/backend/functions/graph-api/src/index.js [42:84]
function getNodes({id: vId, arn}) {
return async g => {
const start = vId == null ? g.V().has('arn', arn) : g.V(vId);
const nodes = await start
.hasNot('softDelete')
.optional(__.both().hasNot('softDelete'))
.path()
.by(__.elementMap())
.unfold()
.dedup()
.toList();
return Promise.resolve(nodes)
.then(R.reduce((acc, {label, vpcId, subnetId, resourceType}) => {
const present = ['AWS::EC2::VPC', 'AWS::EC2::Subnet'].includes(resourceType);
if(resourceType === 'AWS::EC2::VPC') {
acc[vpcId] = {propName: 'vpcId', label, present}
} else if (resourceType === 'AWS::EC2::Subnet') {
acc[subnetId] = {propName: 'subnetId', label, present}
} else if (vpcId != null && acc[vpcId] == null) {
acc[vpcId] = {propName: 'vpcId', label, present};
} else if (subnetId != null && acc[subnetId] == null) {
acc[subnetId] = {propName: 'subnetId', label, present};
}
return acc;
}, {}))
.then(Object.entries)
.then(R.reject(([_, {present}]) => present))
.then(R.map(([id, {propName, label}]) => g.V().has(propName, id).hasLabel(label).hasNot('softDelete').elementMap().next().then(x => x.value)))
.then(ps => Promise.all(ps))
.then(xs => [xs, nodes])
.then(R.chain(R.map(async ({id, label, perspectiveBirthDate, ...props}) => {
if(props.resourceType === 'AWS::EC2::Subnet') {
props.private = await run(isPrivateSubnet(id));
}
return {
id, label: label.replace(/_/g, '::'), parent: vId === id, perspectiveBirthDate, properties: createProperties(props)
};
})))
.then(ps => Promise.all(ps));
};
}