node-opcua-address-space 2.130.0 → 2.132.0

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 (28) hide show
  1. package/dist/source/loader/generateAddressSpaceRaw.js +1 -1
  2. package/dist/source/loader/generateAddressSpaceRaw.js.map +1 -1
  3. package/dist/src/alarms_and_conditions/condition.js +1 -1
  4. package/dist/src/alarms_and_conditions/condition.js.map +1 -1
  5. package/dist/src/alarms_and_conditions/condition_snapshot_impl.js +1 -5
  6. package/dist/src/alarms_and_conditions/condition_snapshot_impl.js.map +1 -1
  7. package/dist/src/alarms_and_conditions/ua_certificate_expiration_alarm_impl.js +4 -4
  8. package/dist/src/alarms_and_conditions/ua_certificate_expiration_alarm_impl.js.map +1 -1
  9. package/dist/src/alarms_and_conditions/ua_condition_impl.js +2 -2
  10. package/dist/src/alarms_and_conditions/ua_condition_impl.js.map +1 -1
  11. package/dist/src/base_node_impl.js +3 -5
  12. package/dist/src/base_node_impl.js.map +1 -1
  13. package/dist/src/nodeset_tools/nodeset_to_xml.js +1 -1
  14. package/dist/src/nodeset_tools/nodeset_to_xml.js.map +1 -1
  15. package/dist/src/ua_reference_type_impl.d.ts +1 -1
  16. package/dist/src/ua_variable_impl.d.ts +2 -1
  17. package/dist/src/ua_variable_impl.js +32 -0
  18. package/dist/src/ua_variable_impl.js.map +1 -1
  19. package/dist/tsconfig_common.tsbuildinfo +1 -1
  20. package/package.json +27 -27
  21. package/source/loader/generateAddressSpaceRaw.ts +2 -2
  22. package/src/alarms_and_conditions/condition.ts +2 -2
  23. package/src/alarms_and_conditions/condition_snapshot_impl.ts +1 -2
  24. package/src/alarms_and_conditions/ua_certificate_expiration_alarm_impl.ts +5 -5
  25. package/src/alarms_and_conditions/ua_condition_impl.ts +3 -3
  26. package/src/base_node_impl.ts +3 -5
  27. package/src/nodeset_tools/nodeset_to_xml.ts +5 -6
  28. package/src/ua_variable_impl.ts +38 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-opcua-address-space",
3
- "version": "2.130.0",
3
+ "version": "2.132.0",
4
4
  "description": "pure nodejs OPCUA SDK - module address-space",
5
5
  "main": "./dist/src/index_current.js",
6
6
  "types": "./dist/source/index.d.ts",
