src/registry/ holds what the library knows about an interface: namespace, version, the page it was read from, properties with their value schemas and directives with their payload schemas. Five interfaces are described (Alexa, PowerController, BrightnessController, TemperatureSensor, EndpointHealth); the other 65 names of AlexaInterfaceType are stubs with the version and property names of 1.5.2. schema.ts is the run-time check behind it (241 lines, no new dependency), catalog.ts the vocabularies of the pages: 103 assets (23 units), 6 actions, 9 states, 56 display categories, 22 reserved words, 73 error types under 11 namespaces. AlexaInterface.getVersion() and getProps() read the registry; the two switch statements are gone (-167 lines). On the wire: Alexa.EndpointHealth is announced at 3.1 (was 3.3; the page is titled 3.1 and no page mentions 3.3), and TimeHoldController and Camera.LiveViewController at 3 and 1.7 (1.5.2 sent the string "UNKNOWN"). DisplayCategory gains VACUUM. New exports: registry, DeclarationError, SchemaError, Assets, Units, Actions, States, DisplayCategories and the descriptor types. Tests: 20 JSON examples of the five pages under test/fixtures/alexa-docs; every directive payload and property value in them parses with its descriptor. npm test: 57 pass (was 30) in 10.8 s, also on Node 18.20.8 and 20.20.2. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
109 lines
5.4 KiB
TypeScript
109 lines
5.4 KiB
TypeScript
import type { ActionMapping } from "./ActionMapping.js";
|
|
export declare enum AlexaInterfaceType {
|
|
APPLICATION_STATE_REPORTER = "Alexa.ApplicationStateReporter",
|
|
AUDIO_PLAY_QUEUE = "Alexa.Audio.PlayQueue",
|
|
AUTHORIZATION_CONTROLLER = "Alexa.AuthorizationController",
|
|
AUTOMATION_MANAGEMENT = "Alexa.AutomationManagement",
|
|
AUTOMOTIVE_VEHICLE_DATA = "Alexa.Automotive.VehicleData",
|
|
BRIGHTNESS_CONTROLLER = "Alexa.BrightnessController",
|
|
CAMERA_LIVE_VIEW_CONTROLLER = "Alexa.Camera.LiveViewController",
|
|
CAMERA_STREAM_CONTROLLER = "Alexa.CameraStreamController",
|
|
CHANNEL_CONTROLLER = "Alexa.ChannelController",
|
|
COLOR_CONTROLLER = "Alexa.ColorController",
|
|
COLOR_TEMPERATURE_CONTROLLER = "Alexa.ColorTemperatureController",
|
|
COMMISSIONABLE = "Alexa.Commissionable",
|
|
CONSENT_MANAGEMENT_CONSENT_REQUIRED_REPORTER = "Alexa.ConsentManagement.ConsentRequiredReporter",
|
|
CONTACT_SENSOR = "Alexa.ContactSensor",
|
|
COOKING = "Alexa.Cooking",
|
|
COOKING_FOOD_TEMPERATURE_CONTROLLER = "Alexa.Cooking.FoodTemperatureController",
|
|
COOKING_FOOD_TEMPERATURE_SENSOR = "Alexa.Cooking.FoodTemperatureSensor",
|
|
COOKING_PRESET_CONTROLLER = "Alexa.Cooking.PresetController",
|
|
COOKING_TEMPERATURE_CONTROLLER = "Alexa.Cooking.TemperatureController",
|
|
COOKING_TEMPERATURE_SENSOR = "Alexa.Cooking.TemperatureSensor",
|
|
COOKING_TIME_CONTROLLER = "Alexa.Cooking.TimeController",
|
|
DATA_CONTROLLER = "Alexa.DataController",
|
|
DEVICE_USAGE_ESTIMATION = "Alexa.DeviceUsage.Estimation",
|
|
DEVICE_USAGE_METER = "Alexa.DeviceUsage.Meter",
|
|
DOORBELL_EVENT_SOURCE = "Alexa.DoorbellEventSource",
|
|
ENDPOINT_HEALTH = "Alexa.EndpointHealth",
|
|
EQUALIZER_CONTROLLER = "Alexa.EqualizerController",
|
|
INPUT_CONTROLLER = "Alexa.InputController",
|
|
INVENTORY_LEVEL_SENSOR = "Alexa.InventoryLevelSensor",
|
|
INVENTORY_LEVEL_USAGE_SENSOR = "Alexa.InventoryLevelUsageSensor",
|
|
INVENTORY_USAGE_SENSOR = "Alexa.InventoryUsageSensor",
|
|
KEYPAD_CONTROLLER = "Alexa.KeypadController",
|
|
LAUNCHER = "Alexa.Launcher",
|
|
LOCK_CONTROLLER = "Alexa.LockController",
|
|
MEDIA_PLAYBACK = "Alexa.Media.Playback",
|
|
MEDIA_PLAY_QUEUE = "Alexa.Media.PlayQueue",
|
|
MEDIA_SEARCH = "Alexa.Media.Search",
|
|
MODE_CONTROLLER = "Alexa.ModeController",
|
|
MOTION_SENSOR = "Alexa.MotionSensor",
|
|
PERCENTAGE_CONTROLLER = "Alexa.PercentageController",
|
|
PLAYBACK_CONTROLLER = "Alexa.PlaybackController",
|
|
PLAYBACK_STATE_REPORTER = "Alexa.PlaybackStateReporter",
|
|
POWER_CONTROLLER = "Alexa.PowerController",
|
|
POWER_LEVEL_CONTROLLER = "Alexa.PowerLevelController",
|
|
PROACTIVE_NOTIFICATION_SOURCE = "Alexa.ProactiveNotificationSource",
|
|
RANGE_CONTROLLER = "Alexa.RangeController",
|
|
RECORD_CONTROLLER = "Alexa.RecordController",
|
|
REMOTE_VIDEO_PLAYER = "Alexa.RemoteVideoPlayer",
|
|
RTC_SESSION_CONTROLLER = "Alexa.RTCSessionController",
|
|
SCENE_CONTROLLER = "Alexa.SceneController",
|
|
SECURITY_PANEL_CONTROLLER = "Alexa.SecurityPanelController",
|
|
SECURITY_PANEL_CONTROLLER_ALERT = "Alexa.SecurityPanelController.Alert",
|
|
SEEK_CONTROLLER = "Alexa.SeekController",
|
|
SIMPLE_EVENT_SOURCE = "Alexa.SimpleEventSource",
|
|
SMART_VISION_OBJECT_DETECTION_SENSOR = "Alexa.SmartVision.ObjectDetectionSensor",
|
|
SMART_VISION_SNAPSHOT_PROVIDER = "Alexa.SmartVision.SnapshotProvider",
|
|
SPEAKER = "Alexa.Speaker",
|
|
STEP_SPEAKER = "Alexa.StepSpeaker",
|
|
TEMPERATURE_SENSOR = "Alexa.TemperatureSensor",
|
|
THERMOSTAT_CONTROLLER = "Alexa.ThermostatController",
|
|
THERMOSTAT_CONTROLLER_CONFIGURATION = "Alexa.ThermostatController.Configuration",
|
|
THERMOSTAT_CONTROLLER_HVAC_COMPONENTS = "Alexa.ThermostatController.HVAC.Components",
|
|
THERMOSTAT_CONTROLLER_SCHEDULE = "Alexa.ThermostatController.Schedule",
|
|
TIME_HOLD_CONTROLLER = "Alexa.TimeHoldController",
|
|
TOGGLE_CONTROLLER = "Alexa.ToggleController",
|
|
UI_CONTROLLER = "Alexa.UIController",
|
|
USER_PREFERENCE = "Alexa.UserPreference",
|
|
VIDEO_RECORDER = "Alexa.VideoRecorder",
|
|
WAKE_ON_LAN_CONTROLLER = "Alexa.WakeOnLANController",
|
|
UNKNOWN = "UNKNOWN"
|
|
}
|
|
/** One ModeController mode as discovery lists it (configuration.supportedModes): the value plus its friendly names. */
|
|
export interface SupportedMode {
|
|
value: string;
|
|
modeResources?: {
|
|
friendlyNames: Array<{
|
|
"@type": string;
|
|
value: {
|
|
text?: string;
|
|
locale?: string;
|
|
assetId?: string;
|
|
};
|
|
}>;
|
|
};
|
|
}
|
|
export declare class AlexaInterface {
|
|
type: AlexaInterfaceType;
|
|
retrievable: boolean;
|
|
proactivelyReported: boolean;
|
|
instance: string;
|
|
private friendlyNames;
|
|
private actionMappings;
|
|
private supportedModes;
|
|
constructor(type: AlexaInterfaceType, retrievable?: boolean, proactivelyReported?: boolean, instance?: string);
|
|
addActionMapping(mapping: ActionMapping): void;
|
|
addFriendlyName(name: string, locale: string): void;
|
|
/** The modes of a ModeController: { value, modeResources } objects as Alexa wants them (plain strings pass through as given). */
|
|
addSupportedModes(modes: Array<string | SupportedMode>): void;
|
|
setInstance(name: string): void;
|
|
getType(): AlexaInterfaceType;
|
|
getTypeString(): string;
|
|
/** The version of the interface, from its descriptor. "UNKNOWN" for a name the registry does not have. */
|
|
getVersion(): string;
|
|
/** The names of the properties the interface reports, from its descriptor. */
|
|
getProps(): string[];
|
|
getJSON(): object;
|
|
}
|