Pure Node.js OPC UA SDK constants module providing comprehensive enumerations for data types, objects, variables, methods, and aggregate functions.
npx @tessl/cli install tessl/npm-node-opcua-constants@2.139.0Node OPC UA Constants provides comprehensive standard identifiers and enumerations for the OPC UA (Open Platform Communications Unified Architecture) protocol implementation in Node.js. This TypeScript library serves as a foundational constants package, offering all standardized node identifiers, data types, object types, and aggregate functions required for OPC UA compliance.
npm install node-opcua-constantsimport { DataTypeIds, ObjectIds, VariableIds, MethodIds, AggregateFunction } from "node-opcua-constants";For CommonJS:
const { DataTypeIds, ObjectIds, VariableIds, MethodIds, AggregateFunction } = require("node-opcua-constants");import { DataTypeIds, ObjectIds, MethodIds, AggregateFunction } from "node-opcua-constants";
// Use data type identifiers
const stringType = DataTypeIds.String; // 12
const booleanType = DataTypeIds.Boolean; // 1
// Access OPC UA object identifiers
const rootFolder = ObjectIds.RootFolder;
const serverObject = ObjectIds.Server;
// Reference method identifiers
const getMonitoredItemsMethod = MethodIds.Server_GetMonitoredItems;
const conditionRefreshMethod = MethodIds.ConditionType_ConditionRefresh;
// Reference aggregate functions
const averageFunction = AggregateFunction.Average;
const countFunction = AggregateFunction.Count;
// Combine for OPC UA node creation or reference
console.log(`String data type ID: ${stringType}`);
console.log(`Root folder object ID: ${rootFolder}`);
console.log(`Get monitored items method ID: ${getMonitoredItemsMethod}`);Node OPC UA Constants is built around automatically generated TypeScript enums containing all standard OPC UA node identifiers. The package exports 8 major enums with ~2,450 total constants:
code_gen/generate_node_ids.jsServer_ServerStatus_BuildInfo_ProductName)Standard OPC UA data type identifiers for all built-in and standard data types.
enum DataTypeIds {
Boolean = 1,
SByte = 2,
Byte = 3,
Int16 = 4,
UInt16 = 5,
Int32 = 6,
UInt32 = 7,
Int64 = 8,
UInt64 = 9,
Float = 10,
Double = 11,
String = 12,
DateTime = 13,
Guid = 14,
ByteString = 15,
XmlElement = 16,
NodeId = 17,
ExpandedNodeId = 18,
StatusCode = 19,
QualifiedName = 20,
LocalizedText = 21,
Structure = 22,
DataValue = 23,
BaseDataType = 24,
DiagnosticInfo = 25,
Number = 26,
Integer = 27,
UInteger = 28,
Enumeration = 29,
Image = 30,
Decimal = 50,
PermissionType = 94,
AccessRestrictionType = 95,
RolePermissionType = 96,
DataTypeDefinition = 97,
StructureType = 98,
StructureDefinition = 99,
EnumDefinition = 100,
StructureField = 101,
EnumField = 102,
NamingRuleType = 120,
IdType = 256,
NodeClass = 257,
Node = 258,
ObjectNode = 261,
ObjectTypeNode = 264,
VariableNode = 267,
VariableTypeNode = 270,
ReferenceTypeNode = 273,
MethodNode = 276,
ViewNode = 279,
DataTypeNode = 282,
ReferenceNode = 285
// ... and many more standardized data type identifiers
}OPC UA reference type identifiers for defining relationships between nodes in the address space.
enum ReferenceTypeIds {
References = 31,
NonHierarchicalReferences = 32,
HierarchicalReferences = 33,
HasChild = 34,
Organizes = 35,
HasEventSource = 36,
HasModellingRule = 37,
HasEncoding = 38,
HasDescription = 39,
HasTypeDefinition = 40,
GeneratesEvent = 41,
Aggregates = 44,
HasSubtype = 45,
HasProperty = 46,
HasComponent = 47,
HasNotifier = 48,
HasOrderedComponent = 49
// ... and more reference type identifiers
}Standard object type identifiers for OPC UA object type definitions.
enum ObjectTypeIds {
BaseObjectType = 58,
FolderType = 61,
BaseVariableType = 62,
BaseDataVariableType = 63,
PropertyType = 68,
DataTypeDescriptionType = 69,
DataTypeDictionaryType = 72,
DataTypeSystemType = 75,
OrganizesType = 35,
ModellingRuleType = 77,
ServerType = 2004,
ServerCapabilitiesType = 2013,
ServerDiagnosticsType = 2020,
SessionsDiagnosticsSummaryType = 2026,
SessionDiagnosticsObjectType = 2029,
VendorServerInfoType = 2033,
ServerRedundancyType = 2034
// ... and more object type identifiers
}Standard variable type identifiers for OPC UA variable type definitions.
enum VariableTypeIds {
BaseVariableType = 62,
BaseDataVariableType = 63,
PropertyType = 68,
DataTypeDescriptionType = 69,
DataTypeDictionaryType = 72,
ServerVendorCapabilityType = 2137,
ServerStatusType = 2138,
ServerDiagnosticsSummaryType = 2150,
SamplingIntervalDiagnosticsArrayType = 2164,
SamplingIntervalDiagnosticsType = 2165,
SubscriptionDiagnosticsArrayType = 2171,
SubscriptionDiagnosticsType = 2172,
SessionDiagnosticsArrayType = 2196,
SessionDiagnosticsVariableType = 2197,
SessionSecurityDiagnosticsArrayType = 2243,
SessionSecurityDiagnosticsType = 2244
// ... and more variable type identifiers
}Standard object instance identifiers for objects in the OPC UA address space.
enum ObjectIds {
RootFolder = 84,
ObjectsFolder = 85,
TypesFolder = 86,
ViewsFolder = 87,
ObjectTypesFolder = 88,
VariableTypesFolder = 89,
DataTypesFolder = 90,
ReferenceTypesFolder = 91,
XmlSchemaTypeSystem = 92,
OPCBinarySchema_TypeSystem = 93,
Server = 2253,
Server_ServerCapabilities = 2268,
Server_ServerDiagnostics = 2274,
Server_VendorServerInfo = 2295,
Server_ServerRedundancy = 2296,
Server_Namespaces = 11715,
Server_ServerCapabilities_ServerProfileArray = 2269,
Server_ServerCapabilities_LocaleIdArray = 2271,
Server_ServerCapabilities_MinSupportedSampleRate = 2272,
Server_ServerCapabilities_MaxBrowseContinuationPoints = 2735,
Server_ServerCapabilities_MaxQueryContinuationPoints = 2736,
Server_ServerCapabilities_MaxHistoryContinuationPoints = 2737,
Server_ServerCapabilities_SoftwareCertificates = 2738,
Server_ServerCapabilities_MaxArrayLength = 11702,
Server_ServerCapabilities_MaxStringLength = 11703,
Server_ServerCapabilities_OperationLimits = 11704,
Server_ServerCapabilities_ModellingRules = 2268,
Server_ServerCapabilities_AggregateFunctions = 2340
// ... and many more object instance identifiers including aggregate functions
}Standard variable instance identifiers for variables in the OPC UA address space.
enum VariableIds {
Server_ServerArray = 2254,
Server_NamespaceArray = 2255,
Server_ServerStatus = 2256,
Server_ServerStatus_StartTime = 2257,
Server_ServerStatus_CurrentTime = 2258,
Server_ServerStatus_State = 2259,
Server_ServerStatus_BuildInfo = 2260,
Server_ServerStatus_BuildInfo_ProductUri = 2262,
Server_ServerStatus_BuildInfo_ManufacturerName = 2263,
Server_ServerStatus_BuildInfo_ProductName = 2264,
Server_ServerStatus_BuildInfo_SoftwareVersion = 2265,
Server_ServerStatus_BuildInfo_BuildNumber = 2266,
Server_ServerStatus_BuildInfo_BuildDate = 2267,
Server_ServiceLevel = 2267,
Server_Auditing = 2994,
Server_EstimatedReturnTime = 2992
// ... and more variable instance identifiers
}Standard method identifiers for methods in the OPC UA address space.
enum MethodIds {
Server_GetMonitoredItems = 11492,
Server_ResendData = 11493,
Server_SetSubscriptionDurable = 11494,
ConditionType_ConditionRefresh = 9111,
ConditionType_ConditionRefresh2 = 9113,
DialogConditionType_Respond = 9031,
ExclusiveDeviationAlarmType_ShelvingState_TimedShelve = 9211,
ExclusiveDeviationAlarmType_ShelvingState_Unshelve = 9212,
ExclusiveDeviationAlarmType_ShelvingState_OneShotShelve = 9213,
HistoricalDataConfigurationType_StartOfArchive = 11876,
HistoricalDataConfigurationType_StartOfOnlineArchive = 11877,
ProgramStateMachineType_Start = 2427,
ProgramStateMachineType_Suspend = 2428,
ProgramStateMachineType_Resume = 2429,
ProgramStateMachineType_Halt = 2430,
ProgramStateMachineType_Reset = 2431
// ... and more method identifiers
}OPC UA aggregate function identifiers mapped to their corresponding ObjectIds for data processing and historical data operations.
enum AggregateFunction {
AnnotationCount = ObjectIds.AggregateFunction_AnnotationCount,
Average = ObjectIds.AggregateFunction_Average,
Count = ObjectIds.AggregateFunction_Count,
Delta = ObjectIds.AggregateFunction_Delta,
DeltaBounds = ObjectIds.AggregateFunction_DeltaBounds,
DurationBad = ObjectIds.AggregateFunction_DurationBad,
DurationGood = ObjectIds.AggregateFunction_DurationGood,
DurationInStateNonZero = ObjectIds.AggregateFunction_DurationInStateNonZero,
DurationInStateZero = ObjectIds.AggregateFunction_End,
EndBound = ObjectIds.AggregateFunction_EndBound,
Interpolative = ObjectIds.AggregateFunction_Interpolative,
Maximum = ObjectIds.AggregateFunction_Maximum,
Maximum2 = ObjectIds.AggregateFunction_Maximum2,
MaximumActualTime = ObjectIds.AggregateFunction_MaximumActualTime,
MaximumActualTime2 = ObjectIds.AggregateFunction_MaximumActualTime2,
Minimum = ObjectIds.AggregateFunction_Minimum,
Minimum2 = ObjectIds.AggregateFunction_Minimum2,
MinimumActualTime = ObjectIds.AggregateFunction_MinimumActualTime,
MinimumActualTime2 = ObjectIds.AggregateFunction_MinimumActualTime2,
NumberOfTransitions = ObjectIds.AggregateFunction_NumberOfTransitions,
PercentBad = ObjectIds.AggregateFunction_PercentBad,
PercentGood = ObjectIds.AggregateFunction_PercentGood,
Range = ObjectIds.AggregateFunction_Range,
Range2 = ObjectIds.AggregateFunction_Range2,
StandardDeviationPopulation = ObjectIds.AggregateFunction_StandardDeviationPopulation,
StandardDeviationSample = ObjectIds.AggregateFunction_StandardDeviationSample,
Start = ObjectIds.AggregateFunction_Start,
StartBound = ObjectIds.AggregateFunction_StartBound,
TimeAverage = ObjectIds.AggregateFunction_TimeAverage,
TimeAverage2 = ObjectIds.AggregateFunction_TimeAverage2,
Total = ObjectIds.AggregateFunction_Total,
Total2 = ObjectIds.AggregateFunction_Total2,
VariancePopulation = ObjectIds.AggregateFunction_VariancePopulation,
VarianceSample = ObjectIds.AggregateFunction_VarianceSample,
WorstQuality = ObjectIds.AggregateFunction_WorstQuality,
WorstQuality2 = ObjectIds.AggregateFunction_WorstQuality2
}import { DataTypeIds, ObjectTypeIds, ObjectIds } from "node-opcua-constants";
// Create a string variable node reference
const stringVariableType = {
dataType: DataTypeIds.String,
typeDefinition: ObjectTypeIds.BaseDataVariableType,
parent: ObjectIds.ObjectsFolder
};
// Reference aggregate functions for historical data
const aggregateConfig = {
function: AggregateFunction.Average,
processingInterval: "PT1H", // 1 hour
functionId: ObjectIds.AggregateFunction_Average
};import { ObjectIds, VariableIds, DataTypeIds } from "node-opcua-constants";
// Browse the standard server structure
const serverNode = ObjectIds.Server;
const serverStatusVariable = VariableIds.Server_ServerStatus;
// Read server information
const serverArrayVariable = VariableIds.Server_ServerArray;
const namespaceArrayVariable = VariableIds.Server_NamespaceArray;
// Use in OPC UA client calls
console.log(`Server object ID: ${serverNode}`);
console.log(`Server status variable ID: ${serverStatusVariable}`);import { DataTypeIds, NodeClass } from "node-opcua-constants";
function validateDataType(dataTypeId: number): boolean {
return Object.values(DataTypeIds).includes(dataTypeId);
}
function isBuiltInType(dataTypeId: number): boolean {
const builtInTypes = [
DataTypeIds.Boolean,
DataTypeIds.String,
DataTypeIds.Int32,
DataTypeIds.Double,
DataTypeIds.DateTime
];
return builtInTypes.includes(dataTypeId);
}
// Usage
const isValid = validateDataType(DataTypeIds.String); // true
const isBuiltIn = isBuiltInType(DataTypeIds.Float); // true