node-opcua-address-space 2.169.0 → 2.170.1

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 (49) hide show
  1. package/dist/source/ua_interface.d.ts +2 -3
  2. package/dist/source/ua_interface.js +10 -33
  3. package/dist/source/ua_interface.js.map +1 -1
  4. package/dist/src/_instantiate_helpers.d.ts +1 -1
  5. package/dist/src/_instantiate_helpers.js +32 -9
  6. package/dist/src/_instantiate_helpers.js.map +1 -1
  7. package/dist/src/_mandatory_child_or_requested_optional_filter.js +3 -3
  8. package/dist/src/_mandatory_child_or_requested_optional_filter.js.map +1 -1
  9. package/dist/src/address_space.d.ts +2 -2
  10. package/dist/src/address_space.js +9 -11
  11. package/dist/src/address_space.js.map +1 -1
  12. package/dist/src/alarms_and_conditions/condition_snapshot_impl.js +1 -1
  13. package/dist/src/alarms_and_conditions/condition_snapshot_impl.js.map +1 -1
  14. package/dist/src/base_node_impl.d.ts +1 -1
  15. package/dist/src/base_node_private.d.ts +10 -7
  16. package/dist/src/base_node_private.js +74 -50
  17. package/dist/src/base_node_private.js.map +1 -1
  18. package/dist/src/check_value_rank_compatibility.js +1 -1
  19. package/dist/src/check_value_rank_compatibility.js.map +1 -1
  20. package/dist/src/event_data.d.ts +8 -21
  21. package/dist/src/event_data.js +24 -19
  22. package/dist/src/event_data.js.map +1 -1
  23. package/dist/src/ua_object_impl.d.ts +6 -5
  24. package/dist/src/ua_object_impl.js +30 -4
  25. package/dist/src/ua_object_impl.js.map +1 -1
  26. package/dist/src/ua_object_type_impl.js +2 -2
  27. package/dist/src/ua_object_type_impl.js.map +1 -1
  28. package/dist/src/ua_variable_impl.d.ts +1 -0
  29. package/dist/src/ua_variable_impl.js +79 -1
  30. package/dist/src/ua_variable_impl.js.map +1 -1
  31. package/dist/tsconfig_base.tsbuildinfo +1 -1
  32. package/distHelpers/get_address_space_fixture.js +14 -14
  33. package/distHelpers/get_address_space_fixture.js.map +1 -1
  34. package/distHelpers/index.d.ts +2 -2
  35. package/distHelpers/index.js +2 -2
  36. package/distHelpers/index.js.map +1 -1
  37. package/package.json +18 -18
  38. package/source/ua_interface.ts +24 -38
  39. package/src/_instantiate_helpers.ts +67 -24
  40. package/src/_mandatory_child_or_requested_optional_filter.ts +5 -5
  41. package/src/address_space.ts +15 -16
  42. package/src/alarms_and_conditions/condition_snapshot_impl.ts +3 -3
  43. package/src/base_node_impl.ts +1 -1
  44. package/src/base_node_private.ts +163 -139
  45. package/src/check_value_rank_compatibility.ts +1 -1
  46. package/src/event_data.ts +57 -54
  47. package/src/ua_object_impl.ts +51 -22
  48. package/src/ua_object_type_impl.ts +3 -3
  49. package/src/ua_variable_impl.ts +79 -2
@@ -7,33 +7,33 @@ exports.getAddressSpaceFixture = getAddressSpaceFixture;
7
7
  /**
8
8
  * @module node-opcua-address-space
9
9
  */
10
- const fs_1 = __importDefault(require("fs"));
11
- const path_1 = __importDefault(require("path"));
10
+ const node_fs_1 = __importDefault(require("node:fs"));
11
+ const node_path_1 = __importDefault(require("node:path"));
12
12
  function getAddressSpaceFixture(pathname) {
13
13
  // find in nodesets folder in the first place
14
- const folder1 = path_1.default.join(__dirname, "../nodesets");
15
- if (fs_1.default.existsSync(folder1)) {
16
- const filename = path_1.default.join(folder1, pathname);
17
- if (fs_1.default.existsSync(filename)) {
14
+ const folder1 = node_path_1.default.join(__dirname, "../nodesets");
15
+ if (node_fs_1.default.existsSync(folder1)) {
16
+ const filename = node_path_1.default.join(folder1, pathname);
17
+ if (node_fs_1.default.existsSync(filename)) {
18
18
  return filename;
19
19
  }
20
20
  }
21
21
  // find in test_fixtures seconds
22
- let folder = path_1.default.join(__dirname, "./test_fixtures");
23
- if (!fs_1.default.existsSync(folder)) {
24
- folder = path_1.default.join(__dirname, "../test_helpers/test_fixtures");
25
- if (!fs_1.default.existsSync(folder)) {
26
- folder = path_1.default.join(__dirname, "../../test_helpers/test_fixtures");
22
+ let folder = node_path_1.default.join(__dirname, "./test_fixtures");
23
+ if (!node_fs_1.default.existsSync(folder)) {
24
+ folder = node_path_1.default.join(__dirname, "../test_helpers/test_fixtures");
25
+ if (!node_fs_1.default.existsSync(folder)) {
26
+ folder = node_path_1.default.join(__dirname, "../../test_helpers/test_fixtures");
27
27
  // c8 ignore next
28
- if (!fs_1.default.existsSync(folder)) {
28
+ if (!node_fs_1.default.existsSync(folder)) {
29
29
  // tslint:disable:no-console
30
30
  console.log(" cannot find test_fixtures folder ");
31
31
  }
32
32
  }
33
33
  }
34
- const filename = path_1.default.join(folder, pathname);
34
+ const filename = node_path_1.default.join(folder, pathname);
35
35
  // c8 ignore next
36
- if (!fs_1.default.existsSync(filename)) {
36
+ if (!node_fs_1.default.existsSync(filename)) {
37
37
  throw new Error(" cannot find fixture with name " + pathname);
38
38
  }
39
39
  return filename;
@@ -1 +1 @@
1
- {"version":3,"file":"get_address_space_fixture.js","sourceRoot":"","sources":["../test_helpers/get_address_space_fixture.ts"],"names":[],"mappings":";;;;;AAMA,wDAgCC;AAtCD;;GAEG;AACH,4CAAoB;AACpB,gDAAwB;AAExB,SAAgB,sBAAsB,CAAC,QAAgB;IAEnD,6CAA6C;IAC7C,MAAM,OAAO,GAAG,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;IACpD,IAAI,YAAE,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;QACzB,MAAM,QAAQ,GAAG,cAAI,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QAC9C,IAAI,YAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC1B,OAAO,QAAQ,CAAC;QACpB,CAAC;IACL,CAAC;IAED,iCAAiC;IACjC,IAAI,MAAM,GAAG,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,iBAAiB,CAAC,CAAC;IACrD,IAAI,CAAC,YAAE,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;QACzB,MAAM,GAAG,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,+BAA+B,CAAC,CAAC;QAC/D,IAAI,CAAC,YAAE,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;YACzB,MAAM,GAAG,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,kCAAkC,CAAC,CAAC;YAElE,iBAAiB;YACjB,IAAI,CAAC,YAAE,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;gBACzB,4BAA4B;gBAC5B,OAAO,CAAC,GAAG,CAAC,oCAAoC,CAAC,CAAC;YACtD,CAAC;QACL,CAAC;IACL,CAAC;IACD,MAAM,QAAQ,GAAG,cAAI,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAE7C,iBAAiB;IACjB,IAAI,CAAC,YAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC3B,MAAM,IAAI,KAAK,CAAC,iCAAiC,GAAG,QAAQ,CAAC,CAAC;IAClE,CAAC;IACD,OAAO,QAAQ,CAAC;AACpB,CAAC"}
1
+ {"version":3,"file":"get_address_space_fixture.js","sourceRoot":"","sources":["../test_helpers/get_address_space_fixture.ts"],"names":[],"mappings":";;;;;AAMA,wDAgCC;AAtCD;;GAEG;AACH,sDAAyB;AACzB,0DAA6B;AAE7B,SAAgB,sBAAsB,CAAC,QAAgB;IAEnD,6CAA6C;IAC7C,MAAM,OAAO,GAAG,mBAAI,CAAC,IAAI,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;IACpD,IAAI,iBAAE,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;QACzB,MAAM,QAAQ,GAAG,mBAAI,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QAC9C,IAAI,iBAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC1B,OAAO,QAAQ,CAAC;QACpB,CAAC;IACL,CAAC;IAED,iCAAiC;IACjC,IAAI,MAAM,GAAG,mBAAI,CAAC,IAAI,CAAC,SAAS,EAAE,iBAAiB,CAAC,CAAC;IACrD,IAAI,CAAC,iBAAE,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;QACzB,MAAM,GAAG,mBAAI,CAAC,IAAI,CAAC,SAAS,EAAE,+BAA+B,CAAC,CAAC;QAC/D,IAAI,CAAC,iBAAE,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;YACzB,MAAM,GAAG,mBAAI,CAAC,IAAI,CAAC,SAAS,EAAE,kCAAkC,CAAC,CAAC;YAElE,iBAAiB;YACjB,IAAI,CAAC,iBAAE,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;gBACzB,4BAA4B;gBAC5B,OAAO,CAAC,GAAG,CAAC,oCAAoC,CAAC,CAAC;YACtD,CAAC;QACL,CAAC;IACL,CAAC;IACD,MAAM,QAAQ,GAAG,mBAAI,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAE7C,iBAAiB;IACjB,IAAI,CAAC,iBAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC3B,MAAM,IAAI,KAAK,CAAC,iCAAiC,GAAG,QAAQ,CAAC,CAAC;IAClE,CAAC;IACD,OAAO,QAAQ,CAAC;AACpB,CAAC"}
@@ -4,9 +4,9 @@
4
4
  export * from "./add_event_generator_object";
5
5
  export * from "./alarms_and_conditions_demo";
6
6
  export * from "./assertHasMatchingReference";
7
+ export * from "./boiler_system";
7
8
  export * from "./create_minimalist_address_space_nodeset";
9
+ export * from "./date_utils";
8
10
  export * from "./get_address_space_fixture";
9
11
  export * from "./get_mini_address_space";
10
- export * from "./boiler_system";
11
12
  export * from "./mock_session";
12
- export * from "./date_utils";
@@ -20,10 +20,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
20
20
  __exportStar(require("./add_event_generator_object"), exports);
21
21
  __exportStar(require("./alarms_and_conditions_demo"), exports);
22
22
  __exportStar(require("./assertHasMatchingReference"), exports);
23
+ __exportStar(require("./boiler_system"), exports);
23
24
  __exportStar(require("./create_minimalist_address_space_nodeset"), exports);
25
+ __exportStar(require("./date_utils"), exports);
24
26
  __exportStar(require("./get_address_space_fixture"), exports);
25
27
  __exportStar(require("./get_mini_address_space"), exports);
26
- __exportStar(require("./boiler_system"), exports);
27
28
  __exportStar(require("./mock_session"), exports);
28
- __exportStar(require("./date_utils"), exports);
29
29
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../test_helpers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;;GAEG;AACH,+DAA6C;AAC7C,+DAA6C;AAC7C,+DAA6C;AAC7C,4EAA0D;AAC1D,8DAA4C;AAC5C,2DAAyC;AACzC,kDAAgC;AAChC,iDAA+B;AAC/B,+CAA6B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../test_helpers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;;GAEG;AACH,+DAA6C;AAC7C,+DAA6C;AAC7C,+DAA6C;AAC7C,kDAAgC;AAChC,4EAA0D;AAC1D,+CAA6B;AAC7B,8DAA4C;AAC5C,2DAAyC;AACzC,iDAA+B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-opcua-address-space",
3
- "version": "2.169.0",
3
+ "version": "2.170.1",
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",
@@ -21,35 +21,35 @@
21
21
  "@types/semver": "7.7.1",
22
22
  "chalk": "4.1.2",
23
23
  "dequeue": "^1.0.5",
24
- "node-opcua-address-space-base": "2.169.0",
24
+ "node-opcua-address-space-base": "2.170.1",
25
25
  "node-opcua-assert": "2.164.0",
26
26
  "node-opcua-basic-types": "2.169.0",
27
27
  "node-opcua-binary-stream": "2.169.0",
28
- "node-opcua-client-dynamic-extension-object": "2.169.0",
28
+ "node-opcua-client-dynamic-extension-object": "2.170.1",
29
29
  "node-opcua-constants": "2.157.0",
30
30
  "node-opcua-crypto": "5.3.5",
31
- "node-opcua-data-access": "2.169.0",
32
- "node-opcua-data-model": "2.169.0",
33
- "node-opcua-data-value": "2.169.0",
31
+ "node-opcua-data-access": "2.170.0",
32
+ "node-opcua-data-model": "2.170.0",
33
+ "node-opcua-data-value": "2.170.0",
34
34
  "node-opcua-date-time": "2.169.0",
35
35
  "node-opcua-debug": "2.168.0",
36
36
  "node-opcua-enum": "2.169.0",
37
37
  "node-opcua-extension-object": "2.169.0",
38
38
  "node-opcua-factory": "2.169.0",
39
39
  "node-opcua-nodeid": "2.169.0",
40
- "node-opcua-nodeset-ua": "2.169.0",
40
+ "node-opcua-nodeset-ua": "2.170.1",
41
41
  "node-opcua-numeric-range": "2.169.0",
42
42
  "node-opcua-object-registry": "2.169.0",
43
- "node-opcua-pseudo-session": "2.169.0",
44
- "node-opcua-service-browse": "2.169.0",
45
- "node-opcua-service-call": "2.169.0",
46
- "node-opcua-service-history": "2.169.0",
47
- "node-opcua-service-translate-browse-path": "2.169.0",
48
- "node-opcua-service-write": "2.169.0",
43
+ "node-opcua-pseudo-session": "2.170.1",
44
+ "node-opcua-service-browse": "2.170.0",
45
+ "node-opcua-service-call": "2.170.0",
46
+ "node-opcua-service-history": "2.170.0",
47
+ "node-opcua-service-translate-browse-path": "2.170.0",
48
+ "node-opcua-service-write": "2.170.0",
49
49
  "node-opcua-status-code": "2.169.0",
50
- "node-opcua-types": "2.169.0",
50
+ "node-opcua-types": "2.170.0",
51
51
  "node-opcua-utils": "2.169.0",
52
- "node-opcua-variant": "2.169.0",
52
+ "node-opcua-variant": "2.170.0",
53
53
  "node-opcua-xml2json": "2.169.0",
54
54
  "semver": "^7.7.4",
55
55
  "thenify-ex": "4.4.0",
@@ -61,8 +61,8 @@
61
61
  "node-opcua-leak-detector": "2.169.0",
62
62
  "node-opcua-nodesets": "2.163.1",
63
63
  "node-opcua-packet-analyzer": "2.169.0",
64
- "node-opcua-schemas": "2.169.0",
65
- "node-opcua-service-filter": "2.169.0",
64
+ "node-opcua-schemas": "2.170.0",
65
+ "node-opcua-service-filter": "2.170.1",
66
66
  "node-opcua-test-fixtures": "2.157.0"
67
67
  },
68
68
  "author": "Etienne Rossignon",
@@ -80,7 +80,7 @@
80
80
  "internet of things"
81
81
  ],
82
82
  "homepage": "http://node-opcua.github.io/",
83
- "gitHead": "82d570d3e95bea689cbbe30096279885c5282245",
83
+ "gitHead": "40629feaff284ba70596149e58b3cc2a7a0e8f68",
84
84
  "files": [
85
85
  "dist",
86
86
  "distHelpers",
@@ -1,49 +1,35 @@
1
-
2
-
3
- import { UAObject, UAObjectType, UAVariable, UAVariableType } from "node-opcua-address-space-base";
4
- import { BrowseDirection } from "node-opcua-data-model";
1
+ import type { UAObject, UAObjectType, UAVariable, UAVariableType } from "node-opcua-address-space-base";
2
+ import { NodeClass } from "node-opcua-types";
5
3
  import { initialize_properties_and_components } from "../src/_instantiate_helpers";
6
4
 
7
- export function implementInterfaceBad(uaNode: UAObject | UAObjectType | UAVariable | UAVariableType, interfaceType: UAObjectType) {
5
+ export function implementInterface(
6
+ uaNode: UAObject | UAObjectType | UAVariable | UAVariableType,
7
+ interfaceType: UAObjectType,
8
+ optionals?: string[],
9
+ isModellingType?: boolean
10
+ ) {
8
11
 
9
- const addressSpace = uaNode.addressSpace;
10
- const tmp = interfaceType.instantiate({
11
- browseName: uaNode.browseName,
12
- copyAlsoModellingRules: true,
13
- copyAlsoAllOptionals: true,
14
- modellingRule: "Mandatory"
15
- });
16
- //
17
- uaNode.addReference({
18
- nodeId: interfaceType,
19
- referenceType: "HasInterface"
20
- });
21
- const childrenRef = tmp.findReferencesEx("HasChild", BrowseDirection.Forward);
22
- // transfer children to uaNode
23
- for (const childRef of childrenRef) {
12
+ optionals = optionals || [];
24
13
 
25
- tmp.removeReference({
26
- nodeId: childRef.nodeId,
27
- referenceType: childRef.referenceType,
28
- isForward: childRef.isForward
29
- });
30
- uaNode.addReference({
31
- nodeId: childRef.nodeId,
32
- referenceType: childRef.referenceType,
33
- isForward: childRef.isForward
34
- });
14
+ const addressSpace = uaNode.addressSpace;
15
+ const topMost = addressSpace.findObjectType("BaseInterfaceType");
16
+ if (!topMost) {
17
+ throw new Error("cannot find BaseInterfaceType");
35
18
  }
36
- addressSpace.deleteNode(tmp);
37
- }
38
19
 
39
- export function implementInterface(uaNode: UAObject | UAObjectType | UAVariable | UAVariableType, interfaceType: UAObjectType) {
40
-
41
- const addressSpace = uaNode.addressSpace;
42
- const topMost = addressSpace.findObjectType("BaseInterfaceType")!;
43
- initialize_properties_and_components(uaNode as any, topMost, interfaceType, true, true, []);
20
+ isModellingType = isModellingType === undefined ? uaNode.nodeClass === NodeClass.ObjectType || uaNode.nodeClass === NodeClass.VariableType : isModellingType;
21
+
22
+ const copyAlsoModellingRules = isModellingType;
23
+ const copyAlsoAllOptionals = isModellingType;
24
+ initialize_properties_and_components(
25
+ uaNode as UAObject | UAVariable,
26
+ topMost, interfaceType,
27
+ copyAlsoModellingRules,
28
+ copyAlsoAllOptionals,
29
+ optionals
30
+ );
44
31
  uaNode.addReference({
45
32
  nodeId: interfaceType,
46
33
  referenceType: "HasInterface"
47
34
  });
48
-
49
35
  }
@@ -4,33 +4,30 @@
4
4
  // tslint:disable:max-classes-per-file
5
5
  // tslint:disable:no-console
6
6
  import chalk from "chalk";
7
-
8
7
  import {
9
- UAMethod,
10
- UAObject,
11
- UAObjectType,
12
- UAVariable,
13
- UAVariableType,
8
+ CloneHelper,
14
9
  reconstructFunctionalGroupType,
15
10
  reconstructNonHierarchicalReferences,
16
- CloneHelper
11
+ type UAMethod,
12
+ type UAObject,
13
+ type UAObjectType,
14
+ type UAVariable,
15
+ type UAVariableType,
17
16
  } from "node-opcua-address-space-base";
18
-
19
- import { checkDebugFlag, make_debugLog, make_warningLog, make_errorLog } from "node-opcua-debug";
20
- import { sameNodeId } from "node-opcua-nodeid";
21
-
22
- import { makeOptionalsMap, OptionalMap } from "../source/helpers/make_optionals_map";
23
-
24
- import { _clone_hierarchical_references } from "./base_node_private";
17
+ import { checkDebugFlag, make_errorLog, make_warningLog} from "node-opcua-debug";
18
+ import { resolveNodeId, sameNodeId } from "node-opcua-nodeid";
19
+ import { makeOptionalsMap, type OptionalMap } from "../source/helpers/make_optionals_map";
25
20
  import { MandatoryChildOrRequestedOptionalFilter } from "./_mandatory_child_or_requested_optional_filter";
21
+ import { _clone_hierarchical_references } from "./base_node_private";
22
+ import { BrowseDirection } from "node-opcua-data-model";
26
23
 
27
- const debugLog = make_debugLog(__filename);
28
- const doDebug = checkDebugFlag(__filename);
29
- const warningLog = make_warningLog(__filename);
30
- const errorLog = make_errorLog(__filename);
24
+ // const debugLog = make_debugLog("INSTANTIATE");
25
+ // const doDebug = checkDebugFlag("INSTANTIATE");
26
+ const warningLog = make_warningLog("INSTANTIATE");
27
+ const errorLog = make_errorLog("INSTANTIATE");
31
28
 
32
29
  // eslint-disable-next-line prefer-const
33
- let doTrace = checkDebugFlag("INSTANTIATE");
30
+ const doTrace = checkDebugFlag("INSTANTIATE");
34
31
  const traceLog = errorLog;
35
32
 
36
33
  // install properties and components on a instantiated Object
@@ -58,7 +55,7 @@ function _initialize_properties_and_components<B extends UAObject | UAVariable |
58
55
  warningLog("optionalsMap =", Object.keys(optionalsMap).join(" "));
59
56
 
60
57
  const c = typeDefinitionNode.findReferencesEx("Aggregates");
61
- warningLog("typeDefinition aggregates =", c.map((x) => x.node!.browseName.toString()).join(" "));
58
+ warningLog("typeDefinition aggregates =", c.map((x) => x.node?.browseName.toString()).join(" "));
62
59
  }
63
60
  optionalsMap = optionalsMap || {};
64
61
 
@@ -71,7 +68,7 @@ function _initialize_properties_and_components<B extends UAObject | UAVariable |
71
68
  doTrace &&
72
69
  traceLog(
73
70
  chalk.cyan(extraInfo.pad(), "cloning relevant member of typeDefinition class"),
74
- typeDefinitionNode.browseName.toString()+ "\n optionals" + (JSON.stringify(optionalsMap))
71
+ `${typeDefinitionNode.browseName.toString()}\n optionals${JSON.stringify(optionalsMap)}`
75
72
  );
76
73
 
77
74
  _clone_hierarchical_references(typeDefinitionNode, instance, copyAlsoModellingRules, filter, extraInfo, browseNameMap);
@@ -79,7 +76,7 @@ function _initialize_properties_and_components<B extends UAObject | UAVariable |
79
76
  // now apply recursion on baseTypeDefinition to get properties and components from base class
80
77
 
81
78
  const baseTypeDefinitionNodeId = typeDefinitionNode.subtypeOf;
82
- const baseTypeDefinition = typeDefinitionNode.subtypeOfObj!;
79
+ const baseTypeDefinition = typeDefinitionNode.subtypeOfObj;
83
80
 
84
81
  doTrace &&
85
82
  traceLog(
@@ -87,9 +84,9 @@ function _initialize_properties_and_components<B extends UAObject | UAVariable |
87
84
  extraInfo.pad(),
88
85
  "now apply recursion on baseTypeDefinition to get properties and components from base class"
89
86
  ),
90
- baseTypeDefinition.browseName.toString()
87
+ baseTypeDefinition ? baseTypeDefinition.browseName.toString() : "undefined"
91
88
  );
92
-
89
+
93
90
  // c8 ignore next
94
91
  if (!baseTypeDefinition) {
95
92
  throw new Error(chalk.red("Cannot find object with nodeId ") + baseTypeDefinitionNodeId);
@@ -141,7 +138,53 @@ export function initialize_properties_and_components<
141
138
  browseNameMap
142
139
  );
143
140
 
141
+ // instantiate optionals from interfaces
142
+ instantiate_interface_children<B>(nodeType, extraInfo, instance, copyAlsoModellingRules, copyAlsoAllOptionals, optionalsMap, browseNameMap);
143
+
144
144
  reconstructFunctionalGroupType(extraInfo);
145
145
 
146
146
  reconstructNonHierarchicalReferences(extraInfo);
147
147
  }
148
+
149
+ function instantiate_interface_children<B extends UAObject | UAVariable | UAMethod>(
150
+ nodeType: UAObjectType | UAVariableType,
151
+ extraInfo: CloneHelper,
152
+ instance: B,
153
+ copyAlsoModellingRules: boolean,
154
+ copyAlsoAllOptionals: boolean,
155
+ optionalsMap: OptionalMap,
156
+ browseNameMap: Set<string>
157
+ ) {
158
+ const interfaces = nodeType.findReferencesEx(resolveNodeId("HasInterface"), BrowseDirection.Forward);
159
+ if (interfaces.length === 0) {
160
+ return;
161
+ }
162
+ for (const reference of interfaces) {
163
+ const interfaceType =
164
+ (reference.node as UAObjectType) || nodeType.addressSpace.findObjectType(reference.nodeId);
165
+ if (!interfaceType) {
166
+ warningLog(" cannot find node ", reference.nodeId.toString());
167
+ continue;
168
+ }
169
+ const topMostTypeBaseInterface = nodeType.addressSpace.findObjectType("BaseInterfaceType");
170
+ if (!topMostTypeBaseInterface) {
171
+ throw new Error("cannot find BaseInterfaceType");
172
+ }
173
+ doTrace &&
174
+ traceLog(
175
+ chalk.cyan(extraInfo.pad(), "instantiating optionals from interface"),
176
+ `${interfaceType.browseName.toString()}`
177
+ );
178
+ _initialize_properties_and_components(
179
+ instance,
180
+ topMostTypeBaseInterface,
181
+ interfaceType,
182
+ copyAlsoModellingRules,
183
+ copyAlsoAllOptionals,
184
+ optionalsMap,
185
+ extraInfo,
186
+ browseNameMap
187
+ );
188
+ }
189
+ }
190
+
@@ -32,13 +32,13 @@ export class MandatoryChildOrRequestedOptionalFilter implements CloneFilter {
32
32
  const addressSpace = node.addressSpace;
33
33
 
34
34
  const alreadyIn = this.references.filter((r: UAReference) => {
35
- const n = addressSpace.findNode(r.nodeId)!;
35
+ const n = addressSpace.findNode(r.nodeId);
36
36
  // c8 ignore next
37
37
  if (!n) {
38
38
  warningLog(" cannot find node ", r.nodeId.toString());
39
39
  return false;
40
40
  }
41
- return n.browseName!.name!.toString() === node.browseName!.name!.toString();
41
+ return n.browseName?.name?.toString() === node.browseName?.name?.toString();
42
42
  });
43
43
 
44
44
  if (alreadyIn.length > 0) {
@@ -76,7 +76,7 @@ export class MandatoryChildOrRequestedOptionalFilter implements CloneFilter {
76
76
  return true; // keep;
77
77
  case "Optional":
78
78
  // only if in requested optionals
79
- return this.copyAlsoAllOptionals || (node.browseName!.name! in this.optionalsMap);
79
+ return this.copyAlsoAllOptionals || ((node.browseName?.name || "") in this.optionalsMap);
80
80
  case "OptionalPlaceholder":
81
81
  return false; // ignored
82
82
  default:
@@ -85,12 +85,12 @@ export class MandatoryChildOrRequestedOptionalFilter implements CloneFilter {
85
85
  }
86
86
 
87
87
  public filterFor(childInstance: UAVariable | UAObject | UAMethod): CloneFilter {
88
- const browseName: string = childInstance.browseName.name!;
88
+ const browseName: string = childInstance.browseName.name || "";
89
89
 
90
90
  let map: OptionalMap = Object.create(null);
91
91
 
92
92
  if (browseName in this.optionalsMap) {
93
- map = this.optionalsMap[browseName] as any;
93
+ map = this.optionalsMap[browseName] as OptionalMap;
94
94
  }
95
95
  // c8 ignore next
96
96
  doTrace && traceLog("filterFor ", browseName, map);
@@ -693,30 +693,25 @@ export class AddressSpace implements AddressSpacePrivate {
693
693
  /*=
694
694
  * construct a simple javascript object with all the default properties of the event
695
695
  *
696
- * @return result.$eventDataSource {BaseNode} the event type node
697
- * @return result.eventId {NodeId} the
698
- * ...
699
- *
700
696
  *
701
697
  * eventTypeId can be a UAEventType
702
698
  *
703
699
  * @private
704
700
  */
705
- public constructEventData(eventTypeId: UAEventType, data: RaiseEventData): IEventData {
706
- data = data || {};
701
+ public constructEventData(eventTypeId: UAEventType, dataInput: Record<string, unknown>): IEventData {
702
+ const data: RaiseEventData = (dataInput || {}) as RaiseEventData;
707
703
 
708
704
  // construct the reference dataStructure to store event Data
709
- let eventTypeNode = eventTypeId;
705
+ let eventTypeNode: UAEventType | null = eventTypeId;
710
706
 
711
707
  // make sure that eventType is really a object that derived from EventType
712
708
  if (eventTypeId instanceof UAObjectTypeImpl) {
713
- eventTypeNode = this.findEventType(eventTypeId)!;
709
+ eventTypeNode = this.findEventType(eventTypeId) as UAEventType | null;
714
710
  }
715
-
716
711
  /* c8 ignore next */
717
- if (!eventTypeNode) {
718
- throw new Error(` cannot find EvenType for ${eventTypeId}`);
719
- }
712
+ if (!eventTypeNode) throw new Error(` cannot find EventType for ${eventTypeId}`);
713
+
714
+
720
715
  assert(eventTypeNode instanceof UAObjectTypeImpl, "eventTypeId must represent a UAObjectType");
721
716
 
722
717
  // eventId
@@ -732,11 +727,15 @@ export class AddressSpace implements AddressSpacePrivate {
732
727
  assert(data.sourceNode.dataType === DataType.NodeId);
733
728
 
734
729
  // sourceName
735
- const sourceNode = this.findNode(data.sourceNode.value)!;
736
-
730
+ const sourceNode = this.findNode(data.sourceNode.value);
731
+ if (!sourceNode) {
732
+ warningLog(
733
+ `constructEventData: cannot find sourceNode ${data.sourceNode.value?.toString()} for event ${eventTypeNode.browseName.toString()}`
734
+ );
735
+ }
737
736
  data.sourceName = data.sourceName || {
738
737
  dataType: DataType.String,
739
- value: sourceNode.getDisplayName("en")
738
+ value: sourceNode?.getDisplayName("en") || ""
740
739
  };
741
740
 
742
741
  const nowUTC = new Date();
@@ -826,7 +825,7 @@ export class AddressSpace implements AddressSpacePrivate {
826
825
  "' in [ " +
827
826
  Object.keys(visitedProperties).join(", ") +
828
827
  "] when filling " +
829
- eventTypeNode.browseName.toString()
828
+ eventTypeNode?.browseName.toString()
830
829
  );
831
830
  }
832
831
  });
@@ -90,7 +90,7 @@ export class ConditionSnapshotImpl extends EventEmitter implements ConditionSnap
90
90
  }
91
91
  const c = this.condition as UAConditionImpl;
92
92
  const isDisabled = !c.getEnabledState();
93
- const eventData = new EventData(this.condition!);
93
+ const eventData = new EventData(this.condition);
94
94
 
95
95
  for (const fullBrowsePath of this._map.keys()) {
96
96
  const node = this._node_index.get(fullBrowsePath);
@@ -98,10 +98,10 @@ export class ConditionSnapshotImpl extends EventEmitter implements ConditionSnap
98
98
  debugLog("cannot node for find key", fullBrowsePath);
99
99
  continue;
100
100
  }
101
- if (isDisabled && !Object.prototype.hasOwnProperty.call(_varTable, fullBrowsePath)) {
101
+ if (isDisabled && !Object.hasOwn(_varTable, fullBrowsePath)) {
102
102
  eventData._createValue(fullBrowsePath, node, disabledVar);
103
103
  } else {
104
- eventData._createValue(fullBrowsePath, node, this._map.get(fullBrowsePath)!);
104
+ eventData._createValue(fullBrowsePath, node, this._map.get(fullBrowsePath) as Variant);
105
105
  }
106
106
  }
107
107
  return eventData;
@@ -1031,7 +1031,7 @@ export class BaseNodeImpl extends EventEmitter implements BaseNode {
1031
1031
  return options.toString();
1032
1032
  }
1033
1033
 
1034
- public toJSON(): Record<string, string | undefined | null> {
1034
+ public toJSON(): Record<string, unknown> {
1035
1035
  return {
1036
1036
  nodeId: this.nodeId.toString(),
1037
1037
  nodeClass: NodeClass[this.nodeClass],