opcua-webapi-ts 1.0.22 → 1.0.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/dist/cjs/client/UaWebClient.d.ts +10 -11
  2. package/dist/cjs/client/UaWebClient.js +156 -174
  3. package/dist/cjs/client/utils/UaDataTypeDictionary.js +15 -27
  4. package/dist/cjs/client/utils/UaNodeReader.d.ts +1 -1
  5. package/dist/cjs/client/utils/UaNodeReader.js +95 -145
  6. package/dist/cjs/client/utils/UaObjectTypeDictionary.js +8 -15
  7. package/dist/cjs/client/utils/UaReferenceTypeDictionary.js +8 -15
  8. package/dist/cjs/common/index.d.ts +1 -1
  9. package/dist/cjs/common/index.js +1 -1
  10. package/dist/cjs/common/payload/UaBrowseDescription.d.ts +20 -0
  11. package/dist/cjs/common/payload/UaBrowseDescription.js +58 -0
  12. package/dist/cjs/common/payload/UaBrowseResult.d.ts +16 -0
  13. package/dist/cjs/common/payload/UaBrowseResult.js +52 -0
  14. package/dist/cjs/common/payload/UaCallMethodRequest.d.ts +14 -0
  15. package/dist/cjs/common/payload/UaCallMethodRequest.js +50 -0
  16. package/dist/cjs/common/payload/UaCallMethodResult.d.ts +14 -0
  17. package/dist/cjs/common/payload/UaCallMethodResult.js +61 -0
  18. package/dist/cjs/common/payload/UaHistoryReadResult.d.ts +14 -0
  19. package/dist/cjs/common/payload/UaHistoryReadResult.js +41 -0
  20. package/dist/cjs/common/payload/UaHistoryReadValueId.d.ts +14 -0
  21. package/dist/cjs/common/payload/UaHistoryReadValueId.js +39 -0
  22. package/dist/cjs/common/payload/UaPayloadMapper.d.ts +15 -0
  23. package/dist/cjs/common/payload/UaPayloadMapper.js +444 -0
  24. package/dist/cjs/common/payload/UaReadValueId.d.ts +14 -0
  25. package/dist/cjs/common/payload/UaReadValueId.js +39 -0
  26. package/dist/cjs/common/payload/UaReferenceDescription.d.ts +22 -0
  27. package/dist/cjs/common/payload/UaReferenceDescription.js +61 -0
  28. package/dist/cjs/common/payload/UaWriteValue.d.ts +16 -0
  29. package/dist/cjs/common/payload/UaWriteValue.js +49 -0
  30. package/dist/cjs/common/payload/index.d.ts +10 -0
  31. package/dist/cjs/common/payload/index.js +26 -0
  32. package/dist/cjs/common/structure/UaArgument.js +3 -3
  33. package/dist/cjs/common/structure/UaContentFilterElement.js +3 -3
  34. package/dist/cjs/common/structure/UaEUInformation.js +5 -5
  35. package/dist/cjs/common/structure/UaEnumValueType.js +5 -5
  36. package/dist/cjs/common/structure/UaHistoryData.js +3 -3
  37. package/dist/cjs/common/structure/UaHistoryEvent.js +3 -3
  38. package/dist/cjs/common/structure/UaLiteralOperand.js +3 -3
  39. package/dist/cjs/common/types/UaExpandedNodeId.d.ts +1 -0
  40. package/dist/cjs/common/types/UaExpandedNodeId.js +11 -0
  41. package/dist/cjs/common/types/index.d.ts +0 -1
  42. package/dist/cjs/common/types/index.js +0 -1
  43. package/dist/client/UaWebClient.d.ts +10 -11
  44. package/dist/client/UaWebClient.js +156 -174
  45. package/dist/client/utils/UaDataTypeDictionary.js +15 -27
  46. package/dist/client/utils/UaNodeReader.d.ts +1 -1
  47. package/dist/client/utils/UaNodeReader.js +95 -145
  48. package/dist/client/utils/UaObjectTypeDictionary.js +8 -15
  49. package/dist/client/utils/UaReferenceTypeDictionary.js +8 -15
  50. package/dist/common/index.d.ts +1 -1
  51. package/dist/common/index.js +1 -1
  52. package/dist/common/payload/UaBrowseDescription.d.ts +20 -0
  53. package/dist/common/payload/UaBrowseDescription.js +58 -0
  54. package/dist/common/payload/UaBrowseResult.d.ts +16 -0
  55. package/dist/common/payload/UaBrowseResult.js +52 -0
  56. package/dist/common/payload/UaCallMethodRequest.d.ts +14 -0
  57. package/dist/common/payload/UaCallMethodRequest.js +50 -0
  58. package/dist/common/payload/UaCallMethodResult.d.ts +14 -0
  59. package/dist/common/payload/UaCallMethodResult.js +61 -0
  60. package/dist/common/payload/UaHistoryReadResult.d.ts +14 -0
  61. package/dist/common/payload/UaHistoryReadResult.js +41 -0
  62. package/dist/common/payload/UaHistoryReadValueId.d.ts +14 -0
  63. package/dist/common/payload/UaHistoryReadValueId.js +39 -0
  64. package/dist/common/payload/UaPayloadMapper.d.ts +15 -0
  65. package/dist/common/payload/UaPayloadMapper.js +444 -0
  66. package/dist/common/payload/UaReadValueId.d.ts +14 -0
  67. package/dist/common/payload/UaReadValueId.js +39 -0
  68. package/dist/common/payload/UaReferenceDescription.d.ts +22 -0
  69. package/dist/common/payload/UaReferenceDescription.js +61 -0
  70. package/dist/common/payload/UaWriteValue.d.ts +16 -0
  71. package/dist/common/payload/UaWriteValue.js +49 -0
  72. package/dist/common/payload/index.d.ts +10 -0
  73. package/dist/common/payload/index.js +26 -0
  74. package/dist/common/structure/UaArgument.js +3 -3
  75. package/dist/common/structure/UaContentFilterElement.js +3 -3
  76. package/dist/common/structure/UaEUInformation.js +5 -5
  77. package/dist/common/structure/UaEnumValueType.js +5 -5
  78. package/dist/common/structure/UaHistoryData.js +3 -3
  79. package/dist/common/structure/UaHistoryEvent.js +3 -3
  80. package/dist/common/structure/UaLiteralOperand.js +3 -3
  81. package/dist/common/types/UaExpandedNodeId.d.ts +1 -0
  82. package/dist/common/types/UaExpandedNodeId.js +11 -0
  83. package/dist/common/types/index.d.ts +0 -1
  84. package/dist/common/types/index.js +0 -1
  85. package/package.json +1 -1
@@ -42,45 +42,31 @@ class UaWebClient {
42
42
  }
43
43
  browseChild(nodeId, nodeClass, maxReferences) {
44
44
  return __awaiter(this, void 0, void 0, function* () {
45
- let nodesToBrowse = {
46
- NodeId: nodeId.toString(),
47
- BrowseDirection: opcua_webapi_1.BrowseDirection.Forward,
48
- ReferenceTypeId: opcua_webapi_1.ReferenceTypeIds.HierarchicalReferences,
49
- IncludeSubtypes: true,
50
- NodeClassMask: (nodeClass) ? nodeClass : Number(opcua_webapi_1.NodeClass.Object | opcua_webapi_1.NodeClass.Variable | opcua_webapi_1.NodeClass.Method),
51
- ResultMask: 63
52
- };
45
+ let nodesToBrowse = new common_1.UaBrowseDescription(nodeId, opcua_webapi_1.BrowseDirection.Forward, common_1.UaNodeId.from(common_1.ReferenceTypeIds.HierarchicalReferences), true, (nodeClass) ? nodeClass : Number(opcua_webapi_1.NodeClass.Object | opcua_webapi_1.NodeClass.Variable | opcua_webapi_1.NodeClass.Method), 63);
53
46
  let results = yield this.browse([nodesToBrowse], maxReferences);
54
- let statusCode = common_1.UaPayloadMapper.statusCodeFromWebApi(results[0].StatusCode);
47
+ let statusCode = results[0].statusCode;
55
48
  if (statusCode.isNotGood())
56
49
  throw new common_1.UaError(statusCode);
57
- return common_1.UaPayloadMapper.browseResultFromWebApi(results[0]);
50
+ return results[0];
58
51
  });
59
52
  }
60
53
  browseReference(nodeId, nodeClass, direction, referenceTypeId, maxReferences) {
61
54
  return __awaiter(this, void 0, void 0, function* () {
62
- let nodesToBrowse = {
63
- NodeId: nodeId.toString(),
64
- BrowseDirection: (direction) ? direction : opcua_webapi_1.BrowseDirection.Forward,
65
- ReferenceTypeId: (referenceTypeId) ? referenceTypeId.toString() : opcua_webapi_1.ReferenceTypeIds.NonHierarchicalReferences,
66
- IncludeSubtypes: true,
67
- NodeClassMask: (nodeClass) ? nodeClass : Number(opcua_webapi_1.NodeClass.Object | opcua_webapi_1.NodeClass.Variable | opcua_webapi_1.NodeClass.Method),
68
- ResultMask: 63
69
- };
55
+ let nodesToBrowse = new common_1.UaBrowseDescription(nodeId, (direction) ? direction : opcua_webapi_1.BrowseDirection.Forward, (referenceTypeId) ? referenceTypeId : common_1.UaNodeId.from(common_1.ReferenceTypeIds.NonHierarchicalReferences), true, (nodeClass) ? nodeClass : Number(opcua_webapi_1.NodeClass.Object | opcua_webapi_1.NodeClass.Variable | opcua_webapi_1.NodeClass.Method), 63);
70
56
  let results = yield this.browse([nodesToBrowse], maxReferences);
71
- let statusCode = common_1.UaPayloadMapper.statusCodeFromWebApi(results[0].StatusCode);
57
+ let statusCode = results[0].statusCode;
72
58
  if (statusCode.isNotGood())
73
59
  throw new common_1.UaError(statusCode);
74
- return common_1.UaPayloadMapper.browseResultFromWebApi(results[0]);
60
+ return results[0];
75
61
  });
76
62
  }
77
63
  browseNextByCP(continuationPoint) {
78
64
  return __awaiter(this, void 0, void 0, function* () {
79
65
  let results = yield this.browseNext([continuationPoint], false);
80
- let statusCode = common_1.UaPayloadMapper.statusCodeFromWebApi(results[0].StatusCode);
66
+ let statusCode = results[0].statusCode;
81
67
  if (statusCode.isNotGood())
82
68
  throw new common_1.UaError(statusCode);
83
- return common_1.UaPayloadMapper.browseResultFromWebApi(results[0]);
69
+ return results[0];
84
70
  });
85
71
  }
86
72
  readValues(nodeIds, timestampsToReturn) {
@@ -89,75 +75,51 @@ class UaWebClient {
89
75
  throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadNothingToDo));
90
76
  let nodesToRead = [];
91
77
  for (let item of nodeIds) {
92
- nodesToRead.push({ NodeId: item.toString(), AttributeId: opcua_webapi_1.Attributes.Value });
93
- }
94
- let results = yield this.read(nodesToRead, timestampsToReturn);
95
- let dataValues = [];
96
- for (let item of results) {
97
- dataValues.push(common_1.UaPayloadMapper.dataValueFromWebApi(item));
78
+ let nodeToRead = new common_1.UaReadValueId(item, opcua_webapi_1.Attributes.Value);
79
+ nodesToRead.push(nodeToRead);
98
80
  }
