node-opcua-address-space 2.98.0 → 2.98.2

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 (460) hide show
  1. package/dist/source/address_space_ts.d.ts +118 -0
  2. package/dist/source/address_space_ts.js +18 -0
  3. package/dist/source/address_space_ts.js.map +1 -0
  4. package/dist/source/continuation_points/continuation_point_manager.d.ts +91 -0
  5. package/dist/source/continuation_points/continuation_point_manager.js +201 -0
  6. package/dist/source/continuation_points/continuation_point_manager.js.map +1 -0
  7. package/dist/source/helpers/adjust_browse_direction.d.ts +5 -0
  8. package/dist/source/helpers/adjust_browse_direction.js +12 -0
  9. package/dist/source/helpers/adjust_browse_direction.js.map +1 -0
  10. package/dist/source/helpers/argument_list.d.ts +33 -0
  11. package/dist/source/helpers/argument_list.js +255 -0
  12. package/dist/source/helpers/argument_list.js.map +1 -0
  13. package/dist/source/helpers/call_helpers.d.ts +6 -0
  14. package/dist/source/helpers/call_helpers.js +72 -0
  15. package/dist/source/helpers/call_helpers.js.map +1 -0
  16. package/dist/source/helpers/coerce_enum_value.d.ts +6 -0
  17. package/dist/source/helpers/coerce_enum_value.js +34 -0
  18. package/dist/source/helpers/coerce_enum_value.js.map +1 -0
  19. package/dist/source/helpers/dump_tools.d.ts +14 -0
  20. package/dist/source/helpers/dump_tools.js +79 -0
  21. package/dist/source/helpers/dump_tools.js.map +1 -0
  22. package/dist/source/helpers/ensure_secure_access.d.ts +9 -0
  23. package/dist/source/helpers/ensure_secure_access.js +77 -0
  24. package/dist/source/helpers/ensure_secure_access.js.map +1 -0
  25. package/dist/source/helpers/make_optionals_map.d.ts +21 -0
  26. package/dist/source/helpers/make_optionals_map.js +30 -0
  27. package/dist/source/helpers/make_optionals_map.js.map +1 -0
  28. package/dist/source/helpers/multiform_func.d.ts +11 -0
  29. package/dist/source/helpers/multiform_func.js +76 -0
  30. package/dist/source/helpers/multiform_func.js.map +1 -0
  31. package/dist/source/helpers/resolve_opaque_on_address_space.d.ts +3 -0
  32. package/dist/source/helpers/resolve_opaque_on_address_space.js +37 -0
  33. package/dist/source/helpers/resolve_opaque_on_address_space.js.map +1 -0
  34. package/dist/source/index.d.ts +61 -0
  35. package/dist/source/index.js +90 -0
  36. package/dist/source/index.js.map +1 -0
  37. package/dist/source/interfaces/alarms_and_conditions/condition_info_i.d.ts +19 -0
  38. package/dist/source/interfaces/alarms_and_conditions/condition_info_i.js +3 -0
  39. package/dist/source/interfaces/alarms_and_conditions/condition_info_i.js.map +1 -0
  40. package/dist/source/interfaces/alarms_and_conditions/condition_snapshot.d.ts +193 -0
  41. package/dist/source/interfaces/alarms_and_conditions/condition_snapshot.js +3 -0
  42. package/dist/source/interfaces/alarms_and_conditions/condition_snapshot.js.map +1 -0
  43. package/dist/source/interfaces/alarms_and_conditions/deviation_stuff.d.ts +12 -0
  44. package/dist/source/interfaces/alarms_and_conditions/deviation_stuff.js +3 -0
  45. package/dist/source/interfaces/alarms_and_conditions/deviation_stuff.js.map +1 -0
  46. package/dist/source/interfaces/alarms_and_conditions/install_setpoint_options.d.ts +10 -0
  47. package/dist/source/interfaces/alarms_and_conditions/install_setpoint_options.js +3 -0
  48. package/dist/source/interfaces/alarms_and_conditions/install_setpoint_options.js.map +1 -0
  49. package/dist/source/interfaces/alarms_and_conditions/instantiate_alarm_condition_options.d.ts +7 -0
  50. package/dist/source/interfaces/alarms_and_conditions/instantiate_alarm_condition_options.js +3 -0
  51. package/dist/source/interfaces/alarms_and_conditions/instantiate_alarm_condition_options.js.map +1 -0
  52. package/dist/source/interfaces/alarms_and_conditions/instantiate_condition_options.d.ts +7 -0
  53. package/dist/source/interfaces/alarms_and_conditions/instantiate_condition_options.js +3 -0
  54. package/dist/source/interfaces/alarms_and_conditions/instantiate_condition_options.js.map +1 -0
  55. package/dist/source/interfaces/alarms_and_conditions/instantiate_exclusive_deviation_alarm_options.d.ts +4 -0
  56. package/dist/source/interfaces/alarms_and_conditions/instantiate_exclusive_deviation_alarm_options.js +3 -0
  57. package/dist/source/interfaces/alarms_and_conditions/instantiate_exclusive_deviation_alarm_options.js.map +1 -0
  58. package/dist/source/interfaces/alarms_and_conditions/instantiate_exclusive_limit_alarm_options.d.ts +4 -0
  59. package/dist/source/interfaces/alarms_and_conditions/instantiate_exclusive_limit_alarm_options.js +3 -0
  60. package/dist/source/interfaces/alarms_and_conditions/instantiate_exclusive_limit_alarm_options.js.map +1 -0
  61. package/dist/source/interfaces/alarms_and_conditions/instantiate_limit_alarm_options.d.ts +9 -0
  62. package/dist/source/interfaces/alarms_and_conditions/instantiate_limit_alarm_options.js +3 -0
  63. package/dist/source/interfaces/alarms_and_conditions/instantiate_limit_alarm_options.js.map +1 -0
  64. package/dist/source/interfaces/alarms_and_conditions/instantiate_non_exclusive_deviation_alarm_options.d.ts +4 -0
  65. package/dist/source/interfaces/alarms_and_conditions/instantiate_non_exclusive_deviation_alarm_options.js +3 -0
  66. package/dist/source/interfaces/alarms_and_conditions/instantiate_non_exclusive_deviation_alarm_options.js.map +1 -0
  67. package/dist/source/interfaces/alarms_and_conditions/instantiate_non_exclusive_limit_alarm_options.d.ts +4 -0
  68. package/dist/source/interfaces/alarms_and_conditions/instantiate_non_exclusive_limit_alarm_options.js +3 -0
  69. package/dist/source/interfaces/alarms_and_conditions/instantiate_non_exclusive_limit_alarm_options.js.map +1 -0
  70. package/dist/source/interfaces/alarms_and_conditions/instantiate_off_normal_alarm_options.d.ts +20 -0
  71. package/dist/source/interfaces/alarms_and_conditions/instantiate_off_normal_alarm_options.js +3 -0
  72. package/dist/source/interfaces/alarms_and_conditions/instantiate_off_normal_alarm_options.js.map +1 -0
  73. package/dist/source/interfaces/alarms_and_conditions/ua_acknowledgeable_condition_ex.d.ts +23 -0
  74. package/dist/source/interfaces/alarms_and_conditions/ua_acknowledgeable_condition_ex.js +3 -0
  75. package/dist/source/interfaces/alarms_and_conditions/ua_acknowledgeable_condition_ex.js.map +1 -0
  76. package/dist/source/interfaces/alarms_and_conditions/ua_alarm_condition_ex.d.ts +32 -0
  77. package/dist/source/interfaces/alarms_and_conditions/ua_alarm_condition_ex.js +3 -0
  78. package/dist/source/interfaces/alarms_and_conditions/ua_alarm_condition_ex.js.map +1 -0
  79. package/dist/source/interfaces/alarms_and_conditions/ua_certificate_expiration_alarm_ex.d.ts +19 -0
  80. package/dist/source/interfaces/alarms_and_conditions/ua_certificate_expiration_alarm_ex.js +3 -0
  81. package/dist/source/interfaces/alarms_and_conditions/ua_certificate_expiration_alarm_ex.js.map +1 -0
  82. package/dist/source/interfaces/alarms_and_conditions/ua_condition_ex.d.ts +45 -0
  83. package/dist/source/interfaces/alarms_and_conditions/ua_condition_ex.js +3 -0
  84. package/dist/source/interfaces/alarms_and_conditions/ua_condition_ex.js.map +1 -0
  85. package/dist/source/interfaces/alarms_and_conditions/ua_discrete_alarm_ex.d.ts +7 -0
  86. package/dist/source/interfaces/alarms_and_conditions/ua_discrete_alarm_ex.js +26 -0
  87. package/dist/source/interfaces/alarms_and_conditions/ua_discrete_alarm_ex.js.map +1 -0
  88. package/dist/source/interfaces/alarms_and_conditions/ua_exclusive_deviation_alarm_ex.d.ts +5 -0
  89. package/dist/source/interfaces/alarms_and_conditions/ua_exclusive_deviation_alarm_ex.js +3 -0
  90. package/dist/source/interfaces/alarms_and_conditions/ua_exclusive_deviation_alarm_ex.js.map +1 -0
  91. package/dist/source/interfaces/alarms_and_conditions/ua_exclusive_limit_alarm_ex.d.ts +20 -0
  92. package/dist/source/interfaces/alarms_and_conditions/ua_exclusive_limit_alarm_ex.js +3 -0
  93. package/dist/source/interfaces/alarms_and_conditions/ua_exclusive_limit_alarm_ex.js.map +1 -0
  94. package/dist/source/interfaces/alarms_and_conditions/ua_limit_alarm_ex.d.ts +26 -0
  95. package/dist/source/interfaces/alarms_and_conditions/ua_limit_alarm_ex.js +3 -0
  96. package/dist/source/interfaces/alarms_and_conditions/ua_limit_alarm_ex.js.map +1 -0
  97. package/dist/source/interfaces/alarms_and_conditions/ua_non_exclusive_deviation_alarm_ex.d.ts +8 -0
  98. package/dist/source/interfaces/alarms_and_conditions/ua_non_exclusive_deviation_alarm_ex.js +3 -0
  99. package/dist/source/interfaces/alarms_and_conditions/ua_non_exclusive_deviation_alarm_ex.js.map +1 -0
  100. package/dist/source/interfaces/alarms_and_conditions/ua_non_exclusive_limit_alarm_ex.d.ts +10 -0
  101. package/dist/source/interfaces/alarms_and_conditions/ua_non_exclusive_limit_alarm_ex.js +3 -0
  102. package/dist/source/interfaces/alarms_and_conditions/ua_non_exclusive_limit_alarm_ex.js.map +1 -0
  103. package/dist/source/interfaces/data_access/ua_multistate_discrete_ex.d.ts +21 -0
  104. package/dist/source/interfaces/data_access/ua_multistate_discrete_ex.js +3 -0
  105. package/dist/source/interfaces/data_access/ua_multistate_discrete_ex.js.map +1 -0
  106. package/dist/source/interfaces/data_access/ua_multistate_value_discrete_ex.d.ts +24 -0
  107. package/dist/source/interfaces/data_access/ua_multistate_value_discrete_ex.js +3 -0
  108. package/dist/source/interfaces/data_access/ua_multistate_value_discrete_ex.js.map +1 -0
  109. package/dist/source/interfaces/data_access/ua_two_state_discrete_ex.d.ts +12 -0
  110. package/dist/source/interfaces/data_access/ua_two_state_discrete_ex.js +3 -0
  111. package/dist/source/interfaces/data_access/ua_two_state_discrete_ex.js.map +1 -0
  112. package/dist/source/interfaces/data_access/ua_y_array_item_ex.d.ts +8 -0
  113. package/dist/source/interfaces/data_access/ua_y_array_item_ex.js +3 -0
  114. package/dist/source/interfaces/data_access/ua_y_array_item_ex.js.map +1 -0
  115. package/dist/source/interfaces/extension_object_constructor.d.ts +10 -0
  116. package/dist/source/interfaces/extension_object_constructor.js +3 -0
  117. package/dist/source/interfaces/extension_object_constructor.js.map +1 -0
  118. package/dist/source/interfaces/nodeset_loader_options.d.ts +4 -0
  119. package/dist/source/interfaces/nodeset_loader_options.js +3 -0
  120. package/dist/source/interfaces/nodeset_loader_options.js.map +1 -0
  121. package/dist/source/interfaces/state_machine/ua_exclusive_limit_state_machine_type_ex.d.ts +12 -0
  122. package/dist/source/interfaces/state_machine/ua_exclusive_limit_state_machine_type_ex.js +3 -0
  123. package/dist/source/interfaces/state_machine/ua_exclusive_limit_state_machine_type_ex.js.map +1 -0
  124. package/dist/source/interfaces/state_machine/ua_finite_state_machine_type.d.ts +49 -0
  125. package/dist/source/interfaces/state_machine/ua_finite_state_machine_type.js +3 -0
  126. package/dist/source/interfaces/state_machine/ua_finite_state_machine_type.js.map +1 -0
  127. package/dist/source/interfaces/state_machine/ua_program_state_machine_type.d.ts +11 -0
  128. package/dist/source/interfaces/state_machine/ua_program_state_machine_type.js +3 -0
  129. package/dist/source/interfaces/state_machine/ua_program_state_machine_type.js.map +1 -0
  130. package/dist/source/interfaces/state_machine/ua_shelved_state_machine_ex.d.ts +30 -0
  131. package/dist/source/interfaces/state_machine/ua_shelved_state_machine_ex.js +3 -0
  132. package/dist/source/interfaces/state_machine/ua_shelved_state_machine_ex.js.map +1 -0
  133. package/dist/source/interfaces/state_machine/ua_state_machine_type.d.ts +234 -0
  134. package/dist/source/interfaces/state_machine/ua_state_machine_type.js +3 -0
  135. package/dist/source/interfaces/state_machine/ua_state_machine_type.js.map +1 -0
  136. package/dist/source/interfaces/state_machine/ua_transition_ex.d.ts +6 -0
  137. package/dist/source/interfaces/state_machine/ua_transition_ex.js +3 -0
  138. package/dist/source/interfaces/state_machine/ua_transition_ex.js.map +1 -0
  139. package/dist/source/interfaces/ua_subscription_diagnostics_variable_ex.d.ts +8 -0
  140. package/dist/source/interfaces/ua_subscription_diagnostics_variable_ex.js +3 -0
  141. package/dist/source/interfaces/ua_subscription_diagnostics_variable_ex.js.map +1 -0
  142. package/dist/source/loader/decode_xml_extension_object.d.ts +6 -0
  143. package/dist/source/loader/decode_xml_extension_object.js +72 -0
  144. package/dist/source/loader/decode_xml_extension_object.js.map +1 -0
  145. package/dist/source/loader/ensure_datatype_extracted.d.ts +5 -0
  146. package/dist/source/loader/ensure_datatype_extracted.js +71 -0
  147. package/dist/source/loader/ensure_datatype_extracted.js.map +1 -0
  148. package/dist/source/loader/generateAddressSpaceRaw.d.ts +11 -0
  149. package/dist/source/loader/generateAddressSpaceRaw.js +46 -0
  150. package/dist/source/loader/generateAddressSpaceRaw.js.map +1 -0
  151. package/dist/source/loader/load_nodeset2.d.ts +17 -0
  152. package/dist/source/loader/load_nodeset2.js +1484 -0
  153. package/dist/source/loader/load_nodeset2.js.map +1 -0
  154. package/dist/source/loader/make_semver_compatible.d.ts +6 -0
  155. package/dist/source/loader/make_semver_compatible.js +26 -0
  156. package/dist/source/loader/make_semver_compatible.js.map +1 -0
  157. package/dist/source/loader/make_xml_extension_object_parser.d.ts +28 -0
  158. package/dist/source/loader/make_xml_extension_object_parser.js +327 -0
  159. package/dist/source/loader/make_xml_extension_object_parser.js.map +1 -0
  160. package/dist/source/loader/namespace_post_step.d.ts +10 -0
  161. package/dist/source/loader/namespace_post_step.js +62 -0
  162. package/dist/source/loader/namespace_post_step.js.map +1 -0
  163. package/dist/source/loader/register_node_promoter.d.ts +2 -0
  164. package/dist/source/loader/register_node_promoter.js +10 -0
  165. package/dist/source/loader/register_node_promoter.js.map +1 -0
  166. package/dist/source/namespace.d.ts +6 -0
  167. package/dist/source/namespace.js +3 -0
  168. package/dist/source/namespace.js.map +1 -0
  169. package/dist/source/namespace_alarm_and_condition.d.ts +32 -0
  170. package/dist/source/namespace_alarm_and_condition.js +3 -0
  171. package/dist/source/namespace_alarm_and_condition.js.map +1 -0
  172. package/dist/source/namespace_data_access.d.ts +42 -0
  173. package/dist/source/namespace_data_access.js +3 -0
  174. package/dist/source/namespace_data_access.js.map +1 -0
  175. package/dist/source/namespace_machine_state.d.ts +8 -0
  176. package/dist/source/namespace_machine_state.js +3 -0
  177. package/dist/source/namespace_machine_state.js.map +1 -0
  178. package/dist/source/pseudo_session.d.ts +72 -0
  179. package/dist/source/pseudo_session.js +255 -0
  180. package/dist/source/pseudo_session.js.map +1 -0
  181. package/dist/source/session_context.d.ts +111 -0
  182. package/dist/source/session_context.js +265 -0
  183. package/dist/source/session_context.js.map +1 -0
  184. package/dist/source/set_namespace_meta_data.d.ts +2 -0
  185. package/dist/source/set_namespace_meta_data.js +60 -0
  186. package/dist/source/set_namespace_meta_data.js.map +1 -0
  187. package/dist/source/ua_root_folder.d.ts +9 -0
  188. package/dist/source/ua_root_folder.js +3 -0
  189. package/dist/source/ua_root_folder.js.map +1 -0
  190. package/dist/source/ua_two_state_variable_ex.d.ts +23 -0
  191. package/dist/source/ua_two_state_variable_ex.js +3 -0
  192. package/dist/source/ua_two_state_variable_ex.js.map +1 -0
  193. package/dist/source/xml_writer.d.ts +18 -0
  194. package/dist/source/xml_writer.js +3 -0
  195. package/dist/source/xml_writer.js.map +1 -0
  196. package/dist/src/address_space.d.ts +387 -0
  197. package/dist/src/address_space.js +1386 -0
  198. package/dist/src/address_space.js.map +1 -0
  199. package/dist/src/address_space_change_event_tools.d.ts +6 -0
  200. package/dist/src/address_space_change_event_tools.js +153 -0
  201. package/dist/src/address_space_change_event_tools.js.map +1 -0
  202. package/dist/src/address_space_private.d.ts +43 -0
  203. package/dist/src/address_space_private.js +3 -0
  204. package/dist/src/address_space_private.js.map +1 -0
  205. package/dist/src/alarms_and_conditions/condition.d.ts +5 -0
  206. package/dist/src/alarms_and_conditions/condition.js +79 -0
  207. package/dist/src/alarms_and_conditions/condition.js.map +1 -0
  208. package/dist/src/alarms_and_conditions/condition_info_impl.d.ts +26 -0
  209. package/dist/src/alarms_and_conditions/condition_info_impl.js +55 -0
  210. package/dist/src/alarms_and_conditions/condition_info_impl.js.map +1 -0
  211. package/dist/src/alarms_and_conditions/condition_snapshot_impl.d.ts +222 -0
  212. package/dist/src/alarms_and_conditions/condition_snapshot_impl.js +658 -0
  213. package/dist/src/alarms_and_conditions/condition_snapshot_impl.js.map +1 -0
  214. package/dist/src/alarms_and_conditions/deviation_alarm_helper.d.ts +9 -0
  215. package/dist/src/alarms_and_conditions/deviation_alarm_helper.js +61 -0
  216. package/dist/src/alarms_and_conditions/deviation_alarm_helper.js.map +1 -0
  217. package/dist/src/alarms_and_conditions/index.d.ts +16 -0
  218. package/dist/src/alarms_and_conditions/index.js +33 -0
  219. package/dist/src/alarms_and_conditions/index.js.map +1 -0
  220. package/dist/src/alarms_and_conditions/ua_acknowledgeable_condition_impl.d.ts +44 -0
  221. package/dist/src/alarms_and_conditions/ua_acknowledgeable_condition_impl.js +245 -0
  222. package/dist/src/alarms_and_conditions/ua_acknowledgeable_condition_impl.js.map +1 -0
  223. package/dist/src/alarms_and_conditions/ua_alarm_condition_impl.d.ts +93 -0
  224. package/dist/src/alarms_and_conditions/ua_alarm_condition_impl.js +419 -0
  225. package/dist/src/alarms_and_conditions/ua_alarm_condition_impl.js.map +1 -0
  226. package/dist/src/alarms_and_conditions/ua_base_event_impl.d.ts +26 -0
  227. package/dist/src/alarms_and_conditions/ua_base_event_impl.js +39 -0
  228. package/dist/src/alarms_and_conditions/ua_base_event_impl.js.map +1 -0
  229. package/dist/src/alarms_and_conditions/ua_certificate_expiration_alarm_impl.d.ts +44 -0
  230. package/dist/src/alarms_and_conditions/ua_certificate_expiration_alarm_impl.js +184 -0
  231. package/dist/src/alarms_and_conditions/ua_certificate_expiration_alarm_impl.js.map +1 -0
  232. package/dist/src/alarms_and_conditions/ua_condition_impl.d.ts +155 -0
  233. package/dist/src/alarms_and_conditions/ua_condition_impl.js +1029 -0
  234. package/dist/src/alarms_and_conditions/ua_condition_impl.js.map +1 -0
  235. package/dist/src/alarms_and_conditions/ua_discrete_alarm_impl.d.ts +14 -0
  236. package/dist/src/alarms_and_conditions/ua_discrete_alarm_impl.js +35 -0
  237. package/dist/src/alarms_and_conditions/ua_discrete_alarm_impl.js.map +1 -0
  238. package/dist/src/alarms_and_conditions/ua_exclusive_deviation_alarm_impl.d.ts +24 -0
  239. package/dist/src/alarms_and_conditions/ua_exclusive_deviation_alarm_impl.js +57 -0
  240. package/dist/src/alarms_and_conditions/ua_exclusive_deviation_alarm_impl.js.map +1 -0
  241. package/dist/src/alarms_and_conditions/ua_exclusive_level_alarm_impl.d.ts +11 -0
  242. package/dist/src/alarms_and_conditions/ua_exclusive_level_alarm_impl.js +12 -0
  243. package/dist/src/alarms_and_conditions/ua_exclusive_level_alarm_impl.js.map +1 -0
  244. package/dist/src/alarms_and_conditions/ua_exclusive_limit_alarm_impl.d.ts +23 -0
  245. package/dist/src/alarms_and_conditions/ua_exclusive_limit_alarm_impl.js +87 -0
  246. package/dist/src/alarms_and_conditions/ua_exclusive_limit_alarm_impl.js.map +1 -0
  247. package/dist/src/alarms_and_conditions/ua_exclusive_rate_of_change_alarm_impl.d.ts +11 -0
  248. package/dist/src/alarms_and_conditions/ua_exclusive_rate_of_change_alarm_impl.js +8 -0
  249. package/dist/src/alarms_and_conditions/ua_exclusive_rate_of_change_alarm_impl.js.map +1 -0
  250. package/dist/src/alarms_and_conditions/ua_limit_alarm_impl.d.ts +79 -0
  251. package/dist/src/alarms_and_conditions/ua_limit_alarm_impl.js +251 -0
  252. package/dist/src/alarms_and_conditions/ua_limit_alarm_impl.js.map +1 -0
  253. package/dist/src/alarms_and_conditions/ua_non_exclusive_deviation_alarm_impl.d.ts +24 -0
  254. package/dist/src/alarms_and_conditions/ua_non_exclusive_deviation_alarm_impl.js +51 -0
  255. package/dist/src/alarms_and_conditions/ua_non_exclusive_deviation_alarm_impl.js.map +1 -0
  256. package/dist/src/alarms_and_conditions/ua_non_exclusive_limit_alarm_impl.d.ts +19 -0
  257. package/dist/src/alarms_and_conditions/ua_non_exclusive_limit_alarm_impl.js +163 -0
  258. package/dist/src/alarms_and_conditions/ua_non_exclusive_limit_alarm_impl.js.map +1 -0
  259. package/dist/src/alarms_and_conditions/ua_off_normal_alarm_impl.d.ts +46 -0
  260. package/dist/src/alarms_and_conditions/ua_off_normal_alarm_impl.js +166 -0
  261. package/dist/src/alarms_and_conditions/ua_off_normal_alarm_impl.js.map +1 -0
  262. package/dist/src/alarms_and_conditions/ua_system_off_normal_alarm_impl.d.ts +18 -0
  263. package/dist/src/alarms_and_conditions/ua_system_off_normal_alarm_impl.js +18 -0
  264. package/dist/src/alarms_and_conditions/ua_system_off_normal_alarm_impl.js.map +1 -0
  265. package/dist/src/apply_condition_refresh.d.ts +6 -0
  266. package/dist/src/apply_condition_refresh.js +28 -0
  267. package/dist/src/apply_condition_refresh.js.map +1 -0
  268. package/dist/src/base_node_impl.d.ts +284 -0
  269. package/dist/src/base_node_impl.js +1455 -0
  270. package/dist/src/base_node_impl.js.map +1 -0
  271. package/dist/src/base_node_private.d.ts +81 -0
  272. package/dist/src/base_node_private.js +833 -0
  273. package/dist/src/base_node_private.js.map +1 -0
  274. package/dist/src/check_value_rank_compatibility.d.ts +15 -0
  275. package/dist/src/check_value_rank_compatibility.js +82 -0
  276. package/dist/src/check_value_rank_compatibility.js.map +1 -0
  277. package/dist/src/data_access/add_dataItem_stuff.d.ts +11 -0
  278. package/dist/src/data_access/add_dataItem_stuff.js +62 -0
  279. package/dist/src/data_access/add_dataItem_stuff.js.map +1 -0
  280. package/dist/src/data_access/check_variant_compatibility_ua_analog_item.d.ts +1 -0
  281. package/dist/src/data_access/check_variant_compatibility_ua_analog_item.js +35 -0
  282. package/dist/src/data_access/check_variant_compatibility_ua_analog_item.js.map +1 -0
  283. package/dist/src/data_access/ua_multistate_discrete_impl.d.ts +32 -0
  284. package/dist/src/data_access/ua_multistate_discrete_impl.js +131 -0
  285. package/dist/src/data_access/ua_multistate_discrete_impl.js.map +1 -0
  286. package/dist/src/data_access/ua_multistate_value_discrete_impl.d.ts +52 -0
  287. package/dist/src/data_access/ua_multistate_value_discrete_impl.js +254 -0
  288. package/dist/src/data_access/ua_multistate_value_discrete_impl.js.map +1 -0
  289. package/dist/src/data_access/ua_two_state_discrete_impl.d.ts +25 -0
  290. package/dist/src/data_access/ua_two_state_discrete_impl.js +156 -0
  291. package/dist/src/data_access/ua_two_state_discrete_impl.js.map +1 -0
  292. package/dist/src/event_data.d.ts +34 -0
  293. package/dist/src/event_data.js +65 -0
  294. package/dist/src/event_data.js.map +1 -0
  295. package/dist/src/extension_object_array_node.d.ts +23 -0
  296. package/dist/src/extension_object_array_node.js +249 -0
  297. package/dist/src/extension_object_array_node.js.map +1 -0
  298. package/dist/src/historical_access/address_space_historical_data_node.d.ts +26 -0
  299. package/dist/src/historical_access/address_space_historical_data_node.js +653 -0
  300. package/dist/src/historical_access/address_space_historical_data_node.js.map +1 -0
  301. package/dist/src/idx_iterator.d.ts +8 -0
  302. package/dist/src/idx_iterator.js +51 -0
  303. package/dist/src/idx_iterator.js.map +1 -0
  304. package/dist/src/index_current.d.ts +46 -0
  305. package/dist/src/index_current.js +78 -0
  306. package/dist/src/index_current.js.map +1 -0
  307. package/dist/src/namespace_impl.d.ts +456 -0
  308. package/dist/src/namespace_impl.js +1763 -0
  309. package/dist/src/namespace_impl.js.map +1 -0
  310. package/dist/src/namespace_private.d.ts +23 -0
  311. package/dist/src/namespace_private.js +33 -0
  312. package/dist/src/namespace_private.js.map +1 -0
  313. package/dist/src/nodeid_manager.d.ts +37 -0
  314. package/dist/src/nodeid_manager.js +184 -0
  315. package/dist/src/nodeid_manager.js.map +1 -0
  316. package/dist/src/nodeset_tools/adjust_namespace_array.d.ts +2 -0
  317. package/dist/src/nodeset_tools/adjust_namespace_array.js +14 -0
  318. package/dist/src/nodeset_tools/adjust_namespace_array.js.map +1 -0
  319. package/dist/src/nodeset_tools/construct_namespace_dependency.d.ts +18 -0
  320. package/dist/src/nodeset_tools/construct_namespace_dependency.js +141 -0
  321. package/dist/src/nodeset_tools/construct_namespace_dependency.js.map +1 -0
  322. package/dist/src/nodeset_tools/dump_to_bsd.d.ts +2 -0
  323. package/dist/src/nodeset_tools/dump_to_bsd.js +165 -0
  324. package/dist/src/nodeset_tools/dump_to_bsd.js.map +1 -0
  325. package/dist/src/nodeset_tools/nodeset_to_xml.d.ts +10 -0
  326. package/dist/src/nodeset_tools/nodeset_to_xml.js +1288 -0
  327. package/dist/src/nodeset_tools/nodeset_to_xml.js.map +1 -0
  328. package/dist/src/private_namespace.d.ts +5 -0
  329. package/dist/src/private_namespace.js +20 -0
  330. package/dist/src/private_namespace.js.map +1 -0
  331. package/dist/src/reference_impl.d.ts +43 -0
  332. package/dist/src/reference_impl.js +140 -0
  333. package/dist/src/reference_impl.js.map +1 -0
  334. package/dist/src/role_permissions.d.ts +2 -0
  335. package/dist/src/role_permissions.js +11 -0
  336. package/dist/src/role_permissions.js.map +1 -0
  337. package/dist/src/state_machine/finite_state_machine.d.ts +81 -0
  338. package/dist/src/state_machine/finite_state_machine.js +389 -0
  339. package/dist/src/state_machine/finite_state_machine.js.map +1 -0
  340. package/dist/src/state_machine/ua_shelving_state_machine_ex.d.ts +38 -0
  341. package/dist/src/state_machine/ua_shelving_state_machine_ex.js +251 -0
  342. package/dist/src/state_machine/ua_shelving_state_machine_ex.js.map +1 -0
  343. package/dist/src/state_machine/ua_two_state_variable.d.ts +61 -0
  344. package/dist/src/state_machine/ua_two_state_variable.js +332 -0
  345. package/dist/src/state_machine/ua_two_state_variable.js.map +1 -0
  346. package/dist/src/tool_isSubtypeOf.d.ts +18 -0
  347. package/dist/src/tool_isSubtypeOf.js +125 -0
  348. package/dist/src/tool_isSubtypeOf.js.map +1 -0
  349. package/dist/src/ua_condition_type.d.ts +8 -0
  350. package/dist/src/ua_condition_type.js +3 -0
  351. package/dist/src/ua_condition_type.js.map +1 -0
  352. package/dist/src/ua_data_type_impl.d.ts +89 -0
  353. package/dist/src/ua_data_type_impl.js +369 -0
  354. package/dist/src/ua_data_type_impl.js.map +1 -0
  355. package/dist/src/ua_method_impl.d.ts +42 -0
  356. package/dist/src/ua_method_impl.js +218 -0
  357. package/dist/src/ua_method_impl.js.map +1 -0
  358. package/dist/src/ua_object_impl.d.ts +35 -0
  359. package/dist/src/ua_object_impl.js +169 -0
  360. package/dist/src/ua_object_impl.js.map +1 -0
  361. package/dist/src/ua_object_type_impl.d.ts +50 -0
  362. package/dist/src/ua_object_type_impl.js +127 -0
  363. package/dist/src/ua_object_type_impl.js.map +1 -0
  364. package/dist/src/ua_reference_type_impl.d.ts +45 -0
  365. package/dist/src/ua_reference_type_impl.js +142 -0
  366. package/dist/src/ua_reference_type_impl.js.map +1 -0
  367. package/dist/src/ua_variable_impl.d.ts +380 -0
  368. package/dist/src/ua_variable_impl.js +1739 -0
  369. package/dist/src/ua_variable_impl.js.map +1 -0
  370. package/dist/src/ua_variable_impl_ext_obj.d.ts +23 -0
  371. package/dist/src/ua_variable_impl_ext_obj.js +671 -0
  372. package/dist/src/ua_variable_impl_ext_obj.js.map +1 -0
  373. package/dist/src/ua_variable_type_impl.d.ts +74 -0
  374. package/dist/src/ua_variable_type_impl.js +598 -0
  375. package/dist/src/ua_variable_type_impl.js.map +1 -0
  376. package/dist/src/ua_view_impl.d.ts +19 -0
  377. package/dist/src/ua_view_impl.js +44 -0
  378. package/dist/src/ua_view_impl.js.map +1 -0
  379. package/dist/tsconfig_common.tsbuildinfo +1 -0
  380. package/distHelpers/add_event_generator_object.d.ts +3 -0
  381. package/{test_helpers/add_event_generator_object.ts → distHelpers/add_event_generator_object.js} +16 -22
  382. package/distHelpers/add_event_generator_object.js.map +1 -0
  383. package/distHelpers/alarms_and_conditions_demo.d.ts +9 -0
  384. package/{test_helpers/alarms_and_conditions_demo.ts → distHelpers/alarms_and_conditions_demo.js} +21 -56
  385. package/distHelpers/alarms_and_conditions_demo.js.map +1 -0
  386. package/distHelpers/assertHasMatchingReference.d.ts +19 -0
  387. package/{test_helpers/assertHasMatchingReference.ts → distHelpers/assertHasMatchingReference.js} +12 -14
  388. package/distHelpers/assertHasMatchingReference.js.map +1 -0
  389. package/distHelpers/boiler_system.d.ts +113 -0
  390. package/{test_helpers/boiler_system.ts → distHelpers/boiler_system.js} +81 -295
  391. package/distHelpers/boiler_system.js.map +1 -0
  392. package/distHelpers/create_minimalist_address_space_nodeset.d.ts +5 -0
  393. package/{test_helpers/create_minimalist_address_space_nodeset.ts → distHelpers/create_minimalist_address_space_nodeset.js} +51 -87
  394. package/distHelpers/create_minimalist_address_space_nodeset.js.map +1 -0
  395. package/distHelpers/date_utils.d.ts +3 -0
  396. package/distHelpers/date_utils.js +10 -0
  397. package/distHelpers/date_utils.js.map +1 -0
  398. package/distHelpers/dump_statemachine.d.ts +0 -0
  399. package/distHelpers/dump_statemachine.js +128 -0
  400. package/distHelpers/dump_statemachine.js.map +1 -0
  401. package/distHelpers/get_address_space_fixture.d.ts +1 -0
  402. package/{test_helpers/get_address_space_fixture.ts → distHelpers/get_address_space_fixture.js} +8 -7
  403. package/distHelpers/get_address_space_fixture.js.map +1 -0
  404. package/distHelpers/get_mini_address_space.d.ts +7 -0
  405. package/distHelpers/get_mini_address_space.js +37 -0
  406. package/distHelpers/get_mini_address_space.js.map +1 -0
  407. package/distHelpers/index.js +29 -0
  408. package/distHelpers/index.js.map +1 -0
  409. package/distHelpers/mock_session.d.ts +10 -0
  410. package/distHelpers/mock_session.js +26 -0
  411. package/distHelpers/mock_session.js.map +1 -0
  412. package/distNodeJS/generate_address_space.d.ts +6 -0
  413. package/distNodeJS/generate_address_space.js +53 -0
  414. package/distNodeJS/generate_address_space.js.map +1 -0
  415. package/distNodeJS/index.js +18 -0
  416. package/distNodeJS/index.js.map +1 -0
  417. package/package.json +49 -38
  418. package/source/helpers/dump_tools.ts +92 -0
  419. package/src/nodeset_tools/dump_to_bsd.ts +198 -0
  420. package/.mocharc.yml +0 -12
  421. package/generate.js +0 -1
  422. package/source_nodejs/generate_address_space.ts +0 -60
  423. package/test_helpers/date_utils.ts +0 -5
  424. package/test_helpers/get_mini_address_space.ts +0 -42
  425. package/test_helpers/mock_session.ts +0 -34
  426. package/test_helpers/test_fixtures/dataType_in_separateNamespace.xml +0 -150
  427. package/test_helpers/test_fixtures/dataType_in_separateNamespace_basic.xml +0 -57
  428. package/test_helpers/test_fixtures/dataType_in_separateNamespace_mix.xml +0 -136
  429. package/test_helpers/test_fixtures/dataType_issue.xml +0 -80
  430. package/test_helpers/test_fixtures/dataType_withEnumeration.xml +0 -82
  431. package/test_helpers/test_fixtures/dataType_with_isOptionSet.xml +0 -194
  432. package/test_helpers/test_fixtures/dataType_with_qualifiedname.xml +0 -71
  433. package/test_helpers/test_fixtures/dataType_with_recursive_structure.xml +0 -155
  434. package/test_helpers/test_fixtures/dataType_with_structures.xml +0 -605
  435. package/test_helpers/test_fixtures/dataType_with_union.xml +0 -90
  436. package/test_helpers/test_fixtures/datatype_as_per_1.04.xml +0 -118
  437. package/test_helpers/test_fixtures/datatype_with_allow_subtype.xml +0 -104
  438. package/test_helpers/test_fixtures/eurange_issue.xml +0 -74
  439. package/test_helpers/test_fixtures/example_issue1096.xml +0 -267
  440. package/test_helpers/test_fixtures/fixture_empty_nodeset2.xml +0 -106
  441. package/test_helpers/test_fixtures/fixture_simple_statemachine_nodeset2.xml +0 -1305
  442. package/test_helpers/test_fixtures/fixuture_nodeset_objects_with_some_methods.xml +0 -370
  443. package/test_helpers/test_fixtures/issue_1132_variable_with_nodeid_value.xml +0 -68
  444. package/test_helpers/test_fixtures/issue_846.xml +0 -3172
  445. package/test_helpers/test_fixtures/issue_899_variable_with_nodeid_value.xml +0 -33
  446. package/test_helpers/test_fixtures/mini.Node.Set2.xml +0 -4736
  447. package/test_helpers/test_fixtures/mini.nodeset.withVariousVariables.xml +0 -196
  448. package/test_helpers/test_fixtures/minimalist_nodeset_with_models.xml +0 -8
  449. package/test_helpers/test_fixtures/minimalist_nodeset_with_models_more_complex.xml +0 -20
  450. package/test_helpers/test_fixtures/nodeset_no_aliases.xml +0 -30
  451. package/test_helpers/test_fixtures/nodeset_no_aliases_with_aliases.xml +0 -31
  452. package/test_helpers/test_fixtures/nodeset_with_analog_items.xml +0 -45
  453. package/test_helpers/test_fixtures/nodeset_with_guid.xml +0 -1442
  454. package/test_helpers/test_fixtures/nodeset_with_int64_values.xml +0 -31
  455. package/test_helpers/test_fixtures/nodeset_with_special_char.xml +0 -34
  456. package/test_helpers/test_fixtures/nodeset_with_utf8_special_characters.xml +0 -20
  457. package/test_helpers/test_fixtures/variable_with_value.xml +0 -143
  458. package/test_helpers/test_fixtures/variabletype_with_value.xml +0 -324
  459. /package/{test_helpers/index.ts → distHelpers/index.d.ts} +0 -0
  460. /package/{source_nodejs/index.ts → distNodeJS/index.d.ts} +0 -0