@@ -18,41 +18,41 @@
18
18
  "dependencies": {
19
19
  "@types/lodash": "4.17.7",
20
20
  "@types/semver": "^7.5.8",
21
- "async": "^3.2.5",
21
+ "async": "^3.2.6",
22
22
  "chalk": "4.1.2",
23
23
  "dequeue": "^1.0.5",
24
24
  "lodash": "4.17.21",
25
- "node-opcua-address-space-base": "2.129.0",
25
+ "node-opcua-address-space-base": "2.132.0",
26
26
  "node-opcua-assert": "2.120.0",
27
- "node-opcua-basic-types": "2.128.0",
27
+ "node-opcua-basic-types": "2.132.0",
28
28
  "node-opcua-binary-stream": "2.128.0",
29
- "node-opcua-client-dynamic-extension-object": "2.130.0",
29
+ "node-opcua-client-dynamic-extension-object": "2.132.0",
30
30
  "node-opcua-constants": "2.125.0",
31
- "node-opcua-crypto": "4.9.2",
32
- "node-opcua-data-access": "2.129.0",
33
- "node-opcua-data-model": "2.128.0",
34
- "node-opcua-data-value": "2.129.0",
35
- "node-opcua-date-time": "2.128.0",
31
+ "node-opcua-crypto": "4.9.4",
32
+ "node-opcua-data-access": "2.132.0",
33
+ "node-opcua-data-model": "2.132.0",
34
+ "node-opcua-data-value": "2.132.0",
35
+ "node-opcua-date-time": "2.132.0",
36
36
  "node-opcua-debug": "2.128.0",
37
37
  "node-opcua-enum": "2.128.0",
38
- "node-opcua-extension-object": "2.128.0",
39
- "node-opcua-factory": "2.128.0",
38
+ "node-opcua-extension-object": "2.132.0",
39
+ "node-opcua-factory": "2.132.0",
40
40
  "node-opcua-nodeid": "2.128.0",
41
- "node-opcua-nodeset-ua": "2.129.0",
42
- "node-opcua-numeric-range": "2.128.0",
41
+ "node-opcua-nodeset-ua": "2.132.0",
42
+ "node-opcua-numeric-range": "2.132.0",
43
43
  "node-opcua-object-registry": "2.128.0",
44
- "node-opcua-pseudo-session": "2.130.0",
45
- "node-opcua-service-browse": "2.129.0",
46
- "node-opcua-service-call": "2.129.0",
47
- "node-opcua-service-history": "2.129.0",
48
- "node-opcua-service-translate-browse-path": "2.129.0",
49
- "node-opcua-service-write": "2.129.0",
44
+ "node-opcua-pseudo-session": "2.132.0",
45
+ "node-opcua-service-browse": "2.132.0",
46
+ "node-opcua-service-call": "2.132.0",
47
+ "node-opcua-service-history": "2.132.0",
48
+ "node-opcua-service-translate-browse-path": "2.132.0",
49
+ "node-opcua-service-write": "2.132.0",
50
50
  "node-opcua-status-code": "2.128.0",
51
- "node-opcua-types": "2.129.0",
51
+ "node-opcua-types": "2.132.0",
52
52
  "node-opcua-utils": "2.128.0",
53
- "node-opcua-variant": "2.129.0",
53
+ "node-opcua-variant": "2.132.0",
54
54
  "node-opcua-xml2json": "2.128.0",
55
- "semver": "^7.6.2",
55
+ "semver": "^7.6.3",
56
56
  "set-prototype-of": "^1.0.0",
57
57
  "thenify": "^3.3.1",
58
58
  "xml-writer": "^1.7.0"
@@ -61,9 +61,9 @@
61
61
  "node-opcua-benchmarker": "2.128.0",
62
62
  "node-opcua-leak-detector": "2.128.0",
63
63
  "node-opcua-nodesets": "2.121.0",
64
- "node-opcua-packet-analyzer": "2.128.0",
65
- "node-opcua-service-filter": "2.129.0",
66
- "node-opcua-test-fixtures": "2.129.0",
64
+ "node-opcua-packet-analyzer": "2.132.0",
65
+ "node-opcua-service-filter": "2.132.0",
66
+ "node-opcua-test-fixtures": "2.132.0",
67
67
  "source-map-support": "^0.5.21"
68
68
  },
69
69
  "author": "Etienne Rossignon",
@@ -81,7 +81,7 @@
81
81
  "internet of things"
82
82
  ],
83
83
  "homepage": "http://node-opcua.github.io/",
84
- "gitHead": "94bf9012b03dbd4325cd122ce04edfa5466875bc",
84
+ "gitHead": "5fab0f1eac0e59abf94bab9034035aec44890456",
85
85
  "files": [
86
86
  "dist",
87
87
  "distHelpers",
@@ -2,7 +2,7 @@ import { checkDebugFlag, make_debugLog, make_errorLog } from "node-opcua-debug";
2
2
  import { CallbackT } from "node-opcua-status-code";
3
3
  import { IAddressSpace, RequiredModel } from "node-opcua-address-space-base";
4
4
  import { ReaderStateParserLike, Xml2Json } from "node-opcua-xml2json";
5
- import { minDate } from "node-opcua-date-time";
5
+ import { getMinOPCUADate } from "node-opcua-date-time";
6
6
  import { adjustNamespaceArray } from "../../src/nodeset_tools/adjust_namespace_array";
7
7
  import { NodeSetLoaderOptions } from "../interfaces/nodeset_loader_options";
8
8
  import { NamespacePrivate } from "../../src/namespace_private";
@@ -85,7 +85,7 @@ async function parseDependencies(xmlData: string): Promise<NodesetInfo> {
85
85
  models.push({
86
86
  modelUri: namespaceUris[0],
87
87
  version: "1",
88
- publicationDate: minDate,
88
+ publicationDate: getMinOPCUADate(),
89
89
  requiredModel: []
90
90
  });
91
91
  }
@@ -4,7 +4,7 @@
4
4
  require("set-prototype-of");
5
5
  import { assert } from "node-opcua-assert";
6
6
  import { LocalizedText, LocalizedTextLike } from "node-opcua-data-model";
7
- import { minDate } from "node-opcua-basic-types";
7
+ import { getMinOPCUADate } from "node-opcua-basic-types";
8
8
  import { StatusCode, StatusCodes } from "node-opcua-status-code";
9
9
  import { ISetStateOptions } from "../../source/interfaces/i_set_state_options";
10
10
  import { ConditionSnapshotImpl } from "./condition_snapshot_impl";
@@ -30,7 +30,7 @@ export function _setAckedState(
30
30
  // tslint:disable:max-classes-per-file
31
31
  function prepare_date(sourceTimestamp: { value: Date } | null) {
32
32
  if (!sourceTimestamp || !sourceTimestamp.value) {
33
- return minDate;
33
+ return getMinOPCUADate();
34
34
  }
35
35
  assert(sourceTimestamp.value instanceof Date);
36
36
  return sourceTimestamp;
@@ -542,8 +542,7 @@ export class ConditionSnapshotImpl extends EventEmitter implements ConditionSnap
542
542
  * @param time {Date} : UTCTime
543
543
  */
544
544
  public setReceiveTime(time: UtcTime): void {
545
- if (!(time instanceof Date)) { throw new Error("setReceiveTime expecting a Date")};
546
- return this._set_var("ReceiveTime", DataType.DateTime, time, { sourceTimestamp: time });
545
+ return this._set_var("ReceiveTime", DataType.DateTime, time, { sourceTimestamp: time || undefined });
547
546
  }
548
547
 
549
548
  /**
@@ -2,7 +2,7 @@
2
2
  * @module node-opcua-address-space.AlarmsAndConditions
3
3
  */
4
4
  import { Certificate, exploreCertificate, makeSHA1Thumbprint } from "node-opcua-crypto";
5
- import { DateTime, minOPCUADate, StatusCodes } from "node-opcua-basic-types";
5
+ import { DateTime, getMinOPCUADate, isMinDate, StatusCodes } from "node-opcua-basic-types";
6
6
  import { make_warningLog } from "node-opcua-debug";
7
7
  import { NodeId } from "node-opcua-nodeid";
8
8
  import { DataType, Variant, VariantOptions } from "node-opcua-variant";
@@ -97,7 +97,7 @@ class UACertificateExpirationAlarmImpl extends UASystemOffNormalAlarmImpl implem
97
97
 
98
98
  const certificate = this.getCertificate();
99
99
 
100
- if (!expirationDate || (expirationDate === minOPCUADate && !certificate)) {
100
+ if (!expirationDate || (isMinDate(expirationDate) && !certificate)) {
101
101
  if (!this.currentBranch() || this.currentBranch().getActiveState()) {
102
102
  this.updateAlarmState2(true, 255, "certificate is missing");
103
103
  }
@@ -163,13 +163,13 @@ class UACertificateExpirationAlarmImpl extends UASystemOffNormalAlarmImpl implem
163
163
  private _extractAndSetExpiryDate(certificate: Certificate | null): void {
164
164
  if (certificate && certificate.length > 0) {
165
165
  const info = exploreCertificate(certificate);
166
- if (info.tbsCertificate.validity.notAfter instanceof Date) {
166
+ if (info.tbsCertificate.validity.notAfter) {
167
167
  this.setExpirationDate(info.tbsCertificate.validity.notAfter);
168
168
  } else {
169
- this.setExpirationDate(minOPCUADate);
169
+ this.setExpirationDate(getMinOPCUADate());
170
170
  }
171
171
  } else {
172
- this.setExpirationDate(minOPCUADate);
172
+ this.setExpirationDate(getMinOPCUADate());
173
173
  }
174
174
  }
175
175
 
@@ -18,7 +18,7 @@ import {
18
18
  QualifiedName
19
19
  } from "node-opcua-data-model";
20
20
  import { checkDebugFlag, make_debugLog, make_errorLog, make_warningLog } from "node-opcua-debug";
21
- import { minDate } from "node-opcua-basic-types";
21
+ import { getMinOPCUADate } from "node-opcua-basic-types";
22
22
  import { coerceNodeId, makeNodeId, NodeId, resolveNodeId, sameNodeId } from "node-opcua-nodeid";
23
23
  import { CallbackT, StatusCode, StatusCodes } from "node-opcua-status-code";
24
24
  import { CallMethodResultOptions, TimeZoneDataType } from "node-opcua-types";
@@ -997,8 +997,8 @@ function UACondition_instantiate(
997
997
  );
998
998
  branch0.setMessage("");
999
999
 
1000
- branch0.setReceiveTime(minDate);
1001
- branch0.setTime(minDate);
1000
+ branch0.setReceiveTime(getMinOPCUADate());
1001
+ branch0.setTime(getMinOPCUADate());
1002
1002
 
1003
1003
  return conditionNode;
1004
1004
  }
@@ -1791,12 +1791,10 @@ function install_components_as_object_properties(parentObj: BaseNode) {
1791
1791
  }
1792
1792
 
1793
1793
  // ignore reserved names
1794
- if (doDebug) {
1795
- debugLog("Installing property " + name, " on ", parentObj.browseName.toString());
1796
- }
1794
+ doDebug && debugLog("Installing property " + name, " on ", parentObj.browseName.toString());
1797
1795
 
1798
- /* istanbul ignore next */
1799
- if (Object.prototype.hasOwnProperty.call(parentObj, name)) {
1796
+ const hasProperty = Object.prototype.hasOwnProperty.call(parentObj, name);
1797
+ if (hasProperty && ((parentObj as any)[name] !== null && (parentObj as any)[name] !== undefined)) {
1800
1798
  continue;
1801
1799
  }
1802
1800
 
@@ -17,13 +17,12 @@ import {
17
17
  makeAccessLevelFlag,
18
18
  QualifiedName
19
19
  } from "node-opcua-data-model";
20
- import { ExpandedNodeId, NodeId, NodeIdType, resolveNodeId } from "node-opcua-nodeid";
20
+ import { NodeId, NodeIdType, resolveNodeId } from "node-opcua-nodeid";
21
21
  import { lowerFirstLetter, isNullOrUndefined } from "node-opcua-utils";
22
22
  import { Variant, VariantArrayType, DataType } from "node-opcua-variant";
23
23
  import {
24
24
  IAddressSpace,
25
25
  BaseNode,
26
- INamespace,
27
26
  UADataType,
28
27
  UAMethod,
29
28
  UAObject,
@@ -33,10 +32,10 @@ import {
33
32
  UAVariableType,
34
33
  UAView
35
34
  } from "node-opcua-address-space-base";
36
- import { AttributeIds, Int64, minOPCUADate, StatusCode, StatusCodes } from "node-opcua-basic-types";
35
+ import { AttributeIds, Int64, isMinDate, StatusCode } from "node-opcua-basic-types";
37
36
  import { BrowseDescription, EnumDefinition, StructureDefinition, StructureType } from "node-opcua-types";
38
37
 
39
- import { ITranslationTable, XmlWriter } from "../../source/xml_writer";
38
+ import { XmlWriter } from "../../source/xml_writer";
40
39
  import { ReferenceImpl } from "../reference_impl";
41
40
  import { BaseNodeImpl, getReferenceType } from "../base_node_impl";
42
41
  import { UAReferenceTypeImpl } from "../ua_reference_type_impl";
@@ -50,7 +49,7 @@ import { UAVariableTypeImpl } from "../ua_variable_type_impl";
50
49
  import { SessionContext } from "../index_current";
51
50
  import { UAViewImpl } from "../ua_view_impl";
52
51
 
53
- import { DefinitionMap2, TypeInfo } from "../../source/loader/make_xml_extension_object_parser";
52
+ import { DefinitionMap2 } from "../../source/loader/make_xml_extension_object_parser";
54
53
  import { makeDefinitionMap } from "../../source/loader/decode_xml_extension_object";
55
54
  import {
56
55
  _constructNamespaceTranslationTable,
@@ -558,7 +557,7 @@ function _isDefaultValue(value: Variant): boolean {
558
557
  }
559
558
  break;
560
559
  case DataType.DateTime:
561
- if (!value.value || value.value.getTime() === minOPCUADate) {
560
+ if (!value.value || isMinDate(value.value)) {
562
561
  return true;
563
562
  }
564
563
  break;
@@ -32,7 +32,7 @@ import { extractRange, sameDataValue, DataValue, DataValueLike, DataValueT } fro
32
32
  import { coerceClock, getCurrentClock, PreciseClock } from "node-opcua-date-time";
33
33
  import { checkDebugFlag, make_debugLog, make_errorLog, make_warningLog } from "node-opcua-debug";
34
34
  import { ExtensionObject } from "node-opcua-extension-object";
35
- import { NodeId } from "node-opcua-nodeid";
35
+ import { NodeId, NodeIdLike } from "node-opcua-nodeid";
36
36
  import { NumericRange } from "node-opcua-numeric-range";
37
37
  import { WriteValue } from "node-opcua-service-write";
38
38
  import { StatusCode, StatusCodes, CallbackT } from "node-opcua-status-code";
@@ -421,7 +421,7 @@ export class UAVariableImpl extends BaseNodeImpl implements UAVariable {
421
421
  this.$dataValue = dataValueOrPromise as DataValue;
422
422
  if (this.$dataValue.statusCode.isGoodish()) {
423
423
  this.verifyVariantCompatibility(this.$dataValue.value);
424
- }
424
+ }
425
425
  }
426
426
  } else {
427
427
  errorLog(
@@ -1407,6 +1407,10 @@ export class UAVariableImpl extends BaseNodeImpl implements UAVariable {
1407
1407
  }
1408
1408
  }
1409
1409
 
1410
+ public changeDataType(newDataType: NodeIdLike, newValue?: VariantLike): void {
1411
+ changeUAVariableDataType(this, newDataType, newValue);
1412
+ }
1413
+
1410
1414
  /**
1411
1415
  * @private
1412
1416
  * install UAVariable to exposed th
@@ -2287,3 +2291,35 @@ export interface UAVariableImplT<T, DT extends DataType> extends UAVariableImpl,
2287
2291
  writeValue(context: ISessionContext, dataValue: DataValueT<T, DT>, indexRange?: NumericRange | null): Promise<StatusCode>;
2288
2292
  }
2289
2293
  export class UAVariableImplT<T, DT extends DataType> extends UAVariableImpl {}
2294
+
2295
+ function changeUAVariableDataType(uaVariable: UAVariableImpl, newDataType: NodeIdLike, valueLike?: VariantLike) {
2296
+ let value: Variant | null = valueLike ? (valueLike instanceof Variant ? valueLike : new Variant(valueLike)) : null;
2297
+
2298
+ const addressSpace = uaVariable.addressSpace;
2299
+ const newDataTypeNode = addressSpace.findNode(newDataType) as UADataType;
2300
+ // istanbul ignore next
2301
+ if (!newDataTypeNode || !(newDataTypeNode instanceof UADataTypeImpl)) {
2302
+ throw new Error("Cannot find newDataTypeNode " + newDataType.toString());
2303
+ }
2304
+
2305
+ const newBaseDataType: DataType = newDataTypeNode.basicDataType;
2306
+ // istanbul ignore next
2307
+ if (newBaseDataType === DataType.Null) {
2308
+ throw new Error("newDataTypeNode must be a DataType");
2309
+ }
2310
+ if (!value) {
2311
+ value = uaVariable.readValue().value;
2312
+ value.dataType = newBaseDataType;
2313
+ }
2314
+ if (newBaseDataType !== value.dataType) {
2315
+ throw new Error("newDataTypeNode must be of the same base dataType as the value");
2316
+ }
2317
+
2318
+ // change uaVariable.dataType
2319
+ uaVariable.dataType = newDataTypeNode.nodeId;
2320
+ (uaVariable as any)._basicDataType = null;
2321
+ (uaVariable as any).$dataValue.value.dataType = newDataType;
2322
+ (uaVariable as any).$dataValue.value.value = value;
2323
+ // also change the value to ensure that we have a default value with the correct dataType
2324
+ uaVariable._internal_set_value(value);
2325
+ }