/** * @license * Copyright 2022-2026 Matter.js Authors * SPDX-License-Identifier: Apache-2.0 */ import { ClientRequest } from "#action/client/ClientRequest.js"; import { Duration } from "@matter/general"; import { ClusterType, CommandData, DelayReportData, EndpointNumber, InvokeRequest, TlvSchema } from "@matter/types"; import { Specifier } from "./Specifier.js"; export interface InvokeCommandData extends CommandData { timed?: boolean; } export interface Invoke extends InvokeRequest { /** Timeout only relevant for Client Interactions */ timeout?: Duration; /** Expected processing time of the command on the server side to calculated response timeout */ expectedProcessingTime?: Duration; /** Whether to use extended timeout for fail-safe messages. Ignored when expectedProcessingTime is set */ useExtendedFailSafeMessageResponseTimeout?: boolean; /** * Controls automatic command batching for single-command invokes. * * - `undefined` — batch with zero delay (commands in the same timer tick are combined) * - `Duration` — batch with the specified collection window * - `false` — disable batching; execute immediately * * A request that sets other per-request options, such as {@link expectedProcessingTime}, is never batched and * executes immediately. Batches only combine commands for the same network. */ batchDuration?: false | Duration; /** * Server only: called after the request's paths are validated and before any command runs, with the endpoints at * least one command of the request dispatches to. */ beforeDispatch?: (endpoints: ReadonlySet) => void; } export interface CommandDecodeDetails { responseSchema: TlvSchema; } export interface ClientInvoke extends Invoke, ClientRequest { commands: Map; skipValidation?: boolean; } /** * Request invocation of one or more commands. */ export declare function Invoke(options: Invoke.Definition): ClientInvoke; /** * Request invocation multiple commands with defined options */ export declare function Invoke(options: Invoke.Definition, ...commands: Invoke.CommandRequest[]): ClientInvoke; /** * Request invocation multiple commands as list of Commands with default options. */ export declare function Invoke(...commands: Invoke.CommandRequest[]): ClientInvoke; export declare namespace Invoke { interface Definition { /** List of commands to invoke */ commands: (Invoke.CommandRequest | Invoke.LegacyCommandRequest)[]; /** Tell the server to not send a response */ suppressResponse?: boolean; /** Whether this is sent as a timed request, if no timeout is specified a default is used */ timed?: boolean; /** Timeout when sent as a timed request, if timed flag is not set it will be set automatically */ timeout?: Duration; /** Interaction model revision to use, if not specified a default is used */ interactionModelRevision?: number; /** Processing time of the command of the server assumed for this invoke. If not set a default is used */ expectedProcessingTime?: Duration; /** Whether to use extended timeout for fail-safe messages. Ignored when expectedProcessingTime is set */ useExtendedFailSafeMessageResponseTimeout?: boolean; /** Whether to skip validation of command fields against schema */ skipValidation?: boolean; /** * Ask the server to hold off the next Report Data of the subscriptions on the endpoints the commands target. */ delayReportData?: DelayReportData; } function Command(request: Invoke.CommandRequest, skipValidation?: boolean): InvokeCommandData; /** * @deprecated Scheduled for removal in 0.19. * Use {@link CommandRequest} with {@link ClusterType.Command}. */ function Command(request: Invoke.LegacyCommandRequest, skipValidation?: boolean): InvokeCommandData; function Command(request: Invoke.AnyCommandRequest, skipValidation?: boolean): InvokeCommandData; /** * @deprecated Scheduled for removal in 0.19. * Legacy command request using ClusterType commands. Use {@link CommandRequest} with * {@link ClusterType.Command}. */ interface LegacyCommandRequest { cluster: Specifier.Cluster; command: Specifier.ClusterTypeCommand; endpoint?: Specifier.Endpoint; fields?: unknown; commandName?: string; commandRef?: number; } /** * Union of new-style and legacy command requests. */ type AnyCommandRequest = CommandRequest | LegacyCommandRequest; /** * Type guard for legacy command requests. */ function isLegacy(request: AnyCommandRequest): request is LegacyCommandRequest; type CommandRequest> = Specifier.Command>> = ConcreteCommandRequest | WildcardCommandRequest; type ConcreteCommandRequest> = Specifier.Command>> = WildcardCommandRequest & { endpoint: Specifier.Endpoint; }; /** * @deprecated Scheduled for removal in 0.19. * Use the overload accepting {@link ConcreteCommandRequest}. */ function ConcreteCommandRequest(data: Invoke.LegacyCommandRequest): Invoke.LegacyCommandRequest; function ConcreteCommandRequest(data: Invoke.ConcreteCommandRequest): Invoke.ConcreteCommandRequest; type WildcardCommandRequest> = Specifier.Command>> = { cluster: C; command: CMD; commandName?: string; commandRef?: number; } & Fields, CMD>>; /** * @deprecated Scheduled for removal in 0.19. * Use the overload accepting {@link WildcardCommandRequest}. */ function WildcardCommandRequest(data: Invoke.LegacyCommandRequest): Invoke.LegacyCommandRequest; function WildcardCommandRequest(data: Invoke.WildcardCommandRequest): Invoke.WildcardCommandRequest; /** * Extract the command element from a command request. */ function commandOf(request: R): ClusterType.Command; /** * Extract the request type from a command's function signature phantom type. */ type RequestOf = C extends ClusterType.Command ? F extends (request: infer R, ...args: unknown[]) => unknown ? R : void : void; type Fields = RequestOf extends void ? {} : undefined extends RequestOf ? { fields?: RequestOf; } : { fields: RequestOf; }; } //# sourceMappingURL=Invoke.d.ts.map