99
- return dataValues;
81
+ let results = yield this.read(nodesToRead, (timestampsToReturn) ? timestampsToReturn : opcua_webapi_1.TimestampsToReturn.Neither);
82
+ return results;
100
83
  });
101
84
  }
102
- writeValues(nodesToWrite) {
85
+ writeValue(nodeId, value) {
103
86
  return __awaiter(this, void 0, void 0, function* () {
104
- if (nodesToWrite.length == 0)
105
- throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadNothingToDo));
106
- let writeValues = [];
107
- for (let item of nodesToWrite) {
108
- let variant = common_1.UaPayloadMapper.variantToWebApi(item.value);
109
- writeValues.push({
110
- NodeId: item.nodeId.toString(),
111
- Value: {
112
- UaType: variant.UaType,
113
- Value: variant.Value
114
- },
115
- AttributeId: opcua_webapi_1.Attributes.Value
116
- });
117
- }
118
- let results = yield this.write(writeValues);
119
- let statusCodes = [];
120
- for (let item of results) {
121
- statusCodes.push(common_1.UaPayloadMapper.statusCodeFromWebApi(item));
122
- }
123
- return statusCodes;
87
+ let writeValue = new common_1.UaWriteValue(nodeId, value);
88
+ let results = yield this.write([writeValue]);
89
+ if (results[0].isNotGood())
90
+ throw new common_1.UaError(results[0]);
124
91
  });
125
92
  }
