@sixfathoms/lplex 0.2.0 → 0.2.1
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/README.md +11 -2
- package/dist/index.cjs +4 -2
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +4 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -58,7 +58,7 @@ for (const d of devices) {
|
|
|
58
58
|
}
|
|
59
59
|
```
|
|
60
60
|
|
|
61
|
-
### `client.values(signal?): Promise<DeviceValues[]>`
|
|
61
|
+
### `client.values(filter?, signal?): Promise<DeviceValues[]>`
|
|
62
62
|
|
|
63
63
|
Returns the last-seen value for each (device, PGN) pair, grouped by device. Useful for getting a snapshot of current bus state without subscribing to SSE.
|
|
64
64
|
|
|
@@ -72,6 +72,15 @@ for (const device of snapshot) {
|
|
|
72
72
|
}
|
|
73
73
|
```
|
|
74
74
|
|
|
75
|
+
Pass a `Filter` to narrow results by PGN and/or device criteria:
|
|
76
|
+
|
|
77
|
+
```typescript
|
|
78
|
+
const positions = await client.values({
|
|
79
|
+
pgn: [129025],
|
|
80
|
+
manufacturer: ["Garmin"],
|
|
81
|
+
});
|
|
82
|
+
```
|
|
83
|
+
|
|
75
84
|
### `client.subscribe(filter?, signal?): Promise<AsyncIterable<Event>>`
|
|
76
85
|
|
|
77
86
|
Opens an ephemeral SSE stream. No session state, no replay. Frames flow until you stop reading or abort.
|
|
@@ -326,7 +335,7 @@ interface DeviceValues {
|
|
|
326
335
|
| `/clients/{id}/ack` | PUT | ACK sequence number. JSON body: `{ "seq": N }`. Returns 204. |
|
|
327
336
|
| `/send` | POST | Transmit CAN frame. JSON body: `pgn`, `src`, `dst`, `prio`, `data`. Returns 202. |
|
|
328
337
|
| `/devices` | GET | Device snapshot. Returns JSON array. |
|
|
329
|
-
| `/values` | GET | Last-seen value per (device, PGN). Returns JSON array grouped by device. |
|
|
338
|
+
| `/values` | GET | Last-seen value per (device, PGN). Query params: `pgn`, `manufacturer`, `instance`, `name` (repeatable). Returns JSON array grouped by device. |
|
|
330
339
|
|
|
331
340
|
## License
|
|
332
341
|
|
package/dist/index.cjs
CHANGED
|
@@ -171,8 +171,10 @@ var Client = class {
|
|
|
171
171
|
return resp.json();
|
|
172
172
|
}
|
|
173
173
|
/** Fetch the last-seen value for each (device, PGN) pair. */
|
|
174
|
-
async values(signal) {
|
|
175
|
-
|
|
174
|
+
async values(filter, signal) {
|
|
175
|
+
let url = `${this.#baseURL}/values`;
|
|
176
|
+
const qs = filterToQueryString(filter);
|
|
177
|
+
if (qs) url += `?${qs}`;
|
|
176
178
|
const resp = await this.#fetch(url, { signal });
|
|
177
179
|
if (!resp.ok) {
|
|
178
180
|
const body = await resp.text();
|
package/dist/index.d.cts
CHANGED
|
@@ -143,7 +143,7 @@ declare class Client {
|
|
|
143
143
|
/** Fetch a snapshot of all NMEA 2000 devices discovered by the server. */
|
|
144
144
|
devices(signal?: AbortSignal): Promise<Device[]>;
|
|
145
145
|
/** Fetch the last-seen value for each (device, PGN) pair. */
|
|
146
|
-
values(signal?: AbortSignal): Promise<DeviceValues[]>;
|
|
146
|
+
values(filter?: Filter, signal?: AbortSignal): Promise<DeviceValues[]>;
|
|
147
147
|
/**
|
|
148
148
|
* Open an ephemeral SSE stream with optional filtering.
|
|
149
149
|
* No session, no replay, no ACK.
|
package/dist/index.d.ts
CHANGED
|
@@ -143,7 +143,7 @@ declare class Client {
|
|
|
143
143
|
/** Fetch a snapshot of all NMEA 2000 devices discovered by the server. */
|
|
144
144
|
devices(signal?: AbortSignal): Promise<Device[]>;
|
|
145
145
|
/** Fetch the last-seen value for each (device, PGN) pair. */
|
|
146
|
-
values(signal?: AbortSignal): Promise<DeviceValues[]>;
|
|
146
|
+
values(filter?: Filter, signal?: AbortSignal): Promise<DeviceValues[]>;
|
|
147
147
|
/**
|
|
148
148
|
* Open an ephemeral SSE stream with optional filtering.
|
|
149
149
|
* No session, no replay, no ACK.
|
package/dist/index.js
CHANGED
|
@@ -141,8 +141,10 @@ var Client = class {
|
|
|
141
141
|
return resp.json();
|
|
142
142
|
}
|
|
143
143
|
/** Fetch the last-seen value for each (device, PGN) pair. */
|
|
144
|
-
async values(signal) {
|
|
145
|
-
|
|
144
|
+
async values(filter, signal) {
|
|
145
|
+
let url = `${this.#baseURL}/values`;
|
|
146
|
+
const qs = filterToQueryString(filter);
|
|
147
|
+
if (qs) url += `?${qs}`;
|
|
146
148
|
const resp = await this.#fetch(url, { signal });
|
|
147
149
|
if (!resp.ok) {
|
|
148
150
|
const body = await resp.text();
|