Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
ClientSession.prototype.getArgumentDefinition = function (methodId, callback) {
assert(_.isFunction(callback));
assert(methodId instanceof NodeId);
const session = this;
const browseDescription = new browse_service.BrowseDescription({
nodeId: methodId,
referenceTypeId: resolveNodeId("HasProperty"),
browseDirection: BrowseDirection.Forward,
nodeClassMask: 0,// makeNodeClassMask("Variable"),
includeSubtypes: true,
resultMask: makeResultMask("BrowseName")
});
//Xx console.log("xxxx browseDescription", util.inspect(browseDescription, {colors: true, depth: 10}));
session.browse(browseDescription, function (err, browseResult) {
/* istanbul ignore next */
if (err) {
return callback(err);
}
browseResult.references = browseResult.references || [];
function __findBasicDataType(session, dataTypeId, callback) {
assert(dataTypeId instanceof NodeId);
if (dataTypeId.value <= 25) {
// we have a well-known DataType
const dataType = DataType.get(dataTypeId.value);
callback(null, dataType);
} else {
// let's browse for the SuperType of this object
const nodeToBrowse = new browse_service.BrowseDescription({
referenceTypeId: makeNodeId(ReferenceTypeIds.HasSubtype),
includeSubtypes: false,
browseDirection: BrowseDirection.Inverse,
nodeId: dataTypeId,
resultMask: resultMask
});
session.browse(nodeToBrowse, function (err, browseResult) {
if (err) return callback(err);
const baseDataType = browseResult.references[0].nodeId;
return __findBasicDataType(session, baseDataType, callback);
});
}
}
export function getArgumentDefinitionHelper(
session: IBasicSession,
methodId: MethodId,
callback: ResponseCallback
) {
const browseDescription = new BrowseDescription({
browseDirection: BrowseDirection.Forward,
includeSubtypes: true,
nodeClassMask: 0, // makeNodeClassMask("Variable"),
nodeId: methodId,
referenceTypeId: resolveNodeId("HasProperty"),
resultMask: makeResultMask("BrowseName")
});
session.browse(browseDescription, (err: Error | null, browseResult?: BrowseResult) => {
/* istanbul ignore next */
if (err) {
return callback(err);
}
if (!browseResult) {
return callback(new Error("Invalid"));
function coerceBrowseDescription(data) {
if (typeof data === "string" || data instanceof NodeId) {
return coerceBrowseDescription({
nodeId: data,
includeSubtypes: true,
browseDirection: BrowseDirection.Forward,
nodeClassMask: 0,
resultMask: 63,
referenceTypeId: "HierarchicalReferences"
});
} else {
data.nodeId = resolveNodeId(data.nodeId);
data.referenceTypeId = data.referenceTypeId ? resolveNodeId(data.referenceTypeId) : null;
return new browse_service.BrowseDescription(data);
}
}