/** * @license * Copyright 2022-2026 Matter.js Authors * SPDX-License-Identifier: Apache-2.0 */ import { type Model } from "#models/Model.js"; import { FeatureSet, FieldValue } from "../common/index.js"; import { Aspect } from "./Aspect.js"; /** * An operational view of conformance as defined by the Matter Specification. * * "Conformance" controls when a data field or cluster element is allowed or required. */ export declare class Conformance extends Aspect { ast: Conformance.Ast; get type(): Conformance.Special | Conformance.Operator | Conformance.Flag; /** * Initialize from a Conformance.Definition or the conformance DSL defined by the Matter Specification. */ constructor(definition: Conformance.Definition); extend(other: Conformance): Conformance; validateReferences(errorTarget: Conformance.ErrorTarget, lookup: Conformance.ReferenceResolver): void; validateComputation(errorTarget: Conformance.ErrorTarget, features?: FeatureSet): void; /** * Is the associated element mandatory? * * This supports a limited subset of conformance and is only appropriate for field and requirement conformance. */ get isMandatory(): boolean; /** * Is the associated element provisional? * * A provisional element reads as optional so an application can exercise it and still certify, so this is the only * way to tell "the specification says this is optional" from "the specification has not finished it yet". * * @see {@link MatterSpecification.v161.Core} § 7.3.5 */ get isProvisional(): boolean; /** * Is the associated element disallowed? */ get isDisallowed(): boolean; /** * Is the associated element obsolete? * * An obsolete element stays in the model with its ID and name. A server may not implement it and rejects values * for it as it does for a disallowed element; a client may still send it and decode it, as it may a deprecated one. * * @see Matter Core Specification 1.7 § 14.3.9 */ get isObsolete(): boolean; /** * Perform limited conformance evaluation to determine whether this conformance is applicable given a feature * combination. * * This is useful for filtering elements at compile time. For complete accuracy you then need to filter at runtime * once field values are known. */ applicabilityFor({ definedFeatures: features, supportedFeatures }: Conformance.FeatureContext, options?: Conformance.ApplicabilityOptions): Conformance.Applicability; toString(): string; protected freeze(): void; } export declare namespace Conformance { interface FeatureContext { definedFeatures: Set; supportedFeatures: Set; } interface ApplicabilityOptions { /** * Treat a deprecated ("D") or obsolete ("Z") element as optional instead of disallowed. * * A device may still implement such an element because earlier revisions allowed it. A client judging the * elements a device reports sets this; a server, which does not offer them, does not. A list ending in ", D" is * decided by the terms before the "D" either way. * * @see {@link MatterSpecification.v161.Core} § 7.3.8 * @see Matter Core Specification 1.7 § 14.3.9 */ deprecatedIsOptional?: boolean; } enum Applicability { /** The element may not appear */ None = 0, /** The implementation decides whether the element appears */ Optional = 1, /** Features alone do not decide; the record's own contents or the revision do */ Conditional = 2, /** The element must appear */ Mandatory = 3 } type AstParam = Ast.Name | Ast.Value | Ast.Option | Ast.UnaryOperand | Ast.BinaryOperands | Ast.Otherwise | Ast.Choice; type Ast = { type: Special.Empty | Special.Desc | Flag; } | { type: Special.Name; param: Ast.Name; } | { type: Special.Value; param: Ast.Value; } | { type: Special.Choice; param: Ast.Choice; } | { type: Special.Otherwise; param: Ast.Otherwise; } | { type: Special.OptionalIf; param: Ast.Option; } | { type: Special.Revision; param: number; } | { type: Operator.AND | Operator.OR | Operator.XOR | Operator.DOT | Operator.EQ | Operator.NE | Operator.LT | Operator.GT | Operator.LTE | Operator.GTE; param: Ast.BinaryOperands; } | { type: Operator.NOT; param: Ast.UnaryOperand; }; namespace Ast { type Name = string; type Value = FieldValue; type Option = Ast; type UnaryOperand = Ast; type BinaryOperands = { lhs: Ast; rhs: Ast; }; type Otherwise = Ast[]; type Choice = { name: ChoiceName; num: number; orMore?: boolean; orLess?: boolean; expr: Ast; }; } enum Special { Empty = "empty", Desc = "desc", Name = "name", Value = "value", Choice = "choice", Otherwise = "otherwise", OptionalIf = "optionalIf", /** Revision conformance (spec 1.5.1+): "Rev >= vN" — element present at cluster revision ≥ N */ Revision = "revision" } enum Flag { Mandatory = "M", Optional = "O", Provisional = "P", Deprecated = "D", Disallowed = "X", Obsolete = "Z" } enum Operator { NOT = "!", EQ = "==", NE = "!=", OR = "|", XOR = "^", AND = "&", DOT = ".", GT = ">", LT = "<", GTE = ">=", LTE = "<=" } const M = Flag.Mandatory; const O = Flag.Optional; const P = Flag.Provisional; const D = Flag.Deprecated; const X = Flag.Disallowed; const Z = Flag.Obsolete; const EQ = Operator.EQ; const NE = Operator.NE; const OR = Operator.OR; const XOR = Operator.XOR; const AND = Operator.AND; const DOT = Operator.DOT; const GT = Operator.GT; const LT = Operator.LT; const GTE = Operator.GTE; const LTE = Operator.LTE; type Name = string; type Number = number; type ChoiceName = "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z"; type ReferenceResolver = (name: string | string[]) => Model | undefined; type ErrorTarget = { error(code: string, message: string): void; }; /** * Supported ways of expressing conformance (conceptually union should include Flag but that is covered by string). */ type Definition = string | string[] | { ast: Conformance.Ast; } | undefined; function validateReferences(conformance: Conformance, ast: Ast, errorTarget: ErrorTarget, resolver: ReferenceResolver): void; function serialize(ast: Ast): string; function isBinaryOperator(type: Ast["type"] | Operator): type is Operator; function precedenceOf(operator: Ast["type"] | Operator): number | undefined; function isHigherPrecedence(operator: Ast["type"] | Operator, other: Ast["type"] | Operator): boolean; } /** * Collect name segments from a DOT AST chain. * * Returns `undefined` if the chain contains non-name nodes. */ export declare function collectDotSegments(ast: Conformance.Ast): string[] | undefined; //# sourceMappingURL=Conformance.d.ts.map