126
93
  readNodeAttributes(nodeId, returnDescription) {
127
94
  return __awaiter(this, void 0, void 0, function* () {
128
- let nodeIdStr = nodeId.toString();
129
95
  let nodesToRead = [
130
- { NodeId: nodeIdStr, AttributeId: opcua_webapi_1.Attributes.NodeClass },
131
- { NodeId: nodeIdStr, AttributeId: opcua_webapi_1.Attributes.BrowseName },
132
- { NodeId: nodeIdStr, AttributeId: opcua_webapi_1.Attributes.DisplayName },
133
- { NodeId: nodeIdStr, AttributeId: opcua_webapi_1.Attributes.UserWriteMask }
96
+ new common_1.UaReadValueId(nodeId, opcua_webapi_1.Attributes.NodeClass),
97
+ new common_1.UaReadValueId(nodeId, opcua_webapi_1.Attributes.BrowseName),
98
+ new common_1.UaReadValueId(nodeId, opcua_webapi_1.Attributes.DisplayName),
99
+ new common_1.UaReadValueId(nodeId, opcua_webapi_1.Attributes.UserWriteMask)
134
100
  ];
135
101
  if (returnDescription) {
136
- nodesToRead.push({ NodeId: nodeIdStr, AttributeId: opcua_webapi_1.Attributes.Description });
102
+ nodesToRead.push(new common_1.UaReadValueId(nodeId, opcua_webapi_1.Attributes.Description));
137
103
  }
138
104
  let results = yield this.read(nodesToRead);
139
- let dataValues = [];
140
- for (let item of results) {
141
- dataValues.push(common_1.UaPayloadMapper.dataValueFromWebApi(item));
142
- }
143
- if (dataValues[0].statusCode.isNotGood())
144
- throw new common_1.UaError(dataValues[0].statusCode);
145
- if (dataValues[1].statusCode.isNotGood())
146
- throw new common_1.UaError(dataValues[1].statusCode);
147
- if (dataValues[2].statusCode.isNotGood())
148
- throw new common_1.UaError(dataValues[2].statusCode);
149
- let nodeClassValue = dataValues[0].value;
150
- let browseNameValue = dataValues[1].value;
151
- let displayNameValue = dataValues[2].value;
105
+ if (results[0].statusCode.isNotGood())
106
+ throw new common_1.UaError(results[0].statusCode);
107
+ if (results[1].statusCode.isNotGood())
108
+ throw new common_1.UaError(results[1].statusCode);
109
+ if (results[2].statusCode.isNotGood())
110
+ throw new common_1.UaError(results[2].statusCode);
111
+ let nodeClassValue = results[0].value;
112
+ let browseNameValue = results[1].value;
113
+ let displayNameValue = results[2].value;
152
114
  if (common_1.UaVariantType.Int32 != nodeClassValue.type ||
153
115
  common_1.UaVariantType.QualifiedName != browseNameValue.type ||
154
116
  common_1.UaVariantType.LocalizedText != displayNameValue.type)
155
117
  throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadNodeAttributesInvalid));
156
- let writeMaskValue = (dataValues[3].statusCode.isGood() &&
157
- dataValues[3].value.type == common_1.UaVariantType.UInt32) ? dataValues[3].value : undefined;
118
+ let writeMaskValue = (results[3].statusCode.isGood() &&
119
+ results[3].value.type == common_1.UaVariantType.UInt32) ? results[3].value : undefined;
158
120
  let descriptionValue = (returnDescription &&
159
- dataValues[4].statusCode.isGood() &&
160
- dataValues[4].value.type == common_1.UaVariantType.LocalizedText) ? dataValues[4].value : undefined;
121
+ results[4].statusCode.isGood() &&
122
+ results[4].value.type == common_1.UaVariantType.LocalizedText) ? results[4].value : undefined;
161
123
  let ret = {
162
124
  nodeClass: nodeClassValue.value,
163
125
  browseName: browseNameValue.value,
@@ -174,19 +136,18 @@ class UaWebClient {
174
136
  return [];
175
137
  let nodesToRead = [];
176
138
  for (let item of nodeIds) {
177
- let nodeIdString = item.toString();
178
- nodesToRead.push({ NodeId: nodeIdString, AttributeId: opcua_webapi_1.Attributes.NodeClass });
179
- nodesToRead.push({ NodeId: nodeIdString, AttributeId: opcua_webapi_1.Attributes.DataType });
180
- nodesToRead.push({ NodeId: nodeIdString, AttributeId: opcua_webapi_1.Attributes.ValueRank });
181
- nodesToRead.push({ NodeId: nodeIdString, AttributeId: opcua_webapi_1.Attributes.AccessLevel });
182
- nodesToRead.push({ NodeId: nodeIdString, AttributeId: opcua_webapi_1.Attributes.UserAccessLevel });
183
- nodesToRead.push({ NodeId: nodeIdString, AttributeId: opcua_webapi_1.Attributes.Historizing });
139
+ nodesToRead.push(new common_1.UaReadValueId(item, opcua_webapi_1.Attributes.NodeClass));
140
+ nodesToRead.push(new common_1.UaReadValueId(item, opcua_webapi_1.Attributes.DataType));
141
+ nodesToRead.push(new common_1.UaReadValueId(item, opcua_webapi_1.Attributes.ValueRank));
142
+ nodesToRead.push(new common_1.UaReadValueId(item, opcua_webapi_1.Attributes.AccessLevel));
143
+ nodesToRead.push(new common_1.UaReadValueId(item, opcua_webapi_1.Attributes.UserAccessLevel));
144
+ nodesToRead.push(new common_1.UaReadValueId(item, opcua_webapi_1.Attributes.Historizing));
184
145
  }
185
146
  let results = yield this.read(nodesToRead);
186
147
  let dataValues = [];
187
148
  let ret = [];
188
149
  for (let item of results) {
189
- dataValues.push(common_1.UaPayloadMapper.dataValueFromWebApi(item));
150
+ dataValues.push(item);
190
151
  if (dataValues.length == 6) {
191
152
  let dataType = common_1.UaNodeId.nullNodeId;
192
153
  let valueRank = -1;
@@ -274,18 +235,13 @@ class UaWebClient {
274
235
  }
275
236
  readObjectAttributes(nodeId) {
276
237
  return __awaiter(this, void 0, void 0, function* () {
277
- let nodeIdStr = nodeId.toString();
278
238
  let nodesToRead = [
279
- { NodeId: nodeIdStr, AttributeId: opcua_webapi_1.Attributes.EventNotifier }
239
+ new common_1.UaReadValueId(nodeId, opcua_webapi_1.Attributes.EventNotifier)
280
240
  ];
281
241
  let results = yield this.read(nodesToRead);
282
- let dataValues = [];
283
- for (let item of results) {
284
- dataValues.push(common_1.UaPayloadMapper.dataValueFromWebApi(item));
285
- }
286
- if (dataValues[0].statusCode.isNotGood())
287
- throw new common_1.UaError(dataValues[0].statusCode);
288
- let eventNotifierValue = dataValues[0].value;
242
+ if (results[0].statusCode.isNotGood())
243
+ throw new common_1.UaError(results[0].statusCode);
244
+ let eventNotifierValue = results[0].value;
289
245
  if (common_1.UaVariantType.Byte != eventNotifierValue.type)
290
246
  throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadNodeAttributesInvalid));
291
247
  let ret = {
@@ -301,36 +257,23 @@ class UaWebClient {
301
257
  inputs.push(common_1.UaPayloadMapper.variantToWebApi(item));
302
258
  }
303
259
  let methodsToCall = [
304
- { ObjectId: objectId.toString(), MethodId: methodId.toString(), InputArguments: inputs }
260
+ new common_2.UaCallMethodRequest(objectId, methodId, inputArguments)
305
261
  ];
306
262
  let results = yield this.call(methodsToCall);
307
- let statusCode = common_1.UaPayloadMapper.statusCodeFromWebApi(results[0].StatusCode);
308
- if (statusCode.isNotGood())
309
- throw new common_1.UaError(statusCode);
310
- let outputs = [];
311
- if (results[0].OutputArguments) {
312
- for (let item of results[0].OutputArguments) {
313
- outputs.push(common_1.UaPayloadMapper.variantFromWebApi(item));
314
- }
315
- }
263
+ if (results[0].statusCode.isNotGood())
264
+ throw new common_1.UaError(results[0].statusCode);
265
+ let outputs = results[0].outputArguments;
316
266
  return outputs;
317
267
  });
318
268
  }
319
269
  getGeneratedEventType(typeId) {
320
270
  return __awaiter(this, void 0, void 0, function* () {
321
- let nodesToBrowse = {
322
- NodeId: typeId.toString(),
323
- BrowseDirection: opcua_webapi_1.BrowseDirection.Forward,
324
- ReferenceTypeId: opcua_webapi_1.ReferenceTypeIds.GeneratesEvent,
325
- IncludeSubtypes: false,
326
- NodeClassMask: opcua_webapi_1.NodeClass.ObjectType,
327
- ResultMask: 0
328
- };
271
+ let nodesToBrowse = new common_1.UaBrowseDescription(typeId, opcua_webapi_1.BrowseDirection.Forward, common_1.UaNodeId.from(common_1.ReferenceTypeIds.GeneratesEvent), false, opcua_webapi_1.NodeClass.ObjectType, 0);
329
272
  let results = yield this.browse([nodesToBrowse]);
330
- let statusCode = common_1.UaPayloadMapper.statusCodeFromWebApi(results[0].StatusCode);
273
+ let statusCode = results[0].statusCode;
331
274
  if (statusCode.isNotGood())
332
275
  throw new common_1.UaError(statusCode);
333
- let browseResult = common_1.UaPayloadMapper.browseResultFromWebApi(results[0]);
276
+ let browseResult = results[0];
334
277
  let ret = [];
335
278
  for (let item of browseResult.results) {
336
279
  ret.push(item.nodeId.getNodeId());
@@ -340,24 +283,18 @@ class UaWebClient {
340
283
  }
341
284
  historyReadRawData(nodeId, startTime, endTime, numValuesPerNode, continuationPoint, returnBounds, isReadModified, timestampsToReturn, releaseContinuationPoints) {
342
285
  return __awaiter(this, void 0, void 0, function* () {
343
- let nodeToRead = {
344
- NodeId: nodeId.toString(),
345
- ContinuationPoint: (continuationPoint) ? continuationPoint : undefined
346
- };
286
+ let nodeToRead = new common_1.UaHistoryReadValueId(nodeId, continuationPoint);
347
287
  let details = new common_2.UaReadRawModifiedDetails(startTime, endTime, numValuesPerNode, returnBounds, isReadModified);
348
- let historyReadDetails = common_1.UaPayloadMapper.extensionObjectToWebApi(details.toExtensionObject());
288
+ let historyReadDetails = details.toExtensionObject();
349
289
  let nodesToRead = [nodeToRead];
350
290
  let results = yield this.historyRead(nodesToRead, historyReadDetails, timestampsToReturn, releaseContinuationPoints);
351
- if (results.length != 1)
352
- throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadUnexpectedError));
353
- let statusCode = common_1.UaPayloadMapper.statusCodeFromWebApi(results[0].StatusCode);
354
- if (statusCode.isNotGood())
355
- throw new common_1.UaError(statusCode);
356
- let extensionObject = common_1.UaPayloadMapper.extensionObjectFromWebApi(results[0].HistoryData);
291
+ if (results[0].statusCode.isNotGood())
292
+ throw new common_1.UaError(results[0].statusCode);
293
+ let extensionObject = results[0].historyData;
357
294
  let historyData = common_1.UaHistoryData.fromExtensionObject(extensionObject);
358
295
  if (null == historyData)
359
296
  throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadDecodingError));
360
- let ret = new common_1.UaHistoryDataResult(historyData.dataValues, results[0].ContinuationPoint);
297
+ let ret = new common_1.UaHistoryDataResult(historyData.dataValues, results[0].continuationPoint);
361
298
  return ret;
362
299
  });
363
300
  }
@@ -365,24 +302,18 @@ class UaWebClient {
365
302
  return __awaiter(this, void 0, void 0, function* () {
366
303
  if (requiredTimes.length == 0)
367
304
  throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadInvalidArgument));
368
- let nodeToRead = {
369
- NodeId: nodeId.toString(),
370
- ContinuationPoint: (continuationPoint) ? continuationPoint : undefined
371
- };
305
+ let nodeToRead = new common_1.UaHistoryReadValueId(nodeId, continuationPoint);
372
306
  let details = new common_2.UaReadAtTimeDetails(requiredTimes, useSimpleBounds);
373
- let historyReadDetails = common_1.UaPayloadMapper.extensionObjectToWebApi(details.toExtensionObject());
307
+ let historyReadDetails = details.toExtensionObject();
374
308
  let nodesToRead = [nodeToRead];
375
309
  let results = yield this.historyRead(nodesToRead, historyReadDetails, timestampsToReturn, releaseContinuationPoints);
376
- if (results.length != 1)
377
- throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadUnexpectedError));
378
- let statusCode = common_1.UaPayloadMapper.statusCodeFromWebApi(results[0].StatusCode);
379
- if (statusCode.isNotGood())
380
- throw new common_1.UaError(statusCode);
381
- let extensionObject = common_1.UaPayloadMapper.extensionObjectFromWebApi(results[0].HistoryData);
310
+ if (results[0].statusCode.isNotGood())
311
+ throw new common_1.UaError(results[0].statusCode);
312
+ let extensionObject = results[0].historyData;
382
313
  let historyData = common_1.UaHistoryData.fromExtensionObject(extensionObject);
383
314
  if (null == historyData)
384
315
  throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadDecodingError));
385
- let ret = new common_1.UaHistoryDataResult(historyData.dataValues, results[0].ContinuationPoint);
316
+ let ret = new common_1.UaHistoryDataResult(historyData.dataValues, results[0].continuationPoint);
386
317
  return ret;
387
318
  });
388
319
  }
@@ -390,10 +321,7 @@ class UaWebClient {
390
321
  return __awaiter(this, void 0, void 0, function* () {
391
322
  if (select.length == 0)
392
323
  throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadInvalidArgument));
393
- let nodeToRead = {
394
- NodeId: nodeId.toString(),
395
- ContinuationPoint: (continuationPoint) ? continuationPoint : undefined
396
- };
324
+ let nodeToRead = new common_1.UaHistoryReadValueId(nodeId, continuationPoint);
397
325
  let selectClauses = [];
398
326
  let whereClauses = (where) ? where.toContentFilter() : null;
399
327
  for (let item of select) {
@@ -401,19 +329,16 @@ class UaWebClient {
401
329
  selectClauses.push(selectedField);
402
330
  }
403
331
  let details = new common_1.UaReadEventDetails(startTime, endTime, new common_1.UaEventFilter(selectClauses, whereClauses), numValuesPerNode);
404
- let historyReadDetails = common_1.UaPayloadMapper.extensionObjectToWebApi(details.toExtensionObject());
332
+ let historyReadDetails = details.toExtensionObject();
405
333
  let nodesToRead = [nodeToRead];
406
334
  let results = yield this.historyRead(nodesToRead, historyReadDetails, opcua_webapi_1.TimestampsToReturn.Both, releaseContinuationPoints);
407
- if (results.length != 1)
408
- throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadUnexpectedError));
409
- let statusCode = common_1.UaPayloadMapper.statusCodeFromWebApi(results[0].StatusCode);
410
- if (statusCode.isNotGood())
411
- throw new common_1.UaError(statusCode);
412
- let extensionObject = common_1.UaPayloadMapper.extensionObjectFromWebApi(results[0].HistoryData);
335
+ if (results[0].statusCode.isNotGood())
336
+ throw new common_1.UaError(results[0].statusCode);
337
+ let extensionObject = results[0].historyData;
413
338
  let historyData = common_2.UaHistoryEvent.fromExtensionObject(extensionObject);
