@matter/node 0.18.0 → 0.18.1-alpha.0-20261111-b84c5d1bc

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 (618) hide show
  1. package/dist/cjs/behavior/Behavior.d.ts.map +1 -1
  2. package/dist/cjs/behavior/Behavior.js +2 -0
  3. package/dist/cjs/behavior/Behavior.js.map +1 -1
  4. package/dist/cjs/behavior/Events.d.ts.map +1 -1
  5. package/dist/cjs/behavior/Events.js +4 -2
  6. package/dist/cjs/behavior/Events.js.map +1 -1
  7. package/dist/cjs/behavior/cluster/ClusterBehavior.d.ts +17 -3
  8. package/dist/cjs/behavior/cluster/ClusterBehavior.d.ts.map +1 -1
  9. package/dist/cjs/behavior/cluster/ClusterBehavior.js +2 -20
  10. package/dist/cjs/behavior/cluster/ClusterBehavior.js.map +1 -1
  11. package/dist/cjs/behavior/cluster/ClusterBehaviorType.d.ts.map +1 -1
  12. package/dist/cjs/behavior/cluster/ClusterBehaviorType.js +8 -150
  13. package/dist/cjs/behavior/cluster/ClusterBehaviorType.js.map +1 -1
  14. package/dist/cjs/behavior/context/server/LocalActorContext.d.ts +1 -1
  15. package/dist/cjs/behavior/context/server/LocalActorContext.d.ts.map +1 -1
  16. package/dist/cjs/behavior/internal/BehaviorBacking.d.ts +2 -2
  17. package/dist/cjs/behavior/internal/BehaviorBacking.d.ts.map +1 -1
  18. package/dist/cjs/behavior/internal/BehaviorBacking.js +2 -0
  19. package/dist/cjs/behavior/internal/BehaviorBacking.js.map +1 -1
  20. package/dist/cjs/behavior/internal/ClusterDerivation.d.ts +45 -0
  21. package/dist/cjs/behavior/internal/ClusterDerivation.d.ts.map +1 -0
  22. package/dist/cjs/behavior/internal/ClusterDerivation.js +192 -0
  23. package/dist/cjs/behavior/internal/ClusterDerivation.js.map +6 -0
  24. package/dist/cjs/behavior/internal/ClusterStatics.d.ts +16 -0
  25. package/dist/cjs/behavior/internal/ClusterStatics.d.ts.map +1 -0
  26. package/dist/cjs/behavior/internal/ClusterStatics.js +138 -0
  27. package/dist/cjs/behavior/internal/ClusterStatics.js.map +6 -0
  28. package/dist/cjs/behavior/internal/ModeledState.d.ts +18 -0
  29. package/dist/cjs/behavior/internal/ModeledState.d.ts.map +1 -0
  30. package/dist/cjs/behavior/internal/ModeledState.js +54 -0
  31. package/dist/cjs/behavior/internal/ModeledState.js.map +6 -0
  32. package/dist/cjs/behavior/internal/ServerBehaviorBacking.d.ts +1 -1
  33. package/dist/cjs/behavior/internal/ServerBehaviorBacking.d.ts.map +1 -1
  34. package/dist/cjs/behavior/internal/ServerBehaviorBacking.js +3 -12
  35. package/dist/cjs/behavior/internal/ServerBehaviorBacking.js.map +1 -1
  36. package/dist/cjs/behavior/state/managed/Datasource.d.ts +54 -10
  37. package/dist/cjs/behavior/state/managed/Datasource.d.ts.map +1 -1
  38. package/dist/cjs/behavior/state/managed/Datasource.js +107 -38
  39. package/dist/cjs/behavior/state/managed/Datasource.js.map +1 -1
  40. package/dist/cjs/behavior/state/managed/Internal.d.ts +20 -5
  41. package/dist/cjs/behavior/state/managed/Internal.d.ts.map +1 -1
  42. package/dist/cjs/behavior/state/managed/Internal.js +28 -26
  43. package/dist/cjs/behavior/state/managed/Internal.js.map +1 -1
  44. package/dist/cjs/behavior/state/managed/ManagedReference.d.ts +56 -12
  45. package/dist/cjs/behavior/state/managed/ManagedReference.d.ts.map +1 -1
  46. package/dist/cjs/behavior/state/managed/ManagedReference.js +103 -43
  47. package/dist/cjs/behavior/state/managed/ManagedReference.js.map +1 -1
  48. package/dist/cjs/behavior/state/managed/NameResolver.js +1 -1
  49. package/dist/cjs/behavior/state/managed/NameResolver.js.map +1 -1
  50. package/dist/cjs/behavior/state/managed/ReadOnlyReference.d.ts +33 -0
  51. package/dist/cjs/behavior/state/managed/ReadOnlyReference.d.ts.map +1 -0
  52. package/dist/cjs/behavior/state/{validation/peer-forwarding.js → managed/ReadOnlyReference.js} +36 -17
  53. package/dist/cjs/behavior/state/managed/ReadOnlyReference.js.map +6 -0
  54. package/dist/cjs/behavior/state/managed/ValReference.d.ts +80 -13
  55. package/dist/cjs/behavior/state/managed/ValReference.d.ts.map +1 -1
  56. package/dist/cjs/behavior/state/managed/ValReference.js +32 -0
  57. package/dist/cjs/behavior/state/managed/ValReference.js.map +2 -2
  58. package/dist/cjs/behavior/state/managed/errors.d.ts +25 -0
  59. package/dist/cjs/behavior/state/managed/errors.d.ts.map +1 -0
  60. package/dist/cjs/behavior/state/{validation/FabricIndexSentinel.js → managed/errors.js} +15 -10
  61. package/dist/cjs/behavior/state/managed/errors.js.map +6 -0
  62. package/dist/cjs/behavior/state/managed/index.d.ts +1 -0
  63. package/dist/cjs/behavior/state/managed/index.d.ts.map +1 -1
  64. package/dist/cjs/behavior/state/managed/index.js +1 -0
  65. package/dist/cjs/behavior/state/managed/index.js.map +1 -1
  66. package/dist/cjs/behavior/state/managed/values/BitmapManager.js +5 -20
  67. package/dist/cjs/behavior/state/managed/values/BitmapManager.js.map +1 -1
  68. package/dist/cjs/behavior/state/managed/values/ListManager.d.ts +0 -5
  69. package/dist/cjs/behavior/state/managed/values/ListManager.d.ts.map +1 -1
  70. package/dist/cjs/behavior/state/managed/values/ListManager.js +274 -133
  71. package/dist/cjs/behavior/state/managed/values/ListManager.js.map +2 -2
  72. package/dist/cjs/behavior/state/managed/values/StructManager.d.ts.map +1 -1
  73. package/dist/cjs/behavior/state/managed/values/StructManager.js +30 -35
  74. package/dist/cjs/behavior/state/managed/values/StructManager.js.map +2 -2
  75. package/dist/cjs/behavior/state/managed/values/ValuePatcher.d.ts +8 -0
  76. package/dist/cjs/behavior/state/managed/values/ValuePatcher.d.ts.map +1 -1
  77. package/dist/cjs/behavior/state/managed/values/ValuePatcher.js +13 -2
  78. package/dist/cjs/behavior/state/managed/values/ValuePatcher.js.map +1 -1
  79. package/dist/cjs/behavior/state/validation/FabricIndexField.d.ts +30 -0
  80. package/dist/cjs/behavior/state/validation/FabricIndexField.d.ts.map +1 -0
  81. package/dist/cjs/behavior/state/validation/FabricIndexField.js +53 -0
  82. package/dist/cjs/behavior/state/validation/FabricIndexField.js.map +6 -0
  83. package/dist/cjs/behavior/state/validation/ValueValidator.d.ts.map +1 -1
  84. package/dist/cjs/behavior/state/validation/ValueValidator.js +16 -36
  85. package/dist/cjs/behavior/state/validation/ValueValidator.js.map +1 -1
  86. package/dist/cjs/behavior/state/validation/conformance.d.ts.map +1 -1
  87. package/dist/cjs/behavior/state/validation/conformance.js +6 -5
  88. package/dist/cjs/behavior/state/validation/conformance.js.map +1 -1
  89. package/dist/cjs/behavior/state/validation/constraint.d.ts.map +1 -1
  90. package/dist/cjs/behavior/state/validation/constraint.js +3 -1
  91. package/dist/cjs/behavior/state/validation/constraint.js.map +1 -1
  92. package/dist/cjs/behavior/state/validation/location.d.ts +6 -0
  93. package/dist/cjs/behavior/state/validation/location.d.ts.map +1 -1
  94. package/dist/cjs/behavior/state/validation/remote-validation.d.ts +57 -0
  95. package/dist/cjs/behavior/state/validation/remote-validation.d.ts.map +1 -0
  96. package/dist/cjs/behavior/state/validation/remote-validation.js +63 -0
  97. package/dist/cjs/behavior/state/validation/remote-validation.js.map +6 -0
  98. package/dist/cjs/behavior/supervision/Supervision.d.ts.map +1 -1
  99. package/dist/cjs/behavior/supervision/Supervision.js +1 -1
  100. package/dist/cjs/behavior/supervision/Supervision.js.map +1 -1
  101. package/dist/cjs/behavior/supervision/SupervisionConfig.d.ts.map +1 -1
  102. package/dist/cjs/behavior/supervision/SupervisionConfig.js +1 -1
  103. package/dist/cjs/behavior/supervision/SupervisionConfig.js.map +1 -1
  104. package/dist/cjs/behavior/supervision/ValueSupervisor.d.ts +3 -12
  105. package/dist/cjs/behavior/supervision/ValueSupervisor.d.ts.map +1 -1
  106. package/dist/cjs/behavior/system/commissioning/CommissioningClient.d.ts +57 -6
  107. package/dist/cjs/behavior/system/commissioning/CommissioningClient.d.ts.map +1 -1
  108. package/dist/cjs/behavior/system/commissioning/CommissioningClient.js +86 -0
  109. package/dist/cjs/behavior/system/commissioning/CommissioningClient.js.map +1 -1
  110. package/dist/cjs/behavior/system/commissioning/RemoteDescriptor.d.ts +9 -1
  111. package/dist/cjs/behavior/system/commissioning/RemoteDescriptor.d.ts.map +1 -1
  112. package/dist/cjs/behavior/system/commissioning/RemoteDescriptor.js +9 -0
  113. package/dist/cjs/behavior/system/commissioning/RemoteDescriptor.js.map +1 -1
  114. package/dist/cjs/behavior/system/controller/ControllerBehavior.d.ts +2 -1
  115. package/dist/cjs/behavior/system/controller/ControllerBehavior.d.ts.map +1 -1
  116. package/dist/cjs/behavior/system/controller/ControllerBehavior.js +2 -1
  117. package/dist/cjs/behavior/system/controller/ControllerBehavior.js.map +1 -1
  118. package/dist/cjs/behavior/system/dcl/DclBehavior.d.ts +3 -3
  119. package/dist/cjs/behavior/system/network/ServerGroupNetworking.d.ts +2 -1
  120. package/dist/cjs/behavior/system/network/ServerGroupNetworking.d.ts.map +1 -1
  121. package/dist/cjs/behavior/system/network/ServerGroupNetworking.js.map +1 -1
  122. package/dist/cjs/behavior/system/remote/api/ApiResource.d.ts +14 -0
  123. package/dist/cjs/behavior/system/remote/api/ApiResource.d.ts.map +1 -1
  124. package/dist/cjs/behavior/system/remote/api/ApiResource.js +19 -0
  125. package/dist/cjs/behavior/system/remote/api/ApiResource.js.map +1 -1
  126. package/dist/cjs/behavior/system/remote/api/Envelope.d.ts +4 -2
  127. package/dist/cjs/behavior/system/remote/api/Envelope.d.ts.map +1 -1
  128. package/dist/cjs/behavior/system/remote/api/Envelope.js +7 -5
  129. package/dist/cjs/behavior/system/remote/api/Envelope.js.map +1 -1
  130. package/dist/cjs/behavior/system/remote/api/resources/CommandResource.js +2 -2
  131. package/dist/cjs/behavior/system/remote/api/resources/CommandResource.js.map +1 -1
  132. package/dist/cjs/behavior/system/remote/api/resources/NodeResource.d.ts +1 -0
  133. package/dist/cjs/behavior/system/remote/api/resources/NodeResource.d.ts.map +1 -1
  134. package/dist/cjs/behavior/system/remote/api/resources/NodeResource.js +3 -0
  135. package/dist/cjs/behavior/system/remote/api/resources/NodeResource.js.map +1 -1
  136. package/dist/cjs/behavior/system/remote/api/resources/PropertyResource.d.ts.map +1 -1
  137. package/dist/cjs/behavior/system/remote/api/resources/PropertyResource.js +5 -3
  138. package/dist/cjs/behavior/system/remote/api/resources/PropertyResource.js.map +1 -1
  139. package/dist/cjs/behavior/system/remote/api/resources/ServerNodeResource.d.ts.map +1 -1
  140. package/dist/cjs/behavior/system/remote/api/resources/ServerNodeResource.js +2 -11
  141. package/dist/cjs/behavior/system/remote/api/resources/ServerNodeResource.js.map +1 -1
  142. package/dist/cjs/behavior/system/sessions/SessionsBehavior.d.ts +4 -0
  143. package/dist/cjs/behavior/system/sessions/SessionsBehavior.d.ts.map +1 -1
  144. package/dist/cjs/behavior/system/sessions/SessionsBehavior.js +6 -1
  145. package/dist/cjs/behavior/system/sessions/SessionsBehavior.js.map +1 -1
  146. package/dist/cjs/behavior/system/subscriptions/SubscriptionStore.d.ts +28 -0
  147. package/dist/cjs/behavior/system/subscriptions/SubscriptionStore.d.ts.map +1 -0
  148. package/dist/cjs/behavior/system/subscriptions/SubscriptionStore.js +74 -0
  149. package/dist/cjs/behavior/system/subscriptions/SubscriptionStore.js.map +6 -0
  150. package/dist/cjs/behavior/system/subscriptions/SubscriptionsServer.d.ts +8 -3
  151. package/dist/cjs/behavior/system/subscriptions/SubscriptionsServer.d.ts.map +1 -1
  152. package/dist/cjs/behavior/system/subscriptions/SubscriptionsServer.js +61 -30
  153. package/dist/cjs/behavior/system/subscriptions/SubscriptionsServer.js.map +1 -1
  154. package/dist/cjs/behaviors/access-control/AccessControlServer.d.ts +2 -2
  155. package/dist/cjs/behaviors/access-control/AccessControlServer.d.ts.map +1 -1
  156. package/dist/cjs/behaviors/administrator-commissioning/AdministratorCommissioningServer.d.ts.map +1 -1
  157. package/dist/cjs/behaviors/administrator-commissioning/AdministratorCommissioningServer.js +43 -21
  158. package/dist/cjs/behaviors/administrator-commissioning/AdministratorCommissioningServer.js.map +1 -1
  159. package/dist/cjs/behaviors/general-diagnostics/GeneralDiagnosticsServer.d.ts +29 -23
  160. package/dist/cjs/behaviors/general-diagnostics/GeneralDiagnosticsServer.d.ts.map +1 -1
  161. package/dist/cjs/behaviors/general-diagnostics/GeneralDiagnosticsServer.js +104 -60
  162. package/dist/cjs/behaviors/general-diagnostics/GeneralDiagnosticsServer.js.map +1 -1
  163. package/dist/cjs/behaviors/group-key-management/GroupKeyManagementServer.d.ts +9 -1
  164. package/dist/cjs/behaviors/group-key-management/GroupKeyManagementServer.d.ts.map +1 -1
  165. package/dist/cjs/behaviors/group-key-management/GroupKeyManagementServer.js +11 -7
  166. package/dist/cjs/behaviors/group-key-management/GroupKeyManagementServer.js.map +1 -1
  167. package/dist/cjs/behaviors/groupcast/GroupcastServer.d.ts.map +1 -1
  168. package/dist/cjs/behaviors/groupcast/GroupcastServer.js +41 -25
  169. package/dist/cjs/behaviors/groupcast/GroupcastServer.js.map +2 -2
  170. package/dist/cjs/behaviors/localization-configuration/LocalizationConfigurationServer.d.ts +1 -1
  171. package/dist/cjs/behaviors/localization-configuration/LocalizationConfigurationServer.d.ts.map +1 -1
  172. package/dist/cjs/behaviors/localization-configuration/LocalizationConfigurationServer.js +15 -4
  173. package/dist/cjs/behaviors/localization-configuration/LocalizationConfigurationServer.js.map +2 -2
  174. package/dist/cjs/behaviors/operational-credentials/VendorIdVerification.d.ts +2 -0
  175. package/dist/cjs/behaviors/operational-credentials/VendorIdVerification.d.ts.map +1 -1
  176. package/dist/cjs/behaviors/operational-credentials/VendorIdVerification.js +27 -23
  177. package/dist/cjs/behaviors/operational-credentials/VendorIdVerification.js.map +1 -1
  178. package/dist/cjs/behaviors/thermostat/ThermostatServer.d.ts +15 -4
  179. package/dist/cjs/behaviors/thermostat/ThermostatServer.d.ts.map +1 -1
  180. package/dist/cjs/behaviors/thermostat/ThermostatServer.js +66 -49
  181. package/dist/cjs/behaviors/thermostat/ThermostatServer.js.map +1 -1
  182. package/dist/cjs/behaviors/time-format-localization/TimeFormatLocalizationServer.d.ts +4 -4
  183. package/dist/cjs/behaviors/time-format-localization/TimeFormatLocalizationServer.d.ts.map +1 -1
  184. package/dist/cjs/behaviors/time-format-localization/TimeFormatLocalizationServer.js +19 -5
  185. package/dist/cjs/behaviors/time-format-localization/TimeFormatLocalizationServer.js.map +2 -2
  186. package/dist/cjs/behaviors/unit-localization/UnitLocalizationServer.d.ts.map +1 -1
  187. package/dist/cjs/behaviors/unit-localization/UnitLocalizationServer.js +13 -3
  188. package/dist/cjs/behaviors/unit-localization/UnitLocalizationServer.js.map +1 -1
  189. package/dist/cjs/endpoint/Endpoint.d.ts +5 -9
  190. package/dist/cjs/endpoint/Endpoint.d.ts.map +1 -1
  191. package/dist/cjs/endpoint/Endpoint.js +4 -23
  192. package/dist/cjs/endpoint/Endpoint.js.map +1 -1
  193. package/dist/cjs/endpoint/properties/Behaviors.d.ts.map +1 -1
  194. package/dist/cjs/endpoint/properties/Behaviors.js +5 -1
  195. package/dist/cjs/endpoint/properties/Behaviors.js.map +1 -1
  196. package/dist/cjs/node/ClientNode.d.ts +25 -0
  197. package/dist/cjs/node/ClientNode.d.ts.map +1 -1
  198. package/dist/cjs/node/ClientNode.js +41 -0
  199. package/dist/cjs/node/ClientNode.js.map +1 -1
  200. package/dist/cjs/node/ServerNode.d.ts.map +1 -1
  201. package/dist/cjs/node/ServerNode.js +2 -0
  202. package/dist/cjs/node/ServerNode.js.map +1 -1
  203. package/dist/cjs/node/client/ClientCommandMethod.d.ts.map +1 -1
  204. package/dist/cjs/node/client/ClientCommandMethod.js +3 -15
  205. package/dist/cjs/node/client/ClientCommandMethod.js.map +1 -1
  206. package/dist/cjs/node/client/ClientEventEmitter.d.ts.map +1 -1
  207. package/dist/cjs/node/client/ClientEventEmitter.js +6 -2
  208. package/dist/cjs/node/client/ClientEventEmitter.js.map +1 -1
  209. package/dist/cjs/node/client/ClientStructure.d.ts.map +1 -1
  210. package/dist/cjs/node/client/ClientStructure.js +181 -108
  211. package/dist/cjs/node/client/ClientStructure.js.map +2 -2
  212. package/dist/cjs/node/client/Peers.d.ts +18 -6
  213. package/dist/cjs/node/client/Peers.d.ts.map +1 -1
  214. package/dist/cjs/node/client/Peers.js +29 -13
  215. package/dist/cjs/node/client/Peers.js.map +1 -1
  216. package/dist/cjs/node/integration/ChangeNotificationService.d.ts +14 -3
  217. package/dist/cjs/node/integration/ChangeNotificationService.d.ts.map +1 -1
  218. package/dist/cjs/node/integration/ProtocolService.d.ts.map +1 -1
  219. package/dist/cjs/node/integration/ProtocolService.js +38 -56
  220. package/dist/cjs/node/integration/ProtocolService.js.map +1 -1
  221. package/dist/cjs/node/server/InteractionServer.d.ts.map +1 -1
  222. package/dist/cjs/node/server/InteractionServer.js +28 -24
  223. package/dist/cjs/node/server/InteractionServer.js.map +2 -2
  224. package/dist/cjs/node/server/ServerSubscription.d.ts +7 -2
  225. package/dist/cjs/node/server/ServerSubscription.d.ts.map +1 -1
  226. package/dist/cjs/node/server/ServerSubscription.js +83 -47
  227. package/dist/cjs/node/server/ServerSubscription.js.map +1 -1
  228. package/dist/cjs/storage/EndpointStore.d.ts +1 -1
  229. package/dist/cjs/storage/EndpointStore.js +1 -1
  230. package/dist/cjs/storage/client/ClientEndpointStore.d.ts +2 -2
  231. package/dist/cjs/storage/client/ClientEndpointStore.d.ts.map +1 -1
  232. package/dist/cjs/storage/client/ClientEndpointStore.js +1 -1
  233. package/dist/cjs/storage/client/DatasourceCache.d.ts +5 -3
  234. package/dist/cjs/storage/client/DatasourceCache.d.ts.map +1 -1
  235. package/dist/cjs/storage/client/DatasourceCache.js +68 -71
  236. package/dist/cjs/storage/client/DatasourceCache.js.map +1 -1
  237. package/dist/cjs/storage/client/FabricScopedListWrite.d.ts +73 -0
  238. package/dist/cjs/storage/client/FabricScopedListWrite.d.ts.map +1 -0
  239. package/dist/cjs/storage/client/FabricScopedListWrite.js +168 -0
  240. package/dist/cjs/storage/client/FabricScopedListWrite.js.map +6 -0
  241. package/dist/cjs/storage/client/RemoteWriteParticipant.d.ts +9 -6
  242. package/dist/cjs/storage/client/RemoteWriteParticipant.d.ts.map +1 -1
  243. package/dist/cjs/storage/client/RemoteWriteParticipant.js +11 -15
  244. package/dist/cjs/storage/client/RemoteWriteParticipant.js.map +1 -1
  245. package/dist/cjs/storage/client/RemoteWriter.d.ts +67 -7
  246. package/dist/cjs/storage/client/RemoteWriter.d.ts.map +1 -1
  247. package/dist/cjs/storage/client/RemoteWriter.js +61 -13
  248. package/dist/cjs/storage/client/RemoteWriter.js.map +1 -1
  249. package/dist/cjs/storage/server/DatasourceStore.d.ts +2 -2
  250. package/dist/cjs/storage/server/DatasourceStore.d.ts.map +1 -1
  251. package/dist/cjs/storage/server/DatasourceStore.js.map +1 -1
  252. package/dist/cjs/storage/server/ServerEndpointStore.d.ts +2 -2
  253. package/dist/cjs/storage/server/ServerEndpointStore.d.ts.map +1 -1
  254. package/dist/cjs/storage/server/ServerEndpointStore.js +1 -1
  255. package/dist/cjs/testing/mock-server-node.d.ts +2 -1
  256. package/dist/cjs/testing/mock-server-node.d.ts.map +1 -1
  257. package/dist/cjs/testing/mock-server-node.js +8 -5
  258. package/dist/cjs/testing/mock-server-node.js.map +2 -2
  259. package/dist/cjs/testing/node-helpers.d.ts +5 -0
  260. package/dist/cjs/testing/node-helpers.d.ts.map +1 -1
  261. package/dist/cjs/testing/node-helpers.js +4 -4
  262. package/dist/cjs/testing/node-helpers.js.map +1 -1
  263. package/dist/esm/behavior/Behavior.d.ts.map +1 -1
  264. package/dist/esm/behavior/Behavior.js +2 -0
  265. package/dist/esm/behavior/Behavior.js.map +1 -1
  266. package/dist/esm/behavior/Events.d.ts.map +1 -1
  267. package/dist/esm/behavior/Events.js +4 -2
  268. package/dist/esm/behavior/Events.js.map +1 -1
  269. package/dist/esm/behavior/cluster/ClusterBehavior.d.ts +17 -3
  270. package/dist/esm/behavior/cluster/ClusterBehavior.d.ts.map +1 -1
  271. package/dist/esm/behavior/cluster/ClusterBehavior.js +2 -20
  272. package/dist/esm/behavior/cluster/ClusterBehavior.js.map +1 -1
  273. package/dist/esm/behavior/cluster/ClusterBehaviorType.d.ts.map +1 -1
  274. package/dist/esm/behavior/cluster/ClusterBehaviorType.js +10 -159
  275. package/dist/esm/behavior/cluster/ClusterBehaviorType.js.map +1 -1
  276. package/dist/esm/behavior/context/server/LocalActorContext.d.ts +1 -1
  277. package/dist/esm/behavior/context/server/LocalActorContext.d.ts.map +1 -1
  278. package/dist/esm/behavior/internal/BehaviorBacking.d.ts +2 -2
  279. package/dist/esm/behavior/internal/BehaviorBacking.d.ts.map +1 -1
  280. package/dist/esm/behavior/internal/BehaviorBacking.js +2 -0
  281. package/dist/esm/behavior/internal/BehaviorBacking.js.map +1 -1
  282. package/dist/esm/behavior/internal/ClusterDerivation.d.ts +45 -0
  283. package/dist/esm/behavior/internal/ClusterDerivation.d.ts.map +1 -0
  284. package/dist/esm/behavior/internal/ClusterDerivation.js +172 -0
  285. package/dist/esm/behavior/internal/ClusterDerivation.js.map +6 -0
  286. package/dist/esm/behavior/internal/ClusterStatics.d.ts +16 -0
  287. package/dist/esm/behavior/internal/ClusterStatics.d.ts.map +1 -0
  288. package/dist/esm/behavior/internal/ClusterStatics.js +118 -0
  289. package/dist/esm/behavior/internal/ClusterStatics.js.map +6 -0
  290. package/dist/esm/behavior/internal/ModeledState.d.ts +18 -0
  291. package/dist/esm/behavior/internal/ModeledState.d.ts.map +1 -0
  292. package/dist/esm/behavior/internal/ModeledState.js +34 -0
  293. package/dist/esm/behavior/internal/ModeledState.js.map +6 -0
  294. package/dist/esm/behavior/internal/ServerBehaviorBacking.d.ts +1 -1
  295. package/dist/esm/behavior/internal/ServerBehaviorBacking.d.ts.map +1 -1
  296. package/dist/esm/behavior/internal/ServerBehaviorBacking.js +3 -12
  297. package/dist/esm/behavior/internal/ServerBehaviorBacking.js.map +1 -1
  298. package/dist/esm/behavior/state/managed/Datasource.d.ts +54 -10
  299. package/dist/esm/behavior/state/managed/Datasource.d.ts.map +1 -1
  300. package/dist/esm/behavior/state/managed/Datasource.js +107 -38
  301. package/dist/esm/behavior/state/managed/Datasource.js.map +1 -1
  302. package/dist/esm/behavior/state/managed/Internal.d.ts +20 -5
  303. package/dist/esm/behavior/state/managed/Internal.d.ts.map +1 -1
  304. package/dist/esm/behavior/state/managed/Internal.js +28 -26
  305. package/dist/esm/behavior/state/managed/Internal.js.map +1 -1
  306. package/dist/esm/behavior/state/managed/ManagedReference.d.ts +56 -12
  307. package/dist/esm/behavior/state/managed/ManagedReference.d.ts.map +1 -1
  308. package/dist/esm/behavior/state/managed/ManagedReference.js +103 -43
  309. package/dist/esm/behavior/state/managed/ManagedReference.js.map +1 -1
  310. package/dist/esm/behavior/state/managed/NameResolver.js +1 -1
  311. package/dist/esm/behavior/state/managed/NameResolver.js.map +1 -1
  312. package/dist/esm/behavior/state/managed/ReadOnlyReference.d.ts +33 -0
  313. package/dist/esm/behavior/state/managed/ReadOnlyReference.d.ts.map +1 -0
  314. package/dist/esm/behavior/state/managed/ReadOnlyReference.js +45 -0
  315. package/dist/esm/behavior/state/managed/ReadOnlyReference.js.map +6 -0
  316. package/dist/esm/behavior/state/managed/ValReference.d.ts +80 -13
  317. package/dist/esm/behavior/state/managed/ValReference.d.ts.map +1 -1
  318. package/dist/esm/behavior/state/managed/ValReference.js +28 -0
  319. package/dist/esm/behavior/state/managed/ValReference.js.map +2 -2
  320. package/dist/esm/behavior/state/managed/errors.d.ts +25 -0
  321. package/dist/esm/behavior/state/managed/errors.d.ts.map +1 -0
  322. package/dist/esm/behavior/state/managed/errors.js +20 -0
  323. package/dist/esm/behavior/state/managed/errors.js.map +6 -0
  324. package/dist/esm/behavior/state/managed/index.d.ts +1 -0
  325. package/dist/esm/behavior/state/managed/index.d.ts.map +1 -1
  326. package/dist/esm/behavior/state/managed/index.js +1 -0
  327. package/dist/esm/behavior/state/managed/index.js.map +1 -1
  328. package/dist/esm/behavior/state/managed/values/BitmapManager.js +6 -21
  329. package/dist/esm/behavior/state/managed/values/BitmapManager.js.map +1 -1
  330. package/dist/esm/behavior/state/managed/values/ListManager.d.ts +0 -5
  331. package/dist/esm/behavior/state/managed/values/ListManager.d.ts.map +1 -1
  332. package/dist/esm/behavior/state/managed/values/ListManager.js +277 -144
  333. package/dist/esm/behavior/state/managed/values/ListManager.js.map +2 -2
  334. package/dist/esm/behavior/state/managed/values/StructManager.d.ts.map +1 -1
  335. package/dist/esm/behavior/state/managed/values/StructManager.js +31 -36
  336. package/dist/esm/behavior/state/managed/values/StructManager.js.map +2 -2
  337. package/dist/esm/behavior/state/managed/values/ValuePatcher.d.ts +8 -0
  338. package/dist/esm/behavior/state/managed/values/ValuePatcher.d.ts.map +1 -1
  339. package/dist/esm/behavior/state/managed/values/ValuePatcher.js +13 -2
  340. package/dist/esm/behavior/state/managed/values/ValuePatcher.js.map +1 -1
  341. package/dist/esm/behavior/state/validation/FabricIndexField.d.ts +30 -0
  342. package/dist/esm/behavior/state/validation/FabricIndexField.d.ts.map +1 -0
  343. package/dist/esm/behavior/state/validation/FabricIndexField.js +33 -0
  344. package/dist/esm/behavior/state/validation/FabricIndexField.js.map +6 -0
  345. package/dist/esm/behavior/state/validation/ValueValidator.d.ts.map +1 -1
  346. package/dist/esm/behavior/state/validation/ValueValidator.js +17 -37
  347. package/dist/esm/behavior/state/validation/ValueValidator.js.map +1 -1
  348. package/dist/esm/behavior/state/validation/conformance.d.ts.map +1 -1
  349. package/dist/esm/behavior/state/validation/conformance.js +6 -5
  350. package/dist/esm/behavior/state/validation/conformance.js.map +1 -1
  351. package/dist/esm/behavior/state/validation/constraint.d.ts.map +1 -1
  352. package/dist/esm/behavior/state/validation/constraint.js +3 -1
  353. package/dist/esm/behavior/state/validation/constraint.js.map +1 -1
  354. package/dist/esm/behavior/state/validation/location.d.ts +6 -0
  355. package/dist/esm/behavior/state/validation/location.d.ts.map +1 -1
  356. package/dist/esm/behavior/state/validation/remote-validation.d.ts +57 -0
  357. package/dist/esm/behavior/state/validation/remote-validation.d.ts.map +1 -0
  358. package/dist/esm/behavior/state/validation/remote-validation.js +48 -0
  359. package/dist/esm/behavior/state/validation/remote-validation.js.map +6 -0
  360. package/dist/esm/behavior/supervision/Supervision.d.ts.map +1 -1
  361. package/dist/esm/behavior/supervision/Supervision.js +1 -1
  362. package/dist/esm/behavior/supervision/Supervision.js.map +1 -1
  363. package/dist/esm/behavior/supervision/SupervisionConfig.d.ts.map +1 -1
  364. package/dist/esm/behavior/supervision/SupervisionConfig.js +1 -1
  365. package/dist/esm/behavior/supervision/SupervisionConfig.js.map +1 -1
  366. package/dist/esm/behavior/supervision/ValueSupervisor.d.ts +3 -12
  367. package/dist/esm/behavior/supervision/ValueSupervisor.d.ts.map +1 -1
  368. package/dist/esm/behavior/system/commissioning/CommissioningClient.d.ts +57 -6
  369. package/dist/esm/behavior/system/commissioning/CommissioningClient.d.ts.map +1 -1
  370. package/dist/esm/behavior/system/commissioning/CommissioningClient.js +87 -0
  371. package/dist/esm/behavior/system/commissioning/CommissioningClient.js.map +1 -1
  372. package/dist/esm/behavior/system/commissioning/RemoteDescriptor.d.ts +9 -1
  373. package/dist/esm/behavior/system/commissioning/RemoteDescriptor.d.ts.map +1 -1
  374. package/dist/esm/behavior/system/commissioning/RemoteDescriptor.js +10 -1
  375. package/dist/esm/behavior/system/commissioning/RemoteDescriptor.js.map +1 -1
  376. package/dist/esm/behavior/system/controller/ControllerBehavior.d.ts +2 -1
  377. package/dist/esm/behavior/system/controller/ControllerBehavior.d.ts.map +1 -1
  378. package/dist/esm/behavior/system/controller/ControllerBehavior.js +2 -1
  379. package/dist/esm/behavior/system/controller/ControllerBehavior.js.map +1 -1
  380. package/dist/esm/behavior/system/dcl/DclBehavior.d.ts +3 -3
  381. package/dist/esm/behavior/system/network/ServerGroupNetworking.d.ts +2 -1
  382. package/dist/esm/behavior/system/network/ServerGroupNetworking.d.ts.map +1 -1
  383. package/dist/esm/behavior/system/network/ServerGroupNetworking.js.map +1 -1
  384. package/dist/esm/behavior/system/remote/api/ApiResource.d.ts +14 -0
  385. package/dist/esm/behavior/system/remote/api/ApiResource.d.ts.map +1 -1
  386. package/dist/esm/behavior/system/remote/api/ApiResource.js +19 -0
  387. package/dist/esm/behavior/system/remote/api/ApiResource.js.map +1 -1
  388. package/dist/esm/behavior/system/remote/api/Envelope.d.ts +4 -2
  389. package/dist/esm/behavior/system/remote/api/Envelope.d.ts.map +1 -1
  390. package/dist/esm/behavior/system/remote/api/Envelope.js +7 -5
  391. package/dist/esm/behavior/system/remote/api/Envelope.js.map +1 -1
  392. package/dist/esm/behavior/system/remote/api/resources/CommandResource.js +2 -2
  393. package/dist/esm/behavior/system/remote/api/resources/CommandResource.js.map +1 -1
  394. package/dist/esm/behavior/system/remote/api/resources/NodeResource.d.ts +1 -0
  395. package/dist/esm/behavior/system/remote/api/resources/NodeResource.d.ts.map +1 -1
  396. package/dist/esm/behavior/system/remote/api/resources/NodeResource.js +3 -0
  397. package/dist/esm/behavior/system/remote/api/resources/NodeResource.js.map +1 -1
  398. package/dist/esm/behavior/system/remote/api/resources/PropertyResource.d.ts.map +1 -1
  399. package/dist/esm/behavior/system/remote/api/resources/PropertyResource.js +5 -3
  400. package/dist/esm/behavior/system/remote/api/resources/PropertyResource.js.map +1 -1
  401. package/dist/esm/behavior/system/remote/api/resources/ServerNodeResource.d.ts.map +1 -1
  402. package/dist/esm/behavior/system/remote/api/resources/ServerNodeResource.js +2 -11
  403. package/dist/esm/behavior/system/remote/api/resources/ServerNodeResource.js.map +1 -1
  404. package/dist/esm/behavior/system/sessions/SessionsBehavior.d.ts +4 -0
  405. package/dist/esm/behavior/system/sessions/SessionsBehavior.d.ts.map +1 -1
  406. package/dist/esm/behavior/system/sessions/SessionsBehavior.js +6 -1
  407. package/dist/esm/behavior/system/sessions/SessionsBehavior.js.map +1 -1
  408. package/dist/esm/behavior/system/subscriptions/SubscriptionStore.d.ts +28 -0
  409. package/dist/esm/behavior/system/subscriptions/SubscriptionStore.d.ts.map +1 -0
  410. package/dist/esm/behavior/system/subscriptions/SubscriptionStore.js +54 -0
  411. package/dist/esm/behavior/system/subscriptions/SubscriptionStore.js.map +6 -0
  412. package/dist/esm/behavior/system/subscriptions/SubscriptionsServer.d.ts +8 -3
  413. package/dist/esm/behavior/system/subscriptions/SubscriptionsServer.d.ts.map +1 -1
  414. package/dist/esm/behavior/system/subscriptions/SubscriptionsServer.js +61 -30
  415. package/dist/esm/behavior/system/subscriptions/SubscriptionsServer.js.map +1 -1
  416. package/dist/esm/behaviors/access-control/AccessControlServer.d.ts +2 -2
  417. package/dist/esm/behaviors/access-control/AccessControlServer.d.ts.map +1 -1
  418. package/dist/esm/behaviors/administrator-commissioning/AdministratorCommissioningServer.d.ts.map +1 -1
  419. package/dist/esm/behaviors/administrator-commissioning/AdministratorCommissioningServer.js +43 -21
  420. package/dist/esm/behaviors/administrator-commissioning/AdministratorCommissioningServer.js.map +1 -1
  421. package/dist/esm/behaviors/general-diagnostics/GeneralDiagnosticsServer.d.ts +29 -23
  422. package/dist/esm/behaviors/general-diagnostics/GeneralDiagnosticsServer.d.ts.map +1 -1
  423. package/dist/esm/behaviors/general-diagnostics/GeneralDiagnosticsServer.js +105 -60
  424. package/dist/esm/behaviors/general-diagnostics/GeneralDiagnosticsServer.js.map +1 -1
  425. package/dist/esm/behaviors/group-key-management/GroupKeyManagementServer.d.ts +9 -1
  426. package/dist/esm/behaviors/group-key-management/GroupKeyManagementServer.d.ts.map +1 -1
  427. package/dist/esm/behaviors/group-key-management/GroupKeyManagementServer.js +11 -7
  428. package/dist/esm/behaviors/group-key-management/GroupKeyManagementServer.js.map +1 -1
  429. package/dist/esm/behaviors/groupcast/GroupcastServer.d.ts.map +1 -1
  430. package/dist/esm/behaviors/groupcast/GroupcastServer.js +42 -25
  431. package/dist/esm/behaviors/groupcast/GroupcastServer.js.map +2 -2
  432. package/dist/esm/behaviors/localization-configuration/LocalizationConfigurationServer.d.ts +1 -1
  433. package/dist/esm/behaviors/localization-configuration/LocalizationConfigurationServer.d.ts.map +1 -1
  434. package/dist/esm/behaviors/localization-configuration/LocalizationConfigurationServer.js +15 -4
  435. package/dist/esm/behaviors/localization-configuration/LocalizationConfigurationServer.js.map +2 -2
  436. package/dist/esm/behaviors/operational-credentials/VendorIdVerification.d.ts +2 -0
  437. package/dist/esm/behaviors/operational-credentials/VendorIdVerification.d.ts.map +1 -1
  438. package/dist/esm/behaviors/operational-credentials/VendorIdVerification.js +32 -24
  439. package/dist/esm/behaviors/operational-credentials/VendorIdVerification.js.map +1 -1
  440. package/dist/esm/behaviors/thermostat/ThermostatServer.d.ts +15 -4
  441. package/dist/esm/behaviors/thermostat/ThermostatServer.d.ts.map +1 -1
  442. package/dist/esm/behaviors/thermostat/ThermostatServer.js +66 -49
  443. package/dist/esm/behaviors/thermostat/ThermostatServer.js.map +1 -1
  444. package/dist/esm/behaviors/time-format-localization/TimeFormatLocalizationServer.d.ts +4 -4
  445. package/dist/esm/behaviors/time-format-localization/TimeFormatLocalizationServer.d.ts.map +1 -1
  446. package/dist/esm/behaviors/time-format-localization/TimeFormatLocalizationServer.js +19 -5
  447. package/dist/esm/behaviors/time-format-localization/TimeFormatLocalizationServer.js.map +2 -2
  448. package/dist/esm/behaviors/unit-localization/UnitLocalizationServer.d.ts.map +1 -1
  449. package/dist/esm/behaviors/unit-localization/UnitLocalizationServer.js +13 -3
  450. package/dist/esm/behaviors/unit-localization/UnitLocalizationServer.js.map +1 -1
  451. package/dist/esm/endpoint/Endpoint.d.ts +5 -9
  452. package/dist/esm/endpoint/Endpoint.d.ts.map +1 -1
  453. package/dist/esm/endpoint/Endpoint.js +5 -24
  454. package/dist/esm/endpoint/Endpoint.js.map +1 -1
  455. package/dist/esm/endpoint/properties/Behaviors.d.ts.map +1 -1
  456. package/dist/esm/endpoint/properties/Behaviors.js +6 -2
  457. package/dist/esm/endpoint/properties/Behaviors.js.map +1 -1
  458. package/dist/esm/node/ClientNode.d.ts +25 -0
  459. package/dist/esm/node/ClientNode.d.ts.map +1 -1
  460. package/dist/esm/node/ClientNode.js +41 -0
  461. package/dist/esm/node/ClientNode.js.map +1 -1
  462. package/dist/esm/node/ServerNode.d.ts.map +1 -1
  463. package/dist/esm/node/ServerNode.js +2 -0
  464. package/dist/esm/node/ServerNode.js.map +1 -1
  465. package/dist/esm/node/client/ClientCommandMethod.d.ts.map +1 -1
  466. package/dist/esm/node/client/ClientCommandMethod.js +4 -16
  467. package/dist/esm/node/client/ClientCommandMethod.js.map +1 -1
  468. package/dist/esm/node/client/ClientEventEmitter.d.ts.map +1 -1
  469. package/dist/esm/node/client/ClientEventEmitter.js +6 -2
  470. package/dist/esm/node/client/ClientEventEmitter.js.map +1 -1
  471. package/dist/esm/node/client/ClientStructure.d.ts.map +1 -1
  472. package/dist/esm/node/client/ClientStructure.js +181 -108
  473. package/dist/esm/node/client/ClientStructure.js.map +2 -2
  474. package/dist/esm/node/client/Peers.d.ts +18 -6
  475. package/dist/esm/node/client/Peers.d.ts.map +1 -1
  476. package/dist/esm/node/client/Peers.js +29 -14
  477. package/dist/esm/node/client/Peers.js.map +1 -1
  478. package/dist/esm/node/integration/ChangeNotificationService.d.ts +14 -3
  479. package/dist/esm/node/integration/ChangeNotificationService.d.ts.map +1 -1
  480. package/dist/esm/node/integration/ProtocolService.d.ts.map +1 -1
  481. package/dist/esm/node/integration/ProtocolService.js +40 -57
  482. package/dist/esm/node/integration/ProtocolService.js.map +1 -1
  483. package/dist/esm/node/server/InteractionServer.d.ts.map +1 -1
  484. package/dist/esm/node/server/InteractionServer.js +28 -25
  485. package/dist/esm/node/server/InteractionServer.js.map +2 -2
  486. package/dist/esm/node/server/ServerSubscription.d.ts +7 -2
  487. package/dist/esm/node/server/ServerSubscription.d.ts.map +1 -1
  488. package/dist/esm/node/server/ServerSubscription.js +83 -47
  489. package/dist/esm/node/server/ServerSubscription.js.map +1 -1
  490. package/dist/esm/storage/EndpointStore.d.ts +1 -1
  491. package/dist/esm/storage/EndpointStore.js +1 -1
  492. package/dist/esm/storage/client/ClientEndpointStore.d.ts +2 -2
  493. package/dist/esm/storage/client/ClientEndpointStore.d.ts.map +1 -1
  494. package/dist/esm/storage/client/ClientEndpointStore.js +1 -1
  495. package/dist/esm/storage/client/DatasourceCache.d.ts +5 -3
  496. package/dist/esm/storage/client/DatasourceCache.d.ts.map +1 -1
  497. package/dist/esm/storage/client/DatasourceCache.js +68 -71
  498. package/dist/esm/storage/client/DatasourceCache.js.map +1 -1
  499. package/dist/esm/storage/client/FabricScopedListWrite.d.ts +73 -0
  500. package/dist/esm/storage/client/FabricScopedListWrite.d.ts.map +1 -0
  501. package/dist/esm/storage/client/FabricScopedListWrite.js +148 -0
  502. package/dist/esm/storage/client/FabricScopedListWrite.js.map +6 -0
  503. package/dist/esm/storage/client/RemoteWriteParticipant.d.ts +9 -6
  504. package/dist/esm/storage/client/RemoteWriteParticipant.d.ts.map +1 -1
  505. package/dist/esm/storage/client/RemoteWriteParticipant.js +11 -15
  506. package/dist/esm/storage/client/RemoteWriteParticipant.js.map +1 -1
  507. package/dist/esm/storage/client/RemoteWriter.d.ts +67 -7
  508. package/dist/esm/storage/client/RemoteWriter.d.ts.map +1 -1
  509. package/dist/esm/storage/client/RemoteWriter.js +65 -14
  510. package/dist/esm/storage/client/RemoteWriter.js.map +1 -1
  511. package/dist/esm/storage/server/DatasourceStore.d.ts +2 -2
  512. package/dist/esm/storage/server/DatasourceStore.d.ts.map +1 -1
  513. package/dist/esm/storage/server/DatasourceStore.js.map +1 -1
  514. package/dist/esm/storage/server/ServerEndpointStore.d.ts +2 -2
  515. package/dist/esm/storage/server/ServerEndpointStore.d.ts.map +1 -1
  516. package/dist/esm/storage/server/ServerEndpointStore.js +1 -1
  517. package/dist/esm/testing/mock-server-node.d.ts +2 -1
  518. package/dist/esm/testing/mock-server-node.d.ts.map +1 -1
  519. package/dist/esm/testing/mock-server-node.js +16 -7
  520. package/dist/esm/testing/mock-server-node.js.map +2 -2
  521. package/dist/esm/testing/node-helpers.d.ts +5 -0
  522. package/dist/esm/testing/node-helpers.d.ts.map +1 -1
  523. package/dist/esm/testing/node-helpers.js +4 -4
  524. package/dist/esm/testing/node-helpers.js.map +1 -1
  525. package/package.json +6 -6
  526. package/src/behavior/Behavior.ts +2 -0
  527. package/src/behavior/Events.ts +6 -3
  528. package/src/behavior/cluster/ClusterBehavior.ts +22 -13
  529. package/src/behavior/cluster/ClusterBehaviorType.ts +9 -270
  530. package/src/behavior/context/server/LocalActorContext.ts +1 -4
  531. package/src/behavior/internal/BehaviorBacking.ts +10 -2
  532. package/src/behavior/internal/ClusterDerivation.ts +295 -0
  533. package/src/behavior/internal/ClusterStatics.ts +180 -0
  534. package/src/behavior/internal/ModeledState.ts +58 -0
  535. package/src/behavior/internal/ServerBehaviorBacking.ts +9 -16
  536. package/src/behavior/state/managed/Datasource.ts +181 -58
  537. package/src/behavior/state/managed/Internal.ts +44 -34
  538. package/src/behavior/state/managed/ManagedReference.ts +159 -70
  539. package/src/behavior/state/managed/NameResolver.ts +1 -1
  540. package/src/behavior/state/managed/ReadOnlyReference.ts +61 -0
  541. package/src/behavior/state/managed/ValReference.ts +104 -14
  542. package/src/behavior/state/managed/errors.ts +33 -0
  543. package/src/behavior/state/managed/index.ts +1 -0
  544. package/src/behavior/state/managed/values/BitmapManager.ts +6 -22
  545. package/src/behavior/state/managed/values/ListManager.ts +313 -164
  546. package/src/behavior/state/managed/values/StructManager.ts +48 -52
  547. package/src/behavior/state/managed/values/ValuePatcher.ts +25 -3
  548. package/src/behavior/state/validation/FabricIndexField.ts +51 -0
  549. package/src/behavior/state/validation/ValueValidator.ts +24 -54
  550. package/src/behavior/state/validation/conformance.ts +9 -7
  551. package/src/behavior/state/validation/constraint.ts +5 -1
  552. package/src/behavior/state/validation/location.ts +8 -0
  553. package/src/behavior/state/validation/remote-validation.ts +107 -0
  554. package/src/behavior/supervision/Supervision.ts +1 -2
  555. package/src/behavior/supervision/SupervisionConfig.ts +1 -2
  556. package/src/behavior/supervision/ValueSupervisor.ts +3 -13
  557. package/src/behavior/system/commissioning/CommissioningClient.ts +122 -6
  558. package/src/behavior/system/commissioning/RemoteDescriptor.ts +17 -1
  559. package/src/behavior/system/controller/ControllerBehavior.ts +2 -1
  560. package/src/behavior/system/dcl/DclBehavior.ts +3 -3
  561. package/src/behavior/system/network/ServerGroupNetworking.ts +3 -2
  562. package/src/behavior/system/remote/api/ApiResource.ts +23 -0
  563. package/src/behavior/system/remote/api/Envelope.ts +8 -6
  564. package/src/behavior/system/remote/api/resources/CommandResource.ts +2 -2
  565. package/src/behavior/system/remote/api/resources/NodeResource.ts +4 -0
  566. package/src/behavior/system/remote/api/resources/PropertyResource.ts +5 -3
  567. package/src/behavior/system/remote/api/resources/ServerNodeResource.ts +2 -13
  568. package/src/behavior/system/sessions/SessionsBehavior.ts +8 -2
  569. package/src/behavior/system/subscriptions/SubscriptionStore.ts +66 -0
  570. package/src/behavior/system/subscriptions/SubscriptionsServer.ts +73 -33
  571. package/src/behaviors/access-control/AccessControlServer.ts +3 -3
  572. package/src/behaviors/administrator-commissioning/AdministratorCommissioningServer.ts +47 -24
  573. package/src/behaviors/general-diagnostics/GeneralDiagnosticsServer.ts +138 -84
  574. package/src/behaviors/group-key-management/GroupKeyManagementServer.ts +12 -8
  575. package/src/behaviors/groupcast/GroupcastServer.ts +50 -34
  576. package/src/behaviors/localization-configuration/LocalizationConfigurationServer.ts +18 -6
  577. package/src/behaviors/operational-credentials/VendorIdVerification.ts +50 -35
  578. package/src/behaviors/thermostat/ThermostatServer.ts +93 -70
  579. package/src/behaviors/time-format-localization/TimeFormatLocalizationServer.ts +24 -9
  580. package/src/behaviors/unit-localization/UnitLocalizationServer.ts +17 -4
  581. package/src/endpoint/Endpoint.ts +5 -31
  582. package/src/endpoint/properties/Behaviors.ts +6 -2
  583. package/src/node/ClientNode.ts +41 -0
  584. package/src/node/ServerNode.ts +2 -0
  585. package/src/node/client/ClientCommandMethod.ts +4 -19
  586. package/src/node/client/ClientEventEmitter.ts +7 -3
  587. package/src/node/client/ClientStructure.ts +208 -135
  588. package/src/node/client/Peers.ts +36 -20
  589. package/src/node/integration/ChangeNotificationService.ts +18 -3
  590. package/src/node/integration/ProtocolService.ts +45 -57
  591. package/src/node/server/InteractionServer.ts +33 -35
  592. package/src/node/server/ServerSubscription.ts +88 -50
  593. package/src/storage/EndpointStore.ts +1 -1
  594. package/src/storage/client/ClientEndpointStore.ts +1 -1
  595. package/src/storage/client/DatasourceCache.ts +86 -79
  596. package/src/storage/client/FabricScopedListWrite.ts +245 -0
  597. package/src/storage/client/RemoteWriteParticipant.ts +20 -23
  598. package/src/storage/client/RemoteWriter.ts +156 -26
  599. package/src/storage/server/DatasourceStore.ts +2 -2
  600. package/src/storage/server/ServerEndpointStore.ts +1 -1
  601. package/src/testing/mock-server-node.ts +22 -9
  602. package/src/testing/node-helpers.ts +5 -1
  603. package/dist/cjs/behavior/state/validation/FabricIndexSentinel.d.ts +0 -14
  604. package/dist/cjs/behavior/state/validation/FabricIndexSentinel.d.ts.map +0 -1
  605. package/dist/cjs/behavior/state/validation/FabricIndexSentinel.js.map +0 -6
  606. package/dist/cjs/behavior/state/validation/peer-forwarding.d.ts +0 -20
  607. package/dist/cjs/behavior/state/validation/peer-forwarding.d.ts.map +0 -1
  608. package/dist/cjs/behavior/state/validation/peer-forwarding.js.map +0 -6
  609. package/dist/esm/behavior/state/validation/FabricIndexSentinel.d.ts +0 -14
  610. package/dist/esm/behavior/state/validation/FabricIndexSentinel.d.ts.map +0 -1
  611. package/dist/esm/behavior/state/validation/FabricIndexSentinel.js +0 -15
  612. package/dist/esm/behavior/state/validation/FabricIndexSentinel.js.map +0 -6
  613. package/dist/esm/behavior/state/validation/peer-forwarding.d.ts +0 -20
  614. package/dist/esm/behavior/state/validation/peer-forwarding.d.ts.map +0 -1
  615. package/dist/esm/behavior/state/validation/peer-forwarding.js +0 -26
  616. package/dist/esm/behavior/state/validation/peer-forwarding.js.map +0 -6
  617. package/src/behavior/state/validation/FabricIndexSentinel.ts +0 -20
  618. package/src/behavior/state/validation/peer-forwarding.ts +0 -47
