/** * @license * Copyright 2022-2026 Matter.js Authors * SPDX-License-Identifier: Apache-2.0 */ import { ElementTag } from "../common/index.js"; import { Access, Conformance, Constraint, FieldElement, Quality } from "../index.js"; import { BaseElement } from "./BaseElement.js"; /** * Describes a cluster or cluster element requirement for a device. */ export type RequirementElement = BaseElement & { tag: `${RequirementElement.Tag}`; /** * Requirement element type. */ element: `${RequirementElement.ElementType}`; constraint?: Constraint.Definition; access?: Access.Definition; quality?: Quality.Definition; conformance?: Conformance.Definition; default?: any; /** * When a device type requires multiple instances of the same component device type (e.g. two PowerSource * endpoints), each instance is numbered starting from 1. Requirements without an instance number apply to all * instances or to the single required instance. */ instance?: number; /** * Where a condition requirement asserts its condition. * * @see {@link MatterSpecification.v161.Core} § 9.2.6 */ location?: `${RequirementElement.Location}`; children?: (RequirementElement | FieldElement)[]; }; export function RequirementElement( definition: RequirementElement.Properties, ...children: (RequirementElement | FieldElement)[] ) { return { ...BaseElement(RequirementElement.Tag, definition, children), tag: RequirementElement.Tag, } as RequirementElement; } export namespace RequirementElement { export type Tag = ElementTag.Requirement; export const Tag = ElementTag.Requirement; export type Properties = BaseElement.Properties; export enum ElementType { ClientCluster = "clientCluster", ServerCluster = "serverCluster", Feature = "feature", Attribute = "attribute", Command = "command", Event = "event", CommandField = "commandField", DeviceType = "deviceType", Condition = "condition", } /** * Where a condition requirement asserts its condition. * * @see {@link MatterSpecification.v161.Core} § 9.2.6 */ export enum Location { /** * The root node endpoint of the node. */ Root = "Root", /** * The endpoint of the device type that states the requirement. */ Self = "Self", /** * A descendant of the endpoint of the device type that states the requirement, an endpoint its `PartsList` * reaches. */ Descendant = "Descendant", } }