messages: pure builders for every event the bridge sends
src/messages builds Response, StateReport, DeferredResponse, ErrorResponse, ChangeReport and the scene, doorbell and simple events from plain values; messageId and times are parameters, so a test compares whole objects. StateBuilder collects properties checked by the descriptors, AlexaError and AlexaErrors carry the payload fields of an error type. AlexaStatusMessage and AlexaErrorResponse move to src/compat and are written on the builders. On the wire, against 1.5.2: a DeferredResponse has no context key, a ChangeReport has no correlationToken, the namespace of an ErrorResponse follows its type, and a ChangeReport without a changed property is not published: send() resolves "" and the bridge reports an error that names the endpoint. 143 tests pass (108 before). Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
parent
2558e21787
commit
46fa06728c
68 changed files with 3410 additions and 1208 deletions
26
dist/esm/compat/AlexaErrorResponse.d.ts
vendored
Normal file
26
dist/esm/compat/AlexaErrorResponse.d.ts
vendored
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
import type { MqttClient } from "mqtt";
|
||||
import type { ErrorResponseMessage } from "../messages/types.js";
|
||||
/** An ErrorResponse as 1.x builds it: device.getErrorMessage(token), setErrorMessage(), send(). */
|
||||
export declare class AlexaErrorResponse {
|
||||
private readonly correlationToken;
|
||||
private readonly rootTopic;
|
||||
private readonly endpointId;
|
||||
private readonly mqttClient;
|
||||
private error;
|
||||
private namespace?;
|
||||
private readonly messageId;
|
||||
/** Where a failed publish is reported (set by the Device that built this message, 1.5.2): send() never rejects. */
|
||||
onPublishError?: (err: Error) => void;
|
||||
constructor(correlationToken: string, rootTopic: string, endpointId: string, mqttClient: MqttClient);
|
||||
/**
|
||||
* The error to answer with. otherParams are the fields the type adds to the payload (validRange). The header
|
||||
* carries the namespace the type is documented under, Alexa.ThermostatController for THERMOSTAT_IS_OFF;
|
||||
* options.namespace names another.
|
||||
*/
|
||||
setErrorMessage(type: string, message: string, otherParams?: Record<string, any>, options?: {
|
||||
namespace?: string;
|
||||
}): void;
|
||||
toJSON(): ErrorResponseMessage;
|
||||
/** Resolves with the topic published to, or "" when the publish failed. Never rejects. */
|
||||
send(sendAsync?: boolean): Promise<string>;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue