@homelib/xiaomi 0.0.0-wip.ba4eafa051eb
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/LICENSE +19 -0
- package/README.md +22 -0
- package/bld/library/backend/client.d.ts +68 -0
- package/bld/library/backend/client.js +477 -0
- package/bld/library/backend/client.js.map +1 -0
- package/bld/library/backend/constants.d.ts +7 -0
- package/bld/library/backend/constants.js +11 -0
- package/bld/library/backend/constants.js.map +1 -0
- package/bld/library/backend/index.d.ts +3 -0
- package/bld/library/backend/index.js +4 -0
- package/bld/library/backend/index.js.map +1 -0
- package/bld/library/backend/oauth.d.ts +24 -0
- package/bld/library/backend/oauth.js +121 -0
- package/bld/library/backend/oauth.js.map +1 -0
- package/bld/library/binding.d.ts +44 -0
- package/bld/library/binding.js +212 -0
- package/bld/library/binding.js.map +1 -0
- package/bld/library/cloud/client.d.ts +27 -0
- package/bld/library/cloud/client.js +109 -0
- package/bld/library/cloud/client.js.map +1 -0
- package/bld/library/cloud/constants.d.ts +9 -0
- package/bld/library/cloud/constants.js +11 -0
- package/bld/library/cloud/constants.js.map +1 -0
- package/bld/library/cloud/device.d.ts +84 -0
- package/bld/library/cloud/device.js +686 -0
- package/bld/library/cloud/device.js.map +1 -0
- package/bld/library/cloud/index.d.ts +5 -0
- package/bld/library/cloud/index.js +6 -0
- package/bld/library/cloud/index.js.map +1 -0
- package/bld/library/cloud/mqtt.d.ts +69 -0
- package/bld/library/cloud/mqtt.js +517 -0
- package/bld/library/cloud/mqtt.js.map +1 -0
- package/bld/library/cloud/transport.d.ts +8 -0
- package/bld/library/cloud/transport.js +30 -0
- package/bld/library/cloud/transport.js.map +1 -0
- package/bld/library/command.d.ts +6 -0
- package/bld/library/command.js +6 -0
- package/bld/library/command.js.map +1 -0
- package/bld/library/configuration.d.ts +62 -0
- package/bld/library/configuration.js +303 -0
- package/bld/library/configuration.js.map +1 -0
- package/bld/library/device.d.ts +68 -0
- package/bld/library/device.js +235 -0
- package/bld/library/device.js.map +1 -0
- package/bld/library/devices/air-conditioner.d.ts +48 -0
- package/bld/library/devices/air-conditioner.js +155 -0
- package/bld/library/devices/air-conditioner.js.map +1 -0
- package/bld/library/devices/command-effect.d.ts +35 -0
- package/bld/library/devices/command-effect.js +269 -0
- package/bld/library/devices/command-effect.js.map +1 -0
- package/bld/library/devices/dehumidifier.d.ts +41 -0
- package/bld/library/devices/dehumidifier.js +124 -0
- package/bld/library/devices/dehumidifier.js.map +1 -0
- package/bld/library/devices/fan.d.ts +37 -0
- package/bld/library/devices/fan.js +135 -0
- package/bld/library/devices/fan.js.map +1 -0
- package/bld/library/devices/index.d.ts +7 -0
- package/bld/library/devices/index.js +8 -0
- package/bld/library/devices/index.js.map +1 -0
- package/bld/library/devices/light.d.ts +22 -0
- package/bld/library/devices/light.js +112 -0
- package/bld/library/devices/light.js.map +1 -0
- package/bld/library/devices/placeholder.d.ts +3 -0
- package/bld/library/devices/placeholder.js +4 -0
- package/bld/library/devices/placeholder.js.map +1 -0
- package/bld/library/devices/value-range.d.ts +2 -0
- package/bld/library/devices/value-range.js +6 -0
- package/bld/library/devices/value-range.js.map +1 -0
- package/bld/library/endpoint-connection.d.ts +154 -0
- package/bld/library/endpoint-connection.js +510 -0
- package/bld/library/endpoint-connection.js.map +1 -0
- package/bld/library/index.d.ts +26 -0
- package/bld/library/index.js +31 -0
- package/bld/library/index.js.map +1 -0
- package/bld/library/local/certificate.d.ts +31 -0
- package/bld/library/local/certificate.js +298 -0
- package/bld/library/local/certificate.js.map +1 -0
- package/bld/library/local/controller.d.ts +70 -0
- package/bld/library/local/controller.js +497 -0
- package/bld/library/local/controller.js.map +1 -0
- package/bld/library/local/discovery.d.ts +29 -0
- package/bld/library/local/discovery.js +321 -0
- package/bld/library/local/discovery.js.map +1 -0
- package/bld/library/local/index.d.ts +6 -0
- package/bld/library/local/index.js +7 -0
- package/bld/library/local/index.js.map +1 -0
- package/bld/library/local/message.d.ts +11 -0
- package/bld/library/local/message.js +128 -0
- package/bld/library/local/message.js.map +1 -0
- package/bld/library/local/mqtt.d.ts +113 -0
- package/bld/library/local/mqtt.js +1044 -0
- package/bld/library/local/mqtt.js.map +1 -0
- package/bld/library/local/routed-message-client.d.ts +49 -0
- package/bld/library/local/routed-message-client.js +326 -0
- package/bld/library/local/routed-message-client.js.map +1 -0
- package/bld/library/miot/index.d.ts +4 -0
- package/bld/library/miot/index.js +5 -0
- package/bld/library/miot/index.js.map +1 -0
- package/bld/library/miot/matcher.d.ts +65 -0
- package/bld/library/miot/matcher.js +217 -0
- package/bld/library/miot/matcher.js.map +1 -0
- package/bld/library/miot/request.d.ts +16 -0
- package/bld/library/miot/request.js +27 -0
- package/bld/library/miot/request.js.map +1 -0
- package/bld/library/miot/result.d.ts +4 -0
- package/bld/library/miot/result.js +5 -0
- package/bld/library/miot/result.js.map +1 -0
- package/bld/library/miot/spec.d.ts +74 -0
- package/bld/library/miot/spec.js +78 -0
- package/bld/library/miot/spec.js.map +1 -0
- package/bld/library/provider.d.ts +71 -0
- package/bld/library/provider.js +600 -0
- package/bld/library/provider.js.map +1 -0
- package/bld/library/session-manager.d.ts +34 -0
- package/bld/library/session-manager.js +177 -0
- package/bld/library/session-manager.js.map +1 -0
- package/bld/library/session.d.ts +36 -0
- package/bld/library/session.js +370 -0
- package/bld/library/session.js.map +1 -0
- package/bld/library/storage.d.ts +2 -0
- package/bld/library/storage.js +66 -0
- package/bld/library/storage.js.map +1 -0
- package/bld/library/terminal/bindings.d.ts +3 -0
- package/bld/library/terminal/bindings.js +280 -0
- package/bld/library/terminal/bindings.js.map +1 -0
- package/bld/library/terminal/index.d.ts +2 -0
- package/bld/library/terminal/index.js +3 -0
- package/bld/library/terminal/index.js.map +1 -0
- package/bld/library/terminal/provider-details.d.ts +3 -0
- package/bld/library/terminal/provider-details.js +477 -0
- package/bld/library/terminal/provider-details.js.map +1 -0
- package/package.json +29 -0
- package/src/library/backend/client.ts +713 -0
- package/src/library/backend/constants.ts +17 -0
- package/src/library/backend/index.ts +3 -0
- package/src/library/backend/oauth.ts +170 -0
- package/src/library/binding.ts +387 -0
- package/src/library/cloud/client.ts +155 -0
- package/src/library/cloud/constants.ts +19 -0
- package/src/library/cloud/device.ts +938 -0
- package/src/library/cloud/index.ts +5 -0
- package/src/library/cloud/mqtt.ts +671 -0
- package/src/library/cloud/transport.ts +38 -0
- package/src/library/command.ts +7 -0
- package/src/library/configuration.ts +480 -0
- package/src/library/device.ts +548 -0
- package/src/library/devices/air-conditioner.ts +171 -0
- package/src/library/devices/command-effect.ts +425 -0
- package/src/library/devices/dehumidifier.ts +131 -0
- package/src/library/devices/fan.ts +140 -0
- package/src/library/devices/index.ts +7 -0
- package/src/library/devices/light.ts +119 -0
- package/src/library/devices/placeholder.ts +3 -0
- package/src/library/devices/value-range.ts +14 -0
- package/src/library/endpoint-connection.ts +841 -0
- package/src/library/index.ts +62 -0
- package/src/library/local/certificate.ts +401 -0
- package/src/library/local/controller.ts +692 -0
- package/src/library/local/discovery.ts +485 -0
- package/src/library/local/index.ts +6 -0
- package/src/library/local/message.ts +174 -0
- package/src/library/local/mqtt.ts +1493 -0
- package/src/library/local/routed-message-client.ts +377 -0
- package/src/library/miot/index.ts +4 -0
- package/src/library/miot/matcher.ts +461 -0
- package/src/library/miot/request.ts +30 -0
- package/src/library/miot/result.ts +10 -0
- package/src/library/miot/spec.ts +103 -0
- package/src/library/provider.ts +745 -0
- package/src/library/session-manager.ts +224 -0
- package/src/library/session.ts +528 -0
- package/src/library/storage.ts +83 -0
- package/src/library/terminal/bindings.tsx +612 -0
- package/src/library/terminal/index.ts +2 -0
- package/src/library/terminal/provider-details.tsx +871 -0
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
const MIOT_INTEGER_FORMAT_RANGES = {
|
|
2
|
+
int8: [-128, 127],
|
|
3
|
+
int16: [-32768, 32767],
|
|
4
|
+
int32: [-2147483648, 2147483647],
|
|
5
|
+
uint8: [0, 255],
|
|
6
|
+
uint16: [0, 65535],
|
|
7
|
+
uint32: [0, 4294967295],
|
|
8
|
+
};
|
|
9
|
+
export function assertMiotPropertySchema(schema) {
|
|
10
|
+
const services = Object.entries(schema);
|
|
11
|
+
if (services.length === 0) {
|
|
12
|
+
throw new TypeError('A MIoT property schema requires a service.');
|
|
13
|
+
}
|
|
14
|
+
const nameSet = new Set();
|
|
15
|
+
for (const [serviceType, properties] of services) {
|
|
16
|
+
if (serviceType.length === 0 || Object.keys(properties).length === 0) {
|
|
17
|
+
throw new TypeError('Invalid MIoT property schema service.');
|
|
18
|
+
}
|
|
19
|
+
for (const [propertyType, mapping] of Object.entries(properties)) {
|
|
20
|
+
if (propertyType.length === 0) {
|
|
21
|
+
throw new TypeError('Invalid MIoT property schema property.');
|
|
22
|
+
}
|
|
23
|
+
const { name, enum: enumMapping } = getPropertyMapping(mapping);
|
|
24
|
+
if (name.length === 0 || name === '__proto__' || nameSet.has(name)) {
|
|
25
|
+
throw new TypeError('Invalid MIoT property schema name.');
|
|
26
|
+
}
|
|
27
|
+
nameSet.add(name);
|
|
28
|
+
if (enumMapping !== undefined && !isValidEnumMapping(enumMapping)) {
|
|
29
|
+
throw new TypeError('Invalid MIoT property schema enum.');
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
export function resolveMiotPropertySchema(spec, schema, options = {}) {
|
|
35
|
+
assertMiotPropertySchema(schema);
|
|
36
|
+
const { services, type: deviceType } = spec;
|
|
37
|
+
const resources = [];
|
|
38
|
+
const serviceIidSet = new Set();
|
|
39
|
+
for (const [serviceType, propertySchema] of Object.entries(schema)) {
|
|
40
|
+
const required = Object.values(propertySchema).some(mapping => !getPropertyMapping(mapping).optional);
|
|
41
|
+
const matches = services.flatMap(service => {
|
|
42
|
+
if (!matchesMiotUrnPattern(service.type, serviceType)) {
|
|
43
|
+
return [];
|
|
44
|
+
}
|
|
45
|
+
const properties = resolveServiceProperties(deviceType, service, propertySchema);
|
|
46
|
+
return properties === undefined ||
|
|
47
|
+
(!required && Object.keys(properties).length === 0)
|
|
48
|
+
? []
|
|
49
|
+
: [{ service, properties }];
|
|
50
|
+
});
|
|
51
|
+
if ((required && matches.length !== 1) ||
|
|
52
|
+
(!required &&
|
|
53
|
+
!options.allowMultipleOptionalServices &&
|
|
54
|
+
matches.length > 1)) {
|
|
55
|
+
return undefined;
|
|
56
|
+
}
|
|
57
|
+
for (const match of matches) {
|
|
58
|
+
if (serviceIidSet.has(match.service.iid)) {
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
61
|
+
serviceIidSet.add(match.service.iid);
|
|
62
|
+
resources.push(match);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return resources;
|
|
66
|
+
}
|
|
67
|
+
export function isValidMiotSpecValueList(valueList) {
|
|
68
|
+
if (valueList === undefined || valueList.length === 0) {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
return isValidUniqueNumberSet(valueList.map(entry => entry.value));
|
|
72
|
+
}
|
|
73
|
+
export function isValidMiotSpecValueRange(valueRange, format) {
|
|
74
|
+
if (valueRange === undefined) {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
const [minimum, maximum, step] = valueRange;
|
|
78
|
+
if (!Number.isFinite(minimum) ||
|
|
79
|
+
!Number.isFinite(maximum) ||
|
|
80
|
+
!Number.isFinite(step) ||
|
|
81
|
+
minimum >= maximum ||
|
|
82
|
+
step <= 0) {
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
const stepCount = (maximum - minimum) / step;
|
|
86
|
+
if (!isApproximatelyInteger(stepCount)) {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
const formatRange = format === undefined ? undefined : MIOT_INTEGER_FORMAT_RANGES[format];
|
|
90
|
+
if (formatRange === undefined) {
|
|
91
|
+
return true;
|
|
92
|
+
}
|
|
93
|
+
const [formatMinimum, formatMaximum] = formatRange;
|
|
94
|
+
return (Number.isInteger(minimum) &&
|
|
95
|
+
Number.isInteger(maximum) &&
|
|
96
|
+
Number.isInteger(step) &&
|
|
97
|
+
minimum >= formatMinimum &&
|
|
98
|
+
maximum <= formatMaximum);
|
|
99
|
+
}
|
|
100
|
+
function resolveServiceProperties(deviceType, service, schema) {
|
|
101
|
+
var _a;
|
|
102
|
+
const properties = {};
|
|
103
|
+
const usedPropertyIids = new Set();
|
|
104
|
+
const optionalCandidates = [];
|
|
105
|
+
const optionalPropertyUseCount = new Map();
|
|
106
|
+
for (const [propertyType, configuredMapping] of Object.entries(schema)) {
|
|
107
|
+
const mapping = getPropertyMapping(configuredMapping);
|
|
108
|
+
const enumMapping = mapping.enum === undefined
|
|
109
|
+
? undefined
|
|
110
|
+
: selectMiotUrnPatternValue(deviceType, mapping.enum);
|
|
111
|
+
const candidates = findPropertyCandidates(service, propertyType, enumMapping, mapping.enum !== undefined);
|
|
112
|
+
const [property] = candidates;
|
|
113
|
+
if (!mapping.optional) {
|
|
114
|
+
if (candidates.length !== 1 ||
|
|
115
|
+
property === undefined ||
|
|
116
|
+
usedPropertyIids.has(property.iid)) {
|
|
117
|
+
return undefined;
|
|
118
|
+
}
|
|
119
|
+
properties[mapping.name] = resolveProperty(property, enumMapping);
|
|
120
|
+
usedPropertyIids.add(property.iid);
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
if (candidates.length !== 1 ||
|
|
124
|
+
property === undefined ||
|
|
125
|
+
usedPropertyIids.has(property.iid)) {
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
optionalCandidates.push([
|
|
129
|
+
mapping.name,
|
|
130
|
+
resolveProperty(property, enumMapping),
|
|
131
|
+
]);
|
|
132
|
+
optionalPropertyUseCount.set(property.iid, ((_a = optionalPropertyUseCount.get(property.iid)) !== null && _a !== void 0 ? _a : 0) + 1);
|
|
133
|
+
}
|
|
134
|
+
for (const [name, property] of optionalCandidates) {
|
|
135
|
+
if (optionalPropertyUseCount.get(property.iid) === 1 &&
|
|
136
|
+
!usedPropertyIids.has(property.iid)) {
|
|
137
|
+
properties[name] = property;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return properties;
|
|
141
|
+
}
|
|
142
|
+
function findPropertyCandidates(service, propertyType, enumMapping, requiresEnumMapping) {
|
|
143
|
+
var _a;
|
|
144
|
+
return ((_a = service.properties) !== null && _a !== void 0 ? _a : []).filter(property => {
|
|
145
|
+
if (!matchesMiotUrnPattern(property.type, propertyType)) {
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
148
|
+
// Vendor instances can declare different access modes for the same base
|
|
149
|
+
// property type.
|
|
150
|
+
// State-backed aliases must remain observable between commands so that
|
|
151
|
+
// acknowledged effects can be reconciled with manual device changes.
|
|
152
|
+
if (!property.access.includes('read') ||
|
|
153
|
+
!property.access.includes('notify')) {
|
|
154
|
+
return false;
|
|
155
|
+
}
|
|
156
|
+
if (enumMapping === undefined) {
|
|
157
|
+
return !requiresEnumMapping;
|
|
158
|
+
}
|
|
159
|
+
const valueList = property['value-list'];
|
|
160
|
+
return (isValidMiotSpecValueList(valueList) &&
|
|
161
|
+
Object.values(enumMapping).some(value => valueList.some(entry => entry.value === value)));
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
function resolveProperty(property, enumMapping) {
|
|
165
|
+
return enumMapping === undefined
|
|
166
|
+
? property
|
|
167
|
+
: Object.assign({}, property, { enum: enumMapping });
|
|
168
|
+
}
|
|
169
|
+
function getPropertyMapping(mapping) {
|
|
170
|
+
return typeof mapping === 'string'
|
|
171
|
+
? { name: mapping, optional: false }
|
|
172
|
+
: {
|
|
173
|
+
name: mapping.name,
|
|
174
|
+
enum: mapping.enum,
|
|
175
|
+
optional: mapping.optional === true,
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
function isValidEnumMapping(mapping) {
|
|
179
|
+
const entries = Object.entries(mapping);
|
|
180
|
+
return (entries.length > 0 &&
|
|
181
|
+
entries.every(([pattern, valueMapping]) => pattern.length > 0 && isValidEnumValueMapping(valueMapping)));
|
|
182
|
+
}
|
|
183
|
+
function isValidEnumValueMapping(mapping) {
|
|
184
|
+
const entries = Object.entries(mapping);
|
|
185
|
+
return (entries.length > 0 &&
|
|
186
|
+
entries.every(([key, value]) => key.length > 0 && Number.isFinite(value)) &&
|
|
187
|
+
new Set(entries.map(([, value]) => value)).size === entries.length);
|
|
188
|
+
}
|
|
189
|
+
/** Selects a matching pattern that is nested within every other match. */
|
|
190
|
+
export function selectMiotUrnPatternValue(urn, values) {
|
|
191
|
+
var _a;
|
|
192
|
+
const matches = Object.entries(values).filter(([pattern]) => matchesMiotUrnPattern(urn, pattern));
|
|
193
|
+
const nestedMatches = matches.filter(([pattern]) => matches.every(([otherPattern]) => pattern === otherPattern ||
|
|
194
|
+
matchesMiotUrnPattern(pattern, otherPattern)));
|
|
195
|
+
return nestedMatches.length === 1 ? (_a = nestedMatches[0]) === null || _a === void 0 ? void 0 : _a[1] : undefined;
|
|
196
|
+
}
|
|
197
|
+
/** Matches a pattern against the beginning of a complete MIoT URN. */
|
|
198
|
+
export function matchesMiotUrnPattern(urn, pattern) {
|
|
199
|
+
const source = pattern
|
|
200
|
+
.split('*')
|
|
201
|
+
.map(part => part.replace(/[\\^$.*+?()[\]{}|]/g, '\\$&'))
|
|
202
|
+
.join('[^:]+');
|
|
203
|
+
return new RegExp(`^${source}(?=:|$)`).test(urn);
|
|
204
|
+
}
|
|
205
|
+
function isValidUniqueNumberSet(values) {
|
|
206
|
+
return (values.every(value => Number.isFinite(value)) &&
|
|
207
|
+
new Set(values).size === values.length);
|
|
208
|
+
}
|
|
209
|
+
function isApproximatelyInteger(value) {
|
|
210
|
+
if (!Number.isFinite(value)) {
|
|
211
|
+
return false;
|
|
212
|
+
}
|
|
213
|
+
const nearestInteger = Math.round(value);
|
|
214
|
+
const tolerance = Number.EPSILON * Math.max(1, Math.abs(value)) * 8;
|
|
215
|
+
return Math.abs(value - nearestInteger) <= tolerance;
|
|
216
|
+
}
|
|
217
|
+
//# sourceMappingUR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AC,MAAyB;IACvD,OAAO,CACL,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QAC7C,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC,MAAM,CACvC,CAAC;AACJ,CAAC;AAED,SAAS,sBAAsB,CAAC,KAAa;IAC3C,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QAC5B,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACzC,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC;IAEpE,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,cAAc,CAAC,IAAI,SAAS,CAAC;AACvD,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare abstract class MiotRequest {
|
|
2
|
+
private readonly requestBrand;
|
|
3
|
+
toLogString(): string;
|
|
4
|
+
}
|
|
5
|
+
export declare class MiotSetPropertyRequest extends MiotRequest {
|
|
6
|
+
readonly property: MiotProperty;
|
|
7
|
+
readonly value: unknown;
|
|
8
|
+
constructor(property: MiotProperty, value: unknown);
|
|
9
|
+
toLogString(): string;
|
|
10
|
+
}
|
|
11
|
+
export type MiotExecutionRequest = MiotSetPropertyRequest;
|
|
12
|
+
export type MiotProperty = {
|
|
13
|
+
readonly did: string;
|
|
14
|
+
readonly siid: number;
|
|
15
|
+
readonly piid: number;
|
|
16
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export class MiotRequest {
|
|
2
|
+
toLogString() {
|
|
3
|
+
return this.constructor.name;
|
|
4
|
+
}
|
|
5
|
+
}
|
|
6
|
+
export class MiotSetPropertyRequest extends MiotRequest {
|
|
7
|
+
constructor(property, value) {
|
|
8
|
+
super();
|
|
9
|
+
Object.defineProperty(this, "property", {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
configurable: true,
|
|
12
|
+
writable: true,
|
|
13
|
+
value: property
|
|
14
|
+
});
|
|
15
|
+
Object.defineProperty(this, "value", {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
configurable: true,
|
|
18
|
+
writable: true,
|
|
19
|
+
value: value
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
toLogString() {
|
|
23
|
+
const { did, siid, piid } = this.property;
|
|
24
|
+
return `miot set did=${did} siid=${siid} piid=${piid}`;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=request.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request.js","sourceRoot":"","sources":["../../../src/library/miot/request.ts"],"names":[],"mappings":"AAAA,MAAM,OAAgB,WAAW;IAG/B,WAAW;QACT,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;IAC/B,CAAC;CACF;AAED,MAAM,OAAO,sBAAuB,SAAQ,WAAW;IACrD,YACW,QAAsB,EACtB,KAAc;QAEvB,KAAK,EAAE,CAAC;QAHR;;;;mBAAS,QAAQ;WAAc;QAC/B;;;;mBAAS,KAAK;WAAS;IAGzB,CAAC;IAEQ,WAAW;QAClB,MAAM,EAAC,GAAG,EAAE,IAAI,EAAE,IAAI,EAAC,GAAG,IAAI,CAAC,QAAQ,CAAC;QAExC,OAAO,gBAAgB,GAAG,SAAS,IAAI,SAAS,IAAI,EAAE,CAAC;IACzD,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"result.js","sourceRoot":"","sources":["../../../src/library/miot/result.ts"],"names":[],"mappings":"AAAA,iFAAiF;AACjF,MAAM,UAAU,+BAA+B,CAC7C,MAA2B;IAE3B,OAAO,MAAM,CAAC,IAAI,KAAK,CAAC,IAAI,MAAM,CAAC,IAAI,KAAK,CAAC,CAAC;AAChD,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import * as x from 'x-value';
|
|
2
|
+
export declare class MiotSpecClient {
|
|
3
|
+
private readonly instancePromiseMap;
|
|
4
|
+
getInstance(urn: string): Promise<MiotSpecInstance>;
|
|
5
|
+
private requestInstance;
|
|
6
|
+
}
|
|
7
|
+
export declare const MiotSpecValueRange: x.TupleType<[x.AtomicType<typeof x.numberTypeSymbol>, x.AtomicType<typeof x.numberTypeSymbol>, x.AtomicType<typeof x.numberTypeSymbol>]>;
|
|
8
|
+
export type MiotSpecValueRange = x.TypeOf<typeof MiotSpecValueRange>;
|
|
9
|
+
export declare const MiotSpecValueListEntry: x.ObjectType<{
|
|
10
|
+
value: x.AtomicType<typeof x.numberTypeSymbol>;
|
|
11
|
+
description: x.AtomicType<typeof x.stringTypeSymbol>;
|
|
12
|
+
}>;
|
|
13
|
+
export type MiotSpecValueListEntry = x.TypeOf<typeof MiotSpecValueListEntry>;
|
|
14
|
+
export declare const MiotSpecValueList: x.ArrayType<x.ObjectType<{
|
|
15
|
+
value: x.AtomicType<typeof x.numberTypeSymbol>;
|
|
16
|
+
description: x.AtomicType<typeof x.stringTypeSymbol>;
|
|
17
|
+
}>>;
|
|
18
|
+
export type MiotSpecValueList = x.TypeOf<typeof MiotSpecValueList>;
|
|
19
|
+
export declare const MiotSpecProperty: x.ObjectType<{
|
|
20
|
+
iid: x.AtomicType<typeof x.numberTypeSymbol>;
|
|
21
|
+
type: x.AtomicType<typeof x.stringTypeSymbol>;
|
|
22
|
+
description: x.AtomicType<typeof x.stringTypeSymbol>;
|
|
23
|
+
format: x.AtomicType<typeof x.stringTypeSymbol>;
|
|
24
|
+
access: x.ArrayType<x.AtomicType<typeof x.stringTypeSymbol>>;
|
|
25
|
+
unit: x.OptionalType<x.AtomicType<typeof x.stringTypeSymbol>>;
|
|
26
|
+
'value-range': x.OptionalType<x.TupleType<[x.AtomicType<typeof x.numberTypeSymbol>, x.AtomicType<typeof x.numberTypeSymbol>, x.AtomicType<typeof x.numberTypeSymbol>]>>;
|
|
27
|
+
'value-list': x.OptionalType<x.ArrayType<x.ObjectType<{
|
|
28
|
+
value: x.AtomicType<typeof x.numberTypeSymbol>;
|
|
29
|
+
description: x.AtomicType<typeof x.stringTypeSymbol>;
|
|
30
|
+
}>>>;
|
|
31
|
+
}>;
|
|
32
|
+
export type MiotSpecProperty = x.TypeOf<typeof MiotSpecProperty>;
|
|
33
|
+
export declare const MiotSpecService: x.ObjectType<{
|
|
34
|
+
iid: x.AtomicType<typeof x.numberTypeSymbol>;
|
|
35
|
+
type: x.AtomicType<typeof x.stringTypeSymbol>;
|
|
36
|
+
description: x.AtomicType<typeof x.stringTypeSymbol>;
|
|
37
|
+
properties: x.OptionalType<x.ArrayType<x.ObjectType<{
|
|
38
|
+
iid: x.AtomicType<typeof x.numberTypeSymbol>;
|
|
39
|
+
type: x.AtomicType<typeof x.stringTypeSymbol>;
|
|
40
|
+
description: x.AtomicType<typeof x.stringTypeSymbol>;
|
|
41
|
+
format: x.AtomicType<typeof x.stringTypeSymbol>;
|
|
42
|
+
access: x.ArrayType<x.AtomicType<typeof x.stringTypeSymbol>>;
|
|
43
|
+
unit: x.OptionalType<x.AtomicType<typeof x.stringTypeSymbol>>;
|
|
44
|
+
'value-range': x.OptionalType<x.TupleType<[x.AtomicType<typeof x.numberTypeSymbol>, x.AtomicType<typeof x.numberTypeSymbol>, x.AtomicType<typeof x.numberTypeSymbol>]>>;
|
|
45
|
+
'value-list': x.OptionalType<x.ArrayType<x.ObjectType<{
|
|
46
|
+
value: x.AtomicType<typeof x.numberTypeSymbol>;
|
|
47
|
+
description: x.AtomicType<typeof x.stringTypeSymbol>;
|
|
48
|
+
}>>>;
|
|
49
|
+
}>>>;
|
|
50
|
+
}>;
|
|
51
|
+
export type MiotSpecService = x.TypeOf<typeof MiotSpecService>;
|
|
52
|
+
export declare const MiotSpecInstance: x.ObjectType<{
|
|
53
|
+
type: x.AtomicType<typeof x.stringTypeSymbol>;
|
|
54
|
+
description: x.AtomicType<typeof x.stringTypeSymbol>;
|
|
55
|
+
services: x.ArrayType<x.ObjectType<{
|
|
56
|
+
iid: x.AtomicType<typeof x.numberTypeSymbol>;
|
|
57
|
+
type: x.AtomicType<typeof x.stringTypeSymbol>;
|
|
58
|
+
description: x.AtomicType<typeof x.stringTypeSymbol>;
|
|
59
|
+
properties: x.OptionalType<x.ArrayType<x.ObjectType<{
|
|
60
|
+
iid: x.AtomicType<typeof x.numberTypeSymbol>;
|
|
61
|
+
type: x.AtomicType<typeof x.stringTypeSymbol>;
|
|
62
|
+
description: x.AtomicType<typeof x.stringTypeSymbol>;
|
|
63
|
+
format: x.AtomicType<typeof x.stringTypeSymbol>;
|
|
64
|
+
access: x.ArrayType<x.AtomicType<typeof x.stringTypeSymbol>>;
|
|
65
|
+
unit: x.OptionalType<x.AtomicType<typeof x.stringTypeSymbol>>;
|
|
66
|
+
'value-range': x.OptionalType<x.TupleType<[x.AtomicType<typeof x.numberTypeSymbol>, x.AtomicType<typeof x.numberTypeSymbol>, x.AtomicType<typeof x.numberTypeSymbol>]>>;
|
|
67
|
+
'value-list': x.OptionalType<x.ArrayType<x.ObjectType<{
|
|
68
|
+
value: x.AtomicType<typeof x.numberTypeSymbol>;
|
|
69
|
+
description: x.AtomicType<typeof x.stringTypeSymbol>;
|
|
70
|
+
}>>>;
|
|
71
|
+
}>>>;
|
|
72
|
+
}>>;
|
|
73
|
+
}>;
|
|
74
|
+
export type MiotSpecInstance = x.TypeOf<typeof MiotSpecInstance>;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import * as x from 'x-value';
|
|
2
|
+
const MIOT_SPEC_INSTANCE_URL = 'https://miot-spec.org/miot-spec-v2/instance';
|
|
3
|
+
const MIOT_SPEC_REQUEST_TIMEOUT = 30000;
|
|
4
|
+
export class MiotSpecClient {
|
|
5
|
+
constructor() {
|
|
6
|
+
Object.defineProperty(this, "instancePromiseMap", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
configurable: true,
|
|
9
|
+
writable: true,
|
|
10
|
+
value: new Map()
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
getInstance(urn) {
|
|
14
|
+
const cachedInstancePromise = this.instancePromiseMap.get(urn);
|
|
15
|
+
if (cachedInstancePromise !== undefined) {
|
|
16
|
+
return cachedInstancePromise;
|
|
17
|
+
}
|
|
18
|
+
const instancePromise = withRequestTimeout(this.requestInstance(urn));
|
|
19
|
+
this.instancePromiseMap.set(urn, instancePromise);
|
|
20
|
+
void instancePromise.catch(() => {
|
|
21
|
+
if (this.instancePromiseMap.get(urn) === instancePromise) {
|
|
22
|
+
this.instancePromiseMap.delete(urn);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
return instancePromise;
|
|
26
|
+
}
|
|
27
|
+
async requestInstance(urn) {
|
|
28
|
+
const url = new URL(MIOT_SPEC_INSTANCE_URL);
|
|
29
|
+
url.searchParams.set('type', urn);
|
|
30
|
+
const response = await fetch(url);
|
|
31
|
+
if (!response.ok) {
|
|
32
|
+
throw new Error(`Failed to get MIoT spec instance: ${response.status}.`);
|
|
33
|
+
}
|
|
34
|
+
return MiotSpecInstance.satisfies(await response.json());
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
export const MiotSpecValueRange = x.tuple([x.number, x.number, x.number]);
|
|
38
|
+
export const MiotSpecValueListEntry = x.object({
|
|
39
|
+
value: x.number,
|
|
40
|
+
description: x.string,
|
|
41
|
+
});
|
|
42
|
+
export const MiotSpecValueList = x.array(MiotSpecValueListEntry);
|
|
43
|
+
export const MiotSpecProperty = x.object({
|
|
44
|
+
iid: x.number,
|
|
45
|
+
type: x.string,
|
|
46
|
+
description: x.string,
|
|
47
|
+
format: x.string,
|
|
48
|
+
access: x.array(x.string),
|
|
49
|
+
unit: x.string.optional(),
|
|
50
|
+
'value-range': MiotSpecValueRange.optional(),
|
|
51
|
+
'value-list': MiotSpecValueList.optional(),
|
|
52
|
+
});
|
|
53
|
+
export const MiotSpecService = x.object({
|
|
54
|
+
iid: x.number,
|
|
55
|
+
type: x.string,
|
|
56
|
+
description: x.string,
|
|
57
|
+
properties: x.array(MiotSpecProperty).optional(),
|
|
58
|
+
});
|
|
59
|
+
export const MiotSpecInstance = x.object({
|
|
60
|
+
type: x.string,
|
|
61
|
+
description: x.string,
|
|
62
|
+
services: x.array(MiotSpecService),
|
|
63
|
+
});
|
|
64
|
+
function withRequestTimeout(request) {
|
|
65
|
+
let timeout;
|
|
66
|
+
const timeoutPromise = new Promise((_resolve, reject) => {
|
|
67
|
+
timeout = setTimeout(() => {
|
|
68
|
+
reject(new Error('MIoT spec request timed out.'));
|
|
69
|
+
}, MIOT_SPEC_REQUEST_TIMEOUT);
|
|
70
|
+
});
|
|
71
|
+
// This bounds the cached request's wait; the underlying fetch keeps running.
|
|
72
|
+
return Promise.race([request, timeoutPromise]).finally(() => {
|
|
73
|
+
if (timeout !== undefined) {
|
|
74
|
+
clearTimeout(timeout);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spec.js","sourceRoot":"","sources":["../../../src/library/miot/spec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAE7B,MAAM,sBAAsB,GAAG,6CAA6C,CAAC;AAC7E,MAAM,yBAAyB,GAAG,KAAM,CAAC;AAEzC,MAAM,OAAO,cAAc;IAA3B;QACmB;;;;mBAAqB,IAAI,GAAG,EAG1C;WAAC;IAgCN,CAAC;IA9BC,WAAW,CAAC,GAAW;QACrB,MAAM,qBAAqB,GAAG,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAE/D,IAAI,qBAAqB,KAAK,SAAS,EAAE,CAAC;YACxC,OAAO,qBAAqB,CAAC;Q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C,EAAE,yBAAyB,CAAC,CAAC;IAChC,CAAC,CAAC,CAAC;IAEH,6EAA6E;IAC7E,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE;QAC1D,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YAC1B,YAAY,CAAC,OAAO,CAAC,CAAC;QACxB,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { type Device, type DeviceConstructor, type EndpointConnectionBindingPlan, type EndpointReference, Provider } from '@homelib/core';
|
|
2
|
+
import { MiotProviderConfiguration } from './configuration.js';
|
|
3
|
+
import { type MiotEndpointConnection, MiotEndpointConnectionMetadata } from './endpoint-connection.js';
|
|
4
|
+
export declare const MIOT_NAMESPACE = "miot";
|
|
5
|
+
export declare class MiotProvider extends Provider<MiotEndpointConnectionMetadata> {
|
|
6
|
+
readonly EndpointConnectionMetadata: import("x-value").RefinedType<import("x-value").ObjectType<{
|
|
7
|
+
device: import("x-value").ObjectType<{
|
|
8
|
+
did: import("x-value").AtomicType<typeof import("x-value").stringTypeSymbol>;
|
|
9
|
+
model: import("x-value").OptionalType<import("x-value").AtomicType<typeof import("x-value").stringTypeSymbol>>;
|
|
10
|
+
urn: import("x-value").AtomicType<typeof import("x-value").stringTypeSymbol>;
|
|
11
|
+
}>;
|
|
12
|
+
resources: import("x-value").ArrayType<import("x-value").ObjectType<{
|
|
13
|
+
service: import("x-value").ObjectType<{
|
|
14
|
+
iid: import("x-value").AtomicType<typeof import("x-value").numberTypeSymbol>;
|
|
15
|
+
type: import("x-value").AtomicType<typeof import("x-value").stringTypeSymbol>;
|
|
16
|
+
description: import("x-value").AtomicType<typeof import("x-value").stringTypeSymbol>;
|
|
17
|
+
properties: import("x-value").OptionalType<import("x-value").ArrayType<import("x-value").ObjectType<{
|
|
18
|
+
iid: import("x-value").AtomicType<typeof import("x-value").numberTypeSymbol>;
|
|
19
|
+
type: import("x-value").AtomicType<typeof import("x-value").stringTypeSymbol>;
|
|
20
|
+
description: import("x-value").AtomicType<typeof import("x-value").stringTypeSymbol>;
|
|
21
|
+
format: import("x-value").AtomicType<typeof import("x-value").stringTypeSymbol>;
|
|
22
|
+
access: import("x-value").ArrayType<import("x-value").AtomicType<typeof import("x-value").stringTypeSymbol>>;
|
|
23
|
+
unit: import("x-value").OptionalType<import("x-value").AtomicType<typeof import("x-value").stringTypeSymbol>>;
|
|
24
|
+
'value-range': import("x-value").OptionalType<import("x-value").TupleType<[import("x-value").AtomicType<typeof import("x-value").numberTypeSymbol>, import("x-value").AtomicType<typeof import("x-value").numberTypeSymbol>, import("x-value").AtomicType<typeof import("x-value").numberTypeSymbol>]>>;
|
|
25
|
+
'value-list': import("x-value").OptionalType<import("x-value").ArrayType<import("x-value").ObjectType<{
|
|
26
|
+
value: import("x-value").AtomicType<typeof import("x-value").numberTypeSymbol>;
|
|
27
|
+
description: import("x-value").AtomicType<typeof import("x-value").stringTypeSymbol>;
|
|
28
|
+
}>>>;
|
|
29
|
+
}>>>;
|
|
30
|
+
}>;
|
|
31
|
+
}>>;
|
|
32
|
+
}>, never, unknown, false>;
|
|
33
|
+
readonly configuration: MiotProviderConfiguration;
|
|
34
|
+
private accessor endpointConnectionValues;
|
|
35
|
+
private readonly endpointConnectionSubscriptionMap;
|
|
36
|
+
private readonly endpointConnectionRuntimeMap;
|
|
37
|
+
private endpointConnectionCreationCount;
|
|
38
|
+
private endpointConnectionDisposalCount;
|
|
39
|
+
private cloudPromise;
|
|
40
|
+
private cloudValue;
|
|
41
|
+
private readonly discoveryBackendClientSet;
|
|
42
|
+
private authorizationInProgress;
|
|
43
|
+
private authorization;
|
|
44
|
+
private authorizationSetupPromise;
|
|
45
|
+
private authorizationGeneration;
|
|
46
|
+
private forgetAuthorizationPromise;
|
|
47
|
+
private readonly sessionPath;
|
|
48
|
+
private readonly oauthUuidPath;
|
|
49
|
+
private readonly localCertificateDirectory;
|
|
50
|
+
private readonly providerDirectory;
|
|
51
|
+
private readonly sessionManager;
|
|
52
|
+
constructor(name: string);
|
|
53
|
+
get endpointConnections(): readonly MiotEndpointConnection<never>[];
|
|
54
|
+
protected createEndpointConnectionBindingPlanFromMetadata(endpoint: EndpointReference, deviceConstructors: readonly DeviceConstructor<Device>[], metadata: MiotEndpointConnectionMetadata): EndpointConnectionBindingPlan;
|
|
55
|
+
private createEndpointConnectionBinding;
|
|
56
|
+
private getCloud;
|
|
57
|
+
private createCloud;
|
|
58
|
+
private loadLocalControllerDiscovery;
|
|
59
|
+
private discoverConfigurationDevices;
|
|
60
|
+
private beginConfigurationAuthorization;
|
|
61
|
+
private forgetConfigurationAuthorization;
|
|
62
|
+
private performForgetConfigurationAuthorization;
|
|
63
|
+
private completeForgetConfigurationAuthorization;
|
|
64
|
+
private assertAuthorizationGeneration;
|
|
65
|
+
private subscribeEndpointConnection;
|
|
66
|
+
private disposeEndpointConnection;
|
|
67
|
+
private disposeCloudIfUnused;
|
|
68
|
+
private addEndpointConnection;
|
|
69
|
+
private removeEndpointConnection;
|
|
70
|
+
}
|
|
71
|
+
export declare const $xiaomi: import("@homelib/core").ExtendedConstructorWithNameParameter<[], MiotProvider>;
|