homey-api 1.7.2 → 1.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "homey-api",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.3",
|
|
4
4
|
"description": "Homey API",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"files": [
|
|
7
7
|
"/lib",
|
|
8
|
-
"/assets",
|
|
8
|
+
"/assets/specifications",
|
|
9
|
+
"/assets/types",
|
|
9
10
|
"/index.js",
|
|
10
11
|
"/index.browser.js"
|
|
11
12
|
],
|
|
@@ -17,12 +18,11 @@
|
|
|
17
18
|
"build": "npm run build:specs; npm run build:jsdoc; npm run build:types; npm run build:webpack;",
|
|
18
19
|
"build:webpack": "npm run webpack",
|
|
19
20
|
"build:webpack:watch": "npm run webpack:watch",
|
|
20
|
-
"build:jsdoc": "npm run jsdoc:clean; npm run generate-specs; npm run generate-jsdoc; npm run jsdoc;",
|
|
21
21
|
"build:types": "npm run generate-types;",
|
|
22
22
|
"build:specs": "npm run generate-specs",
|
|
23
23
|
"webpack": "webpack",
|
|
24
24
|
"webpack:watch": "webpack --watch",
|
|
25
|
-
"jsdoc": "jsdoc --configure ./jsdoc.json --recurse
|
|
25
|
+
"jsdoc": "npm run jsdoc:clean; npm run generate-specs; npm run generate-jsdoc; jsdoc --configure ./jsdoc.json --recurse; jsdoc --configure ./jsdoc.json --recurse --private --destination ./jsdoc/private; rm ./jsdoc/*.js.html;",
|
|
26
26
|
"jsdoc:clean": "rm -rf ./build/jsdoc; rm -rf ./build/jsdoc-tmp",
|
|
27
27
|
"jsdoc:watch": "watch \"npm run jsdoc:clean; npm run generate-jsdoc; npm run jsdoc;\" lib \"node_modules/homey-jsdoc-template\" --interval 0.5",
|
|
28
28
|
"jsdoc:serve": "http-server ./build/jsdoc/",
|
|
@@ -78,4 +78,4 @@
|
|
|
78
78
|
"not IE 11",
|
|
79
79
|
"not IE_Mob 11"
|
|
80
80
|
]
|
|
81
|
-
}
|
|
81
|
+
}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
// Class
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @class <%= Api.name %>
|
|
5
|
-
*
|
|
6
|
-
* @description
|
|
7
|
-
* <% if(Api.JSDOC_DESCRIPTION) { %>
|
|
8
|
-
<%- Api.JSDOC_DESCRIPTION.split('\n').join('\n *'); %>
|
|
9
|
-
* <% } %>
|
|
10
|
-
* This API is available at `https://<%= Api.SPECIFICATION.host %><%= Api.SPECIFICATION.basePath %>`
|
|
11
|
-
*
|
|
12
|
-
* <% if(Api.JSDOC_EXAMPLE) { %>
|
|
13
|
-
* @example <%- Api.JSDOC_EXAMPLE %>
|
|
14
|
-
* <% } %>
|
|
15
|
-
*
|
|
16
|
-
* <% if(Api.JSDOC_PRIVATE === true) { %>
|
|
17
|
-
* @private
|
|
18
|
-
* <% } %>
|
|
19
|
-
*
|
|
20
|
-
* @param {object} [opts]
|
|
21
|
-
* @param {string} [opts.baseUrl=`https://<%= Api.SPECIFICATION.host %><%= Api.SPECIFICATION.basePath %>`] - The Base URL of the API. Set `<%= envKey %>_BASEURL=http://...` as environment variable on Node.js, or in `window.localStorage` on browsers to override.
|
|
22
|
-
* @param {boolean} [opts.debug=false] - Send debug messages to `console.log` if set to `true`. Set `<%= envKey %>_DEBUG=1` as environment variable on Node.js, or in `window.localStorage` on browsers to override.
|
|
23
|
-
* @param {secret} [opts.secret] - A shared secret for APIs with a `secret` parameter in an endpoint. Set `<%= envKey %>_SECRET=...` as environment variable on Node.js, or in `window.localStorage` on browsers to override.
|
|
24
|
-
* <% if( Api.JSDOC_PARAMS ) { %>
|
|
25
|
-
<%- Api.JSDOC_PARAMS.split('\n').join('\n *'); %>
|
|
26
|
-
* <% } %>
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
|
-
// Methods
|
|
30
|
-
<% Object.entries(Api.SPECIFICATION.operations).forEach(([ operationId, operation ]) => { %>
|
|
31
|
-
/**
|
|
32
|
-
* <h4>HTTP</h4>
|
|
33
|
-
*
|
|
34
|
-
* `<%= String(operation.method).toUpperCase() %> <%= operation.path %>`
|
|
35
|
-
*
|
|
36
|
-
* @async
|
|
37
|
-
* @function <%= Api.name %>#<%= operationId %>
|
|
38
|
-
* <% if(operation.private) { %>
|
|
39
|
-
* @private
|
|
40
|
-
* <% } %>
|
|
41
|
-
*
|
|
42
|
-
* <% if (Object.keys(operation.parameters || {}).length) { %>
|
|
43
|
-
* @param {object} opts
|
|
44
|
-
* <% Object.entries(operation.parameters).forEach(([parameterId, parameter]) => { %>
|
|
45
|
-
* <% if (parameter.required) { %>
|
|
46
|
-
* @param {<%= String(parameter.type).replace(/\,/g, '|') %>} opts.<%= parameterId %> - In `<%= parameter.in %>` <% if( parameter.unpack ) { %><span>(unpacked)</span><% } %>
|
|
47
|
-
* <% } else { %>
|
|
48
|
-
* @param {<%= String(parameter.type).replace(/\,/g, '|') %>} [opts.<%= parameterId %>] - In `<%= parameter.in %>` <% if( parameter.unpack ) { %><span>(unpacked)</span><% } %>
|
|
49
|
-
* <% } %>
|
|
50
|
-
* <% if (Object.keys(parameter.properties || {}).length) { %>
|
|
51
|
-
* <% Object.entries(parameter.properties).forEach(([propertyId, property]) => { %>
|
|
52
|
-
* @param {<%= String(property.type).replace(/\,/g, '|') %>} opts.<%= parameterId %>.<%= propertyId %>
|
|
53
|
-
* <% }) %>
|
|
54
|
-
* <% } %>
|
|
55
|
-
* <% }) %>
|
|
56
|
-
* <% } %>
|
|
57
|
-
*
|
|
58
|
-
*/
|
|
59
|
-
<% }) %>
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
// Class
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* <%= itemName %> as returned by {@link <%= HomeyAPI %>.<%= managerName %>}.
|
|
5
|
-
* @class <%= itemName %>
|
|
6
|
-
* @hideconstructor
|
|
7
|
-
* @memberof <%= HomeyAPI %>.<%= managerName %>
|
|
8
|
-
*
|
|
9
|
-
* <% if(manager.private) { %>
|
|
10
|
-
* @private
|
|
11
|
-
* <% } %>
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
// Properties
|
|
15
|
-
|
|
16
|
-
<% if (item.schema) { %>
|
|
17
|
-
<% for (const [propertyId, property] of Object.entries(item.schema.properties || {}) ) { %>
|
|
18
|
-
/**
|
|
19
|
-
* <% if (property.type) { %>
|
|
20
|
-
* @var {<%= String(property.type || '*').replace(/\,/g, '|') %>} <%= HomeyAPI %>.<%= managerName %>.<%= itemName %>#<%= propertyId %>
|
|
21
|
-
* <% } %>
|
|
22
|
-
*/
|
|
23
|
-
<% } %>
|
|
24
|
-
<% } %>
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* @memberof <%= HomeyAPI %>.<%= managerName%>.<%= itemName %>
|
|
28
|
-
* @event update
|
|
29
|
-
* @param {object} <%= item.id %>
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* @memberof <%= HomeyAPI %>.<%= managerName%>.<%= itemName %>
|
|
34
|
-
* @event delete
|
|
35
|
-
*/
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
// Class
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @description Access this instance at `{@link <%= HomeyAPI %>}.<%= manager.idCamelCase; %>`.
|
|
5
|
-
* @class <%= managerName %>
|
|
6
|
-
* @hideconstructor
|
|
7
|
-
* @extends <%= HomeyAPI %>.Manager
|
|
8
|
-
* @memberof <%= HomeyAPI %>
|
|
9
|
-
*
|
|
10
|
-
* <% if(manager.private) { %>
|
|
11
|
-
* @private
|
|
12
|
-
* <% } %>
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
// Methods
|
|
16
|
-
<% Object.entries(manager.operations || {}).forEach(([ operationId, operation ]) => { %>
|
|
17
|
-
/**
|
|
18
|
-
* <h4>Scopes</h4>
|
|
19
|
-
*
|
|
20
|
-
* `<%= operation.scopes.length ? operation.scopes.join(', ') : '-' %>`
|
|
21
|
-
*
|
|
22
|
-
* <h4>HTTP</h4>
|
|
23
|
-
*
|
|
24
|
-
* `<%= operation.method %> /api/manager/<%= manager.id %><%= operation.path %>`
|
|
25
|
-
*
|
|
26
|
-
* @async
|
|
27
|
-
* @function <%= HomeyAPI %>.<%= managerName %>#<%= operationId %>
|
|
28
|
-
* <% if(operation.private) { %>
|
|
29
|
-
* @private
|
|
30
|
-
* <% } %>
|
|
31
|
-
*
|
|
32
|
-
* <% if (Object.keys(operation.parameters || {}).length) { %>
|
|
33
|
-
* @param {object} opts
|
|
34
|
-
* <% Object.entries(operation.parameters).forEach(([ parameterId, parameter ]) => { %>
|
|
35
|
-
* <% if (parameter.required) { %>
|
|
36
|
-
* @param {<%= String(parameter.type || '*').replace(/\,/g, '|') %>} opts.<%= parameterId %>
|
|
37
|
-
* <% } else { %>
|
|
38
|
-
* @param {<%= String(parameter.type || '*').replace(/\,/g, '|') %>} [opts.<%= parameterId %>]
|
|
39
|
-
* <% } %>
|
|
40
|
-
* <% }) %>
|
|
41
|
-
* <% } %>
|
|
42
|
-
*
|
|
43
|
-
* <% if(operation.crud) { %>
|
|
44
|
-
* <% if(operation.crud.type === 'getOne' || operation.crud.type === 'createOne' || operation.crud.type === 'updateOne') { %>
|
|
45
|
-
* @returns {Promise<<%= HomeyAPI %>.<%= managerName %>.<%= operation.crud.item %>>}
|
|
46
|
-
* <% } else if(operation.crud.type === 'getAll') { %>
|
|
47
|
-
* @returns {Promise<<%= HomeyAPI %>.<%= managerName %>.<%= operation.crud.item %>>}
|
|
48
|
-
* <% } %>
|
|
49
|
-
* <% } else { %>
|
|
50
|
-
* @returns {Promise<any>}
|
|
51
|
-
* <% } %>
|
|
52
|
-
*/
|
|
53
|
-
<% }) %>
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
// CRUD Events
|
|
58
|
-
<% Object.entries(manager.items || {}).forEach(([ itemName, item ]) => { %>
|
|
59
|
-
/**
|
|
60
|
-
* @memberof <%= HomeyAPI %>.<%= managerName%>
|
|
61
|
-
* @event "<%= item.id %>.create"
|
|
62
|
-
* @param {<%= HomeyAPI %>.<%= managerName %>.<%= itemName %>} <%= item.id %>
|
|
63
|
-
*/
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* @memberof <%= HomeyAPI %>.<%= managerName%>
|
|
67
|
-
* @event "<%= item.id %>.update"
|
|
68
|
-
* @param {<%= HomeyAPI %>.<%= managerName %>.<%= itemName %>} <%= item.id %>
|
|
69
|
-
*/
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* @memberof <%= HomeyAPI %>.<%= managerName%>
|
|
73
|
-
* @event "<%= item.id %>.delete"
|
|
74
|
-
* @param {<%= HomeyAPI %>.<%= managerName %>.<%= itemName %>} <%= item.id %>
|
|
75
|
-
*/
|
|
76
|
-
<% }) %>
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
<%
|
|
2
|
-
function jsdocToTypescript(type) {
|
|
3
|
-
return type.names
|
|
4
|
-
.flatMap(type => type.split('|'))
|
|
5
|
-
.map(type => {
|
|
6
|
-
if (type === 'secret') return 'string';
|
|
7
|
-
if (type === 'array') return 'Array<any>';
|
|
8
|
-
if (type === 'date') return 'string';
|
|
9
|
-
// replace Promise.<> with Promise<>
|
|
10
|
-
return type.replace(/\.\</g, '<');
|
|
11
|
-
})
|
|
12
|
-
.join(' | ');
|
|
13
|
-
}
|
|
14
|
-
%>
|
|
15
|
-
|
|
16
|
-
<% function renderParam(params) { %>
|
|
17
|
-
<% Object.entries(params).forEach(([key, value]) => { %>
|
|
18
|
-
<% if (typeof value === 'object') { %>
|
|
19
|
-
<%= key %>: {<%= renderParam(value) %>},
|
|
20
|
-
<% } else { %>
|
|
21
|
-
<%= key %>: <%- jsdocToTypescript({ names: [value] }) %>,
|
|
22
|
-
<% } %>
|
|
23
|
-
<% }) %>
|
|
24
|
-
<% } %>
|
|
25
|
-
|
|
26
|
-
<% function renderClass(namespaceClass) { %>
|
|
27
|
-
export class <%= namespaceClass.name %> <%= Array.isArray(namespaceClass.augments) ? 'extends ' + namespaceClass.augments[0] : '' %> {
|
|
28
|
-
<% if (namespaceClass.constructor && namespaceClass.hideconstructor !== true) { %>
|
|
29
|
-
constructor(
|
|
30
|
-
<% if (namespaceClass.constructor.params) { %>
|
|
31
|
-
<%= renderParam(namespaceClass.constructor.params) %>
|
|
32
|
-
<% } %>
|
|
33
|
-
)
|
|
34
|
-
<% } %>
|
|
35
|
-
|
|
36
|
-
<% namespaceClass.members.forEach(classMember => { %>
|
|
37
|
-
<%= classMember.name %>: <%- jsdocToTypescript(classMember.type) %>;
|
|
38
|
-
<% }) %>
|
|
39
|
-
|
|
40
|
-
<% namespaceClass.functions.forEach(classFunction => { %>
|
|
41
|
-
<%= classFunction.name %>(
|
|
42
|
-
<% if (classFunction.params) { %>
|
|
43
|
-
<%= renderParam(classFunction.params) %>
|
|
44
|
-
<% } %>
|
|
45
|
-
):
|
|
46
|
-
<%- classFunction.returns
|
|
47
|
-
? jsdocToTypescript(classFunction.returns[0].type)
|
|
48
|
-
: classFunction.async ? 'Promise<any>' : 'any'
|
|
49
|
-
%>;
|
|
50
|
-
<% }) %>
|
|
51
|
-
}
|
|
52
|
-
<% } %>
|
|
53
|
-
|
|
54
|
-
<% global.forEach(globalClass => renderClass(globalClass)) %>
|
|
55
|
-
|
|
56
|
-
<% Object.entries(namespaces).forEach(([namespaceId, namespaceClasses]) => { %>
|
|
57
|
-
<% if (namespaceClasses.length) { %>
|
|
58
|
-
export namespace <%= namespaceId %> {
|
|
59
|
-
<% namespaceClasses.forEach(namespaceClass => renderClass(namespaceClass)) %>
|
|
60
|
-
}
|
|
61
|
-
<% } %>
|
|
62
|
-
<% }); %>
|