Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
addressSpace.modelChangeTransaction(() => {
// ...
for (const r of references) {
const target = addressSpace.findNode(r.nodeId)!;
const modelChangeSrc_l = new ModelChangeStructureDataType({
affected: target.nodeId,
affectedType: null,
verb: makeVerb("ReferenceDeleted")
});
addressSpace._collectModelChange(null, modelChangeSrc_l);
}
const modelChangeSrc = new ModelChangeStructureDataType({
affected: node.nodeId,
affectedType: node.typeDefinition,
verb: makeVerb("NodeDeleted")
});
addressSpace._collectModelChange(null, modelChangeSrc);
});
affected: node.nodeId,
affectedType: typeDefinitionNodeId,
verb: makeVerb("NodeAdded")
});
addressSpace._collectModelChange(null, modelChange1);
const modelChangeSrc = new ModelChangeStructureDataType({
affected: parent.nodeId,
affectedType: null,
verb: makeVerb("ReferenceAdded")
});
addressSpace._collectModelChange(null, modelChangeSrc);
// bidirectional
if (node.nodeVersion) {
const modelChangeTgt = new ModelChangeStructureDataType({
affected: node.nodeId,
affectedType: typeDefinitionNodeId,
verb: makeVerb("ReferenceAdded")
});
addressSpace._collectModelChange(null, modelChangeTgt);
}
});
}
addressSpace.modelChangeTransaction(() => {
let typeDefinitionNodeId = null;
if (node.nodeClass === NodeClass.Object || node.nodeClass === NodeClass.Variable) {
typeDefinitionNodeId = node.typeDefinitionObj.nodeId;
}
const modelChange1 = new ModelChangeStructureDataType({
affected: node.nodeId,
affectedType: typeDefinitionNodeId,
verb: makeVerb("NodeAdded")
});
addressSpace._collectModelChange(null, modelChange1);
const modelChangeSrc = new ModelChangeStructureDataType({
affected: parent.nodeId,
affectedType: null,
verb: makeVerb("ReferenceAdded")
});
addressSpace._collectModelChange(null, modelChangeSrc);
// bidirectional
if (node.nodeVersion) {
const modelChangeTgt = new ModelChangeStructureDataType({
affected: node.nodeId,
affectedType: typeDefinitionNodeId,
verb: makeVerb("ReferenceAdded")
});
addressSpace._collectModelChange(null, modelChangeTgt);
}
});
addressSpace.modelChangeTransaction(() => {
let typeDefinitionNodeId = null;
if (node.nodeClass === NodeClass.Object || node.nodeClass === NodeClass.Variable) {
typeDefinitionNodeId = node.typeDefinitionObj.nodeId;
}
const modelChange1 = new ModelChangeStructureDataType({
affected: node.nodeId,
affectedType: typeDefinitionNodeId,
verb: makeVerb("NodeAdded")
});
addressSpace._collectModelChange(null, modelChange1);
const modelChangeSrc = new ModelChangeStructureDataType({
affected: parent.nodeId,
affectedType: null,
verb: makeVerb("ReferenceAdded")
});
addressSpace._collectModelChange(null, modelChangeSrc);
// bidirectional
if (node.nodeVersion) {
const modelChangeTgt = new ModelChangeStructureDataType({
function _getTypeDef(node: BaseNode) {
if (node.nodeClass === NodeClass.Object || node.nodeClass === NodeClass.Variable) {
return node.typeDefinitionObj.nodeId;
}
return null;
}
let modelChangeTgt = new ModelChangeStructureDataType({
affected: node1.nodeId,
affectedType: _getTypeDef(node1),
verb: makeVerb("ReferenceAdded")
});
addressSpace._collectModelChange(null, modelChangeTgt);
modelChangeTgt = new ModelChangeStructureDataType({
affected: node2.nodeId,
affectedType: _getTypeDef(node2),
verb: makeVerb("ReferenceAdded")
});
addressSpace._collectModelChange(null, modelChangeTgt);
});
}