@whois-homebridge/homebridge-aranet4 0.1.2 → 0.2.0
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/supabaseLogger.d.ts +1 -12
- package/dist/supabaseLogger.js +4 -54
- package/dist/supabaseLogger.js.map +1 -1
- package/package.json +3 -15
package/dist/supabaseLogger.d.ts
CHANGED
|
@@ -1,12 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
url: string;
|
|
3
|
-
key: string;
|
|
4
|
-
}
|
|
5
|
-
export declare function insertRow(config: SupabaseConfig, table: string, row: Record<string, unknown>, log: {
|
|
6
|
-
warn(msg: string): void;
|
|
7
|
-
debug(msg: string): void;
|
|
8
|
-
}): Promise<void>;
|
|
9
|
-
export declare function checkConnection(config: SupabaseConfig, table: string, log: {
|
|
10
|
-
info(msg: string): void;
|
|
11
|
-
warn(msg: string): void;
|
|
12
|
-
}): Promise<boolean>;
|
|
1
|
+
export { SupabaseConfig, insertRow, checkConnection } from '@whois-homebridge/shared';
|
package/dist/supabaseLogger.js
CHANGED
|
@@ -1,57 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.insertRow =
|
|
4
|
-
|
|
5
|
-
function
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
const REQUEST_TIMEOUT_MS = 10_000;
|
|
9
|
-
async function insertRow(config, table, row, log) {
|
|
10
|
-
try {
|
|
11
|
-
const res = await fetch(`${baseUrl(config)}/rest/v1/${table}`, {
|
|
12
|
-
method: 'POST',
|
|
13
|
-
headers: {
|
|
14
|
-
'Content-Type': 'application/json',
|
|
15
|
-
'apikey': config.key,
|
|
16
|
-
'Authorization': `Bearer ${config.key}`,
|
|
17
|
-
'Prefer': 'return=minimal',
|
|
18
|
-
},
|
|
19
|
-
body: JSON.stringify(row),
|
|
20
|
-
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS),
|
|
21
|
-
});
|
|
22
|
-
if (res.ok) {
|
|
23
|
-
log.debug(`[Supabase] Inserted row into ${table}`);
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
const body = await res.text();
|
|
27
|
-
log.warn(`[Supabase] Insert into ${table} failed (HTTP ${res.status}): ${body}`);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
catch (err) {
|
|
31
|
-
log.warn(`[Supabase] Insert into ${table} error: ${err instanceof Error ? err.message : String(err)}`);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
async function checkConnection(config, table, log) {
|
|
35
|
-
try {
|
|
36
|
-
const res = await fetch(`${baseUrl(config)}/rest/v1/${table}?select=id&limit=1`, {
|
|
37
|
-
method: 'GET',
|
|
38
|
-
headers: {
|
|
39
|
-
'apikey': config.key,
|
|
40
|
-
'Authorization': `Bearer ${config.key}`,
|
|
41
|
-
},
|
|
42
|
-
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS),
|
|
43
|
-
});
|
|
44
|
-
if (res.ok) {
|
|
45
|
-
log.info(`[Supabase] Connection to "${table}" verified (HTTP ${res.status})`);
|
|
46
|
-
return true;
|
|
47
|
-
}
|
|
48
|
-
const body = await res.text();
|
|
49
|
-
log.warn(`[Supabase] Connection check for "${table}" failed (HTTP ${res.status}): ${body}`);
|
|
50
|
-
return false;
|
|
51
|
-
}
|
|
52
|
-
catch (err) {
|
|
53
|
-
log.warn(`[Supabase] Connection check error: ${err instanceof Error ? err.message : String(err)}`);
|
|
54
|
-
return false;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
3
|
+
exports.checkConnection = exports.insertRow = void 0;
|
|
4
|
+
var shared_1 = require("@whois-homebridge/shared");
|
|
5
|
+
Object.defineProperty(exports, "insertRow", { enumerable: true, get: function () { return shared_1.insertRow; } });
|
|
6
|
+
Object.defineProperty(exports, "checkConnection", { enumerable: true, get: function () { return shared_1.checkConnection; } });
|
|
57
7
|
//# sourceMappingURL=supabaseLogger.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"supabaseLogger.js","sourceRoot":"","sources":["../src/supabaseLogger.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"supabaseLogger.js","sourceRoot":"","sources":["../src/supabaseLogger.ts"],"names":[],"mappings":";;;AAAA,mDAAsF;AAA7D,mGAAA,SAAS,OAAA;AAAE,yGAAA,eAAe,OAAA"}
|
package/package.json
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@whois-homebridge/homebridge-aranet4",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Homebridge plugin for Aranet4 CO2/environment sensor via passive BLE scanning with Eve history support",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"homepage": "https://github.com/whoiscadenyoung/homebridge-plugins#readme",
|
|
8
|
-
"bugs": {
|
|
9
|
-
"url": "https://github.com/whoiscadenyoung/homebridge-plugins/issues"
|
|
10
|
-
},
|
|
11
8
|
"files": [
|
|
12
9
|
"dist/",
|
|
13
10
|
"config.schema.json",
|
|
@@ -28,18 +25,8 @@
|
|
|
28
25
|
},
|
|
29
26
|
"keywords": [
|
|
30
27
|
"homebridge-plugin",
|
|
31
|
-
"homebridge"
|
|
32
|
-
"aranet4",
|
|
33
|
-
"aranet",
|
|
34
|
-
"co2",
|
|
35
|
-
"carbon-dioxide",
|
|
36
|
-
"air-quality",
|
|
37
|
-
"ble",
|
|
38
|
-
"bluetooth",
|
|
39
|
-
"eve",
|
|
40
|
-
"fakegato"
|
|
28
|
+
"homebridge"
|
|
41
29
|
],
|
|
42
|
-
"author": "whoiscadenyoung",
|
|
43
30
|
"license": "MIT",
|
|
44
31
|
"repository": {
|
|
45
32
|
"type": "git",
|
|
@@ -51,6 +38,7 @@
|
|
|
51
38
|
},
|
|
52
39
|
"dependencies": {
|
|
53
40
|
"@stoprocent/noble": "^2.4.0",
|
|
41
|
+
"@whois-homebridge/shared": "workspace:*",
|
|
54
42
|
"fakegato-history": "^0.6.4"
|
|
55
43
|
},
|
|
56
44
|
"devDependencies": {
|