Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// the application is using an old scheme
console.log(chalk.green("Warning : since node-opcua 0.4.2 " +
"namespace index should not be prepended to the browse name anymore"));
console.log(" ", options.browseName, " will be replaced with ", correctedName);
console.log(" Please update your code");
const indexVerif = parseInt(match[0], 10);
if (indexVerif !== this.index) {
console.log(chalk.red.bold("Error: namespace index used at the front of the browseName " +
indexVerif + " do not match the index of the current namespace (" + this.index + ")"));
console.log(" Please fix your code so that the created node is inserted in the correct namespace," +
" please refer to the NodeOPCUA documentation");
}
}
options.browseName = new QualifiedName({ name: options.browseName, namespaceIndex: this.index });
} else if (!(options.browseName instanceof QualifiedName)) {
options.browseName = new QualifiedName(options.browseName);
}
assert(options.browseName instanceof QualifiedName,
"Expecting options.browseName to be instanceof QualifiedName ");
// ------------- set display name
if (!options.displayName) {
assert(typeof (options.browseName.name) === "string");
options.displayName = options.browseName.name;
}
// --- nodeId adjustment
options.nodeId = this._construct_nodeId(options);
dumpIf(!options.nodeId, options); // missing node Id
console.log(" ", options.browseName, " will be replaced with ", correctedName);
console.log(" Please update your code");
const indexVerif = parseInt(match[0], 10);
if (indexVerif !== this.index) {
console.log(chalk.red.bold("Error: namespace index used at the front of the browseName " +
indexVerif + " do not match the index of the current namespace (" + this.index + ")"));
console.log(" Please fix your code so that the created node is inserted in the correct namespace," +
" please refer to the NodeOPCUA documentation");
}
}
options.browseName = new QualifiedName({ name: options.browseName, namespaceIndex: this.index });
} else if (!(options.browseName instanceof QualifiedName)) {
options.browseName = new QualifiedName(options.browseName);
}
assert(options.browseName instanceof QualifiedName,
"Expecting options.browseName to be instanceof QualifiedName ");
// ------------- set display name
if (!options.displayName) {
assert(typeof (options.browseName.name) === "string");
options.displayName = options.browseName.name;
}
// --- nodeId adjustment
options.nodeId = this._construct_nodeId(options);
dumpIf(!options.nodeId, options); // missing node Id
assert(options.nodeId instanceof NodeId);
// assert(options.browseName.namespaceIndex === this.index,"Expecting browseName to have
const match = options.browseName.match(regExpNamespaceDotBrowseName);
if (match) {
const correctedName= match[1];
// the application is using an old scheme
console.log(chalk.green("Warning : since node-opcua 0.4.2 , namespace should not be prepended to the browse name anymore"));
console.log(" ", options.browseName, " will be replaced with " , correctedName);
console.log(" Please update your code");
const indexVerif = parseInt(match[0]);
if (indexVerif !== self.index) {
console.log(chalk.red.bold("Error: namespace index used at the front of the browseName " + indexVerif + " do not match the index of the current namespace ("+ self.index+ ")"));
console.log(" Please fix your code so that the created node is inserted in the correct namespace, please refer to the NodeOPCUA documentation");
}
}
options.browseName = new QualifiedName({name: options.browseName, namespaceIndex: self.index});
} else if (!(options.browseName instanceof QualifiedName)) {
options.browseName = new QualifiedName(options.browseName);
}
assert(options.browseName instanceof QualifiedName, "Expecting options.browseName to be instanceof QualifiedName ");
// ------------- set display name
if (!options.displayName) {
assert(typeof(options.browseName.name) === "string" );
options.displayName= options.browseName.name;
}
//--- nodeId adjustment
options.nodeId = self._construct_nodeId(options);
dumpIf(!options.nodeId, options); // missing node Id
assert(options.nodeId instanceof NodeId);
// xx conditionNode.quality.setValueFromSource({dataType: DataType.StatusCode,value: StatusCodes.Good });
// install 'LastSeverity' condition variable
_install_condition_variable_type(conditionNode.lastSeverity);
// xx conditionNode.severity.setValueFromSource({dataType: DataType.UInt16,value: 0 });
// xx conditionNode.lastSeverity.setValueFromSource({dataType: DataType.UInt16,value: 0 });
// install 'EnabledState' TwoStateVariable
/**
* @property enabledState
* @type {UATwoStateVariable}
*/
// -------------- fixing missing EnabledState.EffectiveDisplayName
if (!conditionNode.enabledState.effectiveDisplayName) {
namespace.addVariable({
browseName: new QualifiedName({namespaceIndex: 0, name: "EffectiveDisplayName"}),
dataType: "LocalizedText",
propertyOf: conditionNode.enabledState
});
}
_install_TwoStateVariable_machinery(conditionNode.enabledState, {
falseState: "Disabled",
trueState: "Enabled"
});
assert(conditionNode.enabledState._trueState === "Enabled");
assert(conditionNode.enabledState._falseState === "Disabled");
// installing sourceName and sourceNode
conditionNode.enabledState.setValue(true);
// set properties to in initial values
Object.keys(data).forEach((key: string) => {
}
switch (dataType) {
case DataType.Null:
value = null;
break;
case DataType.LocalizedText:
if (!value || !value.schema || value.schema !== LocalizedText.schema) {
value = new LocalizedText(value);
}
break;
case DataType.QualifiedName:
if (!value || !value.schema || value.schema !== QualifiedName.schema) {
value = new QualifiedName(value);
}
break;
case DataType.Int16:
case DataType.UInt16:
case DataType.Int32:
case DataType.UInt32:
assert(value !== undefined);
if (isEnumerationItem(value)) {
// value is a enumeration of some sort
value = value.value;
} else {
value = parseInt(value, 10);
}
/* istanbul ignore next */
if (!_.isFinite(value)) {
export function isNonEmptyQualifiedName(browseName?: null | string | QualifiedName): boolean {
if (!browseName) {
return false;
}
if (typeof browseName === "string") {
return browseName.length >= 0;
}
if (!(browseName instanceof QualifiedName)) {
browseName = new QualifiedName(browseName);
}
assert(browseName instanceof QualifiedName);
return browseName.name!.length > 0;
}
function isNonEmptyQualifiedName(browseName) {
if (!browseName) {
return false;
}
if (typeof browseName === "string") {
return browseName.length >= 0;
}
if (!(browseName instanceof QualifiedName)) {
browseName = new QualifiedName(browseName);
}
assert(browseName instanceof QualifiedName);
return browseName.name.length > 0;
}