@@ -0,0 +1,245 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2022-2026 Matter.js Authors
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+
7
+ import { memberValueOf } from "#behavior/state/managed/MemberKeys.js";
8
+ import { fabricIndexOf, withFabricIndex } from "#behavior/state/validation/FabricIndexField.js";
9
+ import { Bytes, isDeepEqual, isObject, Logger } from "@matter/general";
10
+ import type { DataModelPath, ValueModel } from "@matter/model";
11
+ import { Val, WriteError } from "@matter/protocol";
12
+ import { FabricIndex, Status, TlvOfModel, ValidationError } from "@matter/types";
13
+
14
+ const logger = Logger.get("FabricScopedListWrite");
15
+
16
+ /**
17
+ * How a client node other than a group writes a fabric-scoped list to a peer.
18
+ *
19
+ * The device ignores the FabricIndex written (§ 7.19.1.9.1) and uses the accessing fabric (§ 7.13.6). It replaces
20
+ * only the entries of the accessing fabric (§ 7.19.1.8.2). A cached list read without fabric filtering also holds the
21
+ * entries of other fabrics, so a write sends only our entries:
22
+ *
23
+ * | Entry | Write |
24
+ * | ------------------------------------------------------------------------ | -------------------- |
25
+ * | written, FabricIndex ours, `FabricIndex.OMIT_FABRIC` or absent | sent, with our index |
26
+ * | written, other FabricIndex (`NO_FABRIC` too), equal to a cached entry | left out |
27
+ * | written, other FabricIndex (`NO_FABRIC` too), equal to no cached entry | whole write refused |
28
+ * | written, not a struct | whole write refused |
29
+ * | cached, of another fabric or of no fabric, missing from the written list | kept by the device |
30
+ * | any, while our fabric index on the peer is unknown | whole write refused |
31
+ *
32
+ * @see {@link MatterSpecification.v161.Core} § 7.13.6
33
+ * @see {@link MatterSpecification.v161.Core} § 7.19.1.8.2
34
+ * @see {@link MatterSpecification.v161.Core} § 7.19.1.9.1
35
+ */
36
+ export namespace FabricScopedListWrite {
37
+ /**
38
+ * Whether {@link entry} is ours: a struct whose FabricIndex is our fabric index on the peer,
39
+ * `FabricIndex.OMIT_FABRIC` or absent. An entry of `FabricIndex.NO_FABRIC` is scoped to no fabric, and a value
40
+ * that is not a struct has no fabric, so neither is ours. False does not mean that {@link entry} is not a struct.
41
+ *
42
+ * @see {@link MatterSpecification.v161.Core} § 7.19.1.8.1
43
+ */
44
+ export function isOurs(entry: Val, fabricIndexOnPeer: FabricIndex): entry is Val.Struct {
45
+ if (!isObject(entry)) {
46
+ return false;
47
+ }
48
+ const fabricIndex = fabricIndexOf(entry);
49
+ return (
50
+ fabricIndex === undefined || fabricIndex === FabricIndex.OMIT_FABRIC || fabricIndex === fabricIndexOnPeer
51
+ );
52
+ }
53
+
54
+ /**
55
+ * Our fabric index on the peer, which a write of the fabric-scoped list at {@link path} needs.
56
+ *
57
+ * @throws WriteError with CONSTRAINT_ERROR if {@link fabricIndexOnPeer} is unknown
58
+ */
59
+ export function requireFabricIndex(fabricIndexOnPeer: FabricIndex | undefined, path: DataModelPath) {
60
+ if (fabricIndexOnPeer === undefined) {
61
+ throw new WriteError(
62
+ path,
63
+ "Cannot write a fabric-scoped list while our fabric index on the peer " +
64
+ "(commissioning.fabricIndexOnPeer) is unknown; " +
65
+ "read operationalCredentials.currentFabricIndex first",
66
+ Status.ConstraintError,
67
+ );
68
+ }
69
+ return fabricIndexOnPeer;
70
+ }
71
+
72
+ /**
73
+ * The entries of {@link list} a write of the fabric-scoped list at {@link path} sends, in their order. Each holds
74
+ * our fabric index on the peer as its FabricIndex, under the key the entry already uses for it, else under the
75
+ * property name, so the cache can hold what the device stores. The encoder leaves FabricIndex out of a write.
76
+ *
77
+ * An entry that is not ours is left out if it equals an entry of {@link cached}; the device keeps it. Two entries
78
+ * are equal if each field of {@link entrySchema} is absent from both, holds deep-equal values in both, or has the
79
+ * same TLV encoding in both. So a number and a bigint of the same value are equal, and an unchanged copy of a
80
+ * cached entry is equal to it even when a cached value breaks a bound of the model. A property that is not a field
81
+ * of {@link entrySchema} is not compared, as the encoder never sends it. A field whose values differ and that does
82
+ * not encode makes the entries differ.
83
+ *
84
+ * @param cached the cached value of the list
85
+ * @param entrySchema the schema of an entry of the list
86
+ * @throws WriteError with CONSTRAINT_ERROR for the first entry that is not ours and not left out
87
+ */
88
+ export function entriesToSend(
89
+ list: Val.List,
90
+ cached: Val,
91
+ fabricIndexOnPeer: FabricIndex,
92
+ path: DataModelPath,
93
+ entrySchema: ValueModel,
94
+ ) {
95
+ const cachedEntries = Array.isArray(cached) ? cached : [];
96
+ const ours = new Array<Val>();
97
+ const others = new Array<Val>();
98
+ for (const entry of list) {
99
+ if (isOurs(entry, fabricIndexOnPeer)) {
100
+ ours.push(withFabricIndex(entry, fabricIndexOnPeer));
101
+ } else if (cachedEntries.some(cachedEntry => isSameEntry(entry, cachedEntry, entrySchema))) {
102
+ others.push(entry);
103
+ } else {
104
+ throw new WriteError(
105
+ path,
106
+ refusalMessage(entry, cachedEntries, fabricIndexOnPeer, entrySchema),
107
+ Status.ConstraintError,
108
+ );
109
+ }
110
+ }
111
+
112
+ if (others.length) {
113
+ logger.debug(
114
+ `Leaving ${countOf(others.length)} of other fabrics or of no fabric out of the write of`,
115
+ path,
116
+ );
117
+ }
118
+ const dropped = cachedEntries.filter(
119
+ cachedEntry =>
120
+ !isOurs(cachedEntry, fabricIndexOnPeer) &&
121
+ !others.some(entry => isSameEntry(entry, cachedEntry, entrySchema)),
122
+ ).length;
123
+ if (dropped) {
124
+ logger.debug(
125
+ `The write of ${path} omits ${countOf(dropped)} of other fabrics or of no fabric;`,
126
+ "the device keeps them",
127
+ );
128
+ }
129
+ return ours;
130
+ }
131
+
132
+ /**
133
+ * The cached value of a fabric-scoped list after the device accepted a write of our entries {@link written}.
134
+ *
135
+ * A write replaces only the entries of the accessing fabric, so every other entry of {@link cached} stays in its
136
+ * place. We choose to put {@link written} in the places of our cached entries, in order; entries beyond those
137
+ * places go to the end, and our cached entries that no written entry takes are removed. The device may order the
138
+ * list differently; its next report replaces the cached list.
139
+ *
140
+ * @see {@link MatterSpecification.v161.Core} § 7.19.1.8.2
141
+ */
142
+ export function cachedAfterWrite(cached: Val, written: Val.List, fabricIndexOnPeer: FabricIndex): Val.List {
143
+ if (!Array.isArray(cached)) {
144
+ return written;
145
+ }
146
+
147
+ const merged = new Array<Val>();
148
+ let next = 0;
149
+ for (const entry of cached) {
150
+ if (!isOurs(entry, fabricIndexOnPeer)) {
151
+ merged.push(entry);
152
+ } else if (next < written.length) {
153
+ merged.push(written[next++]);
154
+ }
155
+ }
156
+ merged.push(...written.slice(next));
157
+ return merged;
158
+ }
159
+ }
160
+
161
+ function countOf(entries: number) {
162
+ return entries === 1 ? "1 entry" : `${entries} entries`;
163
+ }
164
+
165
+ function isSameEntry(entry: Val, cachedEntry: Val, entrySchema: ValueModel) {
166
+ if (!isObject(entry) || !isObject(cachedEntry)) {
167
+ return false;
168
+ }
169
+ for (const field of entrySchema.members) {
170
+ const value = memberValueOf(entry, field.propertyName, field.id);
171
+ const cachedValue = memberValueOf(cachedEntry, field.propertyName, field.id);
172
+ if (value === undefined || cachedValue === undefined) {
173
+ if (value !== cachedValue) {
174
+ return false;
175
+ }
176
+ continue;
177
+ }
178
+ if (isDeepEqual(value, cachedValue)) {
179
+ continue;
180
+ }
181
+ const encoded = encodingOf(field, value);
182
+ const cachedEncoded = encodingOf(field, cachedValue);
183
+ if (encoded === undefined || cachedEncoded === undefined || !Bytes.areEqual(encoded, cachedEncoded)) {
184
+ return false;
185
+ }
186
+ }
187
+ return true;
188
+ }
189
+
190
+ /**
191
+ * The TLV encoding of {@link value} as {@link field}, or undefined if the value is not valid for the field.
192
+ */
193
+ function encodingOf(field: ValueModel, value: Val) {
194
+ try {
195
+ return TlvOfModel(field).encode(value);
196
+ } catch (e) {
197
+ if (e instanceof ValidationError) {
198
+ return undefined;
199
+ }
200
+ throw e;
201
+ }
202
+ }
203
+
204
+ /**
205
+ * The first field of {@link entry} that does not encode, if any.
206
+ */
207
+ function unencodableFieldOf(entry: Val.Struct, entrySchema: ValueModel) {
208
+ return entrySchema.members.find(field => {
209
+ const value = memberValueOf(entry, field.propertyName, field.id);
210
+ return value !== undefined && encodingOf(field, value) === undefined;
211
+ });
212
+ }
213
+
214
+ function refusalMessage(
215
+ refused: Val,
216
+ cachedEntries: Val.List,
217
+ fabricIndexOnPeer: FabricIndex,
218
+ entrySchema: ValueModel,
219
+ ) {
220
+ if (!isObject(refused)) {
221
+ return `Cannot write an entry that is not a struct (our fabric index on the peer is ${fabricIndexOnPeer})`;
222
+ }
223
+ const written = fabricIndexOf(refused);
224
+ const what =
225
+ written === FabricIndex.NO_FABRIC
226
+ ? "an entry of no fabric (FabricIndex.NO_FABRIC)"
227
+ : `an entry with fabricIndex ${String(written)}`;
228
+ const message =
229
+ `Cannot write ${what}: our fabric index on the peer is ${fabricIndexOnPeer}, ` +
230
+ "so write that index or FabricIndex.OMIT_FABRIC";
231
+ if (!cachedEntries.some(entry => isObject(entry) && fabricIndexOf(entry) === written)) {
232
+ return message;
233
+ }
234
+ const unencodable = unencodableFieldOf(refused, entrySchema);
235
+ if (unencodable !== undefined) {
236
+ return (
237
+ `${message}; its field ${unencodable.propertyName} holds a value the field does not allow, ` +
238
+ "so it cannot be compared with the cached entries of that fabric"
239
+ );
240
+ }
241
+ return (
242
+ `${message}; the entry differs from every cached entry of that fabric: it was edited, or the cache changed ` +
243
+ "since the list was read, so read the list again and retry"
244
+ );
245
+ }
@@ -36,53 +36,44 @@ function ordinalFor(writer: RemoteWriter) {
36
36
  * notifications are released when the transaction concludes, so no observer runs inside the commit.
37
37
  */
38
38
  export class RemoteWriteParticipant implements Transaction.Participant {
39
- #request: RemoteWriter.Request = [];
40
39
  #writer: RemoteWriter;
41
40
  #name: string;
42
41
  #pending = new Map<string, RemoteWriteParticipant.PendingWrite>();
43
42
  #releases = new Array<() => Promise<void>>();
44
43
 
45
44
  /**
46
- * There is one participant for each transaction/writer pair. We use the writer function itself as the dedup key.
45
+ * There is one participant for each transaction/writer pair. We use the writer itself as the dedup key.
47
46
  */
48
47
  get role() {
49
48
  return this.#writer;
50
49
  }
51
50
 
52
51
  /**
53
- * Add an attribute update to the write request.
52
+ * Add the write of one cluster to the write request.
54
53
  *
54
+ * @param write the write {@link RemoteWriter.prepare} prepared
55
55
  * @param receiver settles the values the peer accepts
56
56
  * @param epoch the receiver's epoch when this write is queued, so it can tell a value the peer settled afterwards
57
57
  * from one that predates the write
58
58
  */
59
- set(
60
- endpointNumber: EndpointNumber,
61
- behaviorId: string,
62
- values: Val.Struct,
63
- receiver: RemoteWriteParticipant.Receiver,
64
- epoch: number,
65
- ) {
66
- const key = writeKey(endpointNumber, behaviorId);
59
+ set(write: RemoteWriter.PreparedWrite, receiver: RemoteWriteParticipant.Receiver, epoch: number) {
60
+ const key = writeKey(write.number, write.behaviorId);
67
61
  if (this.#pending.has(key)) {
68
62
  throw new InternalError(`${this} received a second write for ${key} in one commit`);
69
63
  }
70
64
 
71
- this.#request.push({ number: endpointNumber, behaviorId, values });
72
- this.#pending.set(key, { receiver, epoch, values });
65
+ this.#pending.set(key, { receiver, epoch, write });
73
66
  }
74
67
 
75
68
  async commit1() {
76
- if (!this.#request.length) {
69
+ if (!this.#pending.size) {
77
70
  return;
78
71
  }
79
72
 
80
- const request = this.#request;
81
73
  const pending = this.#pending;
82
- this.#request = [];
83
74
  this.#pending = new Map();
84
75
 
85
- const statuses = await this.#writer(request);
76
+ const statuses = await this.#writer.send([...pending.values()].map(({ write }) => write));
86
77
 
87
78
  const failedByCluster = new Map<string, Set<string>>();
88
79
  for (const { status, path } of statuses) {
@@ -98,11 +89,11 @@ export class RemoteWriteParticipant implements Transaction.Participant {
98
89
  ids.add(String(path.attributeId));
99
90
  }
100
91
 
101
- for (const [key, { receiver, values, epoch }] of pending) {
92
+ for (const [key, { receiver, write, epoch }] of pending) {
102
93
  const failed = failedByCluster.get(key);
103
- const accepted = Object.fromEntries(Object.entries(values).filter(([id]) => !failed?.has(id)));
94
+ const accepted = Object.fromEntries(Object.entries(write.values).filter(([id]) => !failed?.has(id)));
104
95
  try {
105
- const { release, persistFailure } = await receiver.settleAccepted(accepted, epoch);
96
+ const { release, persistFailure } = await receiver.settleAccepted(accepted, epoch, write.cacheMerges);
106
97
  this.#releases.push(release);
107
98
  if (persistFailure !== undefined) {
108
99
  logger.warn(
@@ -132,7 +123,6 @@ export class RemoteWriteParticipant implements Transaction.Participant {
132
123
  }
133
124
 
134
125
  rollback() {
135
- this.#request = [];
136
126
  this.#pending = new Map();
137
127
  }
138
128
 
@@ -159,8 +149,15 @@ export namespace RemoteWriteParticipant {
159
149
  * Settle {@link values}, except for an attribute the peer settled after {@link epoch}: what the device
160
150
  * reported while the write was in flight outranks the write. The values apply in memory even when persisting
161
151
  * them fails.
152
+ *
153
+ * @param cacheMerges per attribute, the value to cache from the value cached when this settles; see
154
+ * {@link RemoteWriter.PreparedWrite.cacheMerges}
162
155
  */
163
- settleAccepted(values: Val.Struct, epoch: number): Promise<Settled>;
156
+ settleAccepted(
157
+ values: Val.Struct,
158
+ epoch: number,
159
+ cacheMerges?: RemoteWriter.PreparedWrite["cacheMerges"],
160
+ ): Promise<Settled>;
164
161
  }
165
162
 
166
163
  /**
@@ -188,6 +185,6 @@ export namespace RemoteWriteParticipant {
188
185
  export interface PendingWrite {
189
186
  receiver: Receiver;
190
187
  epoch: number;
191
- values: Val.Struct;
188
+ write: RemoteWriter.PreparedWrite;
192
189
  }
193
190
  }
@@ -4,13 +4,22 @@
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
 
7
+ import { InvalidGroupOperationError } from "#endpoint/errors.js";
7
8
  import { ClientStructure } from "#node/client/ClientStructure.js";
8
9
  import type { ClientNode } from "#node/ClientNode.js";
9
10
  import { InternalError } from "@matter/general";
10
- import { AttributeModel } from "@matter/model";
11
+ import { AttributeModel, type DataModelPath } from "@matter/model";
11
12
  import { Write, WriteResult, type Val } from "@matter/protocol";
12
- import { AttributeId, Status, type ClusterId, type ClusterType, type EndpointNumber } from "@matter/types";
13
+ import {
14
+ AttributeId,
15
+ Status,
16
+ type ClusterId,
17
+ type ClusterType,
18
+ type EndpointNumber,
19
+ type FabricIndex,
20
+ } from "@matter/types";
13
21
  import type { ClientNodeStore } from "./ClientNodeStore.js";
22
+ import { FabricScopedListWrite } from "./FabricScopedListWrite.js";
14
23
 
15
24
  /**
16
25
  * Persistence handler for {@link ClientNodeStore}.
@@ -18,12 +27,38 @@ import type { ClientNodeStore } from "./ClientNodeStore.js";
18
27
  * A remote writer conveys updates to the remote node. This performs actual persistence for client nodes where the
19
28
  * local store is just a cache and the source of truth is on the remote device.
20
29
  *
21
- * Resolves with a status per attribute once the peer answered, including those declined locally because the peer's
22
- * cluster type cannot express them; when every attribute is declined locally, nothing is sent. Rejects when the peer
23
- * does not answer, as then nothing is known to have been applied.
30
+ * The datasource has a write prepared per cluster in the transaction's settled step, before any participant commits,
31
+ * so a refusal rejects the transaction before any Write Request goes out. The prepared writes of the node's clusters
32
+ * are then sent in one Write Request.
24
33
  */
25
34
  export interface RemoteWriter {
26
- (request: RemoteWriter.Request): Promise<WriteResult.AttributeStatus[]>;
35
+ /**
36
+ * Decide whether {@link proposal} may go to the remote node, and prepare it for {@link send}. Synchronous, and
37
+ * writes nothing.
38
+ *
39
+ * A peer receives only our entries of a fabric-scoped list; see {@link FabricScopedListWrite}. Every write of a
40
+ * fabric-scoped list to a peer needs our fabric index on the peer, also one of a value that is not a list.
41
+ *
42
+ * @throws WriteError with CONSTRAINT_ERROR to refuse a fabric-scoped list
43
+ */
44
+ prepare(proposal: RemoteWriter.Proposal): RemoteWriter.PreparedWrite;
45
+
46
+ /**
47
+ * Refuse every state change on a node that takes no writes through its endpoints.
48
+ *
49
+ * @param path the path of the values the change is for
50
+ * @throws InvalidGroupOperationError for a group node
51
+ */
52
+ assertWritable(path: DataModelPath): void;
53
+
54
+ /**
55
+ * Send {@link writes} in one Write Request.
56
+ *
57
+ * Resolves with a status per attribute once the peer answered, including those declined locally because the peer's
58
+ * cluster type cannot express them; when every attribute is declined locally, nothing is sent. Rejects when the
59
+ * peer does not answer, as then nothing is known to have been applied.
60
+ */
61
+ send(writes: RemoteWriter.PreparedWrite[]): Promise<WriteResult.AttributeStatus[]>;
27
62
  }
28
63
 
29
64
  const attrCache = new WeakMap<object, Record<string, ClusterType.Attribute>>();
@@ -32,17 +67,33 @@ const attrCache = new WeakMap<object, Record<string, ClusterType.Attribute>>();
32
67
  const ID_KEY = /^(0|[1-9]\d*)$/;
33
68
 
34
69
  export function RemoteWriter(node: ClientNode, structure: ClientStructure): RemoteWriter {
35
- return async function writeRemote(request: RemoteWriter.Request) {
36
- const attrWrites = Array<Write.Attribute>();
37
- const declined = Array<WriteResult.AttributeStatus>();
38
-
39
- for (const { number, behaviorId, values } of request) {
40
- const clusterId = Number.parseInt(behaviorId) as ClusterId;
41
- const cluster = structure.clusterFor(number, clusterId);
42
- if (cluster === undefined) {
43
- throw new InternalError(`Cannot remote write to non-cluster behavior ${behaviorId}`);
70
+ function clusterFor(number: EndpointNumber, behaviorId: string) {
71
+ const clusterId = Number.parseInt(behaviorId) as ClusterId;
72
+ const cluster = structure.clusterFor(number, clusterId);
73
+ if (cluster === undefined) {
74
+ throw new InternalError(`Cannot remote write to non-cluster behavior ${behaviorId}`);
75
+ }
76
+ return { clusterId, cluster };
77
+ }
78
+
79
+ return {
80
+ assertWritable(path) {
81
+ if (node.nodeType === "group") {
82
+ throw new InvalidGroupOperationError(
83
+ `Cannot write ${path}: writing state on a group endpoint is not supported; ` +
84
+ "use group.interaction.write() with a group path",
85
+ );
44
86
  }
87
+ },
88
+
89
+ prepare({ number, behaviorId, values, cached, path }) {
90
+ const { clusterId, cluster } = clusterFor(number, behaviorId);
45
91
  const attrs = attrsFor(cluster);
92
+ const attributes = new Array<Write.Attribute>();
93
+ const declined = new Array<WriteResult.AttributeStatus>();
94
+ const sent: Val.Struct = {};
95
+ let cacheMerges: Map<string, (cached: Val) => Val> | undefined;
96
+ let fabricIndex: FabricIndex | undefined;
46
97
 
47
98
  for (const id in values) {
48
99
  if (id.startsWith("__")) {
@@ -55,35 +106,114 @@ export function RemoteWriter(node: ClientNode, structure: ClientStructure): Remo
55
106
  continue;
56
107
  }
57
108
 
58
- attrWrites.push(
109
+ let value = values[id];
110
+
111
+ if (attr.schema.fabricScopedList) {
112
+ // Every write of a fabric-scoped list needs our index, also one of a value that is not a list
113
+ const attributePath = path.at(attr.schema.propertyName);
114
+ fabricIndex ??= FabricScopedListWrite.requireFabricIndex(node.fabricIndexOnPeer, attributePath);
115
+ if (Array.isArray(value)) {
116
+ const entries = FabricScopedListWrite.entriesToSend(
117
+ value,
118
+ cached?.[id],
119
+ fabricIndex,
120
+ attributePath,
121
+ entrySchemaOf(attr.schema, attributePath),
122
+ );
123
+ const index = fabricIndex;
124
+ (cacheMerges ??= new Map<string, (cached: Val) => Val>()).set(id, cachedList =>
125
+ FabricScopedListWrite.cachedAfterWrite(cachedList, entries, index),
126
+ );
127
+ value = entries;
128
+ }
129
+ }
130
+
131
+ sent[id] = value;
132
+ attributes.push(
59
133
  Write.Attribute({
60
134
  endpoint: number,
61
135
  cluster: cluster as any,
62
136
  attributes: [attr as any],
63
- value: values[id],
137
+ value,
64
138
  }),
65
139
  );
66
140
  }
67
- }
68
141
 
69
- // Remote statuses first so a device error, not one of ours, is the error a single-failure write surfaces
70
- const result = attrWrites.length
71
- ? ((await node.interaction.write(Write(...attrWrites))) as WriteResult.AttributeStatus[])
72
- : [];
73
- result.push(...declined);
142
+ return { number, behaviorId, values: sent, attributes, declined, cacheMerges };
143
+ },
144
+
145
+ async send(writes) {
146
+ const attributes = writes.flatMap(write => write.attributes);
147
+
148
+ // Remote statuses first so a device error, not one of ours, is the error a single-failure write surfaces
149
+ const result = attributes.length
150
+ ? ((await node.interaction.write(Write(...attributes))) as WriteResult.AttributeStatus[])
151
+ : [];
152
+ result.push(...writes.flatMap(write => write.declined));
74
153
 
75
- return result;
154
+ return result;
155
+ },
76
156
  };
77
157
  }
78
158
 
159
+ function entrySchemaOf(schema: AttributeModel, path: DataModelPath) {
160
+ const entrySchema = schema.listEntry;
161
+ if (entrySchema === undefined) {
162
+ throw new InternalError(`Fabric-scoped list ${path} has no entry schema`);
163
+ }
164
+ return entrySchema;
165
+ }
166
+
79
167
  export namespace RemoteWriter {
80
- export interface EndpointUpdateRequest {
168
+ /**
169
+ * The values a transaction proposes for one cluster of the remote node.
170
+ */
171
+ export interface Proposal {
81
172
  number: EndpointNumber;
82
173
  behaviorId: string;
83
174
  values: Val.Struct;
175
+
176
+ /**
177
+ * The cached values of the cluster, against which an entry of another fabric in a fabric-scoped list is
178
+ * checked.
179
+ */
180
+ cached: Val.Struct | undefined;
181
+
182
+ /**
183
+ * The path of the values, for a refusal.
184
+ */
185
+ path: DataModelPath;
84
186
  }
85
187
 
86
- export interface Request extends Array<EndpointUpdateRequest> {}
188
+ /**
189
+ * The values to send for one cluster, as {@link RemoteWriter.prepare} decided.
190
+ */
191
+ export interface PreparedWrite {
192
+ number: EndpointNumber;
193
+ behaviorId: string;
194
+
195
+ /**
196
+ * The values sent, by attribute ID. A fabric-scoped list holds only our entries.
197
+ */
198
+ values: Val.Struct;
199
+
200
+ /**
201
+ * The attribute writes of {@link values} for the Write Request.
202
+ */
203
+ attributes: Write.Attribute[];
204
+
205
+ /**
206
+ * The statuses of the attributes declined locally because the peer's cluster type cannot express them.
207
+ */
208
+ declined: WriteResult.AttributeStatus[];
209
+
210
+ /**
211
+ * For an attribute whose cached value does not simply become the value sent, the value to cache once the peer
212
+ * accepted the write, from the value cached then. For a fabric-scoped list the device replaced only our
213
+ * entries, so the cached entries of other fabrics stay.
214
+ */
215
+ cacheMerges?: ReadonlyMap<string, (cached: Val) => Val>;
216
+ }
87
217
  }
88
218
 
89
219
  /**
@@ -15,7 +15,7 @@ interface StorageParticipant extends Transaction.Participant {
15
15
  }
16
16
 
17
17
  /**
18
- * Factory function for the default implementation of {@link Datasource.Store}.
18
+ * Factory function for the default implementation of {@link Datasource.PersistentStore}.
19
19
  *
20
20
  * Performs read & write for non-volatile values for a single behavior via the {@link ServerEndpointStore} interface.
21
21
  */
@@ -23,7 +23,7 @@ export function DatasourceStore(
23
23
  endpointStore: EndpointStore,
24
24
  behaviorId: string,
25
25
  initialValues: Val.Struct | undefined,
26
- ): Datasource.Store {
26
+ ): Datasource.PersistentStore {
27
27
  return {
28
28
  initialValues,
29
29
 
@@ -46,7 +46,7 @@ export class ServerEndpointStore extends EndpointStore {
46
46
  }
47
47
 
48
48
  /**
49
- * Create a {@link Datasource.Store} for a behavior.
49
+ * Create a {@link Datasource.PersistentStore} for a behavior.
50
50
  */
51
51
  createStoreForBehavior(behaviorId: string) {
52
52
  const initialValues = this.consumeInitialValues(behaviorId);
@@ -31,8 +31,16 @@ import {
31
31
  nextEmitOf,
32
32
  } from "@matter/general";
33
33
  import { AccessLevel, MatterModel } from "@matter/model";
34
- import { ExchangeManager, FabricManager, ProtocolMocks, SessionManager, TestFabric } from "@matter/protocol";
35
- import { FabricIndex, NodeId } from "@matter/types";
34
+ import {
35
+ ExchangeManager,
36
+ FabricManager,
37
+ PeerAddress,
38
+ ProtocolMocks,
39
+ Session,
40
+ SessionManager,
41
+ TestFabric,
42
+ } from "@matter/protocol";
43
+ import { FabricIndex, INTERACTION_PROTOCOL_ID, NodeId } from "@matter/types";
36
44
  import { MockExchange } from "./mock-exchange.js";
37
45
 
38
46
  const logger = Logger.get("MockServerNode");
@@ -237,15 +245,19 @@ export class MockServerNode<T extends MockServerNode.RootEndpoint = MockServerNo
237
245
  throw error;
238
246
  }
239
247
 
240
- node.env.get(ExchangeManager).initiateExchange = address => {
241
- const exchange = new MockExchange(address, {
242
- session: node.env.get(SessionManager).maybeSessionFor(address),
243
- });
244
-
248
+ const exchanges = node.env.get(ExchangeManager);
249
+ const initiateExchangeForSession = exchanges.initiateExchangeForSession.bind(exchanges);
250
+ const interceptExchange = (address: PeerAddress, session?: Session) => {
251
+ const exchange = new MockExchange(address, { session });
245
252
  node.#newExchanges.write(exchange);
246
-
247
253
  return exchange;
248
254
  };
255
+ exchanges.initiateExchange = address =>
256
+ interceptExchange(address, node.env.get(SessionManager).maybeSessionFor(address));
257
+ exchanges.initiateExchangeForSession = (session, protocolId, options) =>
258
+ protocolId === INTERACTION_PROTOCOL_ID && session instanceof ProtocolMocks.NodeSession
259
+ ? interceptExchange(session.peerAddress, session)
260
+ : initiateExchangeForSession(session, protocolId, options);
249
261
 
250
262
  if (!node.lifecycle.isOnline) {
251
263
  await nextEmitOf(node.lifecycle.online);
@@ -255,7 +267,8 @@ export class MockServerNode<T extends MockServerNode.RootEndpoint = MockServerNo
255
267
  }
256
268
 
257
269
  /**
258
- * Resolves with the next exchange the node initiates towards a peer. Only available on nodes made by {@link createOnline}.
270
+ * Resolves with the next exchange the node initiates towards a peer, by address or as an interaction exchange on a
271
+ * mock session such as one {@link createExchange} creates. Only available on nodes made by {@link createOnline}.
259
272
  */
260
273
  async handleExchange(): Promise<MockExchange> {
261
274
  return await this.#newExchanges.read();