/** * @license * Copyright 2022-2026 Matter.js Authors * SPDX-License-Identifier: Apache-2.0 */ /** * Deprecated element interfaces and factory functions for the legacy {@link ClusterType} factory. * * These provide a backward-compatible API for consumers that define clusters using the deprecated * {@link ClusterType}() factory rather than generated cluster namespaces or the decorator system. * * @deprecated use generated cluster namespaces or the decorator system instead. */ import { Priority } from "#globals/Priority.js"; import { AccessLevel } from "@matter/model"; import { AttributeId } from "../datatype/AttributeId.js"; import { CommandId } from "../datatype/CommandId.js"; import { EventId } from "../datatype/EventId.js"; import { BitSchema } from "../schema/BitmapSchema.js"; import { TlvSchema } from "../tlv/TlvSchema.js"; /* Attribute interfaces */ /** * @deprecated */ export interface Attribute { id: AttributeId; schema: TlvSchema; optional: boolean; readAcl: AccessLevel; writable: boolean; scene: boolean; persistent: boolean; timed: boolean; fixed: boolean; fabricScoped: boolean; omitChanges: boolean; writeAcl?: AccessLevel; default?: T; unknown: boolean; } /** * @deprecated */ export interface OptionalAttribute extends Attribute { optional: true; } /** * @deprecated */ export interface WritableAttribute extends Attribute { writable: true; } /** * @deprecated */ export interface OptionalWritableAttribute extends OptionalAttribute { writable: true; } /** * @deprecated */ export interface FabricScopedAttribute extends Attribute { fabricScoped: true; } /** * @deprecated */ export interface WritableFabricScopedAttribute extends WritableAttribute { fabricScoped: true; } /** * @deprecated */ export interface OptionalWritableFabricScopedAttribute extends OptionalWritableAttribute { fabricScoped: true; } /** * @deprecated */ export interface FixedAttribute extends Attribute { fixed: true; } /** * @deprecated */ export interface WritableFixedAttribute extends WritableAttribute { fixed: true; } /** * @deprecated */ export interface OptionalFixedAttribute extends OptionalAttribute { fixed: true; } /* Attribute factories */ interface AttributeOptions { scene?: boolean; persistent?: boolean; omitChanges?: boolean; timed?: boolean; default?: T; readAcl?: AccessLevel; writeAcl?: AccessLevel; } /** * @deprecated */ export const Attribute = ( id: number, schema: TlvSchema, { scene = false, persistent = false, omitChanges = false, default: conformanceValue, readAcl = AccessLevel.View, timed = false, }: AttributeOptions = {}, ): Attribute => ({ id: AttributeId(id), schema, optional: false, writable: false, fixed: false, scene, persistent, timed, fabricScoped: false, omitChanges, default: conformanceValue, readAcl, unknown: false, }); /** * @deprecated */ export const OptionalAttribute = ( id: number, schema: TlvSchema, { scene = false, persistent = false, omitChanges = false, default: conformanceValue, readAcl = AccessLevel.View, timed = false, }: AttributeOptions = {}, ): OptionalAttribute => ({ id: AttributeId(id), schema, optional: true, writable: false, fixed: false, scene, persistent, fabricScoped: false, omitChanges, default: conformanceValue, readAcl, timed, unknown: false, }); /** * @deprecated */ export const WritableAttribute = ( id: number, schema: TlvSchema, { scene = false, persistent = true, omitChanges = false, default: conformanceValue, readAcl = AccessLevel.View, writeAcl = AccessLevel.View, timed = false, }: AttributeOptions = {}, ): WritableAttribute => ({ id: AttributeId(id), schema, optional: false, writable: true, fixed: false, scene, persistent, fabricScoped: false, omitChanges, default: conformanceValue, readAcl, timed, writeAcl, unknown: false, }); /** * @deprecated */ export const OptionalWritableAttribute = ( id: number, schema: TlvSchema, { scene = false, persistent = true, omitChanges = false, default: conformanceValue, readAcl = AccessLevel.View, writeAcl = AccessLevel.View, timed = false, }: AttributeOptions = {}, ): OptionalWritableAttribute => ({ id: AttributeId(id), schema, optional: true, writable: true, fixed: false, scene, persistent, fabricScoped: false, omitChanges, default: conformanceValue, readAcl, timed, writeAcl, unknown: false, }); /** * @deprecated */ export const FabricScopedAttribute = ( id: number, schema: TlvSchema, { scene = false, persistent = true, omitChanges = false, default: conformanceValue, readAcl = AccessLevel.View, timed = false, }: AttributeOptions = {}, ): FabricScopedAttribute => ({ id: AttributeId(id), schema, optional: false, writable: false, fixed: false, scene, persistent, fabricScoped: true, omitChanges, default: conformanceValue, readAcl, timed, unknown: false, }); /** * @deprecated */ export const WritableFabricScopedAttribute = ( id: number, schema: TlvSchema, { scene = false, persistent = true, omitChanges = false, default: conformanceValue, readAcl = AccessLevel.View, writeAcl = AccessLevel.View, timed = false, }: AttributeOptions = {}, ): WritableFabricScopedAttribute => ({ id: AttributeId(id), schema, optional: false, writable: true, fixed: false, scene, persistent, fabricScoped: true, omitChanges, default: conformanceValue, readAcl, timed, writeAcl, unknown: false, }); /** * @deprecated */ export const OptionalWritableFabricScopedAttribute = ( id: number, schema: TlvSchema, { scene = false, persistent = true, omitChanges = false, default: conformanceValue, readAcl = AccessLevel.View, writeAcl = AccessLevel.View, timed = false, }: AttributeOptions = {}, ): OptionalWritableFabricScopedAttribute => ({ id: AttributeId(id), schema, optional: true, writable: true, fixed: false, scene, persistent, fabricScoped: true, omitChanges, default: conformanceValue, readAcl, timed, writeAcl, unknown: false, }); /** * @deprecated */ export const FixedAttribute = ( id: number, schema: TlvSchema, { scene = false, persistent = false, omitChanges = false, default: conformanceValue, readAcl = AccessLevel.View, timed = false, }: AttributeOptions = {}, ): FixedAttribute => ({ id: AttributeId(id), schema, optional: false, writable: false, fixed: true, scene, persistent, fabricScoped: false, omitChanges, default: conformanceValue, readAcl, timed, unknown: false, }); /** * @deprecated */ export const WritableFixedAttribute = ( id: number, schema: TlvSchema, { scene = false, persistent = false, omitChanges = false, default: conformanceValue, readAcl = AccessLevel.View, timed = false, }: AttributeOptions = {}, ): FixedAttribute => ({ id: AttributeId(id), schema, optional: false, writable: true, fixed: true, scene, persistent, fabricScoped: false, omitChanges, default: conformanceValue, readAcl, timed, unknown: false, }); /** * @deprecated */ export const OptionalFixedAttribute = ( id: number, schema: TlvSchema, { scene = false, persistent = false, omitChanges = false, default: conformanceValue, readAcl = AccessLevel.View, timed = false, }: AttributeOptions = {}, ): OptionalFixedAttribute => ({ id: AttributeId(id), schema, optional: true, writable: false, fixed: true, scene, persistent, fabricScoped: false, omitChanges, default: conformanceValue, readAcl, timed, unknown: false, }); /* Command interfaces */ /** * @deprecated */ export interface Command { optional: boolean; requestId: CommandId; requestSchema: TlvSchema; responseId: CommandId; responseSchema: TlvSchema; invokeAcl: AccessLevel; timed: boolean; } /** * @deprecated */ export interface OptionalCommand extends Command { optional: true; } /* Command factories */ interface CommandOptions { invokeAcl?: AccessLevel; timed?: boolean; } /** * @deprecated */ export const Command = ( requestId: number, requestSchema: TlvSchema, responseId: number, responseSchema: TlvSchema, { invokeAcl = AccessLevel.Operate, timed = false }: CommandOptions = {}, ): Command => ({ optional: false, requestId: CommandId(requestId), requestSchema, responseId: CommandId(responseId), responseSchema, invokeAcl, timed, }); /** * @deprecated */ export const OptionalCommand = ( requestId: number, requestSchema: TlvSchema, responseId: number, responseSchema: TlvSchema, { invokeAcl = AccessLevel.Operate, timed = false }: CommandOptions = {}, ): OptionalCommand => ({ optional: true, requestId: CommandId(requestId), requestSchema, responseId: CommandId(responseId), responseSchema, invokeAcl, timed, }); /* Event interfaces */ /** * @deprecated */ export interface Event { id: EventId; schema: TlvSchema; priority: Priority; optional: boolean; readAcl: AccessLevel; unknown: boolean; } /** * @deprecated */ export interface OptionalEvent extends Event { optional: true; } /* Event factories */ interface EventOptions { readAcl?: AccessLevel; } /** * @deprecated */ export const Event = ( id: number, priority: Priority, schema: TlvSchema, { readAcl = AccessLevel.View }: EventOptions = {}, ): Event => ({ id: EventId(id), schema, priority, optional: false, readAcl, unknown: false, }); /** * @deprecated */ export const OptionalEvent = ( id: number, priority: Priority, schema: TlvSchema, { readAcl = AccessLevel.View }: EventOptions = {}, ): OptionalEvent => ({ id: EventId(id), schema, priority, optional: true, readAcl, unknown: false, });