node-opcua-address-space 2.51.0

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