Skip to content

Commit 893d6ba

Browse files
Apollon77claude
andauthored
feat(node): add Endpoint.get()/getStateOf(), nodeType discriminant, Read.AttributePaths (#3681)
* feat(node): add Endpoint.get()/getStateOf(), nodeType discriminant, Read.AttributePaths - Endpoint.get()/getStateOf() issue batched reads on client nodes and return local state snapshots on server nodes - nodeType: "server" | "client" | "group" replaces isGroup/isLocalNode boolean properties on Node - ClientGroup.get()/getStateOf() throw InvalidGroupOperationError - Read.AttributePaths replaces Read.Plan as dedup accumulator for batched reads Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix(node): address PR review — stream merge, circular dep, includeKnownVersions - Move InvalidGroupOperationError to endpoint/errors.ts to break CJS circular init (Endpoint → ClientGroupInteraction → ClientNodeInteraction → EndpointInitializer) - Group guard in Endpoint#performRead now throws InvalidGroupOperationError - Client reads collect attr-value stream reports and merge over state-view base (handles version-filter empty responses correctly) - GetOptions gains includeKnownVersions to skip version filter injection - ClientNodeInteraction.read skips version filter injection when request fabric-filter doesn't match subscription fabric-filter Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix(node): address second Copilot review — ClusterModel guard, chai import, visibility - Guard schema access with instanceof ClusterModel before iterating schema.attributes (non-cluster behaviors have no attributes array) - Make ClientStructure.subscribedFabricFiltered public so ClientNodeInteraction can compare fabric-filter settings - Remove explicit chai import from ReadAttributePathsTest (use global expect) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix(node): address third Copilot review — isFabricFiltered, allowedNames, attrNameToId - Normalize isFabricFiltered ?? true before comparing to subscribedFabricFiltered so callers that omit the field still get version filter injection - Fix allowedNames guard: check !== undefined instead of ?.size so an empty Set correctly rejects all attribute names - Precompute attrNameToId map alongside attrs in clusterLookup to replace O(n) schema.attributes.find() with O(1) map lookup - Format fix on includeKnownVersions ternary Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * upgrade js-tools * fix(node): use public elementsOf API and update read JSDoc Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * upgrade js-tools * fix(node): filter failed paths from partial and tighten return types Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * formatting * chore(node): add TODO for StateSelector type tightening Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 9577473 commit 893d6ba

26 files changed

Lines changed: 1110 additions & 427 deletions

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ The main work (all changes without a GitHub username in brackets in the below li
3333
- Feature: (@adeepn) Added `DclBehavior` for centralized DCL configuration via environment variables (`MATTER_DCL_*`), config files, or programmatic setup
3434
- Feature: `CommissioningClient.BaseCommissioningOptions` now accepts `wifiNetwork`, `threadNetwork`, `regulatoryLocation`, and `regulatoryCountryCode` for passing network credentials and regulatory configuration during commissioning
3535
- Feature: DoorLockServer is fully implemented except for Aliro features
36-
- Feature: New Supervision() factory allows for fine-grained control of validation for state, commands, and arbitrary JS values
36+
- Feature: The new Supervision() factory allows for fine-grained control of validation for state, commands, and arbitrary JS values
37+
- Feature: Added `Endpoint.get()` and `Endpoint.getStateOf()` — async read API with optional `fabricFilter` control; on a client endpoint issues a single batched Matter Read; on a server endpoint returns a snapshot of local state
3738
- Enhancement: Re-establish subscriptions in parallel per peer on device/bridge startup
3839
- Enhancement: Added more warnings on invalid values for BasicInformation cluster
3940
- Adjustment: Because we saw devices in the wild that needed up to 2 minutes to respond to mDNS queries, we increased the discovery time for commissioning targets to 3 minutes (previously 1 minute)

package-lock.json

Lines changed: 311 additions & 402 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595
}
9696
},
9797
"dependencies": {
98-
"@nacho-iot/js-tools": "^0.1.3",
98+
"@nacho-iot/js-tools": "^0.1.4",
9999
"memlab": "^2.0.2"
100100
}
101101
}

packages/cli-tool/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"@matter/model": "*",
4040
"@matter/node": "*",
4141
"@matter/protocol": "*",
42-
"@nacho-iot/js-tools": "*",
42+
"@nacho-iot/js-tools": "^0.1.4",
4343
"@matter/types": "*",
4444
"@matter/nodejs": "*",
4545
"@types/escodegen": "^0.0.10",

packages/create/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
},
3333
"homepage": "https://github.com/matter-js/matter.js#readme",
3434
"devDependencies": {
35-
"@nacho-iot/js-tools": "*",
35+
"@nacho-iot/js-tools": "^0.1.4",
3636
"@types/node": "^25.6.0",
3737
"@types/tar-stream": "^3.1.4"
3838
},

packages/node/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"@matter/protocol": "*"
4343
},
4444
"devDependencies": {
45-
"@nacho-iot/js-tools": "*",
45+
"@nacho-iot/js-tools": "^0.1.4",
4646
"@matter/testing": "*"
4747
},
4848
"files": [

packages/node/src/behavior/system/network/NetworkClient.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export class NetworkClient extends NetworkBehavior {
2323
declare readonly events: NetworkClient.Events;
2424

2525
override initialize() {
26-
if (this.#node.isGroup) {
26+
if (this.#node.nodeType === "group") {
2727
// Groups can never subscribe
2828
this.state.autoSubscribe = false;
2929
this.state.defaultSubscription = undefined;

packages/node/src/behavior/system/software-update/OtaAnnouncements.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ export class OtaAnnouncements {
219219
* When a node is applicable for updates, it also subscribes to softwareVersion changes to be able to react
220220
*/
221221
peerApplicableForUpdate(peer: ClientNode) {
222-
if (peer.isGroup || !peer.behaviors.has(BasicInformationClient)) {
222+
if (peer.nodeType === "group" || !peer.behaviors.has(BasicInformationClient)) {
223223
// We need more information on the node to request an update
224224
return;
225225
}

0 commit comments

Comments
 (0)