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.00
# Node OPC UA Constants
1
2
Node 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.
3
4
## Package Information
5
6
- **Package Name**: node-opcua-constants
7
- **Package Type**: npm
8
- **Language**: TypeScript
9
- **Installation**: `npm install node-opcua-constants`
10
11
## Core Imports
12
13
```typescript
14
import { DataTypeIds, ObjectIds, VariableIds, MethodIds, AggregateFunction } from "node-opcua-constants";
15
```
16
17
For CommonJS:
18
19
```javascript
20
const { DataTypeIds, ObjectIds, VariableIds, MethodIds, AggregateFunction } = require("node-opcua-constants");
21
```
22
23
## Basic Usage
24
25
```typescript
26
import { DataTypeIds, ObjectIds, MethodIds, AggregateFunction } from "node-opcua-constants";
27
28
// Use data type identifiers
29
const stringType = DataTypeIds.String; // 12
30
const booleanType = DataTypeIds.Boolean; // 1
31
32
// Access OPC UA object identifiers
33
const rootFolder = ObjectIds.RootFolder;
34
const serverObject = ObjectIds.Server;
35
36
// Reference method identifiers
37
const getMonitoredItemsMethod = MethodIds.Server_GetMonitoredItems;
38
const conditionRefreshMethod = MethodIds.ConditionType_ConditionRefresh;
39
40
// Reference aggregate functions
41
const averageFunction = AggregateFunction.Average;
42
const countFunction = AggregateFunction.Count;
43
44
// Combine for OPC UA node creation or reference
45
console.log(`String data type ID: ${stringType}`);
46
console.log(`Root folder object ID: ${rootFolder}`);
47
console.log(`Get monitored items method ID: ${getMonitoredItemsMethod}`);
48
```
49
50
## Architecture
51
52
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**:
53
54
- **Core Structure**: All constants are defined as TypeScript enums with numeric values representing official OPC UA node identifiers
55
- **Automatic Generation**: Constants are generated from OPC UA specifications using `code_gen/generate_node_ids.js`
56
- **Complete Coverage**: Covers all standard OPC UA nodes including data types, objects, variables, methods, and reference types
57
- **Hierarchical Organization**: Many identifiers use underscore-separated naming to represent hierarchical relationships (e.g., `Server_ServerStatus_BuildInfo_ProductName`)
58
- **Multiple Encodings**: Supports multiple encoding formats (DefaultBinary, DefaultXml, DefaultJson) for the same logical entities
59
60
## Capabilities
61
62
### Data Type Identifiers
63
64
Standard OPC UA data type identifiers for all built-in and standard data types.
65
66
```typescript { .api }
67
enum DataTypeIds {
68
Boolean = 1,
69
SByte = 2,
70
Byte = 3,
71
Int16 = 4,
72
UInt16 = 5,
73
Int32 = 6,
74
UInt32 = 7,
75
Int64 = 8,
76
UInt64 = 9,
77
Float = 10,
78
Double = 11,
79
String = 12,
80
DateTime = 13,
81
Guid = 14,
82
ByteString = 15,
83
XmlElement = 16,
84
NodeId = 17,
85
ExpandedNodeId = 18,
86
StatusCode = 19,
87
QualifiedName = 20,
88
LocalizedText = 21,
89
Structure = 22,
90
DataValue = 23,
91
BaseDataType = 24,
92
DiagnosticInfo = 25,
93
Number = 26,
94
Integer = 27,
95
UInteger = 28,
96
Enumeration = 29,
97
Image = 30,
98
Decimal = 50,
99
PermissionType = 94,
100
AccessRestrictionType = 95,
101
RolePermissionType = 96,
102
DataTypeDefinition = 97,
103
StructureType = 98,
104
StructureDefinition = 99,
105
EnumDefinition = 100,
106
StructureField = 101,
107
EnumField = 102,
108
NamingRuleType = 120,
109
IdType = 256,
110
NodeClass = 257,
111
Node = 258,
112
ObjectNode = 261,
113
ObjectTypeNode = 264,
114
VariableNode = 267,
115
VariableTypeNode = 270,
116
ReferenceTypeNode = 273,
117
MethodNode = 276,
118
ViewNode = 279,
119
DataTypeNode = 282,
120
ReferenceNode = 285
121
// ... and many more standardized data type identifiers
122
}
123
```
124
125
### Reference Type Identifiers
126
127
OPC UA reference type identifiers for defining relationships between nodes in the address space.
128
129
```typescript { .api }
130
enum ReferenceTypeIds {
131
References = 31,
132
NonHierarchicalReferences = 32,
133
HierarchicalReferences = 33,
134
HasChild = 34,
135
Organizes = 35,
136
HasEventSource = 36,
137
HasModellingRule = 37,
138
HasEncoding = 38,
139
HasDescription = 39,
140
HasTypeDefinition = 40,
141
GeneratesEvent = 41,
142
Aggregates = 44,
143
HasSubtype = 45,
144
HasProperty = 46,
145
HasComponent = 47,
146
HasNotifier = 48,
147
HasOrderedComponent = 49
148
// ... and more reference type identifiers
149
}
150
```
151
152
### Object Type Identifiers
153
154
Standard object type identifiers for OPC UA object type definitions.
155
156
```typescript { .api }
157
enum ObjectTypeIds {
158
BaseObjectType = 58,
159
FolderType = 61,
160
BaseVariableType = 62,
161
BaseDataVariableType = 63,
162
PropertyType = 68,
163
DataTypeDescriptionType = 69,
164
DataTypeDictionaryType = 72,
165
DataTypeSystemType = 75,
166
OrganizesType = 35,
167
ModellingRuleType = 77,
168
ServerType = 2004,
169
ServerCapabilitiesType = 2013,
170
ServerDiagnosticsType = 2020,
171
SessionsDiagnosticsSummaryType = 2026,
172
SessionDiagnosticsObjectType = 2029,
173
VendorServerInfoType = 2033,
174
ServerRedundancyType = 2034
175
// ... and more object type identifiers
176
}
177
```
178
179
### Variable Type Identifiers
180
181
Standard variable type identifiers for OPC UA variable type definitions.
182
183
```typescript { .api }
184
enum VariableTypeIds {
185
BaseVariableType = 62,
186
BaseDataVariableType = 63,
187
PropertyType = 68,
188
DataTypeDescriptionType = 69,
189
DataTypeDictionaryType = 72,
190
ServerVendorCapabilityType = 2137,
191
ServerStatusType = 2138,
192
ServerDiagnosticsSummaryType = 2150,
193
SamplingIntervalDiagnosticsArrayType = 2164,
194
SamplingIntervalDiagnosticsType = 2165,
195
SubscriptionDiagnosticsArrayType = 2171,
196
SubscriptionDiagnosticsType = 2172,
197
SessionDiagnosticsArrayType = 2196,
198
SessionDiagnosticsVariableType = 2197,
199
SessionSecurityDiagnosticsArrayType = 2243,
200
SessionSecurityDiagnosticsType = 2244
201
// ... and more variable type identifiers
202
}
203
```
204
205
### Object Instance Identifiers
206
207
Standard object instance identifiers for objects in the OPC UA address space.
208
209
```typescript { .api }
210
enum ObjectIds {
211
RootFolder = 84,
212
ObjectsFolder = 85,
213
TypesFolder = 86,
214
ViewsFolder = 87,
215
ObjectTypesFolder = 88,
216
VariableTypesFolder = 89,
217
DataTypesFolder = 90,
218
ReferenceTypesFolder = 91,
219
XmlSchemaTypeSystem = 92,
220
OPCBinarySchema_TypeSystem = 93,
221
Server = 2253,
222
Server_ServerCapabilities = 2268,
223
Server_ServerDiagnostics = 2274,
224
Server_VendorServerInfo = 2295,
225
Server_ServerRedundancy = 2296,
226
Server_Namespaces = 11715,
227
Server_ServerCapabilities_ServerProfileArray = 2269,
228
Server_ServerCapabilities_LocaleIdArray = 2271,
229
Server_ServerCapabilities_MinSupportedSampleRate = 2272,
230
Server_ServerCapabilities_MaxBrowseContinuationPoints = 2735,
231
Server_ServerCapabilities_MaxQueryContinuationPoints = 2736,
232
Server_ServerCapabilities_MaxHistoryContinuationPoints = 2737,
233
Server_ServerCapabilities_SoftwareCertificates = 2738,
234
Server_ServerCapabilities_MaxArrayLength = 11702,
235
Server_ServerCapabilities_MaxStringLength = 11703,
236
Server_ServerCapabilities_OperationLimits = 11704,
237
Server_ServerCapabilities_ModellingRules = 2268,
238
Server_ServerCapabilities_AggregateFunctions = 2340
239
// ... and many more object instance identifiers including aggregate functions
240
}
241
```
242
243
### Variable Instance Identifiers
244
245
Standard variable instance identifiers for variables in the OPC UA address space.
246
247
```typescript { .api }
248
enum VariableIds {
249
Server_ServerArray = 2254,
250
Server_NamespaceArray = 2255,
251
Server_ServerStatus = 2256,
252
Server_ServerStatus_StartTime = 2257,
253
Server_ServerStatus_CurrentTime = 2258,
254
Server_ServerStatus_State = 2259,
255
Server_ServerStatus_BuildInfo = 2260,
256
Server_ServerStatus_BuildInfo_ProductUri = 2262,
257
Server_ServerStatus_BuildInfo_ManufacturerName = 2263,
258
Server_ServerStatus_BuildInfo_ProductName = 2264,
259
Server_ServerStatus_BuildInfo_SoftwareVersion = 2265,
260
Server_ServerStatus_BuildInfo_BuildNumber = 2266,
261
Server_ServerStatus_BuildInfo_BuildDate = 2267,
262
Server_ServiceLevel = 2267,
263
Server_Auditing = 2994,
264
Server_EstimatedReturnTime = 2992
265
// ... and more variable instance identifiers
266
}
267
```
268
269
### Method Identifiers
270
271
Standard method identifiers for methods in the OPC UA address space.
272
273
```typescript { .api }
274
enum MethodIds {
275
Server_GetMonitoredItems = 11492,
276
Server_ResendData = 11493,
277
Server_SetSubscriptionDurable = 11494,
278
ConditionType_ConditionRefresh = 9111,
279
ConditionType_ConditionRefresh2 = 9113,
280
DialogConditionType_Respond = 9031,
281
ExclusiveDeviationAlarmType_ShelvingState_TimedShelve = 9211,
282
ExclusiveDeviationAlarmType_ShelvingState_Unshelve = 9212,
283
ExclusiveDeviationAlarmType_ShelvingState_OneShotShelve = 9213,
284
HistoricalDataConfigurationType_StartOfArchive = 11876,
285
HistoricalDataConfigurationType_StartOfOnlineArchive = 11877,
286
ProgramStateMachineType_Start = 2427,
287
ProgramStateMachineType_Suspend = 2428,
288
ProgramStateMachineType_Resume = 2429,
289
ProgramStateMachineType_Halt = 2430,
290
ProgramStateMachineType_Reset = 2431
291
// ... and more method identifiers
292
}
293
```
294
295
### Aggregate Functions
296
297
OPC UA aggregate function identifiers mapped to their corresponding ObjectIds for data processing and historical data operations.
298
299
```typescript { .api }
300
enum AggregateFunction {
301
AnnotationCount = ObjectIds.AggregateFunction_AnnotationCount,
302
Average = ObjectIds.AggregateFunction_Average,
303
Count = ObjectIds.AggregateFunction_Count,
304
Delta = ObjectIds.AggregateFunction_Delta,
305
DeltaBounds = ObjectIds.AggregateFunction_DeltaBounds,
306
DurationBad = ObjectIds.AggregateFunction_DurationBad,
307
DurationGood = ObjectIds.AggregateFunction_DurationGood,
308
DurationInStateNonZero = ObjectIds.AggregateFunction_DurationInStateNonZero,
309
DurationInStateZero = ObjectIds.AggregateFunction_End,
310
EndBound = ObjectIds.AggregateFunction_EndBound,
311
Interpolative = ObjectIds.AggregateFunction_Interpolative,
312
Maximum = ObjectIds.AggregateFunction_Maximum,
313
Maximum2 = ObjectIds.AggregateFunction_Maximum2,
314
MaximumActualTime = ObjectIds.AggregateFunction_MaximumActualTime,
315
MaximumActualTime2 = ObjectIds.AggregateFunction_MaximumActualTime2,
316
Minimum = ObjectIds.AggregateFunction_Minimum,
317
Minimum2 = ObjectIds.AggregateFunction_Minimum2,
318
MinimumActualTime = ObjectIds.AggregateFunction_MinimumActualTime,
319
MinimumActualTime2 = ObjectIds.AggregateFunction_MinimumActualTime2,
320
NumberOfTransitions = ObjectIds.AggregateFunction_NumberOfTransitions,
321
PercentBad = ObjectIds.AggregateFunction_PercentBad,
322
PercentGood = ObjectIds.AggregateFunction_PercentGood,
323
Range = ObjectIds.AggregateFunction_Range,
324
Range2 = ObjectIds.AggregateFunction_Range2,
325
StandardDeviationPopulation = ObjectIds.AggregateFunction_StandardDeviationPopulation,
326
StandardDeviationSample = ObjectIds.AggregateFunction_StandardDeviationSample,
327
Start = ObjectIds.AggregateFunction_Start,
328
StartBound = ObjectIds.AggregateFunction_StartBound,
329
TimeAverage = ObjectIds.AggregateFunction_TimeAverage,
330
TimeAverage2 = ObjectIds.AggregateFunction_TimeAverage2,
331
Total = ObjectIds.AggregateFunction_Total,
332
Total2 = ObjectIds.AggregateFunction_Total2,
333
VariancePopulation = ObjectIds.AggregateFunction_VariancePopulation,
334
VarianceSample = ObjectIds.AggregateFunction_VarianceSample,
335
WorstQuality = ObjectIds.AggregateFunction_WorstQuality,
336
WorstQuality2 = ObjectIds.AggregateFunction_WorstQuality2
337
}
338
```
339
340
## Usage Examples
341
342
### Node Creation and References
343
344
```typescript
345
import { DataTypeIds, ObjectTypeIds, ObjectIds } from "node-opcua-constants";
346
347
// Create a string variable node reference
348
const stringVariableType = {
349
dataType: DataTypeIds.String,
350
typeDefinition: ObjectTypeIds.BaseDataVariableType,
351
parent: ObjectIds.ObjectsFolder
352
};
353
354
// Reference aggregate functions for historical data
355
const aggregateConfig = {
356
function: AggregateFunction.Average,
357
processingInterval: "PT1H", // 1 hour
358
functionId: ObjectIds.AggregateFunction_Average
359
};
360
```
361
362
### OPC UA Client Integration
363
364
```typescript
365
import { ObjectIds, VariableIds, DataTypeIds } from "node-opcua-constants";
366
367
// Browse the standard server structure
368
const serverNode = ObjectIds.Server;
369
const serverStatusVariable = VariableIds.Server_ServerStatus;
370
371
// Read server information
372
const serverArrayVariable = VariableIds.Server_ServerArray;
373
const namespaceArrayVariable = VariableIds.Server_NamespaceArray;
374
375
// Use in OPC UA client calls
376
console.log(`Server object ID: ${serverNode}`);
377
console.log(`Server status variable ID: ${serverStatusVariable}`);
378
```
379
380
### Type Checking and Validation
381
382
```typescript
383
import { DataTypeIds, NodeClass } from "node-opcua-constants";
384
385
function validateDataType(dataTypeId: number): boolean {
386
return Object.values(DataTypeIds).includes(dataTypeId);
387
}
388
389
function isBuiltInType(dataTypeId: number): boolean {
390
const builtInTypes = [
391
DataTypeIds.Boolean,
392
DataTypeIds.String,
393
DataTypeIds.Int32,
394
DataTypeIds.Double,
395
DataTypeIds.DateTime
396
];
397
return builtInTypes.includes(dataTypeId);
398
}
399
400
// Usage
401
const isValid = validateDataType(DataTypeIds.String); // true
402
const isBuiltIn = isBuiltInType(DataTypeIds.Float); // true
403
```