Alex2Node/dist/cjs/registry/interfaces/InputController.js
David d7dfc5b122 registry: Speaker, StepSpeaker, EqualizerController, PlaybackController, PlaybackStateReporter, InputController, ChannelController
Seven descriptors written from their pages replace seven stubs. All are version 3; 1.5.2 announced Speaker,
StepSpeaker, EqualizerController and PlaybackStateReporter as version 1, and all but ChannelController without
a property. StepSpeaker has no properties object in discovery and PlaybackController one without fields, next
to supportedOperations; a directive for an operation the device did not list is answered with
INVALID_DIRECTIVE. The equalizer declares bands, modes or both under "configurations", a TV its inputs from
the 61 names of the page.

Not described: the lineup of ChannelController, whose discovery example the page folds away. The discovery
examples of InputController spell one key "friendNames"; the fixtures have friendlyNames, as its table does.
62 examples of the six pages are saved as fixtures. 241 tests pass, 215 before.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-28 20:54:53 +00:00

49 lines
2.7 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.InputController = exports.INPUTS = void 0;
const schema_js_1 = require("../schema.js");
const types_js_1 = require("../types.js");
/** alexa-inputcontroller.html, "Input property values". */
exports.INPUTS = [
"AUX 1", "AUX 2", "AUX 3", "AUX 4", "AUX 5", "AUX 6", "AUX 7", "BLURAY", "CABLE", "CD", "COAX 1", "COAX 2",
"COMPOSITE 1", "DVD", "GAME", "HD RADIO", "HDMI 1", "HDMI 2", "HDMI 3", "HDMI 4", "HDMI 5", "HDMI 6", "HDMI 7",
"HDMI 8", "HDMI 9", "HDMI 10", "HDMI ARC", "INPUT 1", "INPUT 2", "INPUT 3", "INPUT 4", "INPUT 5", "INPUT 6",
"INPUT 7", "INPUT 8", "INPUT 9", "INPUT 10", "IPOD", "LINE 1", "LINE 2", "LINE 3", "LINE 4", "LINE 5", "LINE 6",
"LINE 7", "MEDIA PLAYER", "OPTICAL 1", "OPTICAL 2", "PHONO", "PLAYSTATION", "PLAYSTATION 3", "PLAYSTATION 4",
"SATELLITE", "SMARTCAST", "TUNER", "TV", "USB DAC", "VIDEO 1", "VIDEO 2", "VIDEO 3", "XBOX",
];
const input = schema_js_1.s.oneOf(exports.INPUTS, "an input like HDMI 1");
/**
* The input a TV or a receiver shows. The inputs of the device are on the capability itself, as the discovery
* example of the page has them; its table calls them a configuration object.
*/
exports.InputController = (0, types_js_1.defineInterface)({
namespace: "Alexa.InputController",
version: "3",
doc: "https://developer.amazon.com/docs/alexaplus/device-apis/alexa-inputcontroller.html",
kind: "controller",
tier: 2,
instanced: false,
properties: {
input: { name: "input", value: input },
},
directives: {
SelectInput: { name: "SelectInput", payload: schema_js_1.s.object({ input }) },
},
options: schema_js_1.s.object({
/** friendlyNames: what the user calls the input, "Cable" for HDMI 2. */
inputs: schema_js_1.s.array(schema_js_1.s.object({ name: input, friendlyNames: schema_js_1.s.optional(schema_js_1.s.array(schema_js_1.s.string({ min: 1 }))) }, { unknownKeys: "reject" }), { min: 1 }),
}, { unknownKeys: "reject" }),
// A capability declared the 1.x way has no inputs; check() says so
discovery: ({ options: { inputs } }) => (inputs ? { topLevel: { inputs } } : {}),
validate(capability) {
const names = capability.options.inputs.map(({ name }) => name);
const called = capability.options.inputs.flatMap(({ friendlyNames = [] }) => friendlyNames);
const lists = [names, called];
for (const list of lists) {
const twice = list.find((entry, i) => list.indexOf(entry) !== i);
if (twice)
throw new types_js_1.DeclarationError(capability, `${twice} is listed twice, a name stands for one input`);
}
},
});