@@ -0,0 +1,1455 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getReferenceType = exports.BaseNodeImpl = exports.makeAttributeEventName = void 0;
4
+ /**
5
+ * @module node-opcua-address-space
6
+ */
7
+ const events_1 = require("events");
8
+ const chalk = require("chalk");
9
+ const lodash_1 = require("lodash");
10
+ const node_opcua_assert_1 = require("node-opcua-assert");
11
+ const node_opcua_data_model_1 = require("node-opcua-data-model");
12
+ const node_opcua_data_value_1 = require("node-opcua-data-value");
13
+ const node_opcua_debug_1 = require("node-opcua-debug");
14
+ const node_opcua_nodeid_1 = require("node-opcua-nodeid");
15
+ const node_opcua_status_code_1 = require("node-opcua-status-code");
16
+ const node_opcua_types_1 = require("node-opcua-types");
17
+ const node_opcua_utils_1 = require("node-opcua-utils");
18
+ const node_opcua_variant_1 = require("node-opcua-variant");
19
+ const node_opcua_constants_1 = require("node-opcua-constants");
20
+ const dump_tools_1 = require("../source/helpers/dump_tools");
21
+ const session_context_1 = require("../source/session_context");
22
+ const cetools = require("./address_space_change_event_tools");
23
+ const base_node_private_1 = require("./base_node_private");
24
+ const reference_impl_1 = require("./reference_impl");
25
+ const role_permissions_1 = require("./role_permissions");
26
+ // tslint:disable:no-var-requires
27
+ // tslint:disable:no-bitwise
28
+ // tslint:disable:no-console
29
+ const doDebug = false;
30
+ const warningLog = (0, node_opcua_debug_1.make_warningLog)(__filename);
31
+ const errorLog = (0, node_opcua_debug_1.make_errorLog)(__filename);
32
+ function defaultBrowseFilterFunc(context) {
33
+ return true;
34
+ }
35
+ function _get_QualifiedBrowseName(browseName) {
36
+ return (0, node_opcua_data_model_1.coerceQualifiedName)(browseName);
37
+ }
38
+ function _is_valid_BrowseDirection(browseDirection) {
39
+ return (browseDirection === node_opcua_data_model_1.BrowseDirection.Forward ||
40
+ browseDirection === node_opcua_data_model_1.BrowseDirection.Inverse ||
41
+ browseDirection === node_opcua_data_model_1.BrowseDirection.Both);
42
+ }
43
+ function makeAttributeEventName(attributeId) {
44
+ const attributeName = node_opcua_data_model_1.attributeNameById[attributeId];
45
+ return attributeName + "_changed";
46
+ }
47
+ exports.makeAttributeEventName = makeAttributeEventName;
48
+ /**
49
+ * Base class for all Node classes
50
+ *
51
+ * BaseNode is the base class for all the OPCUA objects in the address space
52
+ * It provides attributes and a set of references to other nodes.
53
+ * see:
54
+ * {{#crossLink "UAObject"}}{{/crossLink}},
55
+ * {{#crossLink "UAVariable"}}{{/crossLink}},
56
+ * {{#crossLink "Reference"}}{{/crossLink}},
57
+ * {{#crossLink "UAMethod"}}{{/crossLink}},
58
+ * {{#crossLink "UAView"}}{{/crossLink}},
59
+ * {{#crossLink "UAObjectType"}}{{/crossLink}},
60
+ * {{#crossLink "UADataType"}}{{/crossLink}},
61
+ * {{#crossLink "UAVariableType"}}{{/crossLink}},
62
+ *
63
+ *
64
+ */
65
+ class BaseNodeImpl extends events_1.EventEmitter {
66
+ static makeAttributeEventName(attributeId) {
67
+ return makeAttributeEventName(attributeId);
68
+ }
69
+ get addressSpace() {
70
+ const _private = (0, base_node_private_1.BaseNode_getPrivate)(this);
71
+ // istanbul ignore next
72
+ if (!_private) {
73
+ throw new Error("Internal error , cannot extract private data from " + this.browseName.toString());
74
+ }
75
+ return _private.__address_space;
76
+ }
77
+ get addressSpacePrivate() {
78
+ const _private = (0, base_node_private_1.BaseNode_getPrivate)(this);
79
+ // istanbul ignore next
80
+ if (!_private) {
81
+ throw new Error("Internal error , cannot extract private data from " + this.browseName.toString());
82
+ }
83
+ return _private.__address_space;
84
+ }
85
+ get displayName() {
86
+ const _private = (0, base_node_private_1.BaseNode_getPrivate)(this);
87
+ return _private._displayName;
88
+ }
89
+ setDisplayName(value) {
90
+ this._setDisplayName(value);
91
+ /**
92
+ * fires when the displayName is changed.
93
+ * @event DisplayName_changed
94
+ * @param dataValue {DataValue}
95
+ */
96
+ this._notifyAttributeChange(node_opcua_data_model_1.AttributeIds.DisplayName);
97
+ }
98
+ get description() {
99
+ const _private = (0, base_node_private_1.BaseNode_getPrivate)(this);
100
+ return _private._description;
101
+ }
102
+ setDescription(value) {
103
+ this._setDescription(value);
104
+ /**
105
+ * fires when the description attribute is changed.
106
+ * @event Description_changed
107
+ * @param dataValue {DataValue}
108
+ */
109
+ this._notifyAttributeChange(node_opcua_data_model_1.AttributeIds.Description);
110
+ }
111
+ /**
112
+ * returns the nodeId of this node's Type Definition
113
+ */
114
+ get typeDefinition() {
115
+ const _cache = (0, base_node_private_1.BaseNode_getCache)(this);
116
+ if (!_cache.typeDefinition) {
117
+ const has_type_definition_ref = this.findReference("HasTypeDefinition", true);
118
+ let nodeId = has_type_definition_ref ? has_type_definition_ref.nodeId : null;
119
+ if (!nodeId) {
120
+ switch (this.nodeClass) {
121
+ case node_opcua_data_model_1.NodeClass.Object:
122
+ nodeId = (0, node_opcua_nodeid_1.coerceNodeId)(node_opcua_constants_1.ObjectTypeIds.BaseObjectType);
123
+ break;
124
+ case node_opcua_data_model_1.NodeClass.Variable:
125
+ nodeId = (0, node_opcua_nodeid_1.coerceNodeId)(node_opcua_constants_1.VariableTypeIds.BaseVariableType);
126
+ break;
127
+ default:
128
+ }
129
+ }
130
+ _cache.typeDefinition = nodeId;
131
+ }
132
+ return _cache.typeDefinition;
133
+ }
134
+ /**
135
+ * returns the nodeId of this node's Type Definition
136
+ */
137
+ get typeDefinitionObj() {
138
+ const _cache = (0, base_node_private_1.BaseNode_getCache)(this);
139
+ if (undefined === _cache.typeDefinitionObj) {
140
+ const nodeId = this.typeDefinition;
141
+ _cache.typeDefinitionObj = nodeId ? this.addressSpace.findNode(nodeId) : null;
142
+ }
143
+ if (!_cache.typeDefinitionObj) {
144
+ warningLog(this.nodeClass, "cannot find typeDefinitionObj ", this.browseName.toString(), this.nodeId.toString(), node_opcua_data_model_1.NodeClass[this.nodeClass]);
145
+ }
146
+ return _cache.typeDefinitionObj;
147
+ }
148
+ get parentNodeId() {
149
+ const parent = this.parent;
150
+ return parent ? parent.nodeId : undefined;
151
+ }
152
+ /**
153
+ * namespace index
154
+ */
155
+ get namespaceIndex() {
156
+ return this.nodeId.namespace;
157
+ }
158
+ /**
159
+ * namespace uri
160
+ */
161
+ get namespaceUri() {
162
+ return this.addressSpace.getNamespaceUri(this.namespaceIndex);
163
+ }
164
+ /**
165
+ * the parent node
166
+ */
167
+ get parent() {
168
+ const _private = (0, base_node_private_1.BaseNode_getPrivate)(this);
169
+ if (_private._parent === undefined) {
170
+ // never been set before
171
+ _private._parent = _setup_parent_item.call(this, _private._referenceIdx);
172
+ }
173
+ return _private._parent || null;
174
+ }
175
+ /**
176
+ * @property modellingRule
177
+ * @type {String|undefined}
178
+ */
179
+ get modellingRule() {
180
+ const r = this.findReferencesAsObject("HasModellingRule");
181
+ if (!r || r.length === 0) {
182
+ return null; /// "? modellingRule missing ?"; // consider "Mandatory"
183
+ }
184
+ const r0 = r[0];
185
+ return r0.browseName.toString();
186
+ }
187
+ /**
188
+ * @internal
189
+ * @param options
190
+ */
191
+ constructor(options) {
192
+ super();
193
+ this.nodeClass = node_opcua_data_model_1.NodeClass.Unspecified;
194
+ (0, node_opcua_assert_1.assert)(this.nodeClass === node_opcua_data_model_1.NodeClass.Unspecified, "must not be specify a nodeClass");
195
+ (0, node_opcua_assert_1.assert)(options.addressSpace); // expecting an address space
196
+ (0, node_opcua_assert_1.assert)(options.browseName instanceof node_opcua_data_model_1.QualifiedName, "Expecting a valid QualifiedName");
197
+ (0, node_opcua_assert_1.assert)(options.nodeId instanceof node_opcua_nodeid_1.NodeId, "Expecting a valid NodeId");
198
+ options.references = options.references || [];
199
+ const _private = (0, base_node_private_1.BaseNode_initPrivate)(this);
200
+ _private.__address_space = options.addressSpace;
201
+ this.nodeId = (0, node_opcua_nodeid_1.resolveNodeId)(options.nodeId);
202
+ // QualifiedName
203
+ /**
204
+ * the node browseName
205
+ * @property browseName
206
+ * @type QualifiedName
207
+ * @static
208
+ */
209
+ this.browseName = _get_QualifiedBrowseName(options.browseName);
210
+ // re-use browseName as displayName if displayName is missing
211
+ options.displayName = options.displayName || this.browseName.name.toString();
212
+ if (options.description === undefined) {
213
+ options.description = null;
214
+ }
215
+ this._setDisplayName(options.displayName);
216
+ this._setDescription(options.description);
217
+ // user defined filter function for browsing
218
+ const _browseFilter = options.browseFilter || defaultBrowseFilterFunc;
219
+ (0, node_opcua_assert_1.assert)(typeof _browseFilter === "function");
220
+ _private._browseFilter = _browseFilter;
221
+ // normalize reference type
222
+ // this will convert any referenceType expressed with its inverseName into
223
+ // its normal name and fix the isForward flag accordingly.
224
+ // ( e.g "ComponentOf" isForward:true => "HasComponent", isForward:false)
225
+ for (const reference of options.references) {
226
+ this.__addReference(reference);
227
+ }
228
+ this._accessRestrictions = options.accessRestrictions;
229
+ this._rolePermissions = (0, role_permissions_1.coerceRolePermissions)(options.rolePermissions);
230
+ }
231
+ getDisplayName(locale) {
232
+ const _private = (0, base_node_private_1.BaseNode_getPrivate)(this);
233
+ return _private._displayName[0].text;
234
+ }
235
+ get namespace() {
236
+ return this.addressSpacePrivate.getNamespace(this.nodeId.namespace);
237
+ }
238
+ // ---------------------------------------------------------------------------------------------------
239
+ // Finders
240
+ // ---------------------------------------------------------------------------------------------------
241
+ findReferencesEx(referenceType, browseDirection) {
242
+ browseDirection = browseDirection !== undefined ? browseDirection : node_opcua_data_model_1.BrowseDirection.Forward;
243
+ (0, node_opcua_assert_1.assert)(_is_valid_BrowseDirection(browseDirection));
244
+ (0, node_opcua_assert_1.assert)(browseDirection !== node_opcua_data_model_1.BrowseDirection.Both);
245
+ const referenceTypeNode = this._coerceReferenceType(referenceType);
246
+ if (!referenceTypeNode) {
247
+ // note: when loading nodeset2.xml files, reference type may not exit yet
248
+ // throw new Error("expecting valid reference name " + strReference);
249
+ return [];
250
+ }
251
+ const isForward = browseDirection === node_opcua_data_model_1.BrowseDirection.Forward;
252
+ const results = [];
253
+ const process = (referenceIdx) => {
254
+ const references = Object.values(referenceIdx);
255
+ for (const ref of references) {
256
+ if (ref.isForward === isForward && referenceTypeNode && referenceTypeNode.checkHasSubtype(ref.referenceType)) {
257
+ results.push(ref);
258
+ }
259
+ }
260
+ };
261
+ const _private = (0, base_node_private_1.BaseNode_getPrivate)(this);
262
+ process(_private._referenceIdx);
263
+ process(_private._back_referenceIdx);
264
+ return results;
265
+ }
266
+ findReferences_no_cache(referenceTypeNode, isForward = true) {
267
+ const _private = (0, base_node_private_1.BaseNode_getPrivate)(this);
268
+ const result = [];
269
+ for (const ref of Object.values(_private._referenceIdx)) {
270
+ if (ref.isForward === isForward) {
271
+ if ((0, node_opcua_nodeid_1.sameNodeId)(ref.referenceType, referenceTypeNode.nodeId)) {
272
+ result.push(ref);
273
+ }
274
+ }
275
+ }
276
+ for (const ref of Object.values(_private._back_referenceIdx)) {
277
+ if (ref.isForward === isForward) {
278
+ if ((0, node_opcua_nodeid_1.sameNodeId)(ref.referenceType, referenceTypeNode.nodeId)) {
279
+ result.push(ref);
280
+ }
281
+ }
282
+ }
283
+ return result;
284
+ }
285
+ findReferences(referenceType, isForward = true) {
286
+ const _cache = (0, base_node_private_1.BaseNode_getCache)(this);
287
+ const referenceTypeNode = this._coerceReferenceType(referenceType);
288
+ if (!referenceTypeNode) {
289
+ // note: when loading nodeset2.xml files, reference type may not exit yet
290
+ // throw new Error("expecting valid reference name " + strReference);
291
+ return [];
292
+ }
293
+ _cache._ref = _cache._ref || {};
294
+ const hash = "_ref_" + referenceTypeNode.nodeId.toString() + isForward.toString();
295
+ if (_cache._ref[hash]) {
296
+ return _cache._ref[hash];
297
+ }
298
+ // istanbul ignore next
299
+ if (doDebug && !this.addressSpace.findReferenceType(referenceTypeNode.nodeId)) {
300
+ throw new Error("expecting valid reference name " + referenceType);
301
+ }
302
+ const result = this.findReferences_no_cache(referenceTypeNode, isForward);
303
+ _cache._ref[hash] = result;
304
+ return result;
305
+ }
306
+ findReference(strReference, isForward) {
307
+ const refs = this.findReferences(strReference, isForward);
308
+ if (refs.length !== 1 && refs.length !== 0) {
309
+ throw new Error("findReference: expecting only one or zero element here");
310
+ }
311
+ return refs[0] || null;
312
+ }
313
+ findReferencesExAsObject(referenceType, browseDirection) {
314
+ const references = this.findReferencesEx(referenceType, browseDirection);
315
+ return _asObject(references, this.addressSpace);
316
+ }
317
+ findReferencesAsObject(referenceType, isForward) {
318
+ const references = this.findReferences(referenceType, isForward);
319
+ return _asObject(references, this.addressSpace);
320
+ }
321
+ /**
322
+ * return an array with the Aggregates of this object.
323
+ */
324
+ getAggregates() {
325
+ // const _cache = BaseNode_getCache(this);
326
+ // if (!_cache._aggregates) {
327
+ // _cache._aggregates = this.findReferencesExAsObject("Aggregates", BrowseDirection.Forward);
328
+ // }
329
+ // return _cache._aggregates;
330
+ return this.findReferencesExAsObject("Aggregates", node_opcua_data_model_1.BrowseDirection.Forward);
331
+ }
332
+ /**
333
+ * return an array with the components of this object.
334
+ */
335
+ getComponents() {
336
+ // const _cache = BaseNode_getCache(this);
337
+ // if (!_cache._components) {
338
+ // _cache._components = this.findReferencesExAsObject("HasComponent", BrowseDirection.Forward);
339
+ // }
340
+ // return _cache._components;
341
+ return this.findReferencesExAsObject("HasComponent", node_opcua_data_model_1.BrowseDirection.Forward);
342
+ }
343
+ /**
344
+ * return a array with the properties of this object.
345
+ */
346
+ getProperties() {
347
+ // const _cache = BaseNode_getCache(this);
348
+ // if (!_cache._properties) {
349
+ // _cache._properties = this.findReferencesExAsObject("HasProperty", BrowseDirection.Forward);
350
+ // }
351
+ // return _cache._properties;
352
+ return this.findReferencesExAsObject("HasProperty", node_opcua_data_model_1.BrowseDirection.Forward);
353
+ }
354
+ /**
355
+ * return a array with the notifiers of this object.
356
+ */
357
+ getNotifiers() {
358
+ // const _cache = BaseNode_getCache(this);
359
+ // if (!_cache._notifiers) {
360
+ // _cache._notifiers = this.findReferencesAsObject("HasNotifier", true);
361
+ // }
362
+ // return _cache._notifiers;
363
+ return this.findReferencesAsObject("HasNotifier", true);
364
+ }
365
+ /**
366
+ * return a array with the event source of this object.
367
+ */
368
+ getEventSources() {
369
+ // const _cache = BaseNode_getCache(this);
370
+ // if (!_cache._eventSources) {
371
+ // _cache._eventSources = this.findReferencesAsObject("HasEventSource", true);
372
+ // }
373
+ // return _cache._eventSources;
374
+ return this.findReferencesAsObject("HasEventSource", true);
375
+ }
376
+ /**
377
+ * return a array of the objects for which this node is an EventSource
378
+ */
379
+ getEventSourceOfs() {
380
+ // const _cache = BaseNode_getCache(this);
381
+ // if (!_cache._eventSources) {
382
+ // _cache._eventSources = this.findReferencesAsObject("HasEventSource", false);
383
+ // }
384
+ // return _cache._eventSources;
385
+ return this.findReferencesAsObject("HasEventSource", false);
386
+ }
387
+ getComponentByName(browseName, namespaceIndex) {
388
+ const components = this.getComponents();
389
+ const select = _filter_by_browse_name(components, browseName, namespaceIndex);
390
+ (0, node_opcua_assert_1.assert)(select.length <= 1, "BaseNode#getComponentByName found duplicated reference");
391
+ if (select.length === 1) {
392
+ const component = select[0];
393
+ if (component.nodeClass === node_opcua_data_model_1.NodeClass.Method) {
394
+ warningLog("please use getMethodByName to retrieve a method");
395
+ return null;
396
+ }
397
+ (0, node_opcua_assert_1.assert)(component.nodeClass === node_opcua_data_model_1.NodeClass.Variable || component.nodeClass === node_opcua_data_model_1.NodeClass.Object);
398
+ return component;
399
+ }
400
+ else {
401
+ return null;
402
+ }
403
+ }
404
+ getPropertyByName(browseName, namespaceIndex) {
405
+ const properties = this.getProperties();
406
+ const select = _filter_by_browse_name(properties, browseName, namespaceIndex);
407
+ (0, node_opcua_assert_1.assert)(select.length <= 1, "BaseNode#getPropertyByName found duplicated reference");
408
+ if (select.length === 1 && select[0].nodeClass !== node_opcua_data_model_1.NodeClass.Variable) {
409
+ throw new Error("Expecting a property to be of nodeClass==NodeClass.Variable");
410
+ }
411
+ return select.length === 1 ? select[0] : null;
412
+ }
413
+ getFolderElementByName(browseName, namespaceIndex) {
414
+ const elements = this.getFolderElements();
415
+ const select = _filter_by_browse_name(elements, browseName, namespaceIndex);
416
+ return select.length === 1 ? select[0] : null;
417
+ }
418
+ /**
419
+ * returns the list of nodes that this folder object organizes
420
+ */
421
+ getFolderElements() {
422
+ return this.findReferencesExAsObject("Organizes", node_opcua_data_model_1.BrowseDirection.Forward);
423
+ }
424
+ /**
425
+ * returns the list of methods that this object provides
426
+ * @method getMethods
427
+ * @return an array with Method objects.
428
+ *
429
+ *
430
+ * Note: internally, methods are special types of components
431
+ */
432
+ getMethods() {
433
+ // const _cache = BaseNode_getCache(this);
434
+ // if (!_cache._methods) {
435
+ // const components = this.getComponents();
436
+ // _cache._methods = components.filter((obj) => obj.nodeClass === NodeClass.Method) as UAMethod[];
437
+ // }
438
+ // return _cache._methods;
439
+ const components = this.getComponents();
440
+ return components.filter((obj) => obj.nodeClass === node_opcua_data_model_1.NodeClass.Method);
441
+ }
442
+ /**
443
+ * returns the method exposed by this object and with the given nodeId
444
+ */
445
+ getMethodById(nodeId) {
446
+ const methods = this.getMethods();
447
+ const found = methods.find((m) => m.nodeId.toString() === nodeId.toString());
448
+ return found || null;
449
+ }
450
+ getMethodByName(methodName, namespaceIndex) {
451
+ const methods = this.getMethods();
452
+ const select = _filter_by_browse_name(methods, methodName, namespaceIndex);
453
+ (0, node_opcua_assert_1.assert)(select.length <= 1, "BaseNode#getMethodByName found duplicated reference");
454
+ return select.length === 1 ? select[0] : null;
455
+ }
456
+ getWriteMask() {
457
+ return 0;
458
+ }
459
+ getUserWriteMask() {
460
+ return 0;
461
+ }
462
+ readAttribute(context, attributeId, indexRange, dataEncoding) {
463
+ indexRange;
464
+ dataEncoding;
465
+ (0, node_opcua_assert_1.assert)(!context || context instanceof session_context_1.SessionContext);
466
+ const options = {};
467
+ options.statusCode = node_opcua_status_code_1.StatusCodes.Good;
468
+ switch (attributeId) {
469
+ case node_opcua_data_model_1.AttributeIds.NodeId: // NodeId
470
+ options.value = { dataType: node_opcua_variant_1.DataType.NodeId, value: this.nodeId };
471
+ break;
472
+ case node_opcua_data_model_1.AttributeIds.NodeClass: // NodeClass
473
+ (0, node_opcua_assert_1.assert)(isFinite(this.nodeClass));
474
+ options.value = { dataType: node_opcua_variant_1.DataType.Int32, value: this.nodeClass };
475
+ break;
476
+ case node_opcua_data_model_1.AttributeIds.BrowseName: // QualifiedName
477
+ (0, node_opcua_assert_1.assert)(this.browseName instanceof node_opcua_data_model_1.QualifiedName);
478
+ options.value = { dataType: node_opcua_variant_1.DataType.QualifiedName, value: this.browseName };
479
+ break;
480
+ case node_opcua_data_model_1.AttributeIds.DisplayName: // LocalizedText
481
+ options.value = { dataType: node_opcua_variant_1.DataType.LocalizedText, value: this.displayName[0] };
482
+ break;
483
+ case node_opcua_data_model_1.AttributeIds.Description: // LocalizedText
484
+ options.value = { dataType: node_opcua_variant_1.DataType.LocalizedText, value: this.description };
485
+ break;
486
+ case node_opcua_data_model_1.AttributeIds.WriteMask:
487
+ options.value = { dataType: node_opcua_variant_1.DataType.UInt32, value: this.getWriteMask() };
488
+ break;
489
+ case node_opcua_data_model_1.AttributeIds.UserWriteMask:
490
+ options.value = { dataType: node_opcua_variant_1.DataType.UInt32, value: this.getUserWriteMask() };
491
+ break;
492
+ case node_opcua_data_model_1.AttributeIds.AccessRestrictions:
493
+ return this._readAccessRestrictions(context);
494
+ case node_opcua_data_model_1.AttributeIds.RolePermissions:
495
+ return this._readRolePermissions(context);
496
+ case node_opcua_data_model_1.AttributeIds.UserRolePermissions:
497
+ return this._readUserRolePermissions(context);
498
+ default:
499
+ options.value = null;
500
+ options.statusCode = node_opcua_status_code_1.StatusCodes.BadAttributeIdInvalid;
501
+ break;
502
+ }
503
+ // xx options.serverTimestamp = new Date();
504
+ return new node_opcua_data_value_1.DataValue(options);
505
+ }
506
+ writeAttribute(context, writeValue, callback) {
507
+ context = context || session_context_1.SessionContext.defaultContext;
508
+ (0, node_opcua_assert_1.assert)(context instanceof session_context_1.SessionContext);
509
+ (0, node_opcua_assert_1.assert)(typeof callback === "function");
510
+ if (writeValue.attributeId === undefined ||
511
+ writeValue.attributeId <= 0 ||
512
+ writeValue.attributeId > node_opcua_data_model_1.AttributeIds.AccessLevelEx) {
513
+ return callback(null, node_opcua_status_code_1.StatusCodes.BadAttributeIdInvalid);
514
+ }
515
+ if (!this.canUserWriteAttribute(context, writeValue.attributeId)) {
516
+ return callback(null, node_opcua_status_code_1.StatusCodes.BadUserAccessDenied);
517
+ }
518
+ // by default Node is read-only,
519
+ // this method needs to be overridden to change the behavior
520
+ callback(null, node_opcua_status_code_1.StatusCodes.BadNotWritable);
521
+ }
522
+ fullName() {
523
+ if (this.parentNodeId) {
524
+ const parent = this.addressSpace.findNode(this.parentNodeId);
525
+ // istanbul ignore else
526
+ if (parent) {
527
+ return parent.fullName() + "." + this.browseName.toString() + "";
528
+ }
529
+ else {
530
+ return "NOT YET REGISTERED" + this.parentNodeId.toString() + "." + this.browseName.toString() + "";
531
+ }
532
+ }
533
+ return this.browseName.toString();
534
+ }
535
+ ownReferences() {
536
+ const _private = (0, base_node_private_1.BaseNode_getPrivate)(this);
537
+ return Object.values(_private._referenceIdx);
538
+ }
539
+ /**
540
+ * @method browseNodeByTargetName
541
+ *
542
+ * @param relativePathElement
543
+ * @param isLast
544
+ * @return {NodeId[]}
545
+ */
546
+ browseNodeByTargetName(relativePathElement, isLast) {
547
+ relativePathElement.targetName = relativePathElement.targetName || new node_opcua_data_model_1.QualifiedName({});
548
+ // part 4.0 v1.03 $7.26 RelativePath
549
+ // The BrowseName of the target node.
550
+ // The final element may have an empty targetName. In this situation all targets of the references identified by
551
+ // the referenceTypeId are the targets of the RelativePath.
552
+ // The targetName shall be specified for all other elements.
553
+ // The current path cannot be followed any further if no targets with the specified BrowseName exist.
554
+ (0, node_opcua_assert_1.assert)(relativePathElement.targetName instanceof node_opcua_data_model_1.QualifiedName);
555
+ (0, node_opcua_assert_1.assert)(relativePathElement.targetName.namespaceIndex >= 0);
556
+ (0, node_opcua_assert_1.assert)(relativePathElement.targetName.name.length > 0);
557
+ // The type of reference to follow from the current node.
558
+ // The current path cannot be followed any further if the referenceTypeId is not available on the Node instance.
559
+ // If not specified then all References are included and the parameter includeSubtypes is ignored.
560
+ (0, node_opcua_assert_1.assert)(Object.prototype.hasOwnProperty.call(relativePathElement, "referenceTypeId"));
561
+ // Indicates whether the inverse Reference should be followed.
562
+ // The inverse reference is followed if this value is TRUE.
563
+ (0, node_opcua_assert_1.assert)(Object.prototype.hasOwnProperty.call(relativePathElement, "isInverse"));
564
+ // Indicates whether subtypes of the ReferenceType should be followed.
565
+ // Subtypes are included if this value is TRUE.
566
+ (0, node_opcua_assert_1.assert)(Object.prototype.hasOwnProperty.call(relativePathElement, "includeSubtypes"));
567
+ const references = this.allReferences();
568
+ const _check_reference = (reference) => {
569
+ if (relativePathElement.referenceTypeId.isEmpty()) {
570
+ return true;
571
+ }
572
+ (0, node_opcua_assert_1.assert)(relativePathElement.referenceTypeId instanceof node_opcua_nodeid_1.NodeId);
573
+ if ((relativePathElement.isInverse && reference.isForward) ||
574
+ (!relativePathElement.isInverse && !reference.isForward)) {
575
+ return false;
576
+ }
577
+ (0, node_opcua_assert_1.assert)(Object.prototype.hasOwnProperty.call(reference, "isForward"));
578
+ const referenceType = resolveReferenceType(this.addressSpace, reference);
579
+ const referenceTypeId = referenceType.nodeId;
580
+ if ((0, node_opcua_nodeid_1.sameNodeId)(relativePathElement.referenceTypeId, referenceTypeId)) {
581
+ return true;
582
+ }
583
+ if (relativePathElement.includeSubtypes) {
584
+ const baseType = this.addressSpace.findReferenceType(relativePathElement.referenceTypeId);
585
+ if (baseType && referenceType.isSubtypeOf(baseType)) {
586
+ return true;
587
+ }
588
+ }
589
+ return false;
590
+ };
591
+ const nodeIdsMap = {};
592
+ let nodeIds = [];
593
+ for (const reference of references) {
594
+ if (!_check_reference(reference)) {
595
+ continue;
596
+ }
597
+ const obj = resolveReferenceNode(this.addressSpace, reference);
598
+ // istanbul ignore next
599
+ if (!obj) {
600
+ throw new Error(" cannot find node with id " + reference.nodeId.toString());
601
+ }
602
+ if ((0, lodash_1.isEqual)(obj.browseName, relativePathElement.targetName)) {
603
+ // compare QualifiedName
604
+ const key = obj.nodeId.toString();
605
+ if (!Object.prototype.hasOwnProperty.call(nodeIdsMap, key)) {
606
+ nodeIds.push(obj.nodeId);
607
+ nodeIdsMap[key] = obj;
608
+ }
609
+ }
610
+ }
611
+ if (nodeIds.length === 0 && (this.nodeClass === node_opcua_data_model_1.NodeClass.ObjectType || this.nodeClass === node_opcua_data_model_1.NodeClass.VariableType)) {
612
+ const nodeType = this;
613
+ if (nodeType.subtypeOf) {
614
+ // browsing also InstanceDeclarations included in base type
615
+ const baseType = this.addressSpace.findNode(nodeType.subtypeOf);
616
+ const n = baseType.browseNodeByTargetName(relativePathElement, isLast);
617
+ nodeIds = [].concat(nodeIds, n);
618
+ }
619
+ }
620
+ return nodeIds;
621
+ }
622
+ /**
623
+ * browse the node to extract information requested in browseDescription
624
+ * and returns an array with reference descriptions
625
+ *
626
+ *
627
+ *
628
+ */
629
+ browseNode(browseDescription, context) {
630
+ (0, node_opcua_assert_1.assert)(isFinite(browseDescription.nodeClassMask));
631
+ const do_debug = false;
632
+ const _private = (0, base_node_private_1.BaseNode_getPrivate)(this);
633
+ const addressSpace = this.addressSpace;
634
+ const referenceTypeId = normalize_referenceTypeId(addressSpace, browseDescription.referenceTypeId);
635
+ (0, node_opcua_assert_1.assert)(referenceTypeId instanceof node_opcua_nodeid_1.NodeId);
636
+ const browseDirection = browseDescription.browseDirection !== undefined ? browseDescription.browseDirection : node_opcua_data_model_1.BrowseDirection.Both;
637
+ // get all possible references
638
+ let references = this.allReferences();
639
+ /* istanbul ignore next */
640
+ if (do_debug) {
641
+ console.log("all references :", this.nodeId.toString(), this.browseName.toString());
642
+ (0, dump_tools_1.dumpReferences)(addressSpace, Object.values(_private._referenceIdx));
643
+ }
644
+ // filter out references not matching referenceType
645
+ references = _filter_by_referenceType.call(this, browseDescription, references, referenceTypeId);
646
+ references = _filter_by_direction(references, browseDirection);
647
+ references = _filter_by_nodeClass.call(this, references, browseDescription.nodeClassMask);
648
+ references = _filter_by_userFilter.call(this, references, context);
649
+ if (context) {
650
+ references = _filter_by_context(this, references, context);
651
+ }
652
+ const referenceDescriptions = (0, base_node_private_1._constructReferenceDescription)(addressSpace, references, browseDescription.resultMask);
653
+ /* istanbul ignore next */
654
+ if (do_debug) {
655
+ (0, dump_tools_1.dumpReferenceDescriptions)(this.addressSpace, referenceDescriptions);
656
+ }
657
+ return referenceDescriptions;
658
+ }
659
+ allReferences() {
660
+ const _private = (0, base_node_private_1.BaseNode_getPrivate)(this);
661
+ return Object.values(_private._referenceIdx).concat(Object.values(_private._back_referenceIdx));
662
+ }
663
+ /**
664
+ * @method addReference
665
+ * @param reference
666
+ * @param reference.referenceType {String}
667
+ * @param [reference.isForward = true] {Boolean}
668
+ * @param reference.nodeId {Node|NodeId|String}
669
+ *
670
+ * @example
671
+ *
672
+ * view.addReference({ referenceType: "Organizes", nodeId: myDevice });
673
+ *
674
+ * or
675
+ *
676
+ * myDevice1.addReference({ referenceType: "OrganizedBy", nodeId: view });
677
+ */
678
+ addReference(reference) {
679
+ const referenceNode = this.__addReference(reference);
680
+ const addressSpace = this.addressSpace;
681
+ if (!resolveReferenceType(addressSpace, referenceNode)) {
682
+ throw new Error("BaseNode#addReference : invalid reference " + reference.toString());
683
+ }
684
+ this._clear_caches();
685
+ _propagate_ref.call(this, addressSpace, referenceNode);
686
+ this.install_extra_properties();
687
+ cetools._handle_add_reference_change_event(this, referenceNode.nodeId);
688
+ }
689
+ removeReference(referenceOpts) {
690
+ const _private = (0, base_node_private_1.BaseNode_getPrivate)(this);
691
+ (0, node_opcua_assert_1.assert)(Object.prototype.hasOwnProperty.call(referenceOpts, "referenceType"));
692
+ // xx isForward is optional : assert(Object.prototype.hasOwnProperty.call(reference,"isForward"));
693
+ (0, node_opcua_assert_1.assert)(Object.prototype.hasOwnProperty.call(referenceOpts, "nodeId"));
694
+ const addressSpace = this.addressSpace;
695
+ // istanbul ignore next
696
+ if (!addressSpace) {
697
+ console.log(" Where is addressSpace ?");
698
+ }
699
+ const reference = addressSpace.normalizeReferenceTypes([referenceOpts])[0];
700
+ const h = reference.hash;
701
+ const relatedNode = addressSpace.findNode(reference.nodeId);
702
+ const invReference = new reference_impl_1.ReferenceImpl({
703
+ isForward: !reference.isForward,
704
+ nodeId: this.nodeId,
705
+ referenceType: reference.referenceType
706
+ });
707
+ if (_private._referenceIdx[h]) {
708
+ delete _private._referenceIdx[h];
709
+ base_node_private_1.BaseNode_remove_backward_reference.call(relatedNode, invReference);
710
+ }
711
+ else if (_private._back_referenceIdx[h]) {
712
+ relatedNode.removeReference(invReference);
713
+ }
714
+ else {
715
+ // throw new Error("Cannot find reference " + reference);
716
+ }
717
+ (0, base_node_private_1._handle_HierarchicalReference)(this, reference);
718
+ this.uninstall_extra_properties(reference);
719
+ this._clear_caches();
720
+ }
721
+ /**
722
+ *
723
+ */
724
+ resolveNodeId(nodeId) {
725
+ return this.addressSpace.resolveNodeId(nodeId);
726
+ }
727
+ install_extra_properties() {
728
+ const addressSpace = this.addressSpace;
729
+ if (addressSpace.isFrugal) {
730
+ // skipping
731
+ return;
732
+ }
733
+ install_components_as_object_properties(this);
734
+ function install_extra_properties_on_parent(ref) {
735
+ const node = reference_impl_1.ReferenceImpl.resolveReferenceNode(addressSpace, ref);
736
+ install_components_as_object_properties(node);
737
+ }
738
+ // make sure parent have extra properties updated
739
+ const parentComponents = this.findReferencesEx("HasComponent", node_opcua_data_model_1.BrowseDirection.Inverse);
740
+ const parentSubfolders = this.findReferencesEx("Organizes", node_opcua_data_model_1.BrowseDirection.Inverse);
741
+ const parentProperties = this.findReferencesEx("HasProperty", node_opcua_data_model_1.BrowseDirection.Inverse);
742
+ for (const p of parentComponents) {
743
+ install_extra_properties_on_parent(p);
744
+ }
745
+ for (const p of parentSubfolders) {
746
+ install_extra_properties_on_parent(p);
747
+ }
748
+ for (const p of parentProperties) {
749
+ install_extra_properties_on_parent(p);
750
+ }
751
+ }
752
+ uninstall_extra_properties(reference) {
753
+ const addressSpace = this.addressSpace;
754
+ if (addressSpace.isFrugal) {
755
+ // skipping
756
+ return;
757
+ }
758
+ const childNode = resolveReferenceNode(addressSpace, reference);
759
+ const name = (0, node_opcua_utils_1.lowerFirstLetter)(childNode.browseName.name.toString());
760
+ if (Object.prototype.hasOwnProperty.call(reservedNames, name)) {
761
+ // istanbul ignore next
762
+ if (doDebug) {
763
+ // tslint:disable-next-line:no-console
764
+ console.log(chalk.bgWhite.red("Ignoring reserved keyword " + name));
765
+ }
766
+ return;
767
+ }
768
+ /* istanbul ignore next */
769
+ if (!Object.prototype.hasOwnProperty.call(this, name)) {
770
+ return;
771
+ }
772
+ Object.defineProperty(this, name, {
773
+ value: undefined
774
+ });
775
+ }
776
+ toString() {
777
+ const options = new base_node_private_1.ToStringBuilder();
778
+ base_node_private_1.BaseNode_toString.call(this, options);
779
+ return options.toString();
780
+ }
781
+ /**
782
+ * @property isFalseSubStateOf
783
+ * @type {BaseNode|null}
784
+ */
785
+ get isFalseSubStateOf() {
786
+ const r = this.findReferencesAsObject("HasFalseSubState", false);
787
+ if (!r || r.length === 0) {
788
+ return null;
789
+ }
790
+ (0, node_opcua_assert_1.assert)(r.length === 1);
791
+ return r[0];
792
+ }
793
+ /**
794
+ * @property isTrueSubStateOf
795
+ * @type {BaseNode|null}
796
+ */
797
+ get isTrueSubStateOf() {
798
+ const r = this.findReferencesAsObject("HasTrueSubState", false);
799
+ if (!r || r.length === 0) {
800
+ return null;
801
+ }
802
+ (0, node_opcua_assert_1.assert)(r.length === 1);
803
+ return r[0];
804
+ }
805
+ /**
806
+ * @method getFalseSubStates
807
+ * @return {UAStateVariable[]} return an array with the SubStates of this object.
808
+ */
809
+ getFalseSubStates() {
810
+ return this.findReferencesAsObject("HasFalseSubState");
811
+ }
812
+ /**
813
+ * @method getTrueSubStates
814
+ * @return {UAStateVariable[]} return an array with the SubStates of this object.
815
+ */
816
+ getTrueSubStates() {
817
+ return this.findReferencesAsObject("HasTrueSubState");
818
+ }
819
+ findHierarchicalReferences() {
820
+ return this.findReferencesEx("HierarchicalReferences", node_opcua_data_model_1.BrowseDirection.Forward);
821
+ }
822
+ getChildByName(browseName, namespaceIndex) {
823
+ // Attention: getChild doesn't care about namespace on browseName
824
+ // !!!!
825
+ if (browseName instanceof node_opcua_data_model_1.QualifiedName) {
826
+ browseName = browseName.name.toString();
827
+ }
828
+ (0, node_opcua_assert_1.assert)(typeof browseName === "string");
829
+ const _cache = (0, base_node_private_1.BaseNode_getCache)(this);
830
+ const addressSpace = this.addressSpace;
831
+ if (!_cache._childByNameMap) {
832
+ _cache._childByNameMap = {};
833
+ const childReferenceTypes = this.findReferencesEx("HasChild");
834
+ for (const r of childReferenceTypes) {
835
+ const child = resolveReferenceNode(addressSpace, r);
836
+ _cache._childByNameMap[child.browseName.name.toString()] = child;
837
+ }
838
+ }
839
+ const ret = _cache._childByNameMap[browseName.toString()] || null;
840
+ return ret;
841
+ }
842
+ get toStateNode() {
843
+ const nodes = this.findReferencesAsObject("ToState", true);
844
+ (0, node_opcua_assert_1.assert)(nodes.length <= 1);
845
+ return nodes.length === 1 ? nodes[0] : null;
846
+ }
847
+ get fromStateNode() {
848
+ const nodes = this.findReferencesAsObject("FromState", true);
849
+ (0, node_opcua_assert_1.assert)(nodes.length <= 1);
850
+ return nodes.length === 1 ? nodes[0] : null;
851
+ }
852
+ /**
853
+ * this methods propagates the forward references to the pointed node
854
+ * by inserting backward references to the counter part node
855
+ */
856
+ propagate_back_references() {
857
+ const _private = (0, base_node_private_1.BaseNode_getPrivate)(this);
858
+ if (this.addressSpace.suspendBackReference) {
859
+ // this indicates that the base node is constructed from an xml definition
860
+ // propagate_back_references will be called later once the file has been completely processed.
861
+ return;
862
+ }
863
+ const addressSpace = this.addressSpace;
864
+ for (const reference of Object.values(_private._referenceIdx)) {
865
+ _propagate_ref.call(this, addressSpace, reference);
866
+ }
867
+ }
868
+ /**
869
+ * the dispose method should be called when the node is no longer used, to release
870
+ * back pointer to the address space and clear caches.
871
+ *
872
+ * @method dispose
873
+ *
874
+ */
875
+ dispose() {
876
+ this.emit("dispose");
877
+ this.removeAllListeners();
878
+ this._clear_caches();
879
+ const _private = (0, base_node_private_1.BaseNode_getPrivate)(this);
880
+ Object.values(_private._back_referenceIdx).forEach((ref) => ref.dispose());
881
+ Object.values(_private._referenceIdx).forEach((ref) => ref.dispose());
882
+ (0, base_node_private_1.BaseNode_removePrivate)(this);
883
+ }
884
+ isDisposed() {
885
+ return !this.addressSpacePrivate;
886
+ }
887
+ // istanbul ignore next
888
+ dumpXML(xmlWriter) {
889
+ console.error(" This ", node_opcua_data_model_1.NodeClass[this.nodeClass]);
890
+ (0, node_opcua_assert_1.assert)(false, "BaseNode#dumpXML NOT IMPLEMENTED !");
891
+ (0, node_opcua_assert_1.assert)(xmlWriter);
892
+ }
893
+ /**
894
+ * Undo the effect of propagate_back_references
895
+ */
896
+ unpropagate_back_references() {
897
+ const _private = (0, base_node_private_1.BaseNode_getPrivate)(this);
898
+ const addressSpace = this.addressSpace;
899
+ for (const reference of Object.values(_private._referenceIdx)) {
900
+ // filter out non Hierarchical References
901
+ const referenceType = resolveReferenceType(addressSpace, reference);
902
+ // istanbul ignore next
903
+ if (!referenceType) {
904
+ console.error(chalk.red(" ERROR"), " cannot find reference ", reference.referenceType, reference.toString());
905
+ }
906
+ const related_node = resolveReferenceNode(addressSpace, reference);
907
+ if (related_node) {
908
+ (0, node_opcua_assert_1.assert)(reference.nodeId.toString() !== this.nodeId.toString());
909
+ base_node_private_1.BaseNode_remove_backward_reference.call(related_node, new reference_impl_1.ReferenceImpl({
910
+ isForward: !reference.isForward,
911
+ nodeId: this.nodeId,
912
+ referenceType: reference.referenceType
913
+ }));
914
+ } // else addressSpace may be incomplete
915
+ }
916
+ }
917
+ installPostInstallFunc(f) {
918
+ if (!f) {
919
+ // nothing to do
920
+ return;
921
+ }
922
+ function chain(f1, f2) {
923
+ return function chaiFunc(...args) {
924
+ if (f1) {
925
+ f1.apply(this, args);
926
+ }
927
+ if (f2) {
928
+ f2.apply(this, args);
929
+ }
930
+ };
931
+ }
932
+ this._postInstantiateFunc = chain.call(this, this._postInstantiateFunc, f);
933
+ }
934
+ _on_child_added() {
935
+ this._clear_caches();
936
+ }
937
+ _on_child_removed(obj) {
938
+ // obj; // unused;
939
+ this._clear_caches();
940
+ }
941
+ /**
942
+ * @private
943
+ * @param reference
944
+ */
945
+ _add_backward_reference(reference) {
946
+ base_node_private_1.BaseNode_add_backward_reference.call(this, reference);
947
+ }
948
+ _coerceReferenceType(referenceType) {
949
+ let result;
950
+ if (typeof referenceType === "string") {
951
+ result = this.addressSpace.findReferenceType(referenceType);
952
+ /* istanbul ignore next */
953
+ if (!result) {
954
+ errorLog("referenceType ", referenceType, " cannot be found");
955
+ throw new Error("Cannot coerce reference with name " + referenceType);
956
+ }
957
+ }
958
+ else if (referenceType instanceof node_opcua_nodeid_1.NodeId) {
959
+ result = this.addressSpace.findNode(referenceType);
960
+ if (!result) {
961
+ return null;
962
+ }
963
+ }
964
+ else {
965
+ result = referenceType;
966
+ }
967
+ (0, node_opcua_assert_1.assert)(result, "reference must exists");
968
+ (0, node_opcua_assert_1.assert)(result.nodeClass === node_opcua_data_model_1.NodeClass.ReferenceType);
969
+ return result;
970
+ }
971
+ __addReference(referenceOpts) {
972
+ const _private = (0, base_node_private_1.BaseNode_getPrivate)(this);
973
+ (0, node_opcua_assert_1.assert)(Object.prototype.hasOwnProperty.call(referenceOpts, "referenceType"));
974
+ // xx isForward is optional : assert(Object.prototype.hasOwnProperty.call(reference,"isForward"));
975
+ (0, node_opcua_assert_1.assert)(Object.prototype.hasOwnProperty.call(referenceOpts, "nodeId"));
976
+ const addressSpace = this.addressSpace;
977
+ const reference = addressSpace.normalizeReferenceTypes([referenceOpts])[0];
978
+ (0, node_opcua_assert_1.assert)(reference instanceof reference_impl_1.ReferenceImpl);
979
+ const h = reference.hash;
980
+ (0, node_opcua_assert_1.assert)(!_private._back_referenceIdx[h], "reference exists already in _back_references");
981
+ (0, node_opcua_assert_1.assert)(!_private._referenceIdx[h], "reference exists already in _references");
982
+ _private._referenceIdx[h] = reference;
983
+ (0, base_node_private_1._handle_HierarchicalReference)(this, reference);
984
+ return reference;
985
+ }
986
+ _setDisplayName(displayName) {
987
+ const displayNames = Array.isArray(displayName) ? displayName : [displayName];
988
+ const _displayNames = displayNames.map(node_opcua_data_model_1.coerceLocalizedText);
989
+ const _private = (0, base_node_private_1.BaseNode_getPrivate)(this);
990
+ _private._displayName = _displayNames;
991
+ }
992
+ _setDescription(description) {
993
+ const __description = (0, node_opcua_data_model_1.coerceLocalizedText)(description);
994
+ const _private = (0, base_node_private_1.BaseNode_getPrivate)(this);
995
+ _private._description = __description;
996
+ }
997
+ _notifyAttributeChange(attributeId) {
998
+ const event_name = BaseNodeImpl.makeAttributeEventName(attributeId);
999
+ this.emit(event_name, this.readAttribute(session_context_1.SessionContext.defaultContext, attributeId));
1000
+ }
1001
+ _clear_caches() {
1002
+ (0, base_node_private_1.BaseNode_clearCache)(this);
1003
+ }
1004
+ canUserWriteAttribute(context, attributeId) {
1005
+ // the Client is allowed to write to Attributes other than the Value,
1006
+ // Historizing or RolePermissions Attribute
1007
+ if (!context)
1008
+ return true;
1009
+ if (attributeId === node_opcua_data_model_1.AttributeIds.Historizing) {
1010
+ return context.checkPermission(this, node_opcua_types_1.PermissionType.WriteHistorizing);
1011
+ }
1012
+ if (attributeId === node_opcua_data_model_1.AttributeIds.RolePermissions) {
1013
+ return context.checkPermission(this, node_opcua_types_1.PermissionType.WriteRolePermissions);
1014
+ }
1015
+ if (attributeId === node_opcua_data_model_1.AttributeIds.Value) {
1016
+ return context.checkPermission(this, node_opcua_types_1.PermissionType.Write);
1017
+ }
1018
+ return context.checkPermission(this, node_opcua_types_1.PermissionType.WriteAttribute);
1019
+ }
1020
+ _readAccessRestrictions(context) {
1021
+ // https://reference.opcfoundation.org/v104/Core/docs/Part3/8.56/
1022
+ if (this.accessRestrictions === undefined) {
1023
+ return new node_opcua_data_value_1.DataValue({ statusCode: node_opcua_status_code_1.StatusCodes.BadAttributeIdInvalid });
1024
+ }
1025
+ return new node_opcua_data_value_1.DataValue({
1026
+ statusCode: node_opcua_status_code_1.StatusCodes.Good,
1027
+ value: {
1028
+ dataType: node_opcua_variant_1.DataType.UInt16,
1029
+ value: this.accessRestrictions
1030
+ }
1031
+ });
1032
+ }
1033
+ _readRolePermissions(context) {
1034
+ // https://reference.opcfoundation.org/v104/Core/docs/Part3/4.8.3/
1035
+ // to do check that current user can read permission
1036
+ if (context && !context.checkPermission(this, node_opcua_types_1.PermissionType.ReadRolePermissions)) {
1037
+ return new node_opcua_data_value_1.DataValue({
1038
+ statusCode: node_opcua_status_code_1.StatusCodes.BadSecurityModeInsufficient
1039
+ });
1040
+ }
1041
+ if (this.rolePermissions === undefined) {
1042
+ // to do : If not specified, the value of DefaultUserRolePermissions Property from
1043
+ // the Namespace Metadata Object associated with the Node is used instead.
1044
+ return new node_opcua_data_value_1.DataValue({
1045
+ statusCode: node_opcua_status_code_1.StatusCodes.BadAttributeIdInvalid
1046
+ });
1047
+ }
1048
+ const rolePermissions = this.rolePermissions.map(({ roleId, permissions }) => {
1049
+ return new node_opcua_types_1.RolePermissionType({
1050
+ roleId: toRoleNodeId(roleId),
1051
+ permissions
1052
+ });
1053
+ });
1054
+ return new node_opcua_data_value_1.DataValue({
1055
+ statusCode: node_opcua_status_code_1.StatusCodes.Good,
1056
+ value: {
1057
+ dataType: node_opcua_variant_1.DataType.ExtensionObject,
1058
+ arrayType: node_opcua_variant_1.VariantArrayType.Array,
1059
+ value: rolePermissions
1060
+ }
1061
+ });
1062
+ }
1063
+ _readUserRolePermissions(context) {
1064
+ const allUserCanSeeTheirOwnRolePermissions = true;
1065
+ if (!allUserCanSeeTheirOwnRolePermissions) {
1066
+ // to do check that current user can read permission
1067
+ if (context && !context.checkPermission(this, node_opcua_types_1.PermissionType.ReadRolePermissions)) {
1068
+ return new node_opcua_data_value_1.DataValue({
1069
+ statusCode: node_opcua_status_code_1.StatusCodes.BadSecurityModeInsufficient
1070
+ });
1071
+ }
1072
+ }
1073
+ if (this.rolePermissions === undefined) {
1074
+ // to do : If not specified, the value of DefaultUserRolePermissions Property from
1075
+ // the Namespace Metadata Object associated with the Node is used instead.
1076
+ return new node_opcua_data_value_1.DataValue({
1077
+ statusCode: node_opcua_status_code_1.StatusCodes.BadAttributeIdInvalid
1078
+ });
1079
+ }
1080
+ const context1 = context === null ? session_context_1.SessionContext.defaultContext : context;
1081
+ // for the time being get user Permission
1082
+ const rolePermissions = this.rolePermissions
1083
+ .map(({ roleId, permissions }) => {
1084
+ return new node_opcua_types_1.RolePermissionType({
1085
+ roleId: toRoleNodeId(roleId),
1086
+ permissions
1087
+ });
1088
+ })
1089
+ .filter(({ roleId }) => context1.currentUserHasRole(roleId));
1090
+ return new node_opcua_data_value_1.DataValue({
1091
+ statusCode: node_opcua_status_code_1.StatusCodes.Good,
1092
+ value: {
1093
+ dataType: node_opcua_variant_1.DataType.ExtensionObject,
1094
+ arrayType: node_opcua_variant_1.VariantArrayType.Array,
1095
+ value: rolePermissions
1096
+ }
1097
+ });
1098
+ }
1099
+ /**
1100
+ *
1101
+ * @param rolePermissions
1102
+ */
1103
+ setRolePermissions(rolePermissions) {
1104
+ this._rolePermissions = (0, role_permissions_1.coerceRolePermissions)(rolePermissions);
1105
+ }
1106
+ getRolePermissions(inherited) {
1107
+ if (this.rolePermissions === undefined && inherited) {
1108
+ return this.namespace.getDefaultRolePermissions();
1109
+ }
1110
+ return this._rolePermissions || null;
1111
+ }
1112
+ get rolePermissions() {
1113
+ return this._rolePermissions || undefined;
1114
+ }
1115
+ setAccessRestrictions(accessRestrictions) {
1116
+ this._accessRestrictions = accessRestrictions;
1117
+ }
1118
+ get accessRestrictions() {
1119
+ return this._accessRestrictions;
1120
+ }
1121
+ getAccessRestrictions(inherited) {
1122
+ if (this._accessRestrictions === undefined && inherited) {
1123
+ return this.namespace.getDefaultAccessRestrictions();
1124
+ }
1125
+ return this._accessRestrictions || node_opcua_data_model_1.AccessRestrictionsFlag.None;
1126
+ }
1127
+ }
1128
+ exports.BaseNodeImpl = BaseNodeImpl;
1129
+ function toRoleNodeId(s) {
1130
+ if (typeof s === "string") {
1131
+ return (0, node_opcua_nodeid_1.resolveNodeId)(session_context_1.WellKnownRolesNodeId[s]);
1132
+ }
1133
+ return (0, node_opcua_nodeid_1.coerceNodeId)(s);
1134
+ }
1135
+ let displayWarning = true;
1136
+ function toString_ReferenceDescription(ref, options) {
1137
+ const addressSpace = options.addressSpace;
1138
+ // xx assert(ref instanceof ReferenceDescription);
1139
+ const refNode = addressSpace.findNode(ref.referenceType);
1140
+ if (!refNode) {
1141
+ return "Unknown Ref : " + ref;
1142
+ }
1143
+ const r = new reference_impl_1.ReferenceImpl({
1144
+ isForward: ref.isForward,
1145
+ nodeId: ref.nodeId,
1146
+ referenceType: refNode.browseName.toString()
1147
+ });
1148
+ const str = r.toString(options);
1149
+ r.dispose();
1150
+ return str;
1151
+ }
1152
+ function _setup_parent_item(references) {
1153
+ references = Object.values(references);
1154
+ const _private = (0, base_node_private_1.BaseNode_getPrivate)(this);
1155
+ (0, node_opcua_assert_1.assert)(!_private._parent, "_setup_parent_item has been already called");
1156
+ const addressSpace = this.addressSpace;
1157
+ if (references.length > 0) {
1158
+ references = this.findReferencesEx("Aggregates", node_opcua_data_model_1.BrowseDirection.Inverse);
1159
+ if (references.length >= 1) {
1160
+ // istanbul ignore next
1161
+ if (references.length > 1) {
1162
+ if (displayWarning) {
1163
+ const options = { addressSpace };
1164
+ // tslint:disable-next-line:no-console
1165
+ console.warn(" More than one Aggregates reference have been found for parent of object");
1166
+ // tslint:disable-next-line:no-console
1167
+ console.warn(" object node id:", this.nodeId.toString(), chalk.cyan(this.browseName.toString()));
1168
+ // tslint:disable-next-line:no-console
1169
+ console.warn(" browseResults:");
1170
+ // tslint:disable-next-line:no-console
1171
+ console.warn(references.map((f) => toString_ReferenceDescription(f, options)).join("\n"));
1172
+ // tslint:disable-next-line:no-console
1173
+ console.warn(" first one will be used as parent");
1174
+ // xx assert(browseResults.length === 1);
1175
+ displayWarning = false;
1176
+ }
1177
+ }
1178
+ return reference_impl_1.ReferenceImpl.resolveReferenceNode(addressSpace, references[0]);
1179
+ }
1180
+ }
1181
+ return null;
1182
+ }
1183
+ function _asObject(references, addressSpace) {
1184
+ function toObject(reference) {
1185
+ const obj = resolveReferenceNode(addressSpace, reference);
1186
+ // istanbul ignore next
1187
+ if (false && !obj) {
1188
+ // tslint:disable-next-line:no-console
1189
+ console.log(chalk.red(" Warning : object with nodeId ") +
1190
+ chalk.cyan(reference.nodeId.toString()) +
1191
+ chalk.red(" cannot be found in the address space !"));
1192
+ }
1193
+ return obj;
1194
+ }
1195
+ function remove_null(o) {
1196
+ return !!o;
1197
+ }
1198
+ return references.map(toObject).filter(remove_null);
1199
+ }
1200
+ function _filter_by_browse_name(components, browseName, namespaceIndex) {
1201
+ let select = [];
1202
+ if ((namespaceIndex === null || namespaceIndex === undefined) && typeof browseName === "string") {
1203
+ select = components.filter((c) => c.browseName.name.toString() === browseName);
1204
+ if (select && select.length > 1) {
1205
+ warningLog("Multiple children exist with name ", browseName, " please specify a namespace index");
1206
+ }
1207
+ }
1208
+ else {
1209
+ const _browseName = (0, node_opcua_data_model_1.coerceQualifiedName)(typeof browseName === "string" ? { name: browseName, namespaceIndex } : browseName);
1210
+ select = components.filter((c) => c.browseName.name === _browseName.name && c.browseName.namespaceIndex === _browseName.namespaceIndex);
1211
+ }
1212
+ return select;
1213
+ }
1214
+ let displayWarningReferencePointingToItSelf = true;
1215
+ function _is_massively_used_reference(referenceType) {
1216
+ const name = referenceType.browseName.toString();
1217
+ return name === "HasTypeDefinition" || name === "HasModellingRule";
1218
+ }
1219
+ function _propagate_ref(addressSpace, reference) {
1220
+ // filter out non Hierarchical References
1221
+ const referenceType = reference_impl_1.ReferenceImpl.resolveReferenceType(addressSpace, reference);
1222
+ // istanbul ignore next
1223
+ if (!referenceType) {
1224
+ // tslint:disable-next-line:no-console
1225
+ console.error(chalk.red(" ERROR"), " cannot find reference ", reference.referenceType, reference.toString());
1226
+ }
1227
+ // ------------------------------- Filter out back reference when reference type
1228
+ // is HasTypeDefinition, HasModellingRule, etc ...
1229
+ //
1230
+ // var referenceNode = Reference.resolveReferenceNode(addressSpace,reference);
1231
+ // ignore propagation on back reference to UAVariableType or UAObject Type reference
1232
+ // because there are too many !
1233
+ if (!referenceType || _is_massively_used_reference(referenceType)) {
1234
+ return;
1235
+ }
1236
+ // ------------------------------- EXPERIMENT
1237
+ // xx if (!referenceType.isSubtypeOf(hierarchicalReferencesId)) { return; }
1238
+ const related_node = resolveReferenceNode(addressSpace, reference);
1239
+ if (related_node) {
1240
+ // verify that reference doesn't point to object it this (see mantis 3099)
1241
+ if ((0, node_opcua_nodeid_1.sameNodeId)(reference.nodeId, this.nodeId)) {
1242
+ // istanbul ignore next
1243
+ if (displayWarningReferencePointingToItSelf) {
1244
+ // this could happen with method
1245
+ console.warn(" Warning: a Reference is pointing to this ", this.nodeId.toString(), this.browseName.toString());
1246
+ displayWarningReferencePointingToItSelf = false;
1247
+ }
1248
+ }
1249
+ // xx ignore this assert(reference.nodeId.toString() !== this.nodeId.toString());
1250
+ // function w(s,l) { return (s+" ").substring(0,l);}
1251
+ // if (reference.isForward) {
1252
+ // console.log(" CHILD => ",w(related_node.browseName + " " + related_node.nodeId.toString(),30),
1253
+ // " PARENT ",w(this.browseName + " " + this.nodeId.toString(),30) , reference.toString());
1254
+ // } else {
1255
+ // console.log(" CHILD => ",w(this.browseName + " " + this.nodeId.toString(),30),
1256
+ // " PARENT ",w(related_node.browseName + " " + related_node.nodeId.toString(),30) , reference.toString());
1257
+ //
1258
+ // }
1259
+ related_node._add_backward_reference(new reference_impl_1.ReferenceImpl({
1260
+ _referenceType: getReferenceType(reference),
1261
+ isForward: !reference.isForward,
1262
+ node: this,
1263
+ nodeId: this.nodeId,
1264
+ referenceType: reference.referenceType
1265
+ }));
1266
+ } // else addressSpace may be incomplete and under construction (while loading a nodeset.xml file for instance)
1267
+ }
1268
+ function nodeid_is_nothing(nodeid) {
1269
+ return nodeid.value === 0 && nodeid.namespace === 0;
1270
+ }
1271
+ /**
1272
+ * @method normalize_referenceTypeId
1273
+ * @param addressSpace {IAddressSpace}
1274
+ * @param referenceTypeId {String|NodeId|null} : the referenceType either as a string or a nodeId
1275
+ * @return {NodeId}
1276
+ */
1277
+ function normalize_referenceTypeId(addressSpace, referenceTypeId) {
1278
+ if (!referenceTypeId) {
1279
+ return (0, node_opcua_nodeid_1.makeNodeId)(0);
1280
+ }
1281
+ if (typeof referenceTypeId === "string") {
1282
+ const ref = addressSpace.findReferenceType(referenceTypeId);
1283
+ if (ref) {
1284
+ return ref.nodeId;
1285
+ }
1286
+ }
1287
+ let nodeId;
1288
+ try {
1289
+ nodeId = addressSpace.resolveNodeId(referenceTypeId);
1290
+ }
1291
+ catch (err) {
1292
+ console.log("cannot normalize_referenceTypeId", referenceTypeId);
1293
+ throw err;
1294
+ }
1295
+ (0, node_opcua_assert_1.assert)(nodeId);
1296
+ return nodeId;
1297
+ }
1298
+ const resolveReferenceNode = reference_impl_1.ReferenceImpl.resolveReferenceNode;
1299
+ const resolveReferenceType = reference_impl_1.ReferenceImpl.resolveReferenceType;
1300
+ function _filter_by_referenceType(browseDescription, references, referenceTypeId) {
1301
+ // make sure we have a valid referenceTypeId if not null
1302
+ if (!nodeid_is_nothing(referenceTypeId)) {
1303
+ (0, node_opcua_assert_1.assert)(referenceTypeId instanceof node_opcua_nodeid_1.NodeId);
1304
+ const referenceType = this.addressSpace.findNode(referenceTypeId);
1305
+ (0, node_opcua_debug_1.dumpIf)(!referenceType, referenceTypeId);
1306
+ // istanbul ignore next
1307
+ if (!referenceType || referenceType.nodeClass !== node_opcua_data_model_1.NodeClass.ReferenceType) {
1308
+ throw new Error("Cannot find reference type");
1309
+ }
1310
+ if (!browseDescription.includeSubtypes && referenceType.isAbstract) {
1311
+ warningLog("filter by reference will skip all reference as referenceType is abstract and includeSubtypes is false");
1312
+ }
1313
+ references = references.filter((reference) => {
1314
+ const ref = resolveReferenceType(this.addressSpace, reference);
1315
+ // istanbul ignore next
1316
+ if (!ref) {
1317
+ throw new Error("Cannot find reference type " + reference.toString());
1318
+ }
1319
+ // unknown type ... this may happen when the address space is not fully build
1320
+ (0, node_opcua_assert_1.assert)(ref.nodeClass === node_opcua_data_model_1.NodeClass.ReferenceType);
1321
+ const isSameType = (0, node_opcua_nodeid_1.sameNodeId)(ref.nodeId, referenceType.nodeId);
1322
+ if (isSameType) {
1323
+ return true;
1324
+ }
1325
+ if (browseDescription.includeSubtypes) {
1326
+ return ref.isSubtypeOf(referenceType);
1327
+ }
1328
+ else {
1329
+ return false;
1330
+ }
1331
+ });
1332
+ }
1333
+ return references;
1334
+ }
1335
+ function forwardOnly(reference) {
1336
+ return reference.isForward;
1337
+ }
1338
+ function reverseOnly(reference) {
1339
+ return !reference.isForward;
1340
+ }
1341
+ function _filter_by_direction(references, browseDirection) {
1342
+ if (browseDirection === node_opcua_data_model_1.BrowseDirection.Both) {
1343
+ return references;
1344
+ }
1345
+ if (browseDirection === node_opcua_data_model_1.BrowseDirection.Forward) {
1346
+ return references.filter(forwardOnly);
1347
+ }
1348
+ else {
1349
+ return references.filter(reverseOnly);
1350
+ }
1351
+ }
1352
+ /*
1353
+ function _filter_by_context(node: BaseNode, references: Reference[], context: SessionContext): Reference[] {
1354
+ if (!context.isBrowseAccessRestricted(node)) {
1355
+ return references;
1356
+ }
1357
+ // browse access is restricted for forward
1358
+ return [];
1359
+ }
1360
+ */
1361
+ function _filter_by_context(node, references, context) {
1362
+ const addressSpace = node.addressSpace;
1363
+ return references.filter((reference) => !context.isBrowseAccessRestricted(resolveReferenceNode(addressSpace, reference)));
1364
+ }
1365
+ function _filter_by_nodeClass(references, nodeClassMask) {
1366
+ (0, node_opcua_assert_1.assert)(isFinite(nodeClassMask));
1367
+ if (nodeClassMask === 0) {
1368
+ return references;
1369
+ }
1370
+ const addressSpace = this.addressSpace;
1371
+ return references.filter((reference) => {
1372
+ const obj = resolveReferenceNode(addressSpace, reference);
1373
+ if (!obj) {
1374
+ return false;
1375
+ }
1376
+ const nodeClassName = node_opcua_data_model_1.NodeClass[obj.nodeClass];
1377
+ const value = (0, node_opcua_data_model_1.makeNodeClassMask)(nodeClassName);
1378
+ return (value & nodeClassMask) === value;
1379
+ });
1380
+ }
1381
+ function _filter_by_userFilter(references, context) {
1382
+ const addressSpace = this.addressSpace;
1383
+ return references.filter((reference) => {
1384
+ const obj = resolveReferenceNode(addressSpace, reference);
1385
+ // istanbul ignore next
1386
+ if (!obj) {
1387
+ return false;
1388
+ }
1389
+ const _private = (0, base_node_private_1.BaseNode_getPrivate)(obj);
1390
+ // istanbul ignore next
1391
+ if (!_private._browseFilter) {
1392
+ throw Error("Internal error : cannot find browseFilter");
1393
+ }
1394
+ const filter1 = _private._browseFilter.call(obj, context);
1395
+ return filter1;
1396
+ });
1397
+ }
1398
+ const reservedNames = {
1399
+ __description: 0,
1400
+ __displayName: 0,
1401
+ browseName: 0,
1402
+ description: 0,
1403
+ displayName: 0,
1404
+ nodeClass: 0,
1405
+ nodeId: 0,
1406
+ typeDefinition: 0
1407
+ };
1408
+ /*
1409
+ * install hierarchical references as javascript properties
1410
+ * Components/Properties/Organizes
1411
+ */
1412
+ function install_components_as_object_properties(parentObj) {
1413
+ if (!parentObj) {
1414
+ return;
1415
+ }
1416
+ const addressSpace = parentObj.addressSpace;
1417
+ const hierarchicalRefs = parentObj.findHierarchicalReferences();
1418
+ const children = hierarchicalRefs.map((r) => reference_impl_1.ReferenceImpl.resolveReferenceNode(addressSpace, r));
1419
+ for (const child of children) {
1420
+ if (!child) {
1421
+ continue;
1422
+ }
1423
+ // assumption: we ignore namespace here .
1424
+ const name = (0, node_opcua_utils_1.lowerFirstLetter)(child.browseName.name.toString());
1425
+ if (Object.prototype.hasOwnProperty.call(reservedNames, name)) {
1426
+ // ignore reserved names
1427
+ if (doDebug) {
1428
+ console.log(chalk.bgWhite.red("Ignoring reserved keyword " + name));
1429
+ }
1430
+ continue;
1431
+ }
1432
+ // ignore reserved names
1433
+ if (doDebug) {
1434
+ console.log("Installing property " + name, " on ", parentObj.browseName.toString());
1435
+ }
1436
+ /* istanbul ignore next */
1437
+ if (Object.prototype.hasOwnProperty.call(parentObj, name)) {
1438
+ continue;
1439
+ }
1440
+ Object.defineProperty(parentObj, name, {
1441
+ configurable: true,
1442
+ enumerable: true,
1443
+ // xx writable: false,
1444
+ get() {
1445
+ return child;
1446
+ }
1447
+ // value: child
1448
+ });
1449
+ }
1450
+ }
1451
+ function getReferenceType(reference) {
1452
+ return reference._referenceType;
1453
+ }
1454
+ exports.getReferenceType = getReferenceType;
1455
+ //# sourceMappingURL=base_node_impl.js.map