registry: describe an Alexa interface as data
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>
This commit is contained in:
parent
128ca35c2a
commit
aa0ffd64ea
93 changed files with 4058 additions and 490 deletions
22
test/fixtures/alexa-docs/alexa-brightnesscontroller/AdjustBrightness.directive.json
vendored
Normal file
22
test/fixtures/alexa-docs/alexa-brightnesscontroller/AdjustBrightness.directive.json
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"directive": {
|
||||
"header": {
|
||||
"namespace": "Alexa.BrightnessController",
|
||||
"name": "AdjustBrightness",
|
||||
"messageId": "Unique version 4 UUID",
|
||||
"correlationToken": "Opaque correlation token",
|
||||
"payloadVersion": "3"
|
||||
},
|
||||
"endpoint": {
|
||||
"scope": {
|
||||
"type": "BearerToken",
|
||||
"token": "OAuth2.0 bearer token"
|
||||
},
|
||||
"endpointId": "Endpoint ID",
|
||||
"cookie": {}
|
||||
},
|
||||
"payload": {
|
||||
"brightnessDelta": -25
|
||||
}
|
||||
}
|
||||
}
|
||||
30
test/fixtures/alexa-docs/alexa-brightnesscontroller/AdjustBrightness.response.json
vendored
Normal file
30
test/fixtures/alexa-docs/alexa-brightnesscontroller/AdjustBrightness.response.json
vendored
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
{
|
||||
"event": {
|
||||
"header": {
|
||||
"namespace": "Alexa",
|
||||
"name": "Response",
|
||||
"messageId": "Unique identifier, preferably a version 4 UUID",
|
||||
"correlationToken": "Opaque correlation token that matches the request",
|
||||
"payloadVersion": "3"
|
||||
},
|
||||
"endpoint": {
|
||||
"scope": {
|
||||
"type": "BearerToken",
|
||||
"token": "OAuth2.0 bearer token"
|
||||
},
|
||||
"endpointId": "Endpoint ID"
|
||||
},
|
||||
"payload": {}
|
||||
},
|
||||
"context": {
|
||||
"properties": [
|
||||
{
|
||||
"namespace": "Alexa.BrightnessController",
|
||||
"name": "brightness",
|
||||
"value": 75,
|
||||
"timeOfSample": "2017-02-03T16:20:50.52Z",
|
||||
"uncertaintyInMilliseconds": 1000
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
42
test/fixtures/alexa-docs/alexa-brightnesscontroller/ChangeReport.json
vendored
Normal file
42
test/fixtures/alexa-docs/alexa-brightnesscontroller/ChangeReport.json
vendored
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
{
|
||||
"event": {
|
||||
"header": {
|
||||
"namespace": "Alexa",
|
||||
"name": "ChangeReport",
|
||||
"messageId": "Unique identifier, preferably a version 4 UUID",
|
||||
"payloadVersion": "3"
|
||||
},
|
||||
"endpoint": {
|
||||
"scope": {
|
||||
"type": "BearerToken",
|
||||
"token": "OAuth2.0 bearer token"
|
||||
},
|
||||
"endpointId": "Endpoint ID"
|
||||
},
|
||||
"payload": {
|
||||
"change": {
|
||||
"cause": {
|
||||
"type": "PHYSICAL_INTERACTION"
|
||||
},
|
||||
"properties": [
|
||||
{
|
||||
"namespace": "Alexa.BrightnessController",
|
||||
"name": "brightness",
|
||||
"value": 75,
|
||||
"timeOfSample": "2024-02-03T16:17:00.00Z",
|
||||
"uncertaintyInMilliseconds": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"context": {
|
||||
"namespace": "Alexa.EndpointHealth",
|
||||
"name": "connectivity",
|
||||
"value": {
|
||||
"value": "OK"
|
||||
},
|
||||
"timeOfSample": "2024-02-03T16:15:00.00Z",
|
||||
"uncertaintyInMilliseconds": 0
|
||||
}
|
||||
}
|
||||
22
test/fixtures/alexa-docs/alexa-brightnesscontroller/SetBrightness.directive.json
vendored
Normal file
22
test/fixtures/alexa-docs/alexa-brightnesscontroller/SetBrightness.directive.json
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"directive": {
|
||||
"header": {
|
||||
"namespace": "Alexa.BrightnessController",
|
||||
"name": "SetBrightness",
|
||||
"messageId": "Unique version 4 UUID",
|
||||
"correlationToken": "Opaque correlation token",
|
||||
"payloadVersion": "3"
|
||||
},
|
||||
"endpoint": {
|
||||
"scope": {
|
||||
"type": "BearerToken",
|
||||
"token": "OAuth2.0 bearer token"
|
||||
},
|
||||
"endpointId": "Endpoint ID",
|
||||
"cookie": {}
|
||||
},
|
||||
"payload": {
|
||||
"brightness": 50
|
||||
}
|
||||
}
|
||||
}
|
||||
30
test/fixtures/alexa-docs/alexa-brightnesscontroller/SetBrightness.response.json
vendored
Normal file
30
test/fixtures/alexa-docs/alexa-brightnesscontroller/SetBrightness.response.json
vendored
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
{
|
||||
"event": {
|
||||
"header": {
|
||||
"namespace": "Alexa",
|
||||
"name": "Response",
|
||||
"messageId": "Unique identifier, preferably a version 4 UUID",
|
||||
"correlationToken": "Opaque correlation token that matches the request",
|
||||
"payloadVersion": "3"
|
||||
},
|
||||
"endpoint": {
|
||||
"scope": {
|
||||
"type": "BearerToken",
|
||||
"token": "OAuth2.0 bearer token"
|
||||
},
|
||||
"endpointId": "Endpoint ID"
|
||||
},
|
||||
"payload": {}
|
||||
},
|
||||
"context": {
|
||||
"properties": [
|
||||
{
|
||||
"namespace": "Alexa.BrightnessController",
|
||||
"name": "brightness",
|
||||
"value": 50,
|
||||
"timeOfSample": "2017-02-03T16:20:50.52Z",
|
||||
"uncertaintyInMilliseconds": 500
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
30
test/fixtures/alexa-docs/alexa-brightnesscontroller/StateReport.json
vendored
Normal file
30
test/fixtures/alexa-docs/alexa-brightnesscontroller/StateReport.json
vendored
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
{
|
||||
"event": {
|
||||
"header": {
|
||||
"namespace": "Alexa",
|
||||
"name": "StateReport",
|
||||
"messageId": "Unique identifier, preferably a version 4 UUID",
|
||||
"correlationToken": "Opaque correlation token that matches the request",
|
||||
"payloadVersion": "3"
|
||||
},
|
||||
"endpoint": {
|
||||
"scope": {
|
||||
"type": "BearerToken",
|
||||
"token": "OAuth2.0 bearer token"
|
||||
},
|
||||
"endpointId": "Endpoint ID"
|
||||
},
|
||||
"payload": {}
|
||||
},
|
||||
"context": {
|
||||
"properties": [
|
||||
{
|
||||
"namespace": "Alexa.BrightnessController",
|
||||
"name": "brightness",
|
||||
"value": 75,
|
||||
"timeOfSample": "2017-02-03T16:20:50.52Z",
|
||||
"uncertaintyInMilliseconds": 1000
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
81
test/fixtures/alexa-docs/alexa-brightnesscontroller/discovery.json
vendored
Normal file
81
test/fixtures/alexa-docs/alexa-brightnesscontroller/discovery.json
vendored
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
{
|
||||
"event": {
|
||||
"header": {
|
||||
"namespace": "Alexa.Discovery",
|
||||
"name": "Discover.Response",
|
||||
"payloadVersion": "3",
|
||||
"messageId": "Unique identifier, preferably a version 4 UUID"
|
||||
},
|
||||
"payload": {
|
||||
"endpoints": [
|
||||
{
|
||||
"endpointId": "Unique ID of the endpoint",
|
||||
"manufacturerName": "Manufacturer of the endpoint",
|
||||
"description": "Description to be shown in the Alexa app",
|
||||
"friendlyName": "Living Room Light",
|
||||
"displayCategories": [
|
||||
"LIGHT"
|
||||
],
|
||||
"additionalAttributes": {
|
||||
"manufacturer": "Manufacturer of the endpoint",
|
||||
"model": "Model of the device",
|
||||
"serialNumber": "Serial number of the device",
|
||||
"firmwareVersion": "Firmware version of the device",
|
||||
"softwareVersion": "Software version of the device",
|
||||
"customIdentifier": "Optional custom identifier for the device"
|
||||
},
|
||||
"cookie": {},
|
||||
"capabilities": [
|
||||
{
|
||||
"type": "AlexaInterface",
|
||||
"interface": "Alexa.BrightnessController",
|
||||
"version": "3",
|
||||
"properties": {
|
||||
"supported": [
|
||||
{
|
||||
"name": "brightness"
|
||||
}
|
||||
],
|
||||
"proactivelyReported": true,
|
||||
"retrievable": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "AlexaInterface",
|
||||
"interface": "Alexa.ColorController",
|
||||
"version": "3",
|
||||
"properties": {
|
||||
"supported": [
|
||||
{
|
||||
"name": "color"
|
||||
}
|
||||
],
|
||||
"proactivelyReported": true,
|
||||
"retrievable": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "AlexaInterface",
|
||||
"interface": "Alexa.EndpointHealth",
|
||||
"version": "3",
|
||||
"properties": {
|
||||
"supported": [
|
||||
{
|
||||
"name": "connectivity"
|
||||
}
|
||||
],
|
||||
"proactivelyReported": true,
|
||||
"retrievable": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "AlexaInterface",
|
||||
"interface": "Alexa",
|
||||
"version": "3"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
7
test/fixtures/alexa-docs/alexa-endpointhealth/connectivity.property.json
vendored
Normal file
7
test/fixtures/alexa-docs/alexa-endpointhealth/connectivity.property.json
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"name": "connectivity",
|
||||
"value": {
|
||||
"value": "UNREACHABLE",
|
||||
"reason": "WIFI_BAD_PASSWORD"
|
||||
}
|
||||
}
|
||||
67
test/fixtures/alexa-docs/alexa-endpointhealth/discovery.json
vendored
Normal file
67
test/fixtures/alexa-docs/alexa-endpointhealth/discovery.json
vendored
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
{
|
||||
"event": {
|
||||
"header": {
|
||||
"namespace": "Alexa.Discovery",
|
||||
"name": "Discover.Response",
|
||||
"payloadVersion": "3",
|
||||
"messageId": "Unique identifier, preferably a version 4 UUID"
|
||||
},
|
||||
"payload": {
|
||||
"endpoints": [
|
||||
{
|
||||
"endpointId": "Unique ID of the endpoint",
|
||||
"manufacturerName": "Sample Manufacturer",
|
||||
"description": "Description to be shown in the Alexa app",
|
||||
"friendlyName": "Your device name, displayed in the Alexa app, for example Front Door>",
|
||||
"displayCategories": [
|
||||
"SMARTLOCK"
|
||||
],
|
||||
"additionalAttributes": {
|
||||
"manufacturer": "Sample Manufacturer",
|
||||
"model": "Sample Model",
|
||||
"serialNumber": "Serial number of the device",
|
||||
"firmwareVersion": "Firmware version of the device",
|
||||
"softwareVersion": "Software version of the device",
|
||||
"customIdentifier": "Optional custom identifier for the device"
|
||||
},
|
||||
"cookie": {},
|
||||
"capabilities": [
|
||||
{
|
||||
"type": "AlexaInterface",
|
||||
"interface": "Alexa.LockController",
|
||||
"version": "3",
|
||||
"properties": {
|
||||
"supported": [
|
||||
{
|
||||
"name": "lockState"
|
||||
}
|
||||
],
|
||||
"proactivelyReported": true,
|
||||
"retrievable": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "AlexaInterface",
|
||||
"interface": "Alexa.EndpointHealth",
|
||||
"version": "3.1",
|
||||
"properties": {
|
||||
"supported": [
|
||||
{
|
||||
"name": "connectivity"
|
||||
}
|
||||
],
|
||||
"proactivelyReported": true,
|
||||
"retrievable": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "AlexaInterface",
|
||||
"interface": "Alexa",
|
||||
"version": "3"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
45
test/fixtures/alexa-docs/alexa-interface/discovery.json
vendored
Normal file
45
test/fixtures/alexa-docs/alexa-interface/discovery.json
vendored
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
{
|
||||
"event": {
|
||||
"header": {
|
||||
"namespace": "Alexa.Discovery",
|
||||
"name": "Discover.Response",
|
||||
"payloadVersion": "3",
|
||||
"messageId": "Unique identifier, preferably a version 4 UUID"
|
||||
},
|
||||
"payload": {
|
||||
"endpoints": [
|
||||
{
|
||||
"endpointId": "Unique ID of the endpoint",
|
||||
"manufacturerName": "Manufacturer of the endpoint",
|
||||
"description": "Description to be shown in the Alexa app",
|
||||
"friendlyName": "Device name, displayed in the Alexa app",
|
||||
"displayCategories": [
|
||||
"LIGHT"
|
||||
],
|
||||
"cookie": {},
|
||||
"capabilities": [
|
||||
{
|
||||
"type": "AlexaInterface",
|
||||
"interface": "Alexa.PowerController",
|
||||
"version": "3",
|
||||
"properties": {
|
||||
"supported": [
|
||||
{
|
||||
"name": "powerState"
|
||||
}
|
||||
],
|
||||
"proactivelyReported": true,
|
||||
"retrievable": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "AlexaInterface",
|
||||
"interface": "Alexa",
|
||||
"version": "3"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
42
test/fixtures/alexa-docs/alexa-powercontroller/ChangeReport.json
vendored
Normal file
42
test/fixtures/alexa-docs/alexa-powercontroller/ChangeReport.json
vendored
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
{
|
||||
"event": {
|
||||
"header": {
|
||||
"namespace": "Alexa",
|
||||
"name": "ChangeReport",
|
||||
"messageId": "Unique identifier, preferably a version 4 UUID",
|
||||
"payloadVersion": "3"
|
||||
},
|
||||
"endpoint": {
|
||||
"scope": {
|
||||
"type": "BearerToken",
|
||||
"token": "OAuth2.0 bearer token"
|
||||
},
|
||||
"endpointId": "Endpoint ID"
|
||||
},
|
||||
"payload": {
|
||||
"change": {
|
||||
"cause": {
|
||||
"type": "PHYSICAL_INTERACTION"
|
||||
},
|
||||
"properties": [
|
||||
{
|
||||
"namespace": "Alexa.PowerController",
|
||||
"name": "powerState",
|
||||
"value": "ON",
|
||||
"timeOfSample": "2024-05-01T09:32:05.05Z",
|
||||
"uncertaintyInMilliseconds": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"context": {
|
||||
"namespace": "Alexa.EndpointHealth",
|
||||
"name": "connectivity",
|
||||
"value": {
|
||||
"value": "OK"
|
||||
},
|
||||
"timeOfSample": "2024-05-01T09:31:00.00Z",
|
||||
"uncertaintyInMilliseconds": 0
|
||||
}
|
||||
}
|
||||
30
test/fixtures/alexa-docs/alexa-powercontroller/StateReport.json
vendored
Normal file
30
test/fixtures/alexa-docs/alexa-powercontroller/StateReport.json
vendored
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
{
|
||||
"event": {
|
||||
"header": {
|
||||
"namespace": "Alexa",
|
||||
"name": "StateReport",
|
||||
"messageId": "Unique identifier, preferably a version 4 UUID",
|
||||
"correlationToken": "Opaque correlation token that matches the request",
|
||||
"payloadVersion": "3"
|
||||
},
|
||||
"endpoint": {
|
||||
"scope": {
|
||||
"type": "BearerToken",
|
||||
"token": "OAuth2.0 bearer token"
|
||||
},
|
||||
"endpointId": "Endpoint ID"
|
||||
},
|
||||
"payload": {}
|
||||
},
|
||||
"context": {
|
||||
"properties": [
|
||||
{
|
||||
"namespace": "Alexa.PowerController",
|
||||
"name": "powerState",
|
||||
"value": "OFF",
|
||||
"timeOfSample": "2017-02-03T16:20:50.52Z",
|
||||
"uncertaintyInMilliseconds": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
20
test/fixtures/alexa-docs/alexa-powercontroller/TurnOff.directive.json
vendored
Normal file
20
test/fixtures/alexa-docs/alexa-powercontroller/TurnOff.directive.json
vendored
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"directive": {
|
||||
"header": {
|
||||
"namespace": "Alexa.PowerController",
|
||||
"name": "TurnOff",
|
||||
"messageId": "Unique version 4 UUID",
|
||||
"correlationToken": "Opaque correlation token",
|
||||
"payloadVersion": "3"
|
||||
},
|
||||
"endpoint": {
|
||||
"scope": {
|
||||
"type": "BearerToken",
|
||||
"token": "OAuth2.0 bearer token"
|
||||
},
|
||||
"endpointId": "Endpoint ID",
|
||||
"cookie": {}
|
||||
},
|
||||
"payload": {}
|
||||
}
|
||||
}
|
||||
30
test/fixtures/alexa-docs/alexa-powercontroller/TurnOff.response.json
vendored
Normal file
30
test/fixtures/alexa-docs/alexa-powercontroller/TurnOff.response.json
vendored
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
{
|
||||
"event": {
|
||||
"header": {
|
||||
"namespace": "Alexa",
|
||||
"name": "Response",
|
||||
"messageId": "Unique identifier, preferably a version 4 UUID",
|
||||
"correlationToken": "Opaque correlation token that matches the request",
|
||||
"payloadVersion": "3"
|
||||
},
|
||||
"endpoint": {
|
||||
"scope": {
|
||||
"type": "BearerToken",
|
||||
"token": "OAuth2.0 bearer token"
|
||||
},
|
||||
"endpointId": "Endpoint ID"
|
||||
},
|
||||
"payload": {}
|
||||
},
|
||||
"context": {
|
||||
"properties": [
|
||||
{
|
||||
"namespace": "Alexa.PowerController",
|
||||
"name": "powerState",
|
||||
"value": "OFF",
|
||||
"timeOfSample": "2017-02-03T16:20:50.52Z",
|
||||
"uncertaintyInMilliseconds": 500
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
20
test/fixtures/alexa-docs/alexa-powercontroller/TurnOn.directive.json
vendored
Normal file
20
test/fixtures/alexa-docs/alexa-powercontroller/TurnOn.directive.json
vendored
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"directive": {
|
||||
"header": {
|
||||
"namespace": "Alexa.PowerController",
|
||||
"name": "TurnOn",
|
||||
"messageId": "Unique version 4 UUID",
|
||||
"correlationToken": "Opaque correlation token",
|
||||
"payloadVersion": "3"
|
||||
},
|
||||
"endpoint": {
|
||||
"scope": {
|
||||
"type": "BearerToken",
|
||||
"token": "OAuth2.0 bearer token"
|
||||
},
|
||||
"endpointId": "Endpoint ID",
|
||||
"cookie": {}
|
||||
},
|
||||
"payload": {}
|
||||
}
|
||||
}
|
||||
30
test/fixtures/alexa-docs/alexa-powercontroller/TurnOn.response.json
vendored
Normal file
30
test/fixtures/alexa-docs/alexa-powercontroller/TurnOn.response.json
vendored
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
{
|
||||
"event": {
|
||||
"header": {
|
||||
"namespace": "Alexa",
|
||||
"name": "Response",
|
||||
"messageId": "Unique identifier, preferably a version 4 UUID",
|
||||
"correlationToken": "Opaque correlation token that matches the request",
|
||||
"payloadVersion": "3"
|
||||
},
|
||||
"endpoint": {
|
||||
"scope": {
|
||||
"type": "BearerToken",
|
||||
"token": "OAuth2.0 bearer token"
|
||||
},
|
||||
"endpointId": "Endpoint ID"
|
||||
},
|
||||
"payload": {}
|
||||
},
|
||||
"context": {
|
||||
"properties": [
|
||||
{
|
||||
"namespace": "Alexa.PowerController",
|
||||
"name": "powerState",
|
||||
"value": "ON",
|
||||
"timeOfSample": "2017-02-03T16:20:50.52Z",
|
||||
"uncertaintyInMilliseconds": 500
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
81
test/fixtures/alexa-docs/alexa-powercontroller/discovery.json
vendored
Normal file
81
test/fixtures/alexa-docs/alexa-powercontroller/discovery.json
vendored
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
{
|
||||
"event": {
|
||||
"header": {
|
||||
"namespace": "Alexa.Discovery",
|
||||
"name": "Discover.Response",
|
||||
"payloadVersion": "3",
|
||||
"messageId": "Unique identifier, preferably a version 4 UUID"
|
||||
},
|
||||
"payload": {
|
||||
"endpoints": [
|
||||
{
|
||||
"endpointId": "Unique ID of the endpoint",
|
||||
"manufacturerName": "Manufacturer of the endpoint",
|
||||
"description": "Description to be shown in the Alexa app",
|
||||
"friendlyName": "Living Room Light",
|
||||
"displayCategories": [
|
||||
"LIGHT"
|
||||
],
|
||||
"additionalAttributes": {
|
||||
"manufacturer": "Manufacturer of the endpoint",
|
||||
"model": "Model of the device",
|
||||
"serialNumber": "Serial number of the device",
|
||||
"firmwareVersion": "Firmware version of the device",
|
||||
"softwareVersion": "Software version of the device",
|
||||
"customIdentifier": "Optional custom identifier for the device"
|
||||
},
|
||||
"cookie": {},
|
||||
"capabilities": [
|
||||
{
|
||||
"type": "AlexaInterface",
|
||||
"interface": "Alexa.PowerController",
|
||||
"version": "3",
|
||||
"properties": {
|
||||
"supported": [
|
||||
{
|
||||
"name": "powerState"
|
||||
}
|
||||
],
|
||||
"proactivelyReported": true,
|
||||
"retrievable": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "AlexaInterface",
|
||||
"interface": "Alexa.BrightnessController",
|
||||
"version": "3",
|
||||
"properties": {
|
||||
"supported": [
|
||||
{
|
||||
"name": "brightness"
|
||||
}
|
||||
],
|
||||
"proactivelyReported": true,
|
||||
"retrievable": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "AlexaInterface",
|
||||
"interface": "Alexa.EndpointHealth",
|
||||
"version": "3",
|
||||
"properties": {
|
||||
"supported": [
|
||||
{
|
||||
"name": "connectivity"
|
||||
}
|
||||
],
|
||||
"proactivelyReported": true,
|
||||
"retrievable": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "AlexaInterface",
|
||||
"interface": "Alexa",
|
||||
"version": "3"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
66
test/fixtures/alexa-docs/alexa-temperaturesensor/ChangeReport.json
vendored
Normal file
66
test/fixtures/alexa-docs/alexa-temperaturesensor/ChangeReport.json
vendored
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
{
|
||||
"event": {
|
||||
"header": {
|
||||
"namespace": "Alexa",
|
||||
"name": "ChangeReport",
|
||||
"messageId": "Unique identifier, preferably a version 4 UUID",
|
||||
"payloadVersion": "3"
|
||||
},
|
||||
"endpoint": {
|
||||
"scope": {
|
||||
"type": "BearerToken",
|
||||
"token": "OAuth2.0 bearer token"
|
||||
},
|
||||
"endpointId": "Endpoint ID"
|
||||
},
|
||||
"payload": {
|
||||
"change": {
|
||||
"cause": {
|
||||
"type": "PHYSICAL_INTERACTION"
|
||||
},
|
||||
"properties": [
|
||||
{
|
||||
"namespace": "Alexa.ThermostatController",
|
||||
"name": "targetSetpoint",
|
||||
"value": {
|
||||
"value": 18,
|
||||
"scale": "CELSIUS"
|
||||
},
|
||||
"timeOfSample": "2017-02-03T16:20:50.52Z",
|
||||
"uncertaintyInMilliseconds": 500
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"context": {
|
||||
"properties": [
|
||||
{
|
||||
"namespace": "Alexa.TemperatureSensor",
|
||||
"name": "temperature",
|
||||
"value": {
|
||||
"value": 19.1,
|
||||
"scale": "CELSIUS"
|
||||
},
|
||||
"timeOfSample": "2017-02-03T16:20:50.52Z",
|
||||
"uncertaintyInMilliseconds": 1000
|
||||
},
|
||||
{
|
||||
"namespace": "Alexa.ThermostatController",
|
||||
"name": "thermostatMode",
|
||||
"value": "COOL",
|
||||
"timeOfSample": "2017-02-03T16:20:50.52Z",
|
||||
"uncertaintyInMilliseconds": 500
|
||||
},
|
||||
{
|
||||
"namespace": "Alexa.EndpointHealth",
|
||||
"name": "connectivity",
|
||||
"value": {
|
||||
"value": "OK"
|
||||
},
|
||||
"timeOfSample": "2017-02-03T16:20:50.52Z",
|
||||
"uncertaintyInMilliseconds": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
59
test/fixtures/alexa-docs/alexa-temperaturesensor/StateReport.json
vendored
Normal file
59
test/fixtures/alexa-docs/alexa-temperaturesensor/StateReport.json
vendored
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
{
|
||||
"event": {
|
||||
"header": {
|
||||
"namespace": "Alexa",
|
||||
"name": "StateReport",
|
||||
"messageId": "Unique identifier, preferably a version 4 UUID",
|
||||
"correlationToken": "Opaque correlation token that matches the request",
|
||||
"payloadVersion": "3"
|
||||
},
|
||||
"endpoint": {
|
||||
"scope": {
|
||||
"type": "BearerToken",
|
||||
"token": "OAuth2.0 bearer token"
|
||||
},
|
||||
"endpointId": "Endpoint ID"
|
||||
},
|
||||
"payload": {}
|
||||
},
|
||||
"context": {
|
||||
"properties": [
|
||||
{
|
||||
"namespace": "Alexa.TemperatureSensor",
|
||||
"name": "temperature",
|
||||
"value": {
|
||||
"value": 19.9,
|
||||
"scale": "CELSIUS"
|
||||
},
|
||||
"timeOfSample": "2024-01-06T09:00:00.05Z",
|
||||
"uncertaintyInMilliseconds": 1000
|
||||
},
|
||||
{
|
||||
"namespace": "Alexa.ThermostatController",
|
||||
"name": "thermostatMode",
|
||||
"value": "HEAT",
|
||||
"timeOfSample": "2024-01-01T08:00:00.05Z",
|
||||
"uncertaintyInMilliseconds": 500
|
||||
},
|
||||
{
|
||||
"namespace": "Alexa.ThermostatController",
|
||||
"name": "targetSetpoint",
|
||||
"value": {
|
||||
"value": 20,
|
||||
"scale": "CELSIUS"
|
||||
},
|
||||
"timeOfSample": "2024-01-01T08:00:00.05Z",
|
||||
"uncertaintyInMilliseconds": 500
|
||||
},
|
||||
{
|
||||
"namespace": "Alexa.EndpointHealth",
|
||||
"name": "connectivity",
|
||||
"value": {
|
||||
"value": "OK"
|
||||
},
|
||||
"timeOfSample": "2024-01-06T09:00:00.05Z",
|
||||
"uncertaintyInMilliseconds": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
91
test/fixtures/alexa-docs/alexa-temperaturesensor/discovery.json
vendored
Normal file
91
test/fixtures/alexa-docs/alexa-temperaturesensor/discovery.json
vendored
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
{
|
||||
"event": {
|
||||
"header": {
|
||||
"namespace": "Alexa.Discovery",
|
||||
"name": "Discover.Response",
|
||||
"payloadVersion": "3",
|
||||
"messageId": "Unique identifier, preferably a version 4 UUID"
|
||||
},
|
||||
"payload": {
|
||||
"endpoints": [
|
||||
{
|
||||
"endpointId": "Unique ID of the endpoint",
|
||||
"manufacturerName": "Manufacturer of the endpoint",
|
||||
"description": "Smart Thermostat by Thermostat Maker",
|
||||
"friendlyName": "Hallway Thermostat",
|
||||
"displayCategories": [
|
||||
"THERMOSTAT",
|
||||
"TEMPERATURE_SENSOR"
|
||||
],
|
||||
"cookie": {},
|
||||
"capabilities": [
|
||||
{
|
||||
"type": "AlexaInterface",
|
||||
"interface": "Alexa.TemperatureSensor",
|
||||
"version": "3",
|
||||
"properties": {
|
||||
"supported": [
|
||||
{
|
||||
"name": "temperature"
|
||||
}
|
||||
],
|
||||
"proactivelyReported": true,
|
||||
"retrievable": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "AlexaInterface",
|
||||
"interface": "Alexa.ThermostatController",
|
||||
"version": "3.1",
|
||||
"properties": {
|
||||
"supported": [
|
||||
{
|
||||
"name": "targetSetpoint"
|
||||
},
|
||||
{
|
||||
"name": "lowerSetpoint"
|
||||
},
|
||||
{
|
||||
"name": "upperSetpoint"
|
||||
},
|
||||
{
|
||||
"name": "thermostatMode"
|
||||
}
|
||||
],
|
||||
"proactivelyReported": true,
|
||||
"retrievable": true
|
||||
},
|
||||
"configuration": {
|
||||
"supportedModes": [
|
||||
"HEAT",
|
||||
"COOL",
|
||||
"AUTO"
|
||||
],
|
||||
"supportsScheduling": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "AlexaInterface",
|
||||
"interface": "Alexa.EndpointHealth",
|
||||
"version": "3",
|
||||
"properties": {
|
||||
"supported": [
|
||||
{
|
||||
"name": "connectivity"
|
||||
}
|
||||
],
|
||||
"proactivelyReported": true,
|
||||
"retrievable": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "AlexaInterface",
|
||||
"interface": "Alexa",
|
||||
"version": "3"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
11
test/fixtures/interfaces.js
vendored
Normal file
11
test/fixtures/interfaces.js
vendored
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
"use strict";
|
||||
// One entry per interface that is described in full: the page its examples were saved from (test/helpers/fixtures.js).
|
||||
// test/registry/descriptors.test.js holds every entry against those examples and fails for a descriptor of tier 1 or
|
||||
// 2 that has no entry here.
|
||||
module.exports = [
|
||||
{ namespace: "Alexa", page: "alexa-interface" },
|
||||
{ namespace: "Alexa.BrightnessController", page: "alexa-brightnesscontroller" },
|
||||
{ namespace: "Alexa.EndpointHealth", page: "alexa-endpointhealth" },
|
||||
{ namespace: "Alexa.PowerController", page: "alexa-powercontroller" },
|
||||
{ namespace: "Alexa.TemperatureSensor", page: "alexa-temperaturesensor" },
|
||||
];
|
||||
32
test/fixtures/types.ts
vendored
32
test/fixtures/types.ts
vendored
|
|
@ -1,8 +1,14 @@
|
|||
// Compiled, never run (test/typings.test.js, npm run check): a CommonJS TypeScript consumer of the declarations in
|
||||
// dist/types, resolved through the package's "exports". A "@ts-expect-error" line fails the compile when the
|
||||
// declaration stops rejecting what follows it.
|
||||
import { ActionMapping, AlexaActions, AlexaInterfaceType, DisplayCategory, EndpointHealth, PowerController } from "alex2node";
|
||||
import type { Alex2MQTT, Alex2MQTTOptions, AlexaInterface, AlexaStatusMessage, ChangeCause, Device, SupportedMode } from "alex2node";
|
||||
import {
|
||||
ActionMapping, AlexaActions, AlexaInterfaceType, Assets, DeclarationError, DisplayCategory, EndpointHealth, PowerController,
|
||||
registry,
|
||||
} from "alex2node";
|
||||
import type {
|
||||
Alex2MQTT, Alex2MQTTOptions, AlexaInterface, AlexaStatusMessage, AssetId, ChangeCause, Device, DisplayCategoryName, Infer,
|
||||
InterfaceDescriptor, Schema, SupportedMode, Temperature, UnitOfMeasure,
|
||||
} from "alex2node";
|
||||
|
||||
declare const bridge: Alex2MQTT;
|
||||
declare const message: AlexaStatusMessage;
|
||||
|
|
@ -33,4 +39,24 @@ const sent: Promise<string> = device.getChangeReport(cause).addPowerControllerPr
|
|||
// @ts-expect-error not a cause Alexa knows
|
||||
device.getChangeReport("BUTTON");
|
||||
|
||||
export { options, added, chained, sent };
|
||||
// The registry: a descriptor by its namespace or by the 1.x enum member
|
||||
const described: InterfaceDescriptor = registry.get("Alexa.PowerController");
|
||||
const version: string = registry.get(AlexaInterfaceType.ENDPOINT_HEALTH).version;
|
||||
const refused: Error = new DeclarationError({ endpointId: "lamp-1", namespace: described.namespace }, "declared twice");
|
||||
|
||||
// The vocabularies are unions of what the pages list
|
||||
const opening: AssetId = Assets[0];
|
||||
const percent: UnitOfMeasure = "Alexa.Unit.Percent";
|
||||
const vacuum: DisplayCategoryName = "VACUUM";
|
||||
// @ts-expect-error not in the global Alexa catalog
|
||||
const misspelt: AssetId = "Alexa.Setting.Openning";
|
||||
// @ts-expect-error an asset, but not a unit of measure
|
||||
const notAUnit: UnitOfMeasure = "Alexa.Setting.Opening";
|
||||
|
||||
// A schema types what it parses
|
||||
declare const temperature: Schema<Temperature>;
|
||||
const measured: Infer<typeof temperature> = { value: 20, scale: "CELSIUS" };
|
||||
// @ts-expect-error not a temperature scale
|
||||
const rankine: Infer<typeof temperature> = { value: 20, scale: "RANKINE" };
|
||||
|
||||
export { options, added, chained, sent, version, refused, opening, percent, vacuum, misspelt, notAUnit, measured, rankine };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue