Repository navigation
feat(@hertzg/hikvision-api)!: Hikvision ISAPI client - #304
Merged
Merged
Conversation
…evice info, channels and motion grid Reads /ISAPI/Event/notification/alertStream as a ReadableStream of parsed alerts and the device info, channel list, motion grid and smart rule documents as typed objects. Basic auth, injectable fetch, no reconnects or timers: the consumer owns backoff and the motion-end threshold, measured from each alert's arrival time.
…ying on fetch Against a real NVR the 30 s AbortSignal did not end the stream: fetch kept the body open and the consumer's loop never returned. On abort the stream now cancels its own reader, which resolves a pending read as done and cancels the response body, so the loop ends and the connection drops whatever fetch does with the signal.
…regions and generic smart rules Verified against the ISAPI guides, the NVR web UI's command table and real device output. Errors keep the device's reason on any HTTP status, motion reads grid and polygons, smart paths take the channel, and the package runs on Bun and Deno alike.
…nd export a single entry point Each reader is now a document description read by one engine instead of hand-written tree walking, and the package exports only its root: the client, its types, and the parse functions. Sub-path imports such as `@hertzg/hikvision-api/config/smart` no longer exist. BREAKING CHANGE: all sub-path exports are gone; import from `@hertzg/hikvision-api`.
A failed request now throws one error whatever the shape of the failure: HTTP status outside 2xx, a failing ResponseStatus body, or both. Its fields are flat and optional, so a consumer branches on subStatusCode for the reason and httpStatus for the transport without string matching. BREAKING CHANGE: HttpError is gone; IsapiError carries url, httpStatus, statusCode, subStatusCode and statusString directly, and is constructed from one options object.
…s through one call
Modules now live under isapi/<area>/ named after the path they read, and
each exports a resource: a path plus a codec. The client reads any of them
with read(resource); the named methods are one-line wrappers.
BREAKING CHANGE: the parseX/readX/xPath functions are gone; use the exported resources (`deviceInfo`, `motionDetection({ channel })`, …) with `client.read` or `resource.codec.parse`.
…eam over a plain Device
Three layers of functions, no client object. A Device is where the device
is and how to log in; every call takes it first. request(device, path)
returns the raw Response; request(device, resource) returns the decoded
document; stream(device, resource, { signal }) returns a ReadableStream.
The alert stream is a resource like any other. http/ holds fetch, auth and
multipart; isapi/ holds the protocol and the documents.
A client with named methods promised every device serves every document.
It cannot: a camera answers notSupport. The vendor's own websdk.js is a
table of name to URL with get and set over it, the same shape as this.
BREAKING CHANGE: createClient, Client, openAlertStream, RequestOptions and
read are gone. Use request(device, resource), stream(device, alertStream,
{ signal }) and the Device type.
…sh stops flagging it as a dynamic import
Contributor
|
Docs preview: https://hertzg.github.io/jsr-monorepo/pr/304/ |
Contributor
Benchmark ResultsNo significant changes detected. 31 benchmark(s) within their noise floor. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #304 +/- ##
==========================================
+ Coverage 97.78% 97.81% +0.02%
==========================================
Files 374 424 +50
Lines 13794 14712 +918
Branches 1458 1560 +102
==========================================
+ Hits 13489 14390 +901
- Misses 175 186 +11
- Partials 130 136 +6 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…ents, tests on node:test A field reads the element it is handed; decodeFields finds children by name and owns required, optional and many. Lists no longer forge a parent around each item, and the lookup helpers stop being exports. Every file exports one function with its type beside it and its test next to it, so the package reads like the tvali libraries it is written for. Tests run on node:test, which Deno and Bun both execute. BREAKING CHANGE: Field.decode takes an element, not a parent and a name; children, child, textContent and decodeFields are no longer exported. Public resources, request, stream and the types are unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
@hertzg/hikvision-api: a small, typed, runtime-agnostic Hikvision ISAPI package for Deno and Bun.request(device, path)returns the rawResponse;request(device, resource)returns the decoded document.stream(device, alertStream, { signal })yields parsed alerts from/ISAPI/Event/notification/alertStreamuntil the signal aborts. No reconnect, no timers, no motion-end inference.IsapiError.Registered in the labeler, Release Please config and manifest, import map, README and AGENTS.md.