fireboard-api-client 0.0.0-stage → 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/LICENSE +21 -0
- package/README.md +276 -2
- package/dist/client.d.ts +198 -0
- package/dist/client.js +68 -0
- package/dist/device-cache.d.ts +11 -0
- package/dist/device-cache.js +40 -0
- package/dist/drive.d.ts +10 -0
- package/dist/drive.js +53 -0
- package/dist/errors.d.ts +6 -0
- package/dist/errors.js +10 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +6 -0
- package/dist/login.d.ts +6 -0
- package/dist/login.js +19 -0
- package/dist/request.d.ts +6 -0
- package/dist/request.js +56 -0
- package/dist/schemas.d.ts +212 -0
- package/dist/schemas.js +276 -0
- package/dist/types.d.ts +26 -0
- package/dist/types.js +1 -0
- package/dist/validation.d.ts +4 -0
- package/dist/validation.js +29 -0
- package/package.json +55 -4
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { RawDevice } from "./schemas.js";
|
|
2
|
+
export interface RequestOptions {
|
|
3
|
+
fetch?: typeof globalThis.fetch;
|
|
4
|
+
timeoutMs?: number;
|
|
5
|
+
userAgent?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface FireboardClientOptions extends RequestOptions {
|
|
8
|
+
token: string;
|
|
9
|
+
baseUrl?: string;
|
|
10
|
+
deviceCacheTtlMs?: number;
|
|
11
|
+
}
|
|
12
|
+
export interface LoginOptions extends RequestOptions {
|
|
13
|
+
loginUrl?: string;
|
|
14
|
+
}
|
|
15
|
+
export type DriveSetpointOptions = {
|
|
16
|
+
setpoint: number;
|
|
17
|
+
channel?: number;
|
|
18
|
+
} | {
|
|
19
|
+
setpoint?: number;
|
|
20
|
+
channel: number;
|
|
21
|
+
};
|
|
22
|
+
export interface DeviceListResult {
|
|
23
|
+
data: RawDevice[];
|
|
24
|
+
fromCache: boolean;
|
|
25
|
+
cacheAgeSeconds: number;
|
|
26
|
+
}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function validateEndpoint(value: string): string;
|
|
2
|
+
export declare function validateTiming(value: number, name: string, allowZero?: boolean): number;
|
|
3
|
+
export declare function encodeDeviceId(uuid: string): string;
|
|
4
|
+
export declare function validateSessionId(id: number): number;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export function validateEndpoint(value) {
|
|
2
|
+
const url = new URL(value);
|
|
3
|
+
if (!["http:", "https:"].includes(url.protocol) ||
|
|
4
|
+
url.username ||
|
|
5
|
+
url.password ||
|
|
6
|
+
url.search ||
|
|
7
|
+
url.hash) {
|
|
8
|
+
throw new TypeError("Endpoint must be an HTTP(S) URL without credentials, query, or fragment");
|
|
9
|
+
}
|
|
10
|
+
return url.href;
|
|
11
|
+
}
|
|
12
|
+
export function validateTiming(value, name, allowZero = false) {
|
|
13
|
+
if (!Number.isFinite(value) || value < (allowZero ? 0 : 1) || value > 2_147_483_647) {
|
|
14
|
+
throw new TypeError(`Invalid ${name}`);
|
|
15
|
+
}
|
|
16
|
+
return value;
|
|
17
|
+
}
|
|
18
|
+
export function encodeDeviceId(uuid) {
|
|
19
|
+
if (typeof uuid !== "string" || !uuid.trim() || uuid === "." || uuid === "..") {
|
|
20
|
+
throw new TypeError("Invalid device UUID");
|
|
21
|
+
}
|
|
22
|
+
return encodeURIComponent(uuid);
|
|
23
|
+
}
|
|
24
|
+
export function validateSessionId(id) {
|
|
25
|
+
if (!Number.isSafeInteger(id) || id < 0) {
|
|
26
|
+
throw new TypeError("Invalid session ID");
|
|
27
|
+
}
|
|
28
|
+
return id;
|
|
29
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,57 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fireboard-api-client",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Unofficial TypeScript client for the Fireboard temperature monitoring API",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"api-client",
|
|
7
|
+
"bbq",
|
|
8
|
+
"fireboard",
|
|
9
|
+
"temperature",
|
|
10
|
+
"typescript"
|
|
11
|
+
],
|
|
12
|
+
"homepage": "https://github.com/benhodgson87/fireboard-api-client#readme",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/benhodgson87/fireboard-api-client/issues"
|
|
15
|
+
},
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/benhodgson87/fireboard-api-client.git"
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist"
|
|
23
|
+
],
|
|
24
|
+
"type": "module",
|
|
25
|
+
"main": "./dist/index.js",
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"import": "./dist/index.js"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"scripts": {
|
|
34
|
+
"build": "node scripts/clean.mjs && tsc",
|
|
35
|
+
"typecheck": "tsc --noEmit && tsc -p tsconfig.tests.json",
|
|
36
|
+
"test": "vitest run",
|
|
37
|
+
"smoke": "npm run build && node scripts/smoke.mjs",
|
|
38
|
+
"lint": "oxlint --deny-warnings src tests scripts",
|
|
39
|
+
"lint:fix": "oxlint --fix --deny-warnings src tests scripts",
|
|
40
|
+
"format": "oxfmt --write .",
|
|
41
|
+
"format:check": "oxfmt --check .",
|
|
42
|
+
"prepack": "npm run build"
|
|
43
|
+
},
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"zod": "^4.0.0"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@types/node": "^22.0.0",
|
|
49
|
+
"oxfmt": "^0.72.0",
|
|
50
|
+
"oxlint": "^1.87.0",
|
|
51
|
+
"typescript": "^5.9.0",
|
|
52
|
+
"vitest": "^3.2.0"
|
|
53
|
+
},
|
|
54
|
+
"engines": {
|
|
55
|
+
"node": ">=22"
|
|
56
|
+
}
|
|
57
|
+
}
|