Alex2Node/dist/cjs/topics.js
David 6789a1a077 bridge: publish through a Publisher; devices no longer hold the broker client
src/transport.ts has the Publisher interface, MqttPublisher (the client the bridge has at the time) and
MemoryPublisher (tests without a broker); src/topics.ts names the four topics the library publishes to.
Device, AlexaStatusMessage, AlexaErrorResponse and sendSceneResponse shared three copies of the
publish-and-report code: they now call one send() that resolves the topic or "" and never rejects.
registerDevice() and addDevice() work before connect(); a send() without a connection resolves "" and the
"error" event says to call connect(). unregisterDevice() and clearDevices() take the publisher from the device.
Device.setMqttClient() is gone, the first constructor argument of Device is ignored, and the message classes
take a Publisher where they took the client. Tests: 108 -> 113.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-28 19:34:39 +00:00

17 lines
1 KiB
JavaScript

"use strict";
// The topics of the Alex2MQTT contract, named once. The backend and Alex2ESP use the same names, so none of them
// can change here alone.
Object.defineProperty(exports, "__esModule", { value: true });
exports.changeReport = exports.deferred = exports.response = exports.discoverReply = void 0;
/** Where the bridge answers a discovery request with its endpoints. */
const discoverReply = (root) => `${root}/discover_r`;
exports.discoverReply = discoverReply;
/** Where the answer to a directive goes. "alexaResponce" is how the backend and Alex2ESP spell it. */
const response = (root, endpointId) => `${root}/${endpointId}/alexaResponce`;
exports.response = response;
/** Where the answer goes once a DeferredResponse was sent for the directive. */
const deferred = (root, endpointId) => `${root}/${endpointId}/deferredResponse`;
exports.deferred = deferred;
/** Where every ChangeReport of the root goes: the backend adds the user's token and posts it to Alexa. */
const changeReport = (root) => `${root}/changeReport`;
exports.changeReport = changeReport;