414
339
  if (null == historyData)
415
340
  throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadDecodingError));
416
- let ret = new common_2.UaHistoryEventResult(historyData.events, results[0].ContinuationPoint);
341
+ let ret = new common_2.UaHistoryEventResult(historyData.events, results[0].continuationPoint);
417
342
  return ret;
418
343
  });
419
344
  }
@@ -421,9 +346,15 @@ class UaWebClient {
421
346
  browse(nodesToBrowse, maxReferencesPerNode, view, additionalParameters) {
422
347
  return __awaiter(this, void 0, void 0, function* () {
423
348
  var _a, _b;
349
+ if (nodesToBrowse.length == 0)
350
+ throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadNothingToDo));
351
+ let NodesToBrowse = [];
352
+ for (let item of nodesToBrowse) {
353
+ NodesToBrowse.push(item.toStruct());
354
+ }
424
355
  let request = (0, opcua_webapi_1.BrowseRequestFromJSON)({
425
356
  RequestHeader: this.requestHeader(this.clientConfig, additionalParameters),
426
- NodesToBrowse: nodesToBrowse,
357
+ NodesToBrowse: NodesToBrowse,
427
358
  RequestedMaxReferencesPerNode: (maxReferencesPerNode && maxReferencesPerNode > 0) ? maxReferencesPerNode : undefined,
428
359
  View: view
429
360
  });
@@ -432,12 +363,23 @@ class UaWebClient {
432
363
  throw new common_1.UaError((0, common_1.makeUaStatusCode)(response.ResponseHeader.ServiceResult.Code));
433
364
  if (!response.Results || nodesToBrowse.length != response.Results.length)
434
365
  throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadDataLost));
435
- return response.Results;
366
+ let results = [];
367
+ if (response.Results) {
368
+ for (let item of response.Results) {
369
+ let result = common_1.UaBrowseResult.fromStruct(item);
370
+ if (null == result)
371
+ throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadDecodingError));
372
+ results.push(result);
373
+ }
374
+ }
375
+ return results;
436
376
  });
437
377
  }
438
378
  browseNext(continuationPoints, releaseContinuationPoints, additionalParameters) {
439
379
  return __awaiter(this, void 0, void 0, function* () {
440
380
  var _a, _b;
381
+ if (continuationPoints.length == 0)
382
+ throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadNothingToDo));
441
383
  let request = (0, opcua_webapi_1.BrowseNextRequestFromJSON)({
442
384
  RequestHeader: this.requestHeader(this.clientConfig, additionalParameters),
443
385
  ContinuationPoints: continuationPoints,
@@ -448,91 +390,131 @@ class UaWebClient {
448
390
  throw new common_1.UaError((0, common_1.makeUaStatusCode)(response.ResponseHeader.ServiceResult.Code));
449
391
  if (!response.Results || continuationPoints.length != response.Results.length)
450
392
  throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadDataLost));
451
- return response.Results;
452
- });
453
- }
454
- translate(browsePaths, additionalParameters) {
455
- return __awaiter(this, void 0, void 0, function* () {
456
- var _a, _b;
457
- let request = (0, opcua_webapi_1.TranslateBrowsePathsToNodeIdsRequestFromJSON)({
458
- RequestHeader: this.requestHeader(this.clientConfig, additionalParameters),
459
- BrowsePaths: browsePaths
460
- });
461
- let response = yield this.api.translateBrowsePathsToNodeIds({ translateBrowsePathsToNodeIdsRequest: request });
462
- if ((_b = (_a = response === null || response === void 0 ? void 0 : response.ResponseHeader) === null || _a === void 0 ? void 0 : _a.ServiceResult) === null || _b === void 0 ? void 0 : _b.Code)
463
- throw new common_1.UaError((0, common_1.makeUaStatusCode)(response.ResponseHeader.ServiceResult.Code));
464
- if (!response.Results || browsePaths.length != response.Results.length)
465
- throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadUnknownResponse));
466
- return response.Results;
393
+ let results = [];
394
+ for (let item of response.Results) {
395
+ let result = common_1.UaBrowseResult.fromStruct(item);
396
+ if (null == result)
397
+ throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadDecodingError));
398
+ results.push(result);
399
+ }
400
+ return results;
467
401
  });
468
402
  }
469
403
  read(nodesToRead, timestampsToReturn, maxAge, additionalParameters) {
470
404
  return __awaiter(this, void 0, void 0, function* () {
471
405
  var _a, _b;
406
+ if (nodesToRead.length == 0)
407
+ throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadNothingToDo));
408
+ let NodesToRead = [];
409
+ for (let item of nodesToRead) {
410
+ NodesToRead.push(item.toStruct());
411
+ }
472
412
  let request = (0, opcua_webapi_1.ReadRequestFromJSON)({
473
413
  RequestHeader: this.requestHeader(this.clientConfig, additionalParameters),
474
- NodesToRead: nodesToRead,
414
+ NodesToRead: NodesToRead,
475
415
  MaxAge: (maxAge && maxAge > 0) ? maxAge : undefined,
476
416
  TimestampsToReturn: (timestampsToReturn &&
477
417
  timestampsToReturn >= opcua_webapi_1.TimestampsToReturn.Source &&
478
- timestampsToReturn < opcua_webapi_1.TimestampsToReturn.Invalid) ? timestampsToReturn : undefined
418
+ timestampsToReturn < opcua_webapi_1.TimestampsToReturn.Invalid) ? timestampsToReturn : opcua_webapi_1.TimestampsToReturn.Neither
479
419
  });
480
420
  let response = yield this.api.read({ readRequest: request });
481
421
  if ((_b = (_a = response === null || response === void 0 ? void 0 : response.ResponseHeader) === null || _a === void 0 ? void 0 : _a.ServiceResult) === null || _b === void 0 ? void 0 : _b.Code)
482
422
  throw new common_1.UaError((0, common_1.makeUaStatusCode)(response.ResponseHeader.ServiceResult.Code));
483
423
  if (!response.Results || nodesToRead.length != response.Results.length)
484
424
  throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadDataLost));
485
- return response.Results;
425
+ let results = [];
426
+ for (let item of response.Results) {
427
+ let result = common_1.UaPayloadMapper.dataValueFromWebApi(item);
428
+ results.push(result);
429
+ }
430
+ return results;
486
431
  });
487
432
  }
488
433
  write(nodesToWrite, additionalParameters) {
489
434
  return __awaiter(this, void 0, void 0, function* () {
490
435
  var _a, _b;
436
+ if (nodesToWrite.length == 0)
437
+ throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadNothingToDo));
438
+ let NodesToWrite = [];
439
+ for (let item of nodesToWrite) {
440
+ NodesToWrite.push(item.toStruct());
441
+ }
491
442
  let request = (0, opcua_webapi_1.WriteRequestFromJSON)({
492
443
  RequestHeader: this.requestHeader(this.clientConfig, additionalParameters),
493
- NodesToWrite: nodesToWrite
444
+ NodesToWrite: NodesToWrite
494
445
  });
495
446
  let response = yield this.api.write({ writeRequest: request });
496
447
  if ((_b = (_a = response === null || response === void 0 ? void 0 : response.ResponseHeader) === null || _a === void 0 ? void 0 : _a.ServiceResult) === null || _b === void 0 ? void 0 : _b.Code)
497
448
  throw new common_1.UaError((0, common_1.makeUaStatusCode)(response.ResponseHeader.ServiceResult.Code));
498
449
  if (!response.Results || nodesToWrite.length != response.Results.length)
499
450
  throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadDataLost));
500
- return response.Results;
451
+ let results = [];
452
+ for (let item of response.Results) {
453
+ let result = common_1.UaPayloadMapper.statusCodeFromWebApi(item);
454
+ results.push(result);
455
+ }
456
+ return results;
501
457
  });
502
458
  }
503
459
  call(methodsToCall, additionalParameters) {
504
460
  return __awaiter(this, void 0, void 0, function* () {
505
461
  var _a, _b;
462
+ if (methodsToCall.length == 0)
463
+ throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadNothingToDo));
464
+ let MethodsToCall = [];
465
+ for (let item of methodsToCall) {
466
+ MethodsToCall.push(item.toStruct());
467
+ }
506
468
  let request = (0, opcua_webapi_1.CallRequestFromJSON)({
507
469
  RequestHeader: this.requestHeader(this.clientConfig, additionalParameters),
508
- MethodsToCall: methodsToCall
470
+ MethodsToCall: MethodsToCall
509
471
  });
510
472
  let response = yield this.api.call({ callRequest: request });
511
473
  if ((_b = (_a = response === null || response === void 0 ? void 0 : response.ResponseHeader) === null || _a === void 0 ? void 0 : _a.ServiceResult) === null || _b === void 0 ? void 0 : _b.Code)
512
474
  throw new common_1.UaError((0, common_1.makeUaStatusCode)(response.ResponseHeader.ServiceResult.Code));
513
475
  if (!response.Results || methodsToCall.length != response.Results.length)
514
476
  throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadDataLost));
515
- return response.Results;
477
+ let results = [];
478
+ for (let item of response.Results) {
479
+ let result = common_2.UaCallMethodResult.fromStruct(item);
480
+ if (null == result)
481
+ throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadDecodingError));
482
+ results.push(result);
483
+ }
484
+ return results;
516
485
  });
517
486
  }
518
487
  historyRead(nodesToRead, historyReadDetails, timestampsToReturn, releaseContinuationPoints, additionalParameters) {
519
488
  return __awaiter(this, void 0, void 0, function* () {
520
489
  var _a, _b;
490
+ if (nodesToRead.length == 0)
491
+ throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadNothingToDo));
492
+ let NodesToRead = [];
493
+ for (let item of nodesToRead) {
494
+ NodesToRead.push(item.toStruct());
495
+ }
521
496
  let request = (0, opcua_webapi_1.HistoryReadRequestFromJSON)({
522
497
  RequestHeader: this.requestHeader(this.clientConfig, additionalParameters),
523
- HistoryReadDetails: historyReadDetails,
498
+ HistoryReadDetails: common_1.UaPayloadMapper.extensionObjectToWebApi(historyReadDetails),
524
499
  TimestampsToReturn: (timestampsToReturn &&
525
500
  timestampsToReturn >= opcua_webapi_1.TimestampsToReturn.Source &&
526
501
  timestampsToReturn < opcua_webapi_1.TimestampsToReturn.Invalid) ? timestampsToReturn : undefined,
527
502
  ReleaseContinuationPoints: releaseContinuationPoints,
528
- NodesToRead: nodesToRead
503
+ NodesToRead: NodesToRead
529
504
  });
530
505
  let response = yield this.api.historyRead({ historyReadRequest: request });
531
506
  if ((_b = (_a = response === null || response === void 0 ? void 0 : response.ResponseHeader) === null || _a === void 0 ? void 0 : _a.ServiceResult) === null || _b === void 0 ? void 0 : _b.Code)
532
507
  throw new common_1.UaError((0, common_1.makeUaStatusCode)(response.ResponseHeader.ServiceResult.Code));
533
508
  if (!response.Results || nodesToRead.length != response.Results.length)
534
509
  throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadDataLost));
535
- return response.Results;
510
+ let results = [];
511
+ for (let item of response.Results) {
512
+ let result = common_1.UaHistoryReadResult.fromStruct(item);
513
+ if (null == result)
514
+ throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadDecodingError));
515
+ results.push(result);
516
+ }
517
+ return results;
536
518
  });
537
519
  }
538
520
  findServer(endpointUrl, serverUris, localeIds, additionalParameters) {
@@ -49,31 +49,25 @@ class UaDataTypeDictionary {
49
49
  let nodeIds = this._remainingNodesToBrowse.splice(0, 15);
50
50
  let nodesToBrowse = [];
51
51
  for (let item of nodeIds) {
52
- nodesToBrowse.push({
53
- NodeId: item.toString(),
54
- BrowseDirection: opcua_webapi_1.BrowseDirection.Forward,
55
- ReferenceTypeId: new common_1.UaNodeId(common_1.ReferenceTypeIds.HasSubtype).toString(),
56
- IncludeSubtypes: false,
57
- NodeClassMask: opcua_webapi_1.NodeClass.DataType,
58
- ResultMask: 31
59
- });
52
+ let browseDescription = new common_1.UaBrowseDescription(item, opcua_webapi_1.BrowseDirection.Forward, new common_1.UaNodeId(common_1.ReferenceTypeIds.HasSubtype), false, opcua_webapi_1.NodeClass.DataType, 31);
53
+ nodesToBrowse.push(browseDescription);
60
54
  }
61
55
  let results = yield client.browse(nodesToBrowse);
62
56
  for (let i = 0; i < nodeIds.length; ++i) {
63
- let statusCode = common_1.UaPayloadMapper.statusCodeFromWebApi(results[i].StatusCode);
64
- if (statusCode.isNotGood() || !results[i].References)
57
+ if (results[i].statusCode.isNotGood())
65
58
  continue;
66
59
  let parentType = this._dataTypes.get(nodeIds[i].toString());
67
- for (let item of results[i].References) {
68
- let dataTypeId = (0, common_1.parseUaNodeIdOrNull)(item.NodeId);
69
- if (!dataTypeId || opcua_webapi_1.NodeClass.DataType != item.NodeClass ||
70
- !item.BrowseName || !item.DisplayName)
60
+ for (let item of results[i].references) {
61
+ let dataTypeId = item.nodeId.getNodeId();
62
+ if (null == dataTypeId ||
63
+ opcua_webapi_1.NodeClass.DataType != item.nodeClass ||
64
+ !item.browseName || !item.displayName)
71
65
  continue;
72
66
  let isAbstract = false;
73
67
  if (dataTypeId.nsIndex == 0 &&
74
68
  UaDataTypeDictionary._abstractDataTypeIds.has(dataTypeId.numericId()))
75
69
  isAbstract = true;
76
- let dataType = new common_1.UaDataType(dataTypeId, item.BrowseName, common_1.UaPayloadMapper.localizedTextFromWebApi(item.DisplayName), isAbstract);
70
+ let dataType = new common_1.UaDataType(dataTypeId, item.browseName, item.displayName, isAbstract);
77
71
  this._dataTypes.set(dataTypeId.toString(), dataType);
78
72
  this._remainingNodesToBrowse.push(dataTypeId);
79
73
  if (parentType)
@@ -97,24 +91,18 @@ class UaDataTypeDictionary {
97
91
  let nodeIds = this._remainingEnumerationToRead.splice(0, 20);
98
92
  let nodesToBrowse = [];
99
93
  for (let item of nodeIds) {
100
- nodesToBrowse.push({
101
- NodeId: item.toString(),
102
- BrowseDirection: opcua_webapi_1.BrowseDirection.Forward,
103
- ReferenceTypeId: new common_1.UaNodeId(common_1.ReferenceTypeIds.HasProperty).toString(),
104
- IncludeSubtypes: false,
105
- NodeClassMask: opcua_webapi_1.NodeClass.Variable,
106
- ResultMask: 8
107
- });
94
+ let browseDescription = new common_1.UaBrowseDescription(item, opcua_webapi_1.BrowseDirection.Forward, new common_1.UaNodeId(common_1.ReferenceTypeIds.HasProperty), false, opcua_webapi_1.NodeClass.Variable, 8);
95
+ nodesToBrowse.push(browseDescription);
108
96
  }
109
97
  let results = yield client.browse(nodesToBrowse);
110
98
  let enumDataTypeIds = [];
111
99
  let enumValueIds = [];
112
100
  for (let i = 0; i < nodeIds.length; ++i) {
113
- let statusCode = common_1.UaPayloadMapper.statusCodeFromWebApi(results[i].StatusCode);
114
- if (statusCode.isNotGood() || !results[i].References || results[i].References.length == 0)
101
+ if (results[i].statusCode.isNotGood() ||
102
+ results[i].references.length == 0)
115
103
  continue;
116
- if (results[i].References[0].BrowseName == "EnumStrings" || results[i].References[0].BrowseName == "EnumValues") {
117
- let enumValueId = (0, common_1.parseUaNodeIdOrNull)(results[i].References[0].NodeId);
104
+ if (results[i].references[0].browseName == "EnumStrings" || results[i].references[0].browseName == "EnumValues") {
105
+ let enumValueId = results[i].references[0].nodeId.getNodeId();
118
106
  if (enumValueId) {
119
107
  enumDataTypeIds.push(nodeIds[i]);
120
108
  enumValueIds.push(enumValueId);
@@ -16,7 +16,7 @@ type BrowseResult = {
16
16
  displayName: UaLocalizedText;
17
17
  referenceTypeId: UaNodeId;
18
18
  isForward: boolean;
19
- typeDefinitionId?: UaNodeId;
19
+ typeDefinitionId?: UaNodeId | null;
20
20
  };
21
21
  type ReadResult = {
22
22
  parentId: UaNodeId;