errors: typed helpers for every documented error type

AlexaErrors has a helper for each of the 73 types of the table on
alexa-errorresponse.html, named after the type in camel case: 63 take the
message only, 10 take the payload fields their page documents. A field the
page requires (reason, currentDeviceMode, currentChargeState, resourceType)
is a required argument, so leaving it out does not compile; from JavaScript
the helper throws a TypeError that lists the values. validRange is optional,
as the page says, and has both ends when given.
temperatureOutOfRange and setpointsTooClose stay as shorter names.
The helpers are compared with the 15 examples of the four error pages.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
David 2026-09-28 21:14:55 +00:00
parent 4a3dd81bcf
commit 94b13f733a
36 changed files with 874 additions and 138 deletions

View file

@ -2,8 +2,8 @@
Object.defineProperty(exports, "__esModule", { value: true });
exports.AlexaErrors = exports.AlexaError = void 0;
exports.errorNamespace = errorNamespace;
// The errors a device answers a directive with (alexa-errorresponse.html). A helper for each type whose payload
// has fields of its own, so that the fields cannot be misspelt.
// The errors a device answers a directive with (alexa-errorresponse.html): a helper for each type of the table.
// The helper of a type whose payload has fields of its own takes them, so that they cannot be misspelt or left out.
const catalog_js_1 = require("../registry/catalog.js");
/**
* The namespace an ErrorResponse of this type goes under: the one the table of error types lists it with
@ -25,46 +25,80 @@ class AlexaError extends Error {
}
}
exports.AlexaError = AlexaError;
// alexa-errorresponse.html, "Properties and objects": the values a field takes
const CURRENT_DEVICE_MODES = ["ASLEEP", "COLOR", "DEMAND_RESPONSE", "ECO", "NOT_PROVISIONED", "VACATION", "OTHER"];
const REASONS = ["DEEP_SLEEP_MODE", "OUT_OF_NETWORK_CONNECTIVITY", "NO_CONNECTIVITY_PACKAGE_ENABLED", "UNKNOWN"];
const CHARGE_STATES = ["ALREADY_CHARGED_TO_REQUIRED_LEVEL", "CURRENTLY_CHARGING", "FULLY_CHARGED", "NOT_CONNECTED_TO_POWER"];
const RESOURCE_TYPES = ["WATER"];
const MAINTENANCE_ACTIONS = ["EMPTY_BIN"];
// A field that was not given is left out of the payload
function given(fields) {
return Object.fromEntries(Object.entries(fields).filter(([, value]) => value !== undefined));
}
exports.AlexaErrors = {
/** An error of any type. */
of(type, message, extra = {}) {
return new AlexaError(type, message, extra);
},
/** The value is outside what the endpoint takes. For a temperature: temperatureOutOfRange(). */
// TypeScript refuses a call without a required field. A JavaScript caller hears of it here, where the helper is
// called: the payload would reach Alexa without the field.
function required(helper, field, value, values) {
if (values.includes(value))
return value;
throw new TypeError(`AlexaErrors.${helper}() got ${JSON.stringify(value)} as ${field}: pass one of ${values.join(", ")}`);
}
function range(helper, validRange) {
if (validRange === undefined)
return undefined;
const { minimumValue, maximumValue } = validRange;
if (minimumValue === undefined || maximumValue === undefined) {
throw new TypeError(`AlexaErrors.${helper}() got a validRange without ${minimumValue === undefined ? "minimumValue" : "maximumValue"}: pass both ends, or no range`);
}
return { minimumValue, maximumValue };
}
// The helpers of the types whose payload has fields next to type and message. A required field is a required
// argument; a field the page calls optional can be left out.
const withFields = {
/** The value is outside what the endpoint takes. For a temperature: temperatureValueOutOfRange(). */
valueOutOfRange(message, validRange) {
return new AlexaError("VALUE_OUT_OF_RANGE", message, { validRange });
return new AlexaError("VALUE_OUT_OF_RANGE", message, given({ validRange: range("valueOutOfRange", validRange) }));
},
temperatureOutOfRange(message, validRange) {
return new AlexaError("TEMPERATURE_VALUE_OUT_OF_RANGE", message, { validRange });
temperatureValueOutOfRange(message, validRange) {
const helper = "temperatureValueOutOfRange";
return new AlexaError("TEMPERATURE_VALUE_OUT_OF_RANGE", message, given({ validRange: range(helper, validRange) }));
},
/** A light showing a color asked for a color temperature: "COLOR". */
notSupportedInCurrentMode(message, currentDeviceMode) {
return new AlexaError("NOT_SUPPORTED_IN_CURRENT_MODE", message, { currentDeviceMode });
const mode = required("notSupportedInCurrentMode", "currentDeviceMode", currentDeviceMode, CURRENT_DEVICE_MODES);
return new AlexaError("NOT_SUPPORTED_IN_CURRENT_MODE", message, { currentDeviceMode: mode });
},
/** percentageState: what is left of the battery, 0 to 100. */
endpointLowPower(message, percentageState) {
return new AlexaError("ENDPOINT_LOW_POWER", message, given({ percentageState }));
},
endpointControlUnavailable(message, reason) {
return new AlexaError("ENDPOINT_CONTROL_UNAVAILABLE", message, { reason });
return new AlexaError("ENDPOINT_CONTROL_UNAVAILABLE", message, {
reason: required("endpointControlUnavailable", "reason", reason, REASONS),
});
},
/** currentChargeLevelInPercentage: the battery level, 0 to 100. */
notSupportedWithCurrentBatteryChargeState(message, currentChargeState, currentChargeLevelInPercentage) {
return new AlexaError("NOT_SUPPORTED_WITH_CURRENT_BATTERY_CHARGE_STATE", message, given({ currentChargeState, currentChargeLevelInPercentage }));
const helper = "notSupportedWithCurrentBatteryChargeState";
return new AlexaError("NOT_SUPPORTED_WITH_CURRENT_BATTERY_CHARGE_STATE", message, given({
currentChargeState: required(helper, "currentChargeState", currentChargeState, CHARGE_STATES),
currentChargeLevelInPercentage,
}));
},
/** What has to be refilled. */
insufficientResource(message, resourceType) {
return new AlexaError("INSUFFICIENT_RESOURCE", message, { resourceType });
return new AlexaError("INSUFFICIENT_RESOURCE", message, {
resourceType: required("insufficientResource", "resourceType", resourceType, RESOURCE_TYPES),
});
},
/** What the user has to do first. */
maintenanceRequired(message, maintenanceAction) {
return new AlexaError("MAINTENANCE_REQUIRED", message, given({ maintenanceAction }));
const action = maintenanceAction === undefined
? undefined
: required("maintenanceRequired", "maintenanceAction", maintenanceAction, MAINTENANCE_ACTIONS);
return new AlexaError("MAINTENANCE_REQUIRED", message, given({ maintenanceAction: action }));
},
/** Goes under Alexa.ThermostatController. minimumTemperatureDelta: how far apart the setpoints have to be. */
setpointsTooClose(message, minimumTemperatureDelta) {
requestedSetpointsTooClose(message, minimumTemperatureDelta) {
return new AlexaError("REQUESTED_SETPOINTS_TOO_CLOSE", message, given({ minimumTemperatureDelta }));
},
/** Goes under Alexa.SecurityPanelController. With the endpoints listed, the user can bypass them by voice. */
@ -72,3 +106,26 @@ exports.AlexaErrors = {
return new AlexaError("BYPASS_NEEDED", message, given({ endpointsNeedingBypass }));
},
};
const camelCase = (type) => type.toLowerCase().replace(/_([a-z])/g, (_, letter) => letter.toUpperCase());
const plain = Object.fromEntries(Object.keys(catalog_js_1.ERROR_TYPES)
.filter((type) => !Object.prototype.hasOwnProperty.call(withFields, camelCase(type)))
.map((type) => [camelCase(type), (message) => new AlexaError(type, message)]));
/**
* An error for every type of the table of alexa-errorresponse.html, under the name of the type in camel case:
*
* throw AlexaErrors.endpointUnreachable("the lamp does not answer");
* throw AlexaErrors.valueOutOfRange("the lift goes from 0 to 100", { minimumValue: 0, maximumValue: 100 });
* throw AlexaErrors.thermostatIsOff("the thermostat is off"); // sent under Alexa.ThermostatController
*/
exports.AlexaErrors = {
...plain,
...withFields,
/** An error of any type, one the table does not have too. */
of(type, message, extra = {}) {
return new AlexaError(type, message, extra);
},
/** temperatureValueOutOfRange() under its shorter name. */
temperatureOutOfRange: withFields.temperatureValueOutOfRange,
/** requestedSetpointsTooClose() under its shorter name. */
setpointsTooClose: withFields.requestedSetpointsTooClose,
};

View file

@ -159,7 +159,7 @@ declare const Connectivity: {
export declare const PowerController: import("../index.js").InterfaceDescriptor<{
powerState: {
name: string;
value: import("../registry/schema.js").EnumSchema<"ON" | "OFF">;
value: import("../registry/schema.js").EnumSchema<"OFF" | "ON">;
};
}, {
TurnOn: {
@ -182,7 +182,7 @@ export declare const EndpointHealth: import("../index.js").InterfaceDescriptor<{
connectivity: {
name: string;
value: import("../index.js").Schema<import("../registry/schema.js").InferShape<{
value: import("../registry/schema.js").EnumSchema<"OK" | "UNREACHABLE">;
value: import("../registry/schema.js").EnumSchema<"UNREACHABLE" | "OK">;
reason: import("../registry/schema.js").OptionalSchema<"UNKNOWN" | "WIFI_BAD_PASSWORD" | "WIFI_AP_NOT_FOUND" | "WIFI_ROUTER_UNREACHABLE" | "WIFI_AP_CHANNEL_QUALITY_LOW" | "INTERNET_UNREACHABLE" | "CAPTIVE_PORTAL_CHECK_FAILED">;
}>>;
note: string;

4
dist/esm/index.d.ts vendored
View file

@ -9,10 +9,10 @@ export { Alexa, BrightnessController, ChannelController, ColorController, ColorT
export { PowerController, EndpointHealth } from "./compat/enums.js";
export { asset, text, semantics, SemanticsBuilder } from "./registry/index.js";
export { ASSETS as Assets, UNITS_OF_MEASURE as Units, ACTIONS as Actions, STATES as States, CAUSES as Causes, DISPLAY_CATEGORIES as DisplayCategories, INPUTS as Inputs, THERMOSTAT_MODES as ThermostatModes, } from "./registry/index.js";
export type { ActionId, AssetId, DisplayCategoryName, StateId, UnitOfMeasure, ActionsToDirective, AnyDescriptor, CapabilityExtras, Declared, DirectiveDescriptor, EndpointView, EventDescriptor, InterfaceDescriptor, Label, PropertyDescriptor, Semantics, StatesToRange, StatesToValue, ActionName, StateName, Cause, InputName, InventoryLevel, Mode, ThermostatModeName, Infer, Schema, Temperature, TimeInterval, } from "./registry/index.js";
export type { ActionId, AssetId, DisplayCategoryName, StateId, UnitOfMeasure, ActionsToDirective, AnyDescriptor, CapabilityExtras, Declared, DirectiveDescriptor, EndpointView, EventDescriptor, InterfaceDescriptor, Label, PropertyDescriptor, Semantics, StatesToRange, StatesToValue, ActionName, StateName, Cause, ErrorType, InputName, InventoryLevel, Mode, ThermostatModeName, Infer, Schema, Temperature, TimeInterval, } from "./registry/index.js";
export * as messages from "./messages/index.js";
export { AlexaError, AlexaErrors, MessageError, StateBuilder, property } from "./messages/index.js";
export type { ChangeCause, ChangeReportMessage, DeferredResponseMessage, ErrorResponseMessage, Header, ProactiveEventFields, ProactiveEventMessage, Property, PropertyOptions, ResponseMessage, SceneEventMessage, } from "./messages/index.js";
export type { ChangeCause, ChangeReportMessage, ChargeState, ControlUnavailableReason, CurrentDeviceMode, DeferredResponseMessage, EndpointNeedingBypass, ErrorResponseMessage, Header, MaintenanceAction, ProactiveEventFields, ProactiveEventMessage, Property, PropertyOptions, ResourceType, ResponseMessage, SceneEventMessage, ValidRange, } from "./messages/index.js";
export * as topics from "./topics.js";
export { MemoryPublisher } from "./transport.js";
export type { Publisher, PublishResult } from "./transport.js";

View file

@ -1,3 +1,4 @@
import type { ErrorType } from "../registry/catalog.js";
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
@ -17,36 +18,145 @@ export declare class AlexaError extends Error {
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;
declare const CURRENT_DEVICE_MODES: readonly ["ASLEEP", "COLOR", "DEMAND_RESPONSE", "ECO", "NOT_PROVISIONED", "VACATION", "OTHER"];
declare const REASONS: readonly ["DEEP_SLEEP_MODE", "OUT_OF_NETWORK_CONNECTIVITY", "NO_CONNECTIVITY_PACKAGE_ENABLED", "UNKNOWN"];
declare const CHARGE_STATES: readonly ["ALREADY_CHARGED_TO_REQUIRED_LEVEL", "CURRENTLY_CHARGING", "FULLY_CHARGED", "NOT_CONNECTED_TO_POWER"];
declare const RESOURCE_TYPES: readonly ["WATER"];
declare const MAINTENANCE_ACTIONS: readonly ["EMPTY_BIN"];
export type CurrentDeviceMode = (typeof CURRENT_DEVICE_MODES)[number];
export type ControlUnavailableReason = (typeof REASONS)[number];
export type ChargeState = (typeof CHARGE_STATES)[number];
export type ResourceType = (typeof RESOURCE_TYPES)[number];
export type MaintenanceAction = (typeof MAINTENANCE_ACTIONS)[number];
/** The acceptable values of a setting: both ends, as numbers or as temperatures. */
export interface ValidRange<T> {
minimumValue: T;
maximumValue: T;
}
/** A sensor that is open while the panel is armed: Alexa says the name, and bypasses the ones with an endpointId. */
export interface EndpointNeedingBypass {
friendlyName: string;
endpointId?: string;
}
declare const withFields: {
/** The value is outside what the endpoint takes. For a temperature: temperatureValueOutOfRange(). */
valueOutOfRange(message: string, validRange?: ValidRange<number>): AlexaError;
temperatureValueOutOfRange(message: string, validRange?: ValidRange<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;
/** currentChargeLevelInPercentage: the battery level, 0 to 100. */
notSupportedWithCurrentBatteryChargeState(message: string, currentChargeState: ChargeState, currentChargeLevelInPercentage?: number): AlexaError;
/** What has to be refilled. */
insufficientResource(message: string, resourceType: "WATER"): AlexaError;
insufficientResource(message: string, resourceType: ResourceType): AlexaError;
/** What the user has to do first. */
maintenanceRequired(message: string, maintenanceAction?: "EMPTY_BIN"): AlexaError;
maintenanceRequired(message: string, maintenanceAction?: MaintenanceAction): AlexaError;
/** Goes under Alexa.ThermostatController. minimumTemperatureDelta: how far apart the setpoints have to be. */
setpointsTooClose(message: string, minimumTemperatureDelta?: Temperature): AlexaError;
requestedSetpointsTooClose(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;
bypassNeeded(message: string, endpointsNeedingBypass?: EndpointNeedingBypass[]): AlexaError;
};
type CamelCase<S extends string> = S extends `${infer First}_${infer Rest}` ? `${Lowercase<First>}${Capitalize<CamelCase<Rest>>}` : Lowercase<S>;
/** The helpers of the types whose payload is the type and the message: AlexaErrors.endpointUnreachable(message). */
export type PlainErrorHelpers = {
[T in ErrorType as CamelCase<T> extends keyof typeof withFields ? never : CamelCase<T>]: (message: string) => AlexaError;
};
/**
* An error for every type of the table of alexa-errorresponse.html, under the name of the type in camel case:
*
* throw AlexaErrors.endpointUnreachable("the lamp does not answer");
* throw AlexaErrors.valueOutOfRange("the lift goes from 0 to 100", { minimumValue: 0, maximumValue: 100 });
* throw AlexaErrors.thermostatIsOff("the thermostat is off"); // sent under Alexa.ThermostatController
*/
export declare const AlexaErrors: {
/** An error of any type, one the table does not have too. */
of(type: string, message: string, extra?: Record<string, unknown>): AlexaError;
/** temperatureValueOutOfRange() under its shorter name. */
temperatureOutOfRange: (message: string, validRange?: ValidRange<Temperature>) => AlexaError;
/** requestedSetpointsTooClose() under its shorter name. */
setpointsTooClose: (message: string, minimumTemperatureDelta?: Temperature) => AlexaError;
/** The value is outside what the endpoint takes. For a temperature: temperatureValueOutOfRange(). */
valueOutOfRange(message: string, validRange?: ValidRange<number>): AlexaError;
temperatureValueOutOfRange(message: string, validRange?: ValidRange<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;
/** currentChargeLevelInPercentage: the battery level, 0 to 100. */
notSupportedWithCurrentBatteryChargeState(message: string, currentChargeState: ChargeState, currentChargeLevelInPercentage?: number): AlexaError;
/** What has to be refilled. */
insufficientResource(message: string, resourceType: ResourceType): AlexaError;
/** What the user has to do first. */
maintenanceRequired(message: string, maintenanceAction?: MaintenanceAction): AlexaError;
/** Goes under Alexa.ThermostatController. minimumTemperatureDelta: how far apart the setpoints have to be. */
requestedSetpointsTooClose(message: string, minimumTemperatureDelta?: Temperature): AlexaError;
/** Goes under Alexa.SecurityPanelController. With the endpoints listed, the user can bypass them by voice. */
bypassNeeded(message: string, endpointsNeedingBypass?: EndpointNeedingBypass[]): AlexaError;
alreadyInOperation: (message: string) => AlexaError;
bridgeUnreachable: (message: string) => AlexaError;
cloudControlDisabled: (message: string) => AlexaError;
deviceStuck: (message: string) => AlexaError;
doNotDisturbMode: (message: string) => AlexaError;
endpointBusy: (message: string) => AlexaError;
endpointUnreachable: (message: string) => AlexaError;
expiredAuthorizationCredential: (message: string) => AlexaError;
firmwareOutOfDate: (message: string) => AlexaError;
hardwareMalfunction: (message: string) => AlexaError;
insufficientPermissions: (message: string) => AlexaError;
internalError: (message: string) => AlexaError;
invalidAuthorizationCredential: (message: string) => AlexaError;
invalidDirective: (message: string) => AlexaError;
invalidValue: (message: string) => AlexaError;
noSuchEndpoint: (message: string) => AlexaError;
notCalibrated: (message: string) => AlexaError;
notInOperation: (message: string) => AlexaError;
partnerApplicationRedirection: (message: string) => AlexaError;
powerLevelNotSupported: (message: string) => AlexaError;
rateLimitExceeded: (message: string) => AlexaError;
tooManyFailedAttempts: (message: string) => AlexaError;
unableToCharge: (message: string) => AlexaError;
failedToBootstrapCommissioningProcess: (message: string) => AlexaError;
maxCommissioningLimitReached: (message: string) => AlexaError;
childLock: (message: string) => AlexaError;
cookDurationTooLong: (message: string) => AlexaError;
doorClosedTooLong: (message: string) => AlexaError;
doorOpen: (message: string) => AlexaError;
preheatRequired: (message: string) => AlexaError;
probeRequired: (message: string) => AlexaError;
remoteStartNotSupported: (message: string) => AlexaError;
removeProbe: (message: string) => AlexaError;
remoteStartDisabled: (message: string) => AlexaError;
dataDeletionNotSupported: (message: string) => AlexaError;
dataRetrievalNotSupported: (message: string) => AlexaError;
obstacleDetected: (message: string) => AlexaError;
safetyBeamBreached: (message: string) => AlexaError;
authorizationRequired: (message: string) => AlexaError;
notReady: (message: string) => AlexaError;
unauthorized: (message: string) => AlexaError;
unclearedAlarm: (message: string) => AlexaError;
unclearedTrouble: (message: string) => AlexaError;
subscriptionRequired: (message: string) => AlexaError;
disabledByUser: (message: string) => AlexaError;
dualSetpointsUnsupported: (message: string) => AlexaError;
thermostatIsOff: (message: string) => AlexaError;
tripleSetpointsUnsupported: (message: string) => AlexaError;
unsupportedThermostatMode: (message: string) => AlexaError;
unwillingToSetSchedule: (message: string) => AlexaError;
unwillingToSetValue: (message: string) => AlexaError;
configurationUpdateNotAllowed: (message: string) => AlexaError;
coolingLockoutTemperatureValueOutOfRange: (message: string) => AlexaError;
coolingStagesExceedsLimit: (message: string) => AlexaError;
heatingLockoutTemperatureValueOutOfRange: (message: string) => AlexaError;
heatingStagesExceedsLimit: (message: string) => AlexaError;
invalidAuxiliaryHeatingSystemType: (message: string) => AlexaError;
invalidSystemType: (message: string) => AlexaError;
invalidTargetState: (message: string) => AlexaError;
invalidTemperatureScale: (message: string) => AlexaError;
invalidTerminalConnection: (message: string) => AlexaError;
missingSetupInformation: (message: string) => AlexaError;
insufficientSpace: (message: string) => AlexaError;
};
export {};

View file

@ -1,5 +1,5 @@
// The errors a device answers a directive with (alexa-errorresponse.html). A helper for each type whose payload
// has fields of its own, so that the fields cannot be misspelt.
// The errors a device answers a directive with (alexa-errorresponse.html): a helper for each type of the table.
// The helper of a type whose payload has fields of its own takes them, so that they cannot be misspelt or left out.
import { ERROR_TYPES } from "../registry/catalog.js";
/**
* The namespace an ErrorResponse of this type goes under: the one the table of error types lists it with
@ -20,46 +20,80 @@ export class AlexaError extends Error {
this.namespace = namespace;
}
}
// alexa-errorresponse.html, "Properties and objects": the values a field takes
const CURRENT_DEVICE_MODES = ["ASLEEP", "COLOR", "DEMAND_RESPONSE", "ECO", "NOT_PROVISIONED", "VACATION", "OTHER"];
const REASONS = ["DEEP_SLEEP_MODE", "OUT_OF_NETWORK_CONNECTIVITY", "NO_CONNECTIVITY_PACKAGE_ENABLED", "UNKNOWN"];
const CHARGE_STATES = ["ALREADY_CHARGED_TO_REQUIRED_LEVEL", "CURRENTLY_CHARGING", "FULLY_CHARGED", "NOT_CONNECTED_TO_POWER"];
const RESOURCE_TYPES = ["WATER"];
const MAINTENANCE_ACTIONS = ["EMPTY_BIN"];
// A field that was not given is left out of the payload
function given(fields) {
return Object.fromEntries(Object.entries(fields).filter(([, value]) => value !== undefined));
}
export const AlexaErrors = {
/** An error of any type. */
of(type, message, extra = {}) {
return new AlexaError(type, message, extra);
},
/** The value is outside what the endpoint takes. For a temperature: temperatureOutOfRange(). */
// TypeScript refuses a call without a required field. A JavaScript caller hears of it here, where the helper is
// called: the payload would reach Alexa without the field.
function required(helper, field, value, values) {
if (values.includes(value))
return value;
throw new TypeError(`AlexaErrors.${helper}() got ${JSON.stringify(value)} as ${field}: pass one of ${values.join(", ")}`);
}
function range(helper, validRange) {
if (validRange === undefined)
return undefined;
const { minimumValue, maximumValue } = validRange;
if (minimumValue === undefined || maximumValue === undefined) {
throw new TypeError(`AlexaErrors.${helper}() got a validRange without ${minimumValue === undefined ? "minimumValue" : "maximumValue"}: pass both ends, or no range`);
}
return { minimumValue, maximumValue };
}
// The helpers of the types whose payload has fields next to type and message. A required field is a required
// argument; a field the page calls optional can be left out.
const withFields = {
/** The value is outside what the endpoint takes. For a temperature: temperatureValueOutOfRange(). */
valueOutOfRange(message, validRange) {
return new AlexaError("VALUE_OUT_OF_RANGE", message, { validRange });
return new AlexaError("VALUE_OUT_OF_RANGE", message, given({ validRange: range("valueOutOfRange", validRange) }));
},
temperatureOutOfRange(message, validRange) {
return new AlexaError("TEMPERATURE_VALUE_OUT_OF_RANGE", message, { validRange });
temperatureValueOutOfRange(message, validRange) {
const helper = "temperatureValueOutOfRange";
return new AlexaError("TEMPERATURE_VALUE_OUT_OF_RANGE", message, given({ validRange: range(helper, validRange) }));
},
/** A light showing a color asked for a color temperature: "COLOR". */
notSupportedInCurrentMode(message, currentDeviceMode) {
return new AlexaError("NOT_SUPPORTED_IN_CURRENT_MODE", message, { currentDeviceMode });
const mode = required("notSupportedInCurrentMode", "currentDeviceMode", currentDeviceMode, CURRENT_DEVICE_MODES);
return new AlexaError("NOT_SUPPORTED_IN_CURRENT_MODE", message, { currentDeviceMode: mode });
},
/** percentageState: what is left of the battery, 0 to 100. */
endpointLowPower(message, percentageState) {
return new AlexaError("ENDPOINT_LOW_POWER", message, given({ percentageState }));
},
endpointControlUnavailable(message, reason) {
return new AlexaError("ENDPOINT_CONTROL_UNAVAILABLE", message, { reason });
return new AlexaError("ENDPOINT_CONTROL_UNAVAILABLE", message, {
reason: required("endpointControlUnavailable", "reason", reason, REASONS),
});
},
/** currentChargeLevelInPercentage: the battery level, 0 to 100. */
notSupportedWithCurrentBatteryChargeState(message, currentChargeState, currentChargeLevelInPercentage) {
return new AlexaError("NOT_SUPPORTED_WITH_CURRENT_BATTERY_CHARGE_STATE", message, given({ currentChargeState, currentChargeLevelInPercentage }));
const helper = "notSupportedWithCurrentBatteryChargeState";
return new AlexaError("NOT_SUPPORTED_WITH_CURRENT_BATTERY_CHARGE_STATE", message, given({
currentChargeState: required(helper, "currentChargeState", currentChargeState, CHARGE_STATES),
currentChargeLevelInPercentage,
}));
},
/** What has to be refilled. */
insufficientResource(message, resourceType) {
return new AlexaError("INSUFFICIENT_RESOURCE", message, { resourceType });
return new AlexaError("INSUFFICIENT_RESOURCE", message, {
resourceType: required("insufficientResource", "resourceType", resourceType, RESOURCE_TYPES),
});
},
/** What the user has to do first. */
maintenanceRequired(message, maintenanceAction) {
return new AlexaError("MAINTENANCE_REQUIRED", message, given({ maintenanceAction }));
const action = maintenanceAction === undefined
? undefined
: required("maintenanceRequired", "maintenanceAction", maintenanceAction, MAINTENANCE_ACTIONS);
return new AlexaError("MAINTENANCE_REQUIRED", message, given({ maintenanceAction: action }));
},
/** Goes under Alexa.ThermostatController. minimumTemperatureDelta: how far apart the setpoints have to be. */
setpointsTooClose(message, minimumTemperatureDelta) {
requestedSetpointsTooClose(message, minimumTemperatureDelta) {
return new AlexaError("REQUESTED_SETPOINTS_TOO_CLOSE", message, given({ minimumTemperatureDelta }));
},
/** Goes under Alexa.SecurityPanelController. With the endpoints listed, the user can bypass them by voice. */
@ -67,3 +101,26 @@ export const AlexaErrors = {
return new AlexaError("BYPASS_NEEDED", message, given({ endpointsNeedingBypass }));
},
};
const camelCase = (type) => type.toLowerCase().replace(/_([a-z])/g, (_, letter) => letter.toUpperCase());
const plain = Object.fromEntries(Object.keys(ERROR_TYPES)
.filter((type) => !Object.prototype.hasOwnProperty.call(withFields, camelCase(type)))
.map((type) => [camelCase(type), (message) => new AlexaError(type, message)]));
/**
* An error for every type of the table of alexa-errorresponse.html, under the name of the type in camel case:
*
* throw AlexaErrors.endpointUnreachable("the lamp does not answer");
* throw AlexaErrors.valueOutOfRange("the lift goes from 0 to 100", { minimumValue: 0, maximumValue: 100 });
* throw AlexaErrors.thermostatIsOff("the thermostat is off"); // sent under Alexa.ThermostatController
*/
export const AlexaErrors = {
...plain,
...withFields,
/** An error of any type, one the table does not have too. */
of(type, message, extra = {}) {
return new AlexaError(type, message, extra);
},
/** temperatureValueOutOfRange() under its shorter name. */
temperatureOutOfRange: withFields.temperatureValueOutOfRange,
/** requestedSetpointsTooClose() under its shorter name. */
setpointsTooClose: withFields.requestedSetpointsTooClose,
};

View file

@ -1,7 +1,7 @@
export { changeReport, deferredResponse, doorbellPress, errorResponse, proactiveEvent, response, sceneEvent, simpleEvent, stateReport, MessageError, } from "./build.js";
export type { ChangeReportFields, DoorbellPressFields, ErrorResponseFields, ProactiveEventFields, ResponseFields, SceneEventFields, SimpleEventFields, } from "./build.js";
export { AlexaError, AlexaErrors, errorNamespace } from "./errors.js";
export type { ChargeState, ControlUnavailableReason, CurrentDeviceMode } from "./errors.js";
export type { ChargeState, ControlUnavailableReason, CurrentDeviceMode, EndpointNeedingBypass, MaintenanceAction, PlainErrorHelpers, ResourceType, ValidRange, } from "./errors.js";
export { property } from "./property.js";
export type { PropertyOptions } from "./property.js";
export { StateBuilder } from "./StateBuilder.js";

View file

@ -42,5 +42,21 @@ export declare const LIMITS: {
readonly additionalAttributeLength: 256;
readonly cookieBytes: 5000;
};
declare const ERROR_TYPES_BY_NAMESPACE: {
readonly Alexa: readonly ["ALREADY_IN_OPERATION", "BRIDGE_UNREACHABLE", "CLOUD_CONTROL_DISABLED", "DEVICE_STUCK", "DO_NOT_DISTURB_MODE", "ENDPOINT_BUSY", "ENDPOINT_CONTROL_UNAVAILABLE", "ENDPOINT_LOW_POWER", "ENDPOINT_UNREACHABLE", "EXPIRED_AUTHORIZATION_CREDENTIAL", "FIRMWARE_OUT_OF_DATE", "HARDWARE_MALFUNCTION", "INSUFFICIENT_PERMISSIONS", "INSUFFICIENT_RESOURCE", "INTERNAL_ERROR", "INVALID_AUTHORIZATION_CREDENTIAL", "INVALID_DIRECTIVE", "INVALID_VALUE", "MAINTENANCE_REQUIRED", "NO_SUCH_ENDPOINT", "NOT_CALIBRATED", "NOT_IN_OPERATION", "NOT_SUPPORTED_IN_CURRENT_MODE", "NOT_SUPPORTED_WITH_CURRENT_BATTERY_CHARGE_STATE", "PARTNER_APPLICATION_REDIRECTION", "POWER_LEVEL_NOT_SUPPORTED", "RATE_LIMIT_EXCEEDED", "TEMPERATURE_VALUE_OUT_OF_RANGE", "TOO_MANY_FAILED_ATTEMPTS", "UNABLE_TO_CHARGE", "VALUE_OUT_OF_RANGE"];
readonly "Alexa.Commissionable.ReportCommissioningInformation": readonly ["FAILED_TO_BOOTSTRAP_COMMISSIONING_PROCESS", "MAX_COMMISSIONING_LIMIT_REACHED"];
readonly "Alexa.Cooking": readonly ["CHILD_LOCK", "COOK_DURATION_TOO_LONG", "DOOR_CLOSED_TOO_LONG", "DOOR_OPEN", "PREHEAT_REQUIRED", "PROBE_REQUIRED", "REMOTE_START_NOT_SUPPORTED", "REMOVE_PROBE", "REMOTE_START_DISABLED"];
readonly "Alexa.DataController": readonly ["DATA_DELETION_NOT_SUPPORTED", "DATA_RETRIEVAL_NOT_SUPPORTED"];
readonly "Alexa.Safety": readonly ["OBSTACLE_DETECTED", "SAFETY_BEAM_BREACHED"];
readonly "Alexa.SecurityPanelController": readonly ["AUTHORIZATION_REQUIRED", "BYPASS_NEEDED", "NOT_READY", "UNAUTHORIZED", "UNCLEARED_ALARM", "UNCLEARED_TROUBLE"];
readonly "Alexa.SmartVision.ObjectDetectionSensor": readonly ["SUBSCRIPTION_REQUIRED"];
readonly "Alexa.SmartVision.SnapshotProvider": readonly ["DISABLED_BY_USER"];
readonly "Alexa.ThermostatController": readonly ["DUAL_SETPOINTS_UNSUPPORTED", "REQUESTED_SETPOINTS_TOO_CLOSE", "THERMOSTAT_IS_OFF", "TRIPLE_SETPOINTS_UNSUPPORTED", "UNSUPPORTED_THERMOSTAT_MODE", "UNWILLING_TO_SET_SCHEDULE", "UNWILLING_TO_SET_VALUE"];
readonly "Alexa.ThermostatController.Configuration": readonly ["CONFIGURATION_UPDATE_NOT_ALLOWED", "COOLING_LOCKOUT_TEMPERATURE_VALUE_OUT_OF_RANGE", "COOLING_STAGES_EXCEEDS_LIMIT", "HEATING_LOCKOUT_TEMPERATURE_VALUE_OUT_OF_RANGE", "HEATING_STAGES_EXCEEDS_LIMIT", "INVALID_AUXILIARY_HEATING_SYSTEM_TYPE", "INVALID_SYSTEM_TYPE", "INVALID_TARGET_STATE", "INVALID_TEMPERATURE_SCALE", "INVALID_TERMINAL_CONNECTION", "MISSING_SETUP_INFORMATION"];
readonly "Alexa.ThermostatController.Schedule": readonly ["INSUFFICIENT_SPACE"];
};
/** "ENDPOINT_UNREACHABLE": a type of the table. */
export type ErrorType = (typeof ERROR_TYPES_BY_NAMESPACE)[keyof typeof ERROR_TYPES_BY_NAMESPACE][number];
/** The 73 error types of the table, each with the namespace its ErrorResponse goes under. */
export declare const ERROR_TYPES: Readonly<Record<string, string>>;
export {};

View file

@ -7,7 +7,7 @@ export declare const EndpointHealth: import("../types.js").InterfaceDescriptor<{
connectivity: {
name: string;
value: import("../schema.js").Schema<import("../schema.js").InferShape<{
value: import("../schema.js").EnumSchema<"OK" | "UNREACHABLE">;
value: import("../schema.js").EnumSchema<"UNREACHABLE" | "OK">;
reason: import("../schema.js").OptionalSchema<"UNKNOWN" | "WIFI_BAD_PASSWORD" | "WIFI_AP_NOT_FOUND" | "WIFI_ROUTER_UNREACHABLE" | "WIFI_AP_CHANNEL_QUALITY_LOW" | "INTERNET_UNREACHABLE" | "CAPTIVE_PORTAL_CHECK_FAILED">;
}>>;
note: string;

View file

@ -1,7 +1,7 @@
export declare const PowerController: import("../types.js").InterfaceDescriptor<{
powerState: {
name: string;
value: import("../schema.js").EnumSchema<"ON" | "OFF">;
value: import("../schema.js").EnumSchema<"OFF" | "ON">;
};
}, {
TurnOn: {

View file

@ -17,25 +17,25 @@ export declare const SecurityPanelController: import("../types.js").InterfaceDes
burglaryAlarm: {
name: string;
value: import("../schema.js").Schema<import("../schema.js").InferShape<{
value: import("../schema.js").EnumSchema<"OK" | "ALARM">;
value: import("../schema.js").EnumSchema<"ALARM" | "OK">;
}>>;
};
fireAlarm: {
name: string;
value: import("../schema.js").Schema<import("../schema.js").InferShape<{
value: import("../schema.js").EnumSchema<"OK" | "ALARM">;
value: import("../schema.js").EnumSchema<"ALARM" | "OK">;
}>>;
};
carbonMonoxideAlarm: {
name: string;
value: import("../schema.js").Schema<import("../schema.js").InferShape<{
value: import("../schema.js").EnumSchema<"OK" | "ALARM">;
value: import("../schema.js").EnumSchema<"ALARM" | "OK">;
}>>;
};
waterAlarm: {
name: string;
value: import("../schema.js").Schema<import("../schema.js").InferShape<{
value: import("../schema.js").EnumSchema<"OK" | "ALARM">;
value: import("../schema.js").EnumSchema<"ALARM" | "OK">;
}>>;
};
}, {

View file

@ -67,5 +67,5 @@ export declare const ThermostatController: import("../types.js").InterfaceDescri
/** The user can set a temperature for a time: SetTargetTemperature comes with holdUntil. Default: false. */
supportsScheduling: import("../schema.js").OptionalSchema<boolean>;
/** The properties the thermostat has. Default: the three setpoints and thermostatMode. */
properties: import("../schema.js").OptionalSchema<("targetSetpoint" | "lowerSetpoint" | "upperSetpoint" | "thermostatMode" | "adaptiveRecoveryStatus")[]>;
properties: import("../schema.js").OptionalSchema<("thermostatMode" | "targetSetpoint" | "lowerSetpoint" | "upperSetpoint" | "adaptiveRecoveryStatus")[]>;
}>, false>;

View file

@ -5,7 +5,7 @@
export declare const ToggleController: import("../types.js").InterfaceDescriptor<{
toggleState: {
name: string;
value: import("../schema.js").EnumSchema<"ON" | "OFF">;
value: import("../schema.js").EnumSchema<"OFF" | "ON">;
};
}, {
TurnOn: {

View file

@ -159,7 +159,7 @@ declare const Connectivity: {
export declare const PowerController: import("../index.js").InterfaceDescriptor<{
powerState: {
name: string;
value: import("../registry/schema.js").EnumSchema<"ON" | "OFF">;
value: import("../registry/schema.js").EnumSchema<"OFF" | "ON">;
};
}, {
TurnOn: {
@ -182,7 +182,7 @@ export declare const EndpointHealth: import("../index.js").InterfaceDescriptor<{
connectivity: {
name: string;
value: import("../index.js").Schema<import("../registry/schema.js").InferShape<{
value: import("../registry/schema.js").EnumSchema<"OK" | "UNREACHABLE">;
value: import("../registry/schema.js").EnumSchema<"UNREACHABLE" | "OK">;
reason: import("../registry/schema.js").OptionalSchema<"UNKNOWN" | "WIFI_BAD_PASSWORD" | "WIFI_AP_NOT_FOUND" | "WIFI_ROUTER_UNREACHABLE" | "WIFI_AP_CHANNEL_QUALITY_LOW" | "INTERNET_UNREACHABLE" | "CAPTIVE_PORTAL_CHECK_FAILED">;
}>>;
note: string;

View file

@ -9,10 +9,10 @@ export { Alexa, BrightnessController, ChannelController, ColorController, ColorT
export { PowerController, EndpointHealth } from "./compat/enums.js";
export { asset, text, semantics, SemanticsBuilder } from "./registry/index.js";
export { ASSETS as Assets, UNITS_OF_MEASURE as Units, ACTIONS as Actions, STATES as States, CAUSES as Causes, DISPLAY_CATEGORIES as DisplayCategories, INPUTS as Inputs, THERMOSTAT_MODES as ThermostatModes, } from "./registry/index.js";
export type { ActionId, AssetId, DisplayCategoryName, StateId, UnitOfMeasure, ActionsToDirective, AnyDescriptor, CapabilityExtras, Declared, DirectiveDescriptor, EndpointView, EventDescriptor, InterfaceDescriptor, Label, PropertyDescriptor, Semantics, StatesToRange, StatesToValue, ActionName, StateName, Cause, InputName, InventoryLevel, Mode, ThermostatModeName, Infer, Schema, Temperature, TimeInterval, } from "./registry/index.js";
export type { ActionId, AssetId, DisplayCategoryName, StateId, UnitOfMeasure, ActionsToDirective, AnyDescriptor, CapabilityExtras, Declared, DirectiveDescriptor, EndpointView, EventDescriptor, InterfaceDescriptor, Label, PropertyDescriptor, Semantics, StatesToRange, StatesToValue, ActionName, StateName, Cause, ErrorType, InputName, InventoryLevel, Mode, ThermostatModeName, Infer, Schema, Temperature, TimeInterval, } from "./registry/index.js";
export * as messages from "./messages/index.js";
export { AlexaError, AlexaErrors, MessageError, StateBuilder, property } from "./messages/index.js";
export type { ChangeCause, ChangeReportMessage, DeferredResponseMessage, ErrorResponseMessage, Header, ProactiveEventFields, ProactiveEventMessage, Property, PropertyOptions, ResponseMessage, SceneEventMessage, } from "./messages/index.js";
export type { ChangeCause, ChangeReportMessage, ChargeState, ControlUnavailableReason, CurrentDeviceMode, DeferredResponseMessage, EndpointNeedingBypass, ErrorResponseMessage, Header, MaintenanceAction, ProactiveEventFields, ProactiveEventMessage, Property, PropertyOptions, ResourceType, ResponseMessage, SceneEventMessage, ValidRange, } from "./messages/index.js";
export * as topics from "./topics.js";
export { MemoryPublisher } from "./transport.js";
export type { Publisher, PublishResult } from "./transport.js";

View file

@ -1,3 +1,4 @@
import type { ErrorType } from "../registry/catalog.js";
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
@ -17,36 +18,145 @@ export declare class AlexaError extends Error {
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;
declare const CURRENT_DEVICE_MODES: readonly ["ASLEEP", "COLOR", "DEMAND_RESPONSE", "ECO", "NOT_PROVISIONED", "VACATION", "OTHER"];
declare const REASONS: readonly ["DEEP_SLEEP_MODE", "OUT_OF_NETWORK_CONNECTIVITY", "NO_CONNECTIVITY_PACKAGE_ENABLED", "UNKNOWN"];
declare const CHARGE_STATES: readonly ["ALREADY_CHARGED_TO_REQUIRED_LEVEL", "CURRENTLY_CHARGING", "FULLY_CHARGED", "NOT_CONNECTED_TO_POWER"];
declare const RESOURCE_TYPES: readonly ["WATER"];
declare const MAINTENANCE_ACTIONS: readonly ["EMPTY_BIN"];
export type CurrentDeviceMode = (typeof CURRENT_DEVICE_MODES)[number];
export type ControlUnavailableReason = (typeof REASONS)[number];
export type ChargeState = (typeof CHARGE_STATES)[number];
export type ResourceType = (typeof RESOURCE_TYPES)[number];
export type MaintenanceAction = (typeof MAINTENANCE_ACTIONS)[number];
/** The acceptable values of a setting: both ends, as numbers or as temperatures. */
export interface ValidRange<T> {
minimumValue: T;
maximumValue: T;
}
/** A sensor that is open while the panel is armed: Alexa says the name, and bypasses the ones with an endpointId. */
export interface EndpointNeedingBypass {
friendlyName: string;
endpointId?: string;
}
declare const withFields: {
/** The value is outside what the endpoint takes. For a temperature: temperatureValueOutOfRange(). */
valueOutOfRange(message: string, validRange?: ValidRange<number>): AlexaError;
temperatureValueOutOfRange(message: string, validRange?: ValidRange<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;
/** currentChargeLevelInPercentage: the battery level, 0 to 100. */
notSupportedWithCurrentBatteryChargeState(message: string, currentChargeState: ChargeState, currentChargeLevelInPercentage?: number): AlexaError;
/** What has to be refilled. */
insufficientResource(message: string, resourceType: "WATER"): AlexaError;
insufficientResource(message: string, resourceType: ResourceType): AlexaError;
/** What the user has to do first. */
maintenanceRequired(message: string, maintenanceAction?: "EMPTY_BIN"): AlexaError;
maintenanceRequired(message: string, maintenanceAction?: MaintenanceAction): AlexaError;
/** Goes under Alexa.ThermostatController. minimumTemperatureDelta: how far apart the setpoints have to be. */
setpointsTooClose(message: string, minimumTemperatureDelta?: Temperature): AlexaError;
requestedSetpointsTooClose(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;
bypassNeeded(message: string, endpointsNeedingBypass?: EndpointNeedingBypass[]): AlexaError;
};
type CamelCase<S extends string> = S extends `${infer First}_${infer Rest}` ? `${Lowercase<First>}${Capitalize<CamelCase<Rest>>}` : Lowercase<S>;
/** The helpers of the types whose payload is the type and the message: AlexaErrors.endpointUnreachable(message). */
export type PlainErrorHelpers = {
[T in ErrorType as CamelCase<T> extends keyof typeof withFields ? never : CamelCase<T>]: (message: string) => AlexaError;
};
/**
* An error for every type of the table of alexa-errorresponse.html, under the name of the type in camel case:
*
* throw AlexaErrors.endpointUnreachable("the lamp does not answer");
* throw AlexaErrors.valueOutOfRange("the lift goes from 0 to 100", { minimumValue: 0, maximumValue: 100 });
* throw AlexaErrors.thermostatIsOff("the thermostat is off"); // sent under Alexa.ThermostatController
*/
export declare const AlexaErrors: {
/** An error of any type, one the table does not have too. */
of(type: string, message: string, extra?: Record<string, unknown>): AlexaError;
/** temperatureValueOutOfRange() under its shorter name. */
temperatureOutOfRange: (message: string, validRange?: ValidRange<Temperature>) => AlexaError;
/** requestedSetpointsTooClose() under its shorter name. */
setpointsTooClose: (message: string, minimumTemperatureDelta?: Temperature) => AlexaError;
/** The value is outside what the endpoint takes. For a temperature: temperatureValueOutOfRange(). */
valueOutOfRange(message: string, validRange?: ValidRange<number>): AlexaError;
temperatureValueOutOfRange(message: string, validRange?: ValidRange<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;
/** currentChargeLevelInPercentage: the battery level, 0 to 100. */
notSupportedWithCurrentBatteryChargeState(message: string, currentChargeState: ChargeState, currentChargeLevelInPercentage?: number): AlexaError;
/** What has to be refilled. */
insufficientResource(message: string, resourceType: ResourceType): AlexaError;
/** What the user has to do first. */
maintenanceRequired(message: string, maintenanceAction?: MaintenanceAction): AlexaError;
/** Goes under Alexa.ThermostatController. minimumTemperatureDelta: how far apart the setpoints have to be. */
requestedSetpointsTooClose(message: string, minimumTemperatureDelta?: Temperature): AlexaError;
/** Goes under Alexa.SecurityPanelController. With the endpoints listed, the user can bypass them by voice. */
bypassNeeded(message: string, endpointsNeedingBypass?: EndpointNeedingBypass[]): AlexaError;
alreadyInOperation: (message: string) => AlexaError;
bridgeUnreachable: (message: string) => AlexaError;
cloudControlDisabled: (message: string) => AlexaError;
deviceStuck: (message: string) => AlexaError;
doNotDisturbMode: (message: string) => AlexaError;
endpointBusy: (message: string) => AlexaError;
endpointUnreachable: (message: string) => AlexaError;
expiredAuthorizationCredential: (message: string) => AlexaError;
firmwareOutOfDate: (message: string) => AlexaError;
hardwareMalfunction: (message: string) => AlexaError;
insufficientPermissions: (message: string) => AlexaError;
internalError: (message: string) => AlexaError;
invalidAuthorizationCredential: (message: string) => AlexaError;
invalidDirective: (message: string) => AlexaError;
invalidValue: (message: string) => AlexaError;
noSuchEndpoint: (message: string) => AlexaError;
notCalibrated: (message: string) => AlexaError;
notInOperation: (message: string) => AlexaError;
partnerApplicationRedirection: (message: string) => AlexaError;
powerLevelNotSupported: (message: string) => AlexaError;
rateLimitExceeded: (message: string) => AlexaError;
tooManyFailedAttempts: (message: string) => AlexaError;
unableToCharge: (message: string) => AlexaError;
failedToBootstrapCommissioningProcess: (message: string) => AlexaError;
maxCommissioningLimitReached: (message: string) => AlexaError;
childLock: (message: string) => AlexaError;
cookDurationTooLong: (message: string) => AlexaError;
doorClosedTooLong: (message: string) => AlexaError;
doorOpen: (message: string) => AlexaError;
preheatRequired: (message: string) => AlexaError;
probeRequired: (message: string) => AlexaError;
remoteStartNotSupported: (message: string) => AlexaError;
removeProbe: (message: string) => AlexaError;
remoteStartDisabled: (message: string) => AlexaError;
dataDeletionNotSupported: (message: string) => AlexaError;
dataRetrievalNotSupported: (message: string) => AlexaError;
obstacleDetected: (message: string) => AlexaError;
safetyBeamBreached: (message: string) => AlexaError;
authorizationRequired: (message: string) => AlexaError;
notReady: (message: string) => AlexaError;
unauthorized: (message: string) => AlexaError;
unclearedAlarm: (message: string) => AlexaError;
unclearedTrouble: (message: string) => AlexaError;
subscriptionRequired: (message: string) => AlexaError;
disabledByUser: (message: string) => AlexaError;
dualSetpointsUnsupported: (message: string) => AlexaError;
thermostatIsOff: (message: string) => AlexaError;
tripleSetpointsUnsupported: (message: string) => AlexaError;
unsupportedThermostatMode: (message: string) => AlexaError;
unwillingToSetSchedule: (message: string) => AlexaError;
unwillingToSetValue: (message: string) => AlexaError;
configurationUpdateNotAllowed: (message: string) => AlexaError;
coolingLockoutTemperatureValueOutOfRange: (message: string) => AlexaError;
coolingStagesExceedsLimit: (message: string) => AlexaError;
heatingLockoutTemperatureValueOutOfRange: (message: string) => AlexaError;
heatingStagesExceedsLimit: (message: string) => AlexaError;
invalidAuxiliaryHeatingSystemType: (message: string) => AlexaError;
invalidSystemType: (message: string) => AlexaError;
invalidTargetState: (message: string) => AlexaError;
invalidTemperatureScale: (message: string) => AlexaError;
invalidTerminalConnection: (message: string) => AlexaError;
missingSetupInformation: (message: string) => AlexaError;
insufficientSpace: (message: string) => AlexaError;
};
export {};

View file

@ -1,7 +1,7 @@
export { changeReport, deferredResponse, doorbellPress, errorResponse, proactiveEvent, response, sceneEvent, simpleEvent, stateReport, MessageError, } from "./build.js";
export type { ChangeReportFields, DoorbellPressFields, ErrorResponseFields, ProactiveEventFields, ResponseFields, SceneEventFields, SimpleEventFields, } from "./build.js";
export { AlexaError, AlexaErrors, errorNamespace } from "./errors.js";
export type { ChargeState, ControlUnavailableReason, CurrentDeviceMode } from "./errors.js";
export type { ChargeState, ControlUnavailableReason, CurrentDeviceMode, EndpointNeedingBypass, MaintenanceAction, PlainErrorHelpers, ResourceType, ValidRange, } from "./errors.js";
export { property } from "./property.js";
export type { PropertyOptions } from "./property.js";
export { StateBuilder } from "./StateBuilder.js";

View file

@ -42,5 +42,21 @@ export declare const LIMITS: {
readonly additionalAttributeLength: 256;
readonly cookieBytes: 5000;
};
declare const ERROR_TYPES_BY_NAMESPACE: {
readonly Alexa: readonly ["ALREADY_IN_OPERATION", "BRIDGE_UNREACHABLE", "CLOUD_CONTROL_DISABLED", "DEVICE_STUCK", "DO_NOT_DISTURB_MODE", "ENDPOINT_BUSY", "ENDPOINT_CONTROL_UNAVAILABLE", "ENDPOINT_LOW_POWER", "ENDPOINT_UNREACHABLE", "EXPIRED_AUTHORIZATION_CREDENTIAL", "FIRMWARE_OUT_OF_DATE", "HARDWARE_MALFUNCTION", "INSUFFICIENT_PERMISSIONS", "INSUFFICIENT_RESOURCE", "INTERNAL_ERROR", "INVALID_AUTHORIZATION_CREDENTIAL", "INVALID_DIRECTIVE", "INVALID_VALUE", "MAINTENANCE_REQUIRED", "NO_SUCH_ENDPOINT", "NOT_CALIBRATED", "NOT_IN_OPERATION", "NOT_SUPPORTED_IN_CURRENT_MODE", "NOT_SUPPORTED_WITH_CURRENT_BATTERY_CHARGE_STATE", "PARTNER_APPLICATION_REDIRECTION", "POWER_LEVEL_NOT_SUPPORTED", "RATE_LIMIT_EXCEEDED", "TEMPERATURE_VALUE_OUT_OF_RANGE", "TOO_MANY_FAILED_ATTEMPTS", "UNABLE_TO_CHARGE", "VALUE_OUT_OF_RANGE"];
readonly "Alexa.Commissionable.ReportCommissioningInformation": readonly ["FAILED_TO_BOOTSTRAP_COMMISSIONING_PROCESS", "MAX_COMMISSIONING_LIMIT_REACHED"];
readonly "Alexa.Cooking": readonly ["CHILD_LOCK", "COOK_DURATION_TOO_LONG", "DOOR_CLOSED_TOO_LONG", "DOOR_OPEN", "PREHEAT_REQUIRED", "PROBE_REQUIRED", "REMOTE_START_NOT_SUPPORTED", "REMOVE_PROBE", "REMOTE_START_DISABLED"];
readonly "Alexa.DataController": readonly ["DATA_DELETION_NOT_SUPPORTED", "DATA_RETRIEVAL_NOT_SUPPORTED"];
readonly "Alexa.Safety": readonly ["OBSTACLE_DETECTED", "SAFETY_BEAM_BREACHED"];
readonly "Alexa.SecurityPanelController": readonly ["AUTHORIZATION_REQUIRED", "BYPASS_NEEDED", "NOT_READY", "UNAUTHORIZED", "UNCLEARED_ALARM", "UNCLEARED_TROUBLE"];
readonly "Alexa.SmartVision.ObjectDetectionSensor": readonly ["SUBSCRIPTION_REQUIRED"];
readonly "Alexa.SmartVision.SnapshotProvider": readonly ["DISABLED_BY_USER"];
readonly "Alexa.ThermostatController": readonly ["DUAL_SETPOINTS_UNSUPPORTED", "REQUESTED_SETPOINTS_TOO_CLOSE", "THERMOSTAT_IS_OFF", "TRIPLE_SETPOINTS_UNSUPPORTED", "UNSUPPORTED_THERMOSTAT_MODE", "UNWILLING_TO_SET_SCHEDULE", "UNWILLING_TO_SET_VALUE"];
readonly "Alexa.ThermostatController.Configuration": readonly ["CONFIGURATION_UPDATE_NOT_ALLOWED", "COOLING_LOCKOUT_TEMPERATURE_VALUE_OUT_OF_RANGE", "COOLING_STAGES_EXCEEDS_LIMIT", "HEATING_LOCKOUT_TEMPERATURE_VALUE_OUT_OF_RANGE", "HEATING_STAGES_EXCEEDS_LIMIT", "INVALID_AUXILIARY_HEATING_SYSTEM_TYPE", "INVALID_SYSTEM_TYPE", "INVALID_TARGET_STATE", "INVALID_TEMPERATURE_SCALE", "INVALID_TERMINAL_CONNECTION", "MISSING_SETUP_INFORMATION"];
readonly "Alexa.ThermostatController.Schedule": readonly ["INSUFFICIENT_SPACE"];
};
/** "ENDPOINT_UNREACHABLE": a type of the table. */
export type ErrorType = (typeof ERROR_TYPES_BY_NAMESPACE)[keyof typeof ERROR_TYPES_BY_NAMESPACE][number];
/** The 73 error types of the table, each with the namespace its ErrorResponse goes under. */
export declare const ERROR_TYPES: Readonly<Record<string, string>>;
export {};

View file

@ -7,7 +7,7 @@ export declare const EndpointHealth: import("../types.js").InterfaceDescriptor<{
connectivity: {
name: string;
value: import("../schema.js").Schema<import("../schema.js").InferShape<{
value: import("../schema.js").EnumSchema<"OK" | "UNREACHABLE">;
value: import("../schema.js").EnumSchema<"UNREACHABLE" | "OK">;
reason: import("../schema.js").OptionalSchema<"UNKNOWN" | "WIFI_BAD_PASSWORD" | "WIFI_AP_NOT_FOUND" | "WIFI_ROUTER_UNREACHABLE" | "WIFI_AP_CHANNEL_QUALITY_LOW" | "INTERNET_UNREACHABLE" | "CAPTIVE_PORTAL_CHECK_FAILED">;
}>>;
note: string;

View file

@ -1,7 +1,7 @@
export declare const PowerController: import("../types.js").InterfaceDescriptor<{
powerState: {
name: string;
value: import("../schema.js").EnumSchema<"ON" | "OFF">;
value: import("../schema.js").EnumSchema<"OFF" | "ON">;
};
}, {
TurnOn: {

View file

@ -17,25 +17,25 @@ export declare const SecurityPanelController: import("../types.js").InterfaceDes
burglaryAlarm: {
name: string;
value: import("../schema.js").Schema<import("../schema.js").InferShape<{
value: import("../schema.js").EnumSchema<"OK" | "ALARM">;
value: import("../schema.js").EnumSchema<"ALARM" | "OK">;
}>>;
};
fireAlarm: {
name: string;
value: import("../schema.js").Schema<import("../schema.js").InferShape<{
value: import("../schema.js").EnumSchema<"OK" | "ALARM">;
value: import("../schema.js").EnumSchema<"ALARM" | "OK">;
}>>;
};
carbonMonoxideAlarm: {
name: string;
value: import("../schema.js").Schema<import("../schema.js").InferShape<{
value: import("../schema.js").EnumSchema<"OK" | "ALARM">;
value: import("../schema.js").EnumSchema<"ALARM" | "OK">;
}>>;
};
waterAlarm: {
name: string;
value: import("../schema.js").Schema<import("../schema.js").InferShape<{
value: import("../schema.js").EnumSchema<"OK" | "ALARM">;
value: import("../schema.js").EnumSchema<"ALARM" | "OK">;
}>>;
};
}, {

View file

@ -67,5 +67,5 @@ export declare const ThermostatController: import("../types.js").InterfaceDescri
/** The user can set a temperature for a time: SetTargetTemperature comes with holdUntil. Default: false. */
supportsScheduling: import("../schema.js").OptionalSchema<boolean>;
/** The properties the thermostat has. Default: the three setpoints and thermostatMode. */
properties: import("../schema.js").OptionalSchema<("targetSetpoint" | "lowerSetpoint" | "upperSetpoint" | "thermostatMode" | "adaptiveRecoveryStatus")[]>;
properties: import("../schema.js").OptionalSchema<("thermostatMode" | "targetSetpoint" | "lowerSetpoint" | "upperSetpoint" | "adaptiveRecoveryStatus")[]>;
}>, false>;

View file

@ -5,7 +5,7 @@
export declare const ToggleController: import("../types.js").InterfaceDescriptor<{
toggleState: {
name: string;
value: import("../schema.js").EnumSchema<"ON" | "OFF">;
value: import("../schema.js").EnumSchema<"OFF" | "ON">;
};
}, {
TurnOn: {