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>
52 lines
3.1 KiB
TypeScript
52 lines
3.1 KiB
TypeScript
import type { Temperature } from "../registry/schema.js";
|
|
/**
|
|
* The namespace an ErrorResponse of this type goes under: the one the table of error types lists it with
|
|
* (THERMOSTAT_IS_OFF: Alexa.ThermostatController, OBSTACLE_DETECTED: Alexa.Safety), Alexa for a type the table
|
|
* does not have.
|
|
*/
|
|
export declare function errorNamespace(type: string): string;
|
|
/** Thrown by a directive handler, or built to be sent: the directive is answered with this ErrorResponse. */
|
|
export declare class AlexaError extends Error {
|
|
/** "ENDPOINT_UNREACHABLE" */
|
|
readonly type: string;
|
|
/** payload.message: for the log of the skill, Alexa does not read it to the user. */
|
|
readonly alexaMessage: string;
|
|
/** The fields of the payload next to type and message. */
|
|
readonly extra: Record<string, unknown>;
|
|
/** The namespace of the header. */
|
|
readonly namespace: string;
|
|
constructor(type: string, message: string, extra?: Record<string, unknown>, namespace?: string);
|
|
}
|
|
export type CurrentDeviceMode = "ASLEEP" | "COLOR" | "DEMAND_RESPONSE" | "ECO" | "NOT_PROVISIONED" | "VACATION" | "OTHER";
|
|
export type ControlUnavailableReason = "DEEP_SLEEP_MODE" | "OUT_OF_NETWORK_CONNECTIVITY" | "NO_CONNECTIVITY_PACKAGE_ENABLED" | "UNKNOWN";
|
|
export type ChargeState = "ALREADY_CHARGED_TO_REQUIRED_LEVEL" | "CURRENTLY_CHARGING" | "FULLY_CHARGED" | "NOT_CONNECTED_TO_POWER";
|
|
export declare const AlexaErrors: {
|
|
/** An error of any type. */
|
|
of(type: string, message: string, extra?: Record<string, unknown>): AlexaError;
|
|
/** The value is outside what the endpoint takes. For a temperature: temperatureOutOfRange(). */
|
|
valueOutOfRange(message: string, validRange: {
|
|
minimumValue: number;
|
|
maximumValue: number;
|
|
}): AlexaError;
|
|
temperatureOutOfRange(message: string, validRange: {
|
|
minimumValue: Temperature;
|
|
maximumValue: Temperature;
|
|
}): AlexaError;
|
|
/** A light showing a color asked for a color temperature: "COLOR". */
|
|
notSupportedInCurrentMode(message: string, currentDeviceMode: CurrentDeviceMode): AlexaError;
|
|
/** percentageState: what is left of the battery, 0 to 100. */
|
|
endpointLowPower(message: string, percentageState?: number): AlexaError;
|
|
endpointControlUnavailable(message: string, reason: ControlUnavailableReason): AlexaError;
|
|
notSupportedWithCurrentBatteryChargeState(message: string, currentChargeState: ChargeState, currentChargeLevelInPercentage?: number): AlexaError;
|
|
/** What has to be refilled. */
|
|
insufficientResource(message: string, resourceType: "WATER"): AlexaError;
|
|
/** What the user has to do first. */
|
|
maintenanceRequired(message: string, maintenanceAction?: "EMPTY_BIN"): AlexaError;
|
|
/** Goes under Alexa.ThermostatController. minimumTemperatureDelta: how far apart the setpoints have to be. */
|
|
setpointsTooClose(message: string, minimumTemperatureDelta?: Temperature): AlexaError;
|
|
/** Goes under Alexa.SecurityPanelController. With the endpoints listed, the user can bypass them by voice. */
|
|
bypassNeeded(message: string, endpointsNeedingBypass?: Array<{
|
|
friendlyName: string;
|
|
endpointId?: string;
|
|
}>): AlexaError;
|
|
};
|