// The interfaces the library knows, by namespace. import { Alexa } from "./interfaces/Alexa.js"; import { BrightnessController } from "./interfaces/BrightnessController.js"; import { EndpointHealth } from "./interfaces/EndpointHealth.js"; import { PowerController } from "./interfaces/PowerController.js"; import { TemperatureSensor } from "./interfaces/TemperatureSensor.js"; import { STUBS } from "./interfaces/stubs.js"; import { DeclarationError } from "./types.js"; const described = [ Alexa, BrightnessController, EndpointHealth, PowerController, TemperatureSensor, ]; const descriptors = new Map(); for (const descriptor of [...described, ...STUBS]) { // A stub left in the table next to the descriptor that replaces it would win or lose by the order of this list if (descriptors.has(descriptor.namespace)) throw new Error(`${descriptor.namespace} is described twice`); descriptors.set(descriptor.namespace, descriptor); } export const registry = { /** Whether an interface of this name is known. */ has(namespace) { return descriptors.has(namespace); }, /** The descriptor of "Alexa.RangeController" or of AlexaInterfaceType.RANGE_CONTROLLER, which is that string. */ get(namespace) { const descriptor = descriptors.get(namespace); if (!descriptor) throw new DeclarationError({}, `${JSON.stringify(namespace)} is not an interface alex2node knows`); return descriptor; }, /** Every descriptor, ordered by namespace. */ list() { return [...descriptors.values()].sort((a, b) => (a.namespace < b.namespace ? -1 : 1)); }, }; export { Alexa, BrightnessController, EndpointHealth, PowerController, TemperatureSensor }; export { DeclarationError, defineInterface } from "./types.js"; export { s, SchemaError } from "./schema.js"; export * from "./catalog.js";