Export types#181
Conversation
Several metering cluster attributes were declared with empty enum8 placeholders marked TODO. Comment them out until proper enum values are defined, and regenerate type definitions.
Align casing with the rest of the codebase: "Zigbee" is the project's spelling for the protocol name. Updates both the generated `index.d.ts` and the `scripts/template.d.ts.txt` source it is rendered from.
Introduce `ZCLNodeInput` describing what the `ZCLNode` constructor actually reads from its argument: a required `sendFrame` and an optional `endpointDescriptors` array. The previous typing forced callers to also provide `handleFrame`, even though the constructor overwrites that slot, which made directly-constructed `ZCLNode` inputs unnecessarily painful to type. The full bidirectional `ZigbeeNode` interface is kept for callers that model the real Homey-provided node.
Local TypeScript scratch file used to validate the exported types against a small consumer. Not part of the library output.
This reverts commit 5d50bb3.
`ZCLNode` exposes `handleFrame` at runtime (see `lib/Node.js`), but the published types omitted it, forcing callers that route frames manually (e.g. inter-PAN handlers) to cast. Add the declaration so the public API matches the runtime.
The base `Cluster<Attributes, Commands>` required both generics, so callers wanting a "cluster of any shape" had to spell out `Cluster<types.AttributeDefinitions, types.CommandDefinitions>` or introduce a local alias. Concrete cluster classes (e.g. `BasicCluster`) already default their generics to their own attribute/command definitions, so the base class was the odd one out. Default the generics on the base class to their constraint types, matching the pattern used by the concrete subclasses and letting callers write a plain `Cluster` again.
…tatic These properties are stored on the class (via Cluster.addCluster) at runtime, not on the instance. The previous declarations as instance properties caused runtime undefined errors when consumers accessed cluster.attributes etc.
|
@JELoohuis I made some changes that follow from trying to update node-zigbee-clusters in node-zigbee. |
The bound command methods present at runtime, such as `move` for a bound LevelControl cluster, could not be added due to TypeScript not allowing for dynamic types on classes. They were only added in a separate interface as to not hinder developers.
|
Looks good to me. 👍 |
Could you merge this PR so we can check lint/test in CI? JELoohuis#1 |
|
I installed the @athombv/data-types from the npm registry to fix the remaining pipeline errors. I don't know why the GitHub registry has these access issues, but you may want to change that back once it is fixed, if the GitHub registry is preferred. |
Depends on athombv/node-data-types#42
Some of the generated types were incomplete, so I rewrote the generation to document more of the properties available at runtime, as well as adding some additional types based on the JS sources and runtime introspection.
I enabled type checking for the definition file and added the SDK types, since these are used by the ZCLNode.
Some broken enum8 attributes in the Metering cluster definition, where the function was not properly called, were also fixed.