node-switchbot 2.5.0-beta.2 → 2.5.0-beta.4
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/dist/parameter-checker.d.ts +78 -18
- package/dist/parameter-checker.d.ts.map +1 -1
- package/dist/parameter-checker.js +139 -334
- package/dist/parameter-checker.js.map +1 -1
- package/dist/settings.d.ts +5 -0
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js +3 -2
- package/dist/settings.js.map +1 -1
- package/dist/switchbot.d.ts +40 -15
- package/dist/switchbot.d.ts.map +1 -1
- package/dist/switchbot.js +41 -59
- package/dist/switchbot.js.map +1 -1
- package/dist/types/types.d.ts +4 -0
- package/dist/types/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ErrorObject } from './types/types.js';
|
|
1
2
|
interface Rule {
|
|
2
3
|
required?: boolean;
|
|
3
4
|
min?: number;
|
|
@@ -9,24 +10,83 @@ interface Rule {
|
|
|
9
10
|
type?: 'float' | 'integer' | 'boolean' | 'array' | 'object' | 'string';
|
|
10
11
|
}
|
|
11
12
|
declare class ParameterChecker {
|
|
12
|
-
_error
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
13
|
+
private _error;
|
|
14
|
+
/**
|
|
15
|
+
* Gets the current error object.
|
|
16
|
+
*
|
|
17
|
+
* @returns {ErrorObject | null} - The current error object or null if no error.
|
|
18
|
+
*/
|
|
19
|
+
get error(): ErrorObject | null;
|
|
20
|
+
/**
|
|
21
|
+
* Checks if the value is specified (not undefined).
|
|
22
|
+
*
|
|
23
|
+
* @param {unknown} value - The value to check.
|
|
24
|
+
* @returns {boolean} - True if the value is specified, false otherwise.
|
|
25
|
+
*/
|
|
26
|
+
isSpecified(value: unknown): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Checks if the specified object contains valid values based on the provided rules.
|
|
29
|
+
*
|
|
30
|
+
* @param {Record<string, unknown>} obj - Object including parameters you want to check.
|
|
31
|
+
* @param {Record<string, Rule>} rules - Object including rules for the parameters.
|
|
32
|
+
* @param {boolean} [required] - Flag whether the `obj` is required or not.
|
|
33
|
+
* @returns {Promise<boolean>} - Resolves to true if the value is valid, false otherwise.
|
|
34
|
+
*/
|
|
35
|
+
check(obj: Record<string, unknown>, rules: Record<string, Rule>, required?: boolean): Promise<boolean>;
|
|
36
|
+
/**
|
|
37
|
+
* Checks if the value is a float.
|
|
38
|
+
*
|
|
39
|
+
* @param {unknown} value - The value to check.
|
|
40
|
+
* @param {Rule} rule - The rule object containing validation criteria.
|
|
41
|
+
* @param {string} [name] - The parameter name.
|
|
42
|
+
* @returns {Promise<boolean>} - Resolves to true if the value is valid, false otherwise.
|
|
43
|
+
*/
|
|
44
|
+
isFloat(value: unknown, rule: Rule, name?: string): Promise<boolean>;
|
|
45
|
+
/**
|
|
46
|
+
* Checks if the value is an integer.
|
|
47
|
+
*
|
|
48
|
+
* @param {unknown} value - The value to check.
|
|
49
|
+
* @param {Rule} rule - The rule object containing validation criteria.
|
|
50
|
+
* @param {string} [name] - The parameter name.
|
|
51
|
+
* @returns {Promise<boolean>} - Resolves to true if the value is valid, false otherwise.
|
|
52
|
+
*/
|
|
53
|
+
isInteger(value: unknown, rule: Rule, name?: string): Promise<boolean>;
|
|
54
|
+
/**
|
|
55
|
+
* Checks if the value is a boolean.
|
|
56
|
+
*
|
|
57
|
+
* @param {unknown} value - The value to check.
|
|
58
|
+
* @param {Rule} rule - The rule object containing validation criteria.
|
|
59
|
+
* @param {string} [name] - The parameter name.
|
|
60
|
+
* @returns {Promise<boolean>} - Resolves to true if the value is valid, false otherwise.
|
|
61
|
+
*/
|
|
62
|
+
isBoolean(value: unknown, rule: Rule, name?: string): Promise<boolean>;
|
|
63
|
+
/**
|
|
64
|
+
* Checks if the value is an object.
|
|
65
|
+
*
|
|
66
|
+
* @param {unknown} value - The value to check.
|
|
67
|
+
* @param {Rule} rule - The rule object containing validation criteria.
|
|
68
|
+
* @param {string} [name] - The parameter name.
|
|
69
|
+
* @returns {Promise<boolean>} - Resolves to true if the value is valid, false otherwise.
|
|
70
|
+
*/
|
|
71
|
+
isObject(value: unknown, rule: Rule, name?: string): Promise<boolean>;
|
|
72
|
+
/**
|
|
73
|
+
* Checks if the value is an array.
|
|
74
|
+
*
|
|
75
|
+
* @param {unknown} value - The value to check.
|
|
76
|
+
* @param {Rule} rule - The rule object containing validation criteria.
|
|
77
|
+
* @param {string} [name] - The parameter name.
|
|
78
|
+
* @returns {Promise<boolean>} - Resolves to true if the value is valid, false otherwise.
|
|
79
|
+
*/
|
|
80
|
+
isArray(value: unknown, rule: Rule, name?: string): Promise<boolean>;
|
|
81
|
+
/**
|
|
82
|
+
* Checks if the value is a string.
|
|
83
|
+
*
|
|
84
|
+
* @param {unknown} value - The value to check.
|
|
85
|
+
* @param {Rule} rule - The rule object containing validation criteria.
|
|
86
|
+
* @param {string} [name] - The parameter name.
|
|
87
|
+
* @returns {Promise<boolean>} - Resolves to true if the value is valid, false otherwise.
|
|
88
|
+
*/
|
|
89
|
+
isString(value: unknown, rule: Rule, name?: string): Promise<boolean>;
|
|
30
90
|
}
|
|
31
91
|
export declare const parameterChecker: ParameterChecker;
|
|
32
92
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parameter-checker.d.ts","sourceRoot":"","sources":["../src/parameter-checker.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"parameter-checker.d.ts","sourceRoot":"","sources":["../src/parameter-checker.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAInD,UAAU,IAAI;IACZ,QAAQ,CAAC,EAAE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;;;;;;OAOG;IACG,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,SAAU,GAAG,OAAO,CAAC,OAAO,CAAC;IAyB3E;;;;;;;OAOG;IACG,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,SAAU,GAAG,OAAO,CAAC,OAAO,CAAC;CAkD7E;AAED,eAAO,MAAM,gBAAgB,kBAAyB,CAAA"}
|
|
@@ -1,214 +1,114 @@
|
|
|
1
|
-
/* Copyright(C) 2024, donavanbecker (https://github.com/donavanbecker). All rights reserved.
|
|
2
|
-
*
|
|
3
|
-
* parameter-checker.ts: Switchbot BLE API registration.
|
|
4
|
-
*/
|
|
5
1
|
import { Buffer } from 'node:buffer';
|
|
6
2
|
class ParameterChecker {
|
|
7
3
|
_error = null;
|
|
4
|
+
/**
|
|
5
|
+
* Gets the current error object.
|
|
6
|
+
*
|
|
7
|
+
* @returns {ErrorObject | null} - The current error object or null if no error.
|
|
8
|
+
*/
|
|
8
9
|
get error() {
|
|
9
|
-
// ----------------------------------
|
|
10
|
-
// Error
|
|
11
|
-
// {
|
|
12
|
-
// code: 'TYPE_INVALID',
|
|
13
|
-
// message: 'The `age` must be an integer.'
|
|
14
|
-
// name: 'age',
|
|
15
|
-
// }
|
|
16
|
-
// ---------------------------------
|
|
17
10
|
return this._error;
|
|
18
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* Checks if the value is specified (not undefined).
|
|
14
|
+
*
|
|
15
|
+
* @param {unknown} value - The value to check.
|
|
16
|
+
* @returns {boolean} - True if the value is specified, false otherwise.
|
|
17
|
+
*/
|
|
19
18
|
isSpecified(value) {
|
|
20
|
-
return value !==
|
|
19
|
+
return value !== undefined;
|
|
21
20
|
}
|
|
22
|
-
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* -
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
*
|
|
32
|
-
* [Return value]
|
|
33
|
-
* - If the value is valid, this method will return `true`.
|
|
34
|
-
* - If the value is invalid, this method will return `false` and
|
|
35
|
-
* an `Error` object will be set to `this._error`.
|
|
36
|
-
*
|
|
37
|
-
* [Usage]
|
|
38
|
-
* const valid = parameterChecker.check(params, {
|
|
39
|
-
* level: {
|
|
40
|
-
* required: false,
|
|
41
|
-
* type: 'integer',
|
|
42
|
-
* max: 100
|
|
43
|
-
* },
|
|
44
|
-
* greeting: {
|
|
45
|
-
* required: true, // But an empty string is allowed.
|
|
46
|
-
* type: 'string',
|
|
47
|
-
* max: 20 // the number of characters must be up to 20.
|
|
48
|
-
* }
|
|
49
|
-
* });
|
|
50
|
-
* if(!valid) {
|
|
51
|
-
* const message = parameterChecker.error.message;
|
|
52
|
-
* throw new Error(message);
|
|
53
|
-
* }
|
|
54
|
-
* ---------------------------------------------------------------- */
|
|
55
|
-
check(obj, rules, required) {
|
|
21
|
+
/**
|
|
22
|
+
* Checks if the specified object contains valid values based on the provided rules.
|
|
23
|
+
*
|
|
24
|
+
* @param {Record<string, unknown>} obj - Object including parameters you want to check.
|
|
25
|
+
* @param {Record<string, Rule>} rules - Object including rules for the parameters.
|
|
26
|
+
* @param {boolean} [required] - Flag whether the `obj` is required or not.
|
|
27
|
+
* @returns {Promise<boolean>} - Resolves to true if the value is valid, false otherwise.
|
|
28
|
+
*/
|
|
29
|
+
async check(obj, rules, required = false) {
|
|
56
30
|
this._error = null;
|
|
57
|
-
if (required) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
code: 'MISSING_REQUIRED',
|
|
61
|
-
message: 'The first argument is missing.',
|
|
62
|
-
};
|
|
63
|
-
return false;
|
|
64
|
-
}
|
|
31
|
+
if (required && !this.isSpecified(obj)) {
|
|
32
|
+
this._error = { code: 'MISSING_REQUIRED', message: 'The first argument is missing.' };
|
|
33
|
+
return false;
|
|
65
34
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
return true;
|
|
69
|
-
}
|
|
35
|
+
if (!required && !obj) {
|
|
36
|
+
return true;
|
|
70
37
|
}
|
|
71
38
|
if (!this.isObject(obj, {})) {
|
|
72
|
-
this._error = {
|
|
73
|
-
code: 'MISSING_REQUIRED',
|
|
74
|
-
message: 'The first argument is missing.',
|
|
75
|
-
};
|
|
39
|
+
this._error = { code: 'MISSING_REQUIRED', message: 'The first argument is missing.' };
|
|
76
40
|
return false;
|
|
77
41
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
const name = name_list[i];
|
|
82
|
-
const v = obj[name];
|
|
83
|
-
let rule = rules[name];
|
|
84
|
-
if (!rule) {
|
|
85
|
-
rule = {};
|
|
86
|
-
}
|
|
87
|
-
if (!this.isSpecified(v)) {
|
|
42
|
+
for (const [name, rule] of Object.entries(rules)) {
|
|
43
|
+
const value = obj[name];
|
|
44
|
+
if (!this.isSpecified(value)) {
|
|
88
45
|
if (rule.required) {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
code: 'MISSING_REQUIRED',
|
|
92
|
-
message: `The \`${name}\` is required.`,
|
|
93
|
-
};
|
|
94
|
-
break;
|
|
46
|
+
this._error = { code: 'MISSING_REQUIRED', message: `The \`${name}\` is required.` };
|
|
47
|
+
return false;
|
|
95
48
|
}
|
|
96
|
-
|
|
97
|
-
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
const typeCheckers = {
|
|
52
|
+
float: this.isFloat.bind(this),
|
|
53
|
+
integer: this.isInteger.bind(this),
|
|
54
|
+
boolean: this.isBoolean.bind(this),
|
|
55
|
+
array: this.isArray.bind(this),
|
|
56
|
+
object: this.isObject.bind(this),
|
|
57
|
+
string: this.isString.bind(this),
|
|
58
|
+
};
|
|
59
|
+
const checker = rule.type && typeCheckers[rule.type];
|
|
60
|
+
if (checker) {
|
|
61
|
+
if (!(await checker(value, rule, name))) {
|
|
62
|
+
return false;
|
|
98
63
|
}
|
|
99
64
|
}
|
|
100
|
-
if (rule.type === 'float') {
|
|
101
|
-
result = this.isFloat(v, rule, name);
|
|
102
|
-
}
|
|
103
|
-
else if (rule.type === 'integer') {
|
|
104
|
-
result = this.isInteger(v, rule, name);
|
|
105
|
-
}
|
|
106
|
-
else if (rule.type === 'boolean') {
|
|
107
|
-
result = this.isBoolean(v, rule, name);
|
|
108
|
-
}
|
|
109
|
-
else if (rule.type === 'array') {
|
|
110
|
-
result = this.isArray(v, rule, name);
|
|
111
|
-
}
|
|
112
|
-
else if (rule.type === 'object') {
|
|
113
|
-
result = this.isObject(v, rule, name);
|
|
114
|
-
}
|
|
115
|
-
else if (rule.type === 'string') {
|
|
116
|
-
result = this.isString(v, rule, name);
|
|
117
|
-
}
|
|
118
65
|
else {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
code: 'TYPE_UNKNOWN',
|
|
122
|
-
message: `The rule specified for the \`${name}\` includes an unknown type: ${rule.type}`,
|
|
123
|
-
};
|
|
66
|
+
this._error = { code: 'TYPE_UNKNOWN', message: `The rule specified for the \`${name}\` includes an unknown type: ${rule.type}` };
|
|
67
|
+
return false;
|
|
124
68
|
}
|
|
125
69
|
}
|
|
126
|
-
return
|
|
70
|
+
return true;
|
|
127
71
|
}
|
|
128
|
-
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
* -
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
* - max | Float | Optional | Maximum number
|
|
138
|
-
* - enum | Array | Optional | list of possible values
|
|
139
|
-
* - name | String | Optional | Parameter name
|
|
140
|
-
*
|
|
141
|
-
* If non-number value is specified to the `min` or `max`,
|
|
142
|
-
* they will be ignored.
|
|
143
|
-
*
|
|
144
|
-
* [Return value]
|
|
145
|
-
* - If the value is valid, this method will return `true`.
|
|
146
|
-
* - If the value is invalid, this method will return `false` and
|
|
147
|
-
* an `Error` object will be set to `this._error`.
|
|
148
|
-
* ---------------------------------------------------------------- */
|
|
149
|
-
isFloat(value, rule, name = 'value') {
|
|
72
|
+
/**
|
|
73
|
+
* Checks if the value is a float.
|
|
74
|
+
*
|
|
75
|
+
* @param {unknown} value - The value to check.
|
|
76
|
+
* @param {Rule} rule - The rule object containing validation criteria.
|
|
77
|
+
* @param {string} [name] - The parameter name.
|
|
78
|
+
* @returns {Promise<boolean>} - Resolves to true if the value is valid, false otherwise.
|
|
79
|
+
*/
|
|
80
|
+
async isFloat(value, rule, name = 'value') {
|
|
150
81
|
this._error = null;
|
|
151
82
|
if (!rule.required && !this.isSpecified(value)) {
|
|
152
83
|
return true;
|
|
153
84
|
}
|
|
154
85
|
if (typeof value !== 'number') {
|
|
155
|
-
this._error = {
|
|
156
|
-
code: 'TYPE_INVALID',
|
|
157
|
-
message: `The \`${name}\` must be a number (integer or float).`,
|
|
158
|
-
};
|
|
86
|
+
this._error = { code: 'TYPE_INVALID', message: `The \`${name}\` must be a number (integer or float).` };
|
|
159
87
|
return false;
|
|
160
88
|
}
|
|
161
|
-
if (typeof rule.min === 'number') {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
code: 'VALUE_UNDERFLOW',
|
|
165
|
-
message: `The \`${name}\` must be grater than or equal to ${rule.min}.`,
|
|
166
|
-
};
|
|
167
|
-
return false;
|
|
168
|
-
}
|
|
89
|
+
if (typeof rule.min === 'number' && value < rule.min) {
|
|
90
|
+
this._error = { code: 'VALUE_UNDERFLOW', message: `The \`${name}\` must be greater than or equal to ${rule.min}.` };
|
|
91
|
+
return false;
|
|
169
92
|
}
|
|
170
|
-
if (typeof rule.max === 'number') {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
code: 'VALUE_OVERFLOW',
|
|
174
|
-
message: `The \`${name}\` must be less than or equal to ${rule.max}.`,
|
|
175
|
-
};
|
|
176
|
-
return false;
|
|
177
|
-
}
|
|
93
|
+
if (typeof rule.max === 'number' && value > rule.max) {
|
|
94
|
+
this._error = { code: 'VALUE_OVERFLOW', message: `The \`${name}\` must be less than or equal to ${rule.max}.` };
|
|
95
|
+
return false;
|
|
178
96
|
}
|
|
179
|
-
if (Array.isArray(rule.enum) && rule.enum.
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
code: 'ENUM_UNMATCH',
|
|
183
|
-
message: `The \`${name}\` must be any one of ${JSON.stringify(rule.enum)}.`,
|
|
184
|
-
};
|
|
185
|
-
return false;
|
|
186
|
-
}
|
|
97
|
+
if (Array.isArray(rule.enum) && !rule.enum.includes(value)) {
|
|
98
|
+
this._error = { code: 'ENUM_UNMATCH', message: `The \`${name}\` must be any one of ${JSON.stringify(rule.enum)}.` };
|
|
99
|
+
return false;
|
|
187
100
|
}
|
|
188
101
|
return true;
|
|
189
102
|
}
|
|
190
|
-
|
|
191
|
-
*
|
|
192
|
-
*
|
|
193
|
-
*
|
|
194
|
-
*
|
|
195
|
-
*
|
|
196
|
-
* -
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
* - max | Float | Optional | Maximum number
|
|
200
|
-
* - enum | Array | Optional | list of possible values
|
|
201
|
-
* - name | String | Optional | Parameter name
|
|
202
|
-
*
|
|
203
|
-
* If non-number value is specified to the `min` or `max`,
|
|
204
|
-
* they will be ignored.
|
|
205
|
-
*
|
|
206
|
-
* [Return value]
|
|
207
|
-
* - If the value is valid, this method will return `true`.
|
|
208
|
-
* - If the value is invalid, this method will return `false` and
|
|
209
|
-
* an `Error` object will be set to `this._error`.
|
|
210
|
-
* ---------------------------------------------------------------- */
|
|
211
|
-
isInteger(value, rule, name = 'value') {
|
|
103
|
+
/**
|
|
104
|
+
* Checks if the value is an integer.
|
|
105
|
+
*
|
|
106
|
+
* @param {unknown} value - The value to check.
|
|
107
|
+
* @param {Rule} rule - The rule object containing validation criteria.
|
|
108
|
+
* @param {string} [name] - The parameter name.
|
|
109
|
+
* @returns {Promise<boolean>} - Resolves to true if the value is valid, false otherwise.
|
|
110
|
+
*/
|
|
111
|
+
async isInteger(value, rule, name = 'value') {
|
|
212
112
|
this._error = null;
|
|
213
113
|
if (!rule.required && !this.isSpecified(value)) {
|
|
214
114
|
return true;
|
|
@@ -216,215 +116,120 @@ class ParameterChecker {
|
|
|
216
116
|
if (Number.isInteger(value)) {
|
|
217
117
|
return true;
|
|
218
118
|
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
code: 'TYPE_INVALID',
|
|
222
|
-
message: `The \`${name}\` must be an integer.`,
|
|
223
|
-
};
|
|
224
|
-
return false;
|
|
225
|
-
}
|
|
119
|
+
this._error = { code: 'TYPE_INVALID', message: `The \`${name}\` must be an integer.` };
|
|
120
|
+
return false;
|
|
226
121
|
}
|
|
227
|
-
|
|
228
|
-
*
|
|
229
|
-
*
|
|
230
|
-
*
|
|
231
|
-
*
|
|
232
|
-
*
|
|
233
|
-
* -
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
*
|
|
237
|
-
* [Return value]
|
|
238
|
-
* - If the value is valid, this method will return `true`.
|
|
239
|
-
* - If the value is invalid, this method will return `false` and
|
|
240
|
-
* an `Error` object will be set to `this._error`.
|
|
241
|
-
* ---------------------------------------------------------------- */
|
|
242
|
-
isBoolean(value, rule, name = 'value') {
|
|
122
|
+
/**
|
|
123
|
+
* Checks if the value is a boolean.
|
|
124
|
+
*
|
|
125
|
+
* @param {unknown} value - The value to check.
|
|
126
|
+
* @param {Rule} rule - The rule object containing validation criteria.
|
|
127
|
+
* @param {string} [name] - The parameter name.
|
|
128
|
+
* @returns {Promise<boolean>} - Resolves to true if the value is valid, false otherwise.
|
|
129
|
+
*/
|
|
130
|
+
async isBoolean(value, rule, name = 'value') {
|
|
243
131
|
this._error = null;
|
|
244
132
|
if (!rule.required && !this.isSpecified(value)) {
|
|
245
133
|
return true;
|
|
246
134
|
}
|
|
247
135
|
if (typeof value !== 'boolean') {
|
|
248
|
-
this._error = {
|
|
249
|
-
code: 'TYPE_INVALID',
|
|
250
|
-
message: `The \`${name}\` must be boolean.`,
|
|
251
|
-
};
|
|
136
|
+
this._error = { code: 'TYPE_INVALID', message: `The \`${name}\` must be boolean.` };
|
|
252
137
|
return false;
|
|
253
138
|
}
|
|
254
139
|
return true;
|
|
255
140
|
}
|
|
256
|
-
|
|
257
|
-
*
|
|
258
|
-
*
|
|
259
|
-
*
|
|
260
|
-
*
|
|
261
|
-
*
|
|
262
|
-
* -
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
*
|
|
266
|
-
* [Return value]
|
|
267
|
-
* - If the value is valid, this method will return `true`.
|
|
268
|
-
* - If the value is invalid, this method will return `false` and
|
|
269
|
-
* an `Error` object will be set to `this._error`.
|
|
270
|
-
* ---------------------------------------------------------------- */
|
|
271
|
-
isObject(value, rule, name = 'value') {
|
|
141
|
+
/**
|
|
142
|
+
* Checks if the value is an object.
|
|
143
|
+
*
|
|
144
|
+
* @param {unknown} value - The value to check.
|
|
145
|
+
* @param {Rule} rule - The rule object containing validation criteria.
|
|
146
|
+
* @param {string} [name] - The parameter name.
|
|
147
|
+
* @returns {Promise<boolean>} - Resolves to true if the value is valid, false otherwise.
|
|
148
|
+
*/
|
|
149
|
+
async isObject(value, rule, name = 'value') {
|
|
272
150
|
this._error = null;
|
|
273
151
|
if (!rule.required && !this.isSpecified(value)) {
|
|
274
152
|
return true;
|
|
275
153
|
}
|
|
276
154
|
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
|
|
277
|
-
this._error = {
|
|
278
|
-
code: 'TYPE_INVALID',
|
|
279
|
-
message: `The \`${name}\` must be an object.`,
|
|
280
|
-
};
|
|
155
|
+
this._error = { code: 'TYPE_INVALID', message: `The \`${name}\` must be an object.` };
|
|
281
156
|
return false;
|
|
282
157
|
}
|
|
283
158
|
return true;
|
|
284
159
|
}
|
|
285
|
-
|
|
286
|
-
*
|
|
287
|
-
*
|
|
288
|
-
*
|
|
289
|
-
*
|
|
290
|
-
*
|
|
291
|
-
* -
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
* - max | Integer | Optional | Maximum number of elements in the array
|
|
295
|
-
* - name | String | Optional | Parameter name
|
|
296
|
-
*
|
|
297
|
-
* If non-number value is specified to the `min` or `max`,
|
|
298
|
-
* they will be ignored.
|
|
299
|
-
*
|
|
300
|
-
* [Return value]
|
|
301
|
-
* - If the value is valid, this method will return `true`.
|
|
302
|
-
* - If the value is invalid, this method will return `false` and
|
|
303
|
-
* an `Error` object will be set to `this._error`.
|
|
304
|
-
* ---------------------------------------------------------------- */
|
|
305
|
-
isArray(value, rule, name = 'value') {
|
|
160
|
+
/**
|
|
161
|
+
* Checks if the value is an array.
|
|
162
|
+
*
|
|
163
|
+
* @param {unknown} value - The value to check.
|
|
164
|
+
* @param {Rule} rule - The rule object containing validation criteria.
|
|
165
|
+
* @param {string} [name] - The parameter name.
|
|
166
|
+
* @returns {Promise<boolean>} - Resolves to true if the value is valid, false otherwise.
|
|
167
|
+
*/
|
|
168
|
+
async isArray(value, rule, name = 'value') {
|
|
306
169
|
this._error = null;
|
|
307
170
|
if (!rule.required && !this.isSpecified(value)) {
|
|
308
171
|
return true;
|
|
309
172
|
}
|
|
310
173
|
if (!Array.isArray(value)) {
|
|
311
|
-
this._error = {
|
|
312
|
-
code: 'TYPE_INVALID',
|
|
313
|
-
message: 'The value must be an array.',
|
|
314
|
-
};
|
|
174
|
+
this._error = { code: 'TYPE_INVALID', message: 'The value must be an array.' };
|
|
315
175
|
return false;
|
|
316
176
|
}
|
|
317
|
-
if (typeof rule.min === 'number') {
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
code: 'LENGTH_UNDERFLOW',
|
|
321
|
-
message: `The number of characters in the \`${name}\` must be grater than or equal to ${rule.min}.`,
|
|
322
|
-
};
|
|
323
|
-
return false;
|
|
324
|
-
}
|
|
177
|
+
if (typeof rule.min === 'number' && value.length < rule.min) {
|
|
178
|
+
this._error = { code: 'LENGTH_UNDERFLOW', message: `The number of elements in the \`${name}\` must be greater than or equal to ${rule.min}.` };
|
|
179
|
+
return false;
|
|
325
180
|
}
|
|
326
|
-
if (typeof rule.max === 'number') {
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
code: 'LENGTH_OVERFLOW',
|
|
330
|
-
message: `The number of characters in the \`${name}\` must be less than or equal to ${rule.max}.`,
|
|
331
|
-
};
|
|
332
|
-
return false;
|
|
333
|
-
}
|
|
181
|
+
if (typeof rule.max === 'number' && value.length > rule.max) {
|
|
182
|
+
this._error = { code: 'LENGTH_OVERFLOW', message: `The number of elements in the \`${name}\` must be less than or equal to ${rule.max}.` };
|
|
183
|
+
return false;
|
|
334
184
|
}
|
|
335
185
|
return true;
|
|
336
186
|
}
|
|
337
|
-
|
|
338
|
-
*
|
|
339
|
-
*
|
|
340
|
-
*
|
|
341
|
-
*
|
|
342
|
-
*
|
|
343
|
-
* -
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
* - max | Integer | Optional | Maximum number of characters in the string
|
|
347
|
-
* - minBytes | Integer | Optional | Minimum bytes of the string (UTF-8)
|
|
348
|
-
* - maxBytes | Integer | Optional | Maximum bytes of the string (UTF-8)
|
|
349
|
-
* - pattern | RegExp | Optional | Pattern of the string
|
|
350
|
-
* - enum | Array | Optional | list of possible values
|
|
351
|
-
* - name | String | Optional | Parameter name
|
|
352
|
-
*
|
|
353
|
-
* If non-number value is specified to the `min` or `max`,
|
|
354
|
-
* they will be ignored.
|
|
355
|
-
*
|
|
356
|
-
* [Return value]
|
|
357
|
-
* - If the value is valid, this method will return `true`.
|
|
358
|
-
* - If the value is invalid, this method will return `false` and
|
|
359
|
-
* an `Error` object will be set to `this._error`.
|
|
360
|
-
* ---------------------------------------------------------------- */
|
|
361
|
-
isString(value, rule, name = 'value') {
|
|
187
|
+
/**
|
|
188
|
+
* Checks if the value is a string.
|
|
189
|
+
*
|
|
190
|
+
* @param {unknown} value - The value to check.
|
|
191
|
+
* @param {Rule} rule - The rule object containing validation criteria.
|
|
192
|
+
* @param {string} [name] - The parameter name.
|
|
193
|
+
* @returns {Promise<boolean>} - Resolves to true if the value is valid, false otherwise.
|
|
194
|
+
*/
|
|
195
|
+
async isString(value, rule, name = 'value') {
|
|
362
196
|
this._error = null;
|
|
363
197
|
if (!rule.required && !this.isSpecified(value)) {
|
|
364
198
|
return true;
|
|
365
199
|
}
|
|
366
200
|
if (typeof value !== 'string') {
|
|
367
|
-
this._error = {
|
|
368
|
-
code: 'TYPE_INVALID',
|
|
369
|
-
message: 'The value must be a string.',
|
|
370
|
-
};
|
|
201
|
+
this._error = { code: 'TYPE_INVALID', message: 'The value must be a string.' };
|
|
371
202
|
return false;
|
|
372
203
|
}
|
|
373
|
-
if (typeof rule.min === 'number') {
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
code: 'LENGTH_UNDERFLOW',
|
|
377
|
-
message: `The number of characters in the \`${name}\` must be grater than or equal to ${rule.min}.`,
|
|
378
|
-
};
|
|
379
|
-
return false;
|
|
380
|
-
}
|
|
204
|
+
if (typeof rule.min === 'number' && value.length < rule.min) {
|
|
205
|
+
this._error = { code: 'LENGTH_UNDERFLOW', message: `The number of characters in the \`${name}\` must be greater than or equal to ${rule.min}.` };
|
|
206
|
+
return false;
|
|
381
207
|
}
|
|
382
|
-
if (typeof rule.max === 'number') {
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
code: 'LENGTH_OVERFLOW',
|
|
386
|
-
message: `The number of characters in the \`${name}\` must be less than or equal to ${rule.max}.`,
|
|
387
|
-
};
|
|
388
|
-
return false;
|
|
389
|
-
}
|
|
208
|
+
if (typeof rule.max === 'number' && value.length > rule.max) {
|
|
209
|
+
this._error = { code: 'LENGTH_OVERFLOW', message: `The number of characters in the \`${name}\` must be less than or equal to ${rule.max}.` };
|
|
210
|
+
return false;
|
|
390
211
|
}
|
|
391
212
|
if (typeof rule.minBytes === 'number') {
|
|
392
213
|
const blen = Buffer.from(value, 'utf8').length;
|
|
393
214
|
if (blen < rule.minBytes) {
|
|
394
|
-
this._error = {
|
|
395
|
-
code: 'LENGTH_UNDERFLOW',
|
|
396
|
-
message: `The byte length of the \`${name}\` (${blen} bytes) must be grater than or equal to ${rule.minBytes} bytes.`,
|
|
397
|
-
};
|
|
215
|
+
this._error = { code: 'LENGTH_UNDERFLOW', message: `The byte length of the \`${name}\` (${blen} bytes) must be greater than or equal to ${rule.minBytes} bytes.` };
|
|
398
216
|
return false;
|
|
399
217
|
}
|
|
400
218
|
}
|
|
401
219
|
if (typeof rule.maxBytes === 'number') {
|
|
402
220
|
const blen = Buffer.from(value, 'utf8').length;
|
|
403
221
|
if (blen > rule.maxBytes) {
|
|
404
|
-
this._error = {
|
|
405
|
-
code: 'LENGTH_OVERFLOW',
|
|
406
|
-
message: `The byte length of the \`${name}\` (${blen} bytes) must be less than or equal to ${rule.maxBytes} bytes.`,
|
|
407
|
-
};
|
|
222
|
+
this._error = { code: 'LENGTH_OVERFLOW', message: `The byte length of the \`${name}\` (${blen} bytes) must be less than or equal to ${rule.maxBytes} bytes.` };
|
|
408
223
|
return false;
|
|
409
224
|
}
|
|
410
225
|
}
|
|
411
|
-
if (rule.pattern instanceof RegExp) {
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
code: 'PATTERN_UNMATCH',
|
|
415
|
-
message: `The \`${name}\` does not conform with the pattern.`,
|
|
416
|
-
};
|
|
417
|
-
return false;
|
|
418
|
-
}
|
|
226
|
+
if (rule.pattern instanceof RegExp && !rule.pattern.test(value)) {
|
|
227
|
+
this._error = { code: 'PATTERN_UNMATCH', message: `The \`${name}\` does not conform with the pattern.` };
|
|
228
|
+
return false;
|
|
419
229
|
}
|
|
420
|
-
if (Array.isArray(rule.enum) && rule.enum.
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
code: 'ENUM_UNMATCH',
|
|
424
|
-
message: `The \`${name}\` must be any one of ${JSON.stringify(rule.enum)}.`,
|
|
425
|
-
};
|
|
426
|
-
return false;
|
|
427
|
-
}
|
|
230
|
+
if (Array.isArray(rule.enum) && !rule.enum.includes(value)) {
|
|
231
|
+
this._error = { code: 'ENUM_UNMATCH', message: `The \`${name}\` must be any one of ${JSON.stringify(rule.enum)}.` };
|
|
232
|
+
return false;
|
|
428
233
|
}
|
|
429
234
|
return true;
|
|
430
235
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parameter-checker.js","sourceRoot":"","sources":["../src/parameter-checker.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"parameter-checker.js","sourceRoot":"","sources":["../src/parameter-checker.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAapC,MAAM,gBAAgB;IACZ,MAAM,GAAuB,IAAI,CAAA;IAEzC;;;;OAIG;IACH,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,CAAA;IACpB,CAAC;IAED;;;;;OAKG;IACH,WAAW,CAAC,KAAc;QACxB,OAAO,KAAK,KAAK,SAAS,CAAA;IAC5B,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,KAAK,CAAC,GAA4B,EAAE,KAA2B,EAAE,QAAQ,GAAG,KAAK;QACrF,IAAI,CAAC,MAAM,GAAG,IAAI,CAAA;QAElB,IAAI,QAAQ,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC;YACvC,IAAI,CAAC,MAAM,GAAG,EAAE,IAAI,EAAE,kBAAkB,EAAE,OAAO,EAAE,gCAAgC,EAAE,CAAA;YACrF,OAAO,KAAK,CAAA;QACd,CAAC;QAED,IAAI,CAAC,QAAQ,IAAI,CAAC,GAAG,EAAE,CAAC;YACtB,OAAO,IAAI,CAAA;QACb,CAAC;QAED,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,CAAC;YAC5B,IAAI,CAAC,MAAM,GAAG,EAAE,IAAI,EAAE,kBAAkB,EAAE,OAAO,EAAE,gCAAgC,EAAE,CAAA;YACrF,OAAO,KAAK,CAAA;QACd,CAAC;QAED,KAAK,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CA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AE,CAAC;YAC3D,IAAI,CAAC,MAAM,GAAG,EAAE,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,SAAS,IAAI,yBAAyB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAA;YACnH,OAAO,KAAK,CAAA;QACd,CAAC;QAED,OAAO,IAAI,CAAA;IACb,CAAC;CACF;AAED,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,gBAAgB,EAAE,CAAA"}
|
package/dist/settings.d.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Switchbot BLE API registration settings.
|
|
3
|
+
*
|
|
4
|
+
* © 2024, donavanbecker (https://github.com/donavanbecker). All rights reserved.
|
|
5
|
+
*/
|
|
1
6
|
export declare const SERV_UUID_PRIMARY = "cba20d00224d11e69fb80002a5d5c51b";
|
|
2
7
|
export declare const CHAR_UUID_WRITE = "cba20002224d11e69fb80002a5d5c51b";
|
|
3
8
|
export declare const CHAR_UUID_NOTIFY = "cba20003224d11e69fb80002a5d5c51b";
|
package/dist/settings.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../src/settings.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../src/settings.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,eAAO,MAAM,iBAAiB,qCAAqC,CAAA;AACnE,eAAO,MAAM,eAAe,qCAAqC,CAAA;AACjE,eAAO,MAAM,gBAAgB,qCAAqC,CAAA;AAClE,eAAO,MAAM,gBAAgB,SAAS,CAAA;AAEtC,eAAO,MAAM,iBAAiB,OAAO,CAAA;AACrC,eAAO,MAAM,kBAAkB,OAAO,CAAA;AACtC,eAAO,MAAM,oBAAoB,OAAO,CAAA"}
|
package/dist/settings.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Switchbot BLE API registration settings.
|
|
2
3
|
*
|
|
3
|
-
*
|
|
4
|
+
* © 2024, donavanbecker (https://github.com/donavanbecker). All rights reserved.
|
|
4
5
|
*/
|
|
5
6
|
export const SERV_UUID_PRIMARY = 'cba20d00224d11e69fb80002a5d5c51b';
|
|
6
7
|
export const CHAR_UUID_WRITE = 'cba20002224d11e69fb80002a5d5c51b';
|
package/dist/settings.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings.js","sourceRoot":"","sources":["../src/settings.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"settings.js","sourceRoot":"","sources":["../src/settings.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,CAAC,MAAM,iBAAiB,GAAG,kCAAkC,CAAA;AACnE,MAAM,CAAC,MAAM,eAAe,GAAG,kCAAkC,CAAA;AACjE,MAAM,CAAC,MAAM,gBAAgB,GAAG,kCAAkC,CAAA;AAClE,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAA;AAEtC,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,CAAA;AACrC,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,CAAA;AACtC,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,CAAA"}
|
package/dist/switchbot.d.ts
CHANGED
|
@@ -2,14 +2,23 @@ import type { Ad } from './advertising.js';
|
|
|
2
2
|
import type { Params } from './types/types.js';
|
|
3
3
|
import * as Noble from '@stoprocent/noble';
|
|
4
4
|
import { SwitchbotDevice } from './device.js';
|
|
5
|
+
/**
|
|
6
|
+
* SwitchBot class to interact with SwitchBot devices.
|
|
7
|
+
*/
|
|
5
8
|
export declare class SwitchBot {
|
|
6
9
|
private ready;
|
|
7
10
|
noble: typeof Noble;
|
|
8
11
|
ondiscover?: (device: SwitchbotDevice) => void;
|
|
9
12
|
onadvertisement?: (ad: Ad) => void;
|
|
10
|
-
onlog
|
|
13
|
+
onlog?: (message: string) => void;
|
|
11
14
|
DEFAULT_DISCOVERY_DURATION: number;
|
|
12
|
-
PRIMARY_SERVICE_UUID_LIST:
|
|
15
|
+
PRIMARY_SERVICE_UUID_LIST: string[];
|
|
16
|
+
/**
|
|
17
|
+
* Constructor
|
|
18
|
+
*
|
|
19
|
+
* @param {Params} [params] - Optional parameters
|
|
20
|
+
* @param {typeof Noble} [params.noble] - Optional noble instance
|
|
21
|
+
*/
|
|
13
22
|
constructor(params?: Params);
|
|
14
23
|
/**
|
|
15
24
|
* Initializes the noble object.
|
|
@@ -26,32 +35,48 @@ export declare class SwitchBot {
|
|
|
26
35
|
* @returns {Promise<SwitchbotDevice[]>} - A promise that resolves with a list of discovered devices.
|
|
27
36
|
*/
|
|
28
37
|
discover(params?: Params): Promise<SwitchbotDevice[]>;
|
|
38
|
+
/**
|
|
39
|
+
* Initializes the noble object and waits for it to be powered on.
|
|
40
|
+
*
|
|
41
|
+
* @returns {Promise<void>} - Resolves when the noble object is powered on.
|
|
42
|
+
*/
|
|
29
43
|
_init(): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Gets the device object based on the peripheral, id, and model.
|
|
46
|
+
*
|
|
47
|
+
* @param {Noble.Peripheral} peripheral - The peripheral object.
|
|
48
|
+
* @param {string} id - The device id.
|
|
49
|
+
* @param {string} model - The device model.
|
|
50
|
+
* @returns {Promise<SwitchbotDevice | null>} - The device object or null.
|
|
51
|
+
*/
|
|
30
52
|
getDeviceObject(peripheral: Noble.Peripheral, id: string, model: string): Promise<SwitchbotDevice | null>;
|
|
53
|
+
/**
|
|
54
|
+
* Filters advertising data based on id and model.
|
|
55
|
+
*
|
|
56
|
+
* @param {Ad} ad - The advertising data.
|
|
57
|
+
* @param {string} id - The device id.
|
|
58
|
+
* @param {string} model - The device model.
|
|
59
|
+
* @returns {boolean} - True if the advertising data matches the id and model, false otherwise.
|
|
60
|
+
*/
|
|
31
61
|
filterAdvertising(ad: Ad, id: string, model: string): boolean;
|
|
32
62
|
/**
|
|
33
|
-
*
|
|
34
|
-
* - Start to monitor advertising packets coming from switchbot devices
|
|
63
|
+
* Starts scanning for SwitchBot devices.
|
|
35
64
|
*
|
|
36
|
-
* @param {
|
|
37
|
-
* @
|
|
38
|
-
* @param {string} [params.id] - Optional ID filter (MAC address, case-insensitive, colons ignored)
|
|
39
|
-
* @returns {Promise<void>} - Resolves when scanning starts successfully
|
|
65
|
+
* @param {Params} [params] - Optional parameters.
|
|
66
|
+
* @returns {Promise<void>} - Resolves when scanning starts successfully.
|
|
40
67
|
*/
|
|
41
68
|
startScan(params?: Params): Promise<void>;
|
|
42
69
|
/**
|
|
43
|
-
*
|
|
44
|
-
* - Stop monitoring advertising packets from SwitchBot devices
|
|
70
|
+
* Stops scanning for SwitchBot devices.
|
|
45
71
|
*
|
|
46
|
-
* @returns {Promise<void>} - Resolves when scanning stops successfully
|
|
72
|
+
* @returns {Promise<void>} - Resolves when scanning stops successfully.
|
|
47
73
|
*/
|
|
48
74
|
stopScan(): Promise<void>;
|
|
49
75
|
/**
|
|
50
|
-
*
|
|
51
|
-
* - Wait for the specified time (msec)
|
|
76
|
+
* Waits for the specified time.
|
|
52
77
|
*
|
|
53
|
-
* @param {number} msec - The time to wait in milliseconds
|
|
54
|
-
* @returns {Promise<void>} - Resolves after the specified time
|
|
78
|
+
* @param {number} msec - The time to wait in milliseconds.
|
|
79
|
+
* @returns {Promise<void>} - Resolves after the specified time.
|
|
55
80
|
*/
|
|
56
81
|
wait(msec: number): Promise<void>;
|
|
57
82
|
}
|
package/dist/switchbot.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"switchbot.d.ts","sourceRoot":"","sources":["../src/switchbot.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAA;AAC1C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAE9C,OAAO,KAAK,KAAK,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O,CAAC,IAAI,CAAC;IAsB5B;;;;;;;OAOG;IACG,eAAe,CAAC,UAAU,EAAE,KAAK,CAAC,UAAU,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC;IAgC/G;;;;;;;OAOG;IACH,iBAAiB,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO;IAoB7D;;;;;OAKG;IACG,SAAS,CAAC,MAAM,GAAE,MAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAiCnD;;;;OAIG;IACG,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAS/B;;;;;OAKG;IACG,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAexC;AAED,OAAO,EAAE,eAAe,EAAE,CAAA"}
|
package/dist/switchbot.js
CHANGED
|
@@ -18,6 +18,9 @@ import { WoSmartLockPro } from './device/wosmartlockpro.js';
|
|
|
18
18
|
import { WoStrip } from './device/wostrip.js';
|
|
19
19
|
import { parameterChecker } from './parameter-checker.js';
|
|
20
20
|
import { SwitchBotBLEModel } from './types/types.js';
|
|
21
|
+
/**
|
|
22
|
+
* SwitchBot class to interact with SwitchBot devices.
|
|
23
|
+
*/
|
|
21
24
|
export class SwitchBot {
|
|
22
25
|
ready;
|
|
23
26
|
noble;
|
|
@@ -26,16 +29,12 @@ export class SwitchBot {
|
|
|
26
29
|
onlog;
|
|
27
30
|
DEFAULT_DISCOVERY_DURATION = 5000;
|
|
28
31
|
PRIMARY_SERVICE_UUID_LIST = [];
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
* | | | This parameter is optional.
|
|
36
|
-
* | | | If you don't specify this parameter, this
|
|
37
|
-
* | | | module automatically creates it.
|
|
38
|
-
* ---------------------------------------------------------------- */
|
|
32
|
+
/**
|
|
33
|
+
* Constructor
|
|
34
|
+
*
|
|
35
|
+
* @param {Params} [params] - Optional parameters
|
|
36
|
+
* @param {typeof Noble} [params.noble] - Optional noble instance
|
|
37
|
+
*/
|
|
39
38
|
constructor(params) {
|
|
40
39
|
this.ready = this.init(params);
|
|
41
40
|
}
|
|
@@ -56,7 +55,6 @@ export class SwitchBot {
|
|
|
56
55
|
* @returns {Promise<SwitchbotDevice[]>} - A promise that resolves with a list of discovered devices.
|
|
57
56
|
*/
|
|
58
57
|
async discover(params = {}) {
|
|
59
|
-
// Validate parameters
|
|
60
58
|
const valid = parameterChecker.check(params, {
|
|
61
59
|
duration: { required: false, type: 'integer', min: 1, max: 60000 },
|
|
62
60
|
model: { required: false, type: 'string', enum: Object.values(SwitchBotBLEModel) },
|
|
@@ -67,7 +65,6 @@ export class SwitchBot {
|
|
|
67
65
|
throw new Error(parameterChecker.error.message);
|
|
68
66
|
}
|
|
69
67
|
const { duration = this.DEFAULT_DISCOVERY_DURATION, model = '', id = '', quick = false } = params;
|
|
70
|
-
// Initialize the noble object
|
|
71
68
|
await this._init();
|
|
72
69
|
if (!this.noble) {
|
|
73
70
|
throw new Error('noble failed to initialize');
|
|
@@ -82,7 +79,6 @@ export class SwitchBot {
|
|
|
82
79
|
};
|
|
83
80
|
return new Promise((resolve, reject) => {
|
|
84
81
|
try {
|
|
85
|
-
// Set a handler for the 'discover' event
|
|
86
82
|
this.noble.on('discover', async (peripheral) => {
|
|
87
83
|
const device = await this.getDeviceObject(peripheral, id, model);
|
|
88
84
|
if (device) {
|
|
@@ -95,7 +91,6 @@ export class SwitchBot {
|
|
|
95
91
|
}
|
|
96
92
|
}
|
|
97
93
|
});
|
|
98
|
-
// Start scanning
|
|
99
94
|
this.noble.startScanningAsync(this.PRIMARY_SERVICE_UUID_LIST, false)
|
|
100
95
|
.then(() => {
|
|
101
96
|
timer = setTimeout(() => {
|
|
@@ -111,6 +106,11 @@ export class SwitchBot {
|
|
|
111
106
|
}
|
|
112
107
|
});
|
|
113
108
|
}
|
|
109
|
+
/**
|
|
110
|
+
* Initializes the noble object and waits for it to be powered on.
|
|
111
|
+
*
|
|
112
|
+
* @returns {Promise<void>} - Resolves when the noble object is powered on.
|
|
113
|
+
*/
|
|
114
114
|
async _init() {
|
|
115
115
|
await this.ready;
|
|
116
116
|
if (this.noble._state === 'poweredOn') {
|
|
@@ -133,12 +133,17 @@ export class SwitchBot {
|
|
|
133
133
|
});
|
|
134
134
|
});
|
|
135
135
|
}
|
|
136
|
+
/**
|
|
137
|
+
* Gets the device object based on the peripheral, id, and model.
|
|
138
|
+
*
|
|
139
|
+
* @param {Noble.Peripheral} peripheral - The peripheral object.
|
|
140
|
+
* @param {string} id - The device id.
|
|
141
|
+
* @param {string} model - The device model.
|
|
142
|
+
* @returns {Promise<SwitchbotDevice | null>} - The device object or null.
|
|
143
|
+
*/
|
|
136
144
|
async getDeviceObject(peripheral, id, model) {
|
|
137
145
|
const ad = await Advertising.parse(peripheral, this.onlog);
|
|
138
|
-
if (!ad) {
|
|
139
|
-
return null;
|
|
140
|
-
}
|
|
141
|
-
if (!this.filterAdvertising(ad, id, model)) {
|
|
146
|
+
if (!ad || !this.filterAdvertising(ad, id, model)) {
|
|
142
147
|
return null;
|
|
143
148
|
}
|
|
144
149
|
const modelMapping = {
|
|
@@ -165,6 +170,14 @@ export class SwitchBot {
|
|
|
165
170
|
const DeviceClass = ad?.serviceData?.model ? modelMapping[ad.serviceData.model] : SwitchbotDevice;
|
|
166
171
|
return new DeviceClass(peripheral, this.noble);
|
|
167
172
|
}
|
|
173
|
+
/**
|
|
174
|
+
* Filters advertising data based on id and model.
|
|
175
|
+
*
|
|
176
|
+
* @param {Ad} ad - The advertising data.
|
|
177
|
+
* @param {string} id - The device id.
|
|
178
|
+
* @param {string} model - The device model.
|
|
179
|
+
* @returns {boolean} - True if the advertising data matches the id and model, false otherwise.
|
|
180
|
+
*/
|
|
168
181
|
filterAdvertising(ad, id, model) {
|
|
169
182
|
if (!ad) {
|
|
170
183
|
return false;
|
|
@@ -182,54 +195,28 @@ export class SwitchBot {
|
|
|
182
195
|
return true;
|
|
183
196
|
}
|
|
184
197
|
/**
|
|
185
|
-
*
|
|
186
|
-
* - Start to monitor advertising packets coming from switchbot devices
|
|
198
|
+
* Starts scanning for SwitchBot devices.
|
|
187
199
|
*
|
|
188
|
-
* @param {
|
|
189
|
-
* @
|
|
190
|
-
* @param {string} [params.id] - Optional ID filter (MAC address, case-insensitive, colons ignored)
|
|
191
|
-
* @returns {Promise<void>} - Resolves when scanning starts successfully
|
|
200
|
+
* @param {Params} [params] - Optional parameters.
|
|
201
|
+
* @returns {Promise<void>} - Resolves when scanning starts successfully.
|
|
192
202
|
*/
|
|
193
203
|
async startScan(params = {}) {
|
|
194
|
-
// Validate parameters
|
|
195
204
|
const valid = parameterChecker.check(params, {
|
|
196
205
|
model: {
|
|
197
206
|
required: false,
|
|
198
207
|
type: 'string',
|
|
199
|
-
enum:
|
|
200
|
-
SwitchBotBLEModel.Bot,
|
|
201
|
-
SwitchBotBLEModel.Curtain,
|
|
202
|
-
SwitchBotBLEModel.Curtain3,
|
|
203
|
-
SwitchBotBLEModel.Humidifier,
|
|
204
|
-
SwitchBotBLEModel.Meter,
|
|
205
|
-
SwitchBotBLEModel.MeterPlus,
|
|
206
|
-
SwitchBotBLEModel.Hub2,
|
|
207
|
-
SwitchBotBLEModel.OutdoorMeter,
|
|
208
|
-
SwitchBotBLEModel.MotionSensor,
|
|
209
|
-
SwitchBotBLEModel.ContactSensor,
|
|
210
|
-
SwitchBotBLEModel.ColorBulb,
|
|
211
|
-
SwitchBotBLEModel.CeilingLight,
|
|
212
|
-
SwitchBotBLEModel.CeilingLightPro,
|
|
213
|
-
SwitchBotBLEModel.StripLight,
|
|
214
|
-
SwitchBotBLEModel.PlugMiniUS,
|
|
215
|
-
SwitchBotBLEModel.PlugMiniJP,
|
|
216
|
-
SwitchBotBLEModel.Lock,
|
|
217
|
-
SwitchBotBLEModel.LockPro,
|
|
218
|
-
SwitchBotBLEModel.BlindTilt,
|
|
219
|
-
],
|
|
208
|
+
enum: Object.values(SwitchBotBLEModel),
|
|
220
209
|
},
|
|
221
210
|
id: { required: false, type: 'string', min: 12, max: 17 },
|
|
222
211
|
}, false);
|
|
223
212
|
if (!valid) {
|
|
224
213
|
throw new Error(parameterChecker.error.message);
|
|
225
214
|
}
|
|
226
|
-
// Initialize the noble object
|
|
227
215
|
await this._init();
|
|
228
|
-
if (this.noble
|
|
216
|
+
if (!this.noble) {
|
|
229
217
|
throw new Error('noble object failed to initialize');
|
|
230
218
|
}
|
|
231
219
|
const { model = '', id = '' } = params;
|
|
232
|
-
// Set a handler for the 'discover' event
|
|
233
220
|
this.noble.on('discover', async (peripheral) => {
|
|
234
221
|
const ad = await Advertising.parse(peripheral, this.onlog);
|
|
235
222
|
if (ad && this.filterAdvertising(ad, id, model)) {
|
|
@@ -238,14 +225,12 @@ export class SwitchBot {
|
|
|
238
225
|
}
|
|
239
226
|
}
|
|
240
227
|
});
|
|
241
|
-
// Start scanning
|
|
242
228
|
await this.noble.startScanningAsync(this.PRIMARY_SERVICE_UUID_LIST, true);
|
|
243
229
|
}
|
|
244
230
|
/**
|
|
245
|
-
*
|
|
246
|
-
* - Stop monitoring advertising packets from SwitchBot devices
|
|
231
|
+
* Stops scanning for SwitchBot devices.
|
|
247
232
|
*
|
|
248
|
-
* @returns {Promise<void>} - Resolves when scanning stops successfully
|
|
233
|
+
* @returns {Promise<void>} - Resolves when scanning stops successfully.
|
|
249
234
|
*/
|
|
250
235
|
async stopScan() {
|
|
251
236
|
if (!this.noble) {
|
|
@@ -255,21 +240,18 @@ export class SwitchBot {
|
|
|
255
240
|
await this.noble.stopScanningAsync();
|
|
256
241
|
}
|
|
257
242
|
/**
|
|
258
|
-
*
|
|
259
|
-
* - Wait for the specified time (msec)
|
|
243
|
+
* Waits for the specified time.
|
|
260
244
|
*
|
|
261
|
-
* @param {number} msec - The time to wait in milliseconds
|
|
262
|
-
* @returns {Promise<void>} - Resolves after the specified time
|
|
245
|
+
* @param {number} msec - The time to wait in milliseconds.
|
|
246
|
+
* @returns {Promise<void>} - Resolves after the specified time.
|
|
263
247
|
*/
|
|
264
248
|
async wait(msec) {
|
|
265
|
-
// Validate parameters
|
|
266
249
|
const valid = parameterChecker.check({ msec }, {
|
|
267
250
|
msec: { required: true, type: 'integer', min: 0 },
|
|
268
251
|
}, true);
|
|
269
252
|
if (!valid) {
|
|
270
253
|
throw new Error(parameterChecker.error.message);
|
|
271
254
|
}
|
|
272
|
-
// Return a promise that resolves after the specified time
|
|
273
255
|
return new Promise(resolve => setTimeout(resolve, msec));
|
|
274
256
|
}
|
|
275
257
|
}
|
package/dist/switchbot.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"switchbot.js","sourceRoot":"","sources":["../src/switchbot.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAA;AAE1C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AACnD,OAAO,EAAE,UAAU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cAAc;IACrB,QAAQ,eAAe;IACvB,UAAU,WAAW;IACrB,KAAK,eAAe;IACpB,IAAI,gBAAgB;IACpB,OAAO,mBAAmB;IAC1B,QAAQ,eAAe;IACvB,UAAU,YAAY;IACtB,SAAS,mBAAmB;IAC5B,YAAY,iBAAiB;IAC7B,aAAa,cAAc;IAC3B,YAAY,aAAa;IACzB,SAAS,gBAAgB;IACzB,YAAY,mBAAmB;IAC/B,eAAe,sBAAsB;IACrC,OAAO,YAAY;CACpB;AAED,oBAAY,6BAA6B;IACvC,GAAG,QAAQ;IACX,IAAI,UAAU;IACd,SAAS,eAAe;IACxB,OAAO,YAAY;IACnB,QAAQ,cAAc;IACtB,UAAU,eAAe;IACzB,KAAK,UAAU;IACf,IAAI,SAAS;IACb,OAAO,aAAa;IACpB,QAAQ,cAAc;IACtB,UAAU,gBAAgB;IAC1B,SAAS,eAAe;IACxB,YAAY,kBAAkB;IAC9B,aAAa,mBAAmB;IAChC,YAAY,kBAAkB;IAC9B,SAAS,eAAe;IACxB,YAAY,kBAAkB;IAC9B,eAAe,sBAAsB;IACrC,OAAO,YAAY;CACpB;AAED,MAAM,WAAW,MAAM;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,KAAK,CAAC,EAAE,KAAK,CAAA;IACb,KAAK,CAAC,EAAE,OAAO,KAAK,CAAA;CACrB;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;CAChB"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-switchbot",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.5.0-beta.
|
|
4
|
+
"version": "2.5.0-beta.4",
|
|
5
5
|
"description": "The node-switchbot is a Node.js module which allows you to control your Switchbot Devices through Bluetooth (BLE).",
|
|
6
6
|
"author": "OpenWonderLabs (https://github.com/OpenWonderLabs)",
|
|
7
7
|
"license": "MIT",
|