-
-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed #489
- Loading branch information
Showing
7 changed files
with
242 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# node-sonos template | ||
|
||
This folder contains the template files for [node-sonos](://github.com/bencevans/node-sonos), and is not used in the actual library just yet. | ||
|
||
## Folder content | ||
|
||
| File | Description | Remarks | | ||
|:-----|:------------|:--------| | ||
| [service](./service.hbs) | Single service | Strong type service template | | ||
|
||
## Use this template | ||
|
||
To use this template you'll need both this generator and node-sonos checked out. | ||
|
||
```shell | ||
# from root of repository | ||
|
||
# generate the intermediate file (this will take the online documentation file) | ||
npx @svrooij/sonos-docs combine | ||
|
||
# Make sure you don't have any changes in node-sonos, that makes it unclear what the generator changed | ||
# generate the service files (set the correct root folder for node-sonos) | ||
npx @svrooij/sonos-docs generate ./.generator/node/ ./ | ||
``` | ||
|
||
## Generator | ||
|
||
See the generator documentation [here](https://github.com/svrooij/sonos-api-docs/tree/main/generator/sonos-docs). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{{#each services}} | ||
const {{serviceName}} = require('./{{#if data.filename}}{{data.filename}}{{else}}{{kebab name}}.service{{/if}}') | ||
{{/each}} | ||
|
||
/** | ||
* Sonos AllServices | ||
* | ||
* A generated class to access all Sonos UPNP services. | ||
* | ||
* @remarks This file is generated, do not edit manually. https://svrooij.io/sonos-api-docs | ||
* @exports | ||
* @class AllServices | ||
*/ | ||
class AllServices { | ||
constructor (host, port) { | ||
this.host = host | ||
this.port = port | ||
} | ||
|
||
{{#each services}} | ||
/** | ||
* Get instance of {{name}} service | ||
* | ||
* @returns {{serviceName}} | ||
*/ | ||
{{serviceName}} () { | ||
if (!this.{{lower serviceName}}) { | ||
this.{{lower serviceName}} = new {{serviceName}}(this.host, this.port) | ||
} | ||
return this.{{lower serviceName}} | ||
} | ||
{{#unless @last}} | ||
|
||
{{/unless}} | ||
{{/each}} | ||
} | ||
|
||
module.exports = { | ||
AllServices, | ||
{{#each services}} | ||
{{serviceName}}{{#unless @last}},{{/unless}} | ||
{{/each}} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
--- | ||
layout: default | ||
title: {{name}} | ||
--- | ||
# {{name}} service | ||
{{#if description}} | ||
|
||
{{description}} | ||
{{/if}} | ||
{{#if availableAt}} | ||
|
||
The {{name}} service is available on these models: {{#each availableAt}}`{{this}}`{{#unless @last}} / {{/unless}}{{/each}}. | ||
{{/if}} | ||
|
||
```js | ||
const Sonos = require('sonos').Sonos | ||
const sonos = new Sonos('192.168.x.x') | ||
sonos.generatedServices.{{serviceName}}().OneOfTheMethodsBelow({...}) | ||
``` | ||
|
||
## Actions | ||
|
||
{{#each actions}} | ||
### {{name}} | ||
{{#if description}} | ||
|
||
{{description}} | ||
{{/if}} | ||
{{#if inputs}} | ||
|
||
```js | ||
const result = await sonos.generatedServices.{{../serviceName}}.{{name}}({ {{#each inputs}}{{name}}:...{{#unless @last}}, {{/unless}}{{/each}} }); | ||
``` | ||
|
||
Input object: | ||
|
||
| property | type | description | | ||
|:----------|:-----|:------------| | ||
{{#each inputs}} | ||
| **{{name}}** | `{{{relatedStateVariable.dataType}}}` | {{{description}}}{{#if relatedStateVariable.allowedValues}} Allowed values: {{#each relatedStateVariable.allowedValues}}`{{this}}`{{#unless @last}} / {{/unless}}{{/each}}{{/if}} | | ||
{{/each}} | ||
{{else}} | ||
|
||
```js | ||
const result = await sonos.generatedServices.{{../serviceName}}.{{name}}(); | ||
``` | ||
{{/if}} | ||
{{#if outputs}} | ||
|
||
Output object: | ||
|
||
| property | type | description | | ||
|:----------|:-----|:------------| | ||
{{#each outputs}} | ||
| **{{name}}** | `{{{relatedStateVariable.dataType}}}` | {{{description}}}{{#if relatedStateVariable.allowedValues}} Possible values: {{#each relatedStateVariable.allowedValues}}`{{this}}`{{#unless @last}} / {{/unless}}{{/each}}{{/if}} | | ||
{{/each}} | ||
{{else}} | ||
|
||
This actions returns a boolean whether or not the requests succeeded. | ||
{{/if}} | ||
{{#if remarks}} | ||
|
||
**Remarks** {{{remarks}}} | ||
{{/if}} | ||
|
||
{{/each}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
const Service = require('./Service') | ||
/** | ||
* Sonos {{serviceName}} | ||
{{#if description}} | ||
* | ||
* {{description}} | ||
{{/if}} | ||
* | ||
* @author Stephan van Rooij - https://svrooij.io | ||
* @remarks This file is generated, do not edit manually. https://svrooij.io/sonos-api-docs | ||
* @export | ||
* @class {{serviceName}} | ||
* @extends {Service} | ||
*/ | ||
class {{serviceName}} extends Service { | ||
constructor (host, port) { | ||
super() | ||
this.name = '{{name}}' | ||
this.host = host | ||
this.port = port || 1400 | ||
this.controlURL = '{{controlURL}}' | ||
this.eventSubURL = '{{eventSubURL}}' | ||
this.SCPDURL = '{{discoveryUri}}' | ||
} | ||
|
||
// #region actions | ||
{{#each actions}} | ||
/** | ||
* {{name}}{{#if description}} - {{{description}}}{{/if}} | ||
{{#if inputs}} | ||
* | ||
* @param {Object} [options] - An object with the following properties | ||
{{/if}} | ||
{{#each inputs}} | ||
* @param { {{~ relatedStateVariable.dataType ~}} } options.{{name}}{{#if description}} - {{{description}}}{{/if}}{{#if relatedStateVariable.allowedValues}} [ {{#each relatedStateVariable.allowedValues}}'{{this}}'{{#unless @last}} / {{/unless}}{{/each}} ]{{/if}} | ||
{{/each}} | ||
{{#if remarks}} | ||
* @remarks {{{remarks}}} | ||
{{/if}} | ||
{{#if outputs}} | ||
* @returns {Object} response object, with these properties {{#each outputs}}'{{name}}'{{#unless @last}}, {{/unless}}{{/each}} | ||
{{/if}} | ||
*/ | ||
{{#if inputs}} | ||
async {{name}} (options{{{sonos_if_only_instance_id inputs ' = { InstanceID: 0 }'}}}) { return this._request('{{name}}', options) } | ||
{{else}} | ||
async {{name}} () { return this._request('{{name}}') } | ||
{{/if}} | ||
{{#unless @last}} | ||
|
||
{{/unless}} | ||
{{/each}} | ||
// #endregion | ||
} | ||
|
||
module.exports = {{serviceName}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
{ | ||
"$schema": "https://svrooij.io/sonos-api-docs/schema/template.json", | ||
"name": "Node sonos", | ||
"slug": "node", | ||
"repository": "https://github.com/bencevans/node-sonos/", | ||
"author": { | ||
"name": "svrooij", | ||
"link": "https://svrooij.io" | ||
}, | ||
"files": [ | ||
{ | ||
"file": "service.hbs", | ||
"outputFile": "lib/services/{snService}.service.js", | ||
"usage":"service" | ||
}, | ||
{ | ||
"file": "all-services.hbs", | ||
"outputFile": "lib/services/all-services.js", | ||
"usage":"index" | ||
}, | ||
{ | ||
"file": "docs-service.hbs", | ||
"outputFile": "docs/services/{snService}-service.md", | ||
"usage":"service" | ||
} | ||
], | ||
"dataTypes": { | ||
"ui4": "number", | ||
"i4": "number", | ||
"ui2": "number", | ||
"i2": "number", | ||
"MetaData": "string", | ||
"ZoneGroupState": "string" | ||
}, | ||
"serviceData": { | ||
"AVTransportService": { | ||
"filename": "av-transport.service" | ||
}, | ||
"HTControlService": { | ||
"filename": "ht-control.service" | ||
} | ||
}, | ||
"license": "MIT" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,3 +14,5 @@ config/*local.json | |
|
||
# Ignore Mac DS_Store files | ||
.DS_Store | ||
|
||
.cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters