higherdata-sdk 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 ADDED
@@ -0,0 +1 @@
1
+ Copyright HigherOps Inc. You may install and use this software with a HigherData account. You may not redistribute modified copies.
package/README.md ADDED
@@ -0,0 +1,89 @@
1
+ # HigherData SDK
2
+
3
+ Node 24+ TypeScript client for HigherData. Install with:
4
+
5
+ ```sh
6
+ npm install higherdata-sdk
7
+ ```
8
+
9
+ ```ts
10
+ import { HigherData, HigherDataError } from "higherdata-sdk";
11
+
12
+ const client = new HigherData({
13
+ apiKey: process.env.HIGHERDATA_API_KEY,
14
+ space: "default",
15
+ });
16
+ const companies = await client.call("search.companies", {
17
+ countryCodes: ["CA"], limit: 25,
18
+ });
19
+ const preview = await client.call("enrich.company", {
20
+ domain: "cedar.example",
21
+ }, { execute: false });
22
+ ```
23
+
24
+ Every registered tool name, input and output is generated from the registry's
25
+ OpenAPI document using pinned `openapi-typescript` 7.13.0. `ToolName`,
26
+ `ToolInput<Name>`, `ToolOutput<Name>`, `operations`, and `components` are exported.
27
+ The small shared transport is handwritten. The server validates inputs,
28
+ authorization and scope; a client cannot choose a tenant. `execute: false`
29
+ sets the API dry-run flag. API-key and space headers stay on the configured
30
+ origin; redirects are refused. HTTPS is required except HTTP loopback for tests.
31
+
32
+ ## Errors and retries
33
+
34
+ ```ts
35
+ try {
36
+ await client.call("account.whoami", {});
37
+ } catch (error) {
38
+ if (error instanceof HigherDataError) {
39
+ console.log(error.code, error.status, error.retryAfter);
40
+ }
41
+ }
42
+ ```
43
+
44
+ API errors retain the API's code, HTTP status and public message. Transport
45
+ failures use status 0 with codes such as `network_error`, `invalid_response`,
46
+ `response_too_large` and `request_aborted`; transport details are not exposed.
47
+ Only HTTP 429 and 503 are retried, twice by default. `Retry-After` seconds or HTTP
48
+ dates take precedence over the error body's `retry_after`; absent either, waits
49
+ are one then two seconds. A requested wait above `maxRetryDelayMs` (default
50
+ 30 seconds) returns the error to the caller rather than retrying early.
51
+ Network errors and other statuses are never retried. Set `maxRetries: 0` to
52
+ turn retries off. The CLI uses that setting to preserve its existing behavior.
53
+
54
+ Each tool call has one idempotency key reused across its retries. Supply
55
+ `idempotencyKey` in call options to retain a key across your own attempts. The
56
+ server returns only a receipt for a replayed write; the SDK throws
57
+ `HigherDataReplayError` with `requestId` instead of returning a value
58
+ with the wrong tool output type. Read replays still return the normal result.
59
+
60
+ Requests have a 30-second timeout per attempt and an 8 MiB response bound.
61
+ `timeoutMs` and an `AbortSignal` may be supplied in call options. Constructor
62
+ options include `apiUrl`, `fetch`, `maxRetries` (0 to 5), `maxRetryDelayMs`,
63
+ `timeoutMs`, `sleep`, and `now` for deterministic tests.
64
+
65
+ ## Streaming downloads
66
+
67
+ ```ts
68
+ for await (const content of client.downloadJob({ jobId, format: "csv" })) {
69
+ await destination.write(content);
70
+ }
71
+ ```
72
+
73
+ The API returns bounded JSON pages; the helper yields content one page at a time
74
+ and fetches the next page only when the consumer asks. It retains the CSV header
75
+ from the first page, follows cursors and stops repeated cursors. Breaking out of
76
+ the loop stops fetching. `downloadJobPages` also yields each page's content type,
77
+ next cursor and suppression count. Every page goes through the authenticated
78
+ job tool, so current suppression applies. Results may change between pages when
79
+ suppression changes. Pass a cursor to resume a paged download.
80
+
81
+ ## Development
82
+
83
+ From the repository root, `npm run sdk:generate` regenerates the checked-in
84
+ contract and `npm run sdk:check` fails if it is stale. The SDK build regenerates
85
+ it; CI checks for drift before any build can overwrite it. Generation imports
86
+ server tool definitions under the `react-server` condition but never invokes
87
+ tools or uses hosted credentials. None of the server implementation is bundled.
88
+ The SDK and CLI publish together through `publish-cli.yml`; see
89
+ `docs/RELEASE-CLI.md` for the release procedure and unresolved B16 prerequisites.