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