@davixlabs/h2i-sdk 0.0.0-stage → 1.1.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/README.md CHANGED
@@ -1,3 +1,55 @@
1
- # Temporary Holding Version
1
+ # @davixlabs/h2i-sdk (Node.js)
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Official Davix H2I client. Methods, enums, typings and metadata are **generated from the canonical Davix H2I contract** (`contract/source`), so they cannot drift from the API. Requires Node 18+; no runtime dependencies.
4
+
5
+ ## Install
6
+
7
+ Published on npm with every app release (app 1.4.0 gives SDK 1.4.0):
8
+
9
+ ```bash
10
+ npm install @davixlabs/h2i-sdk
11
+ ```
12
+
13
+ ## Use
14
+
15
+ ```js
16
+ const { DavixH2I, enums } = require('@davixlabs/h2i-sdk');
17
+ const h2i = new DavixH2I({ apiKey: process.env.DAVIX_H2I_API_KEY, baseUrl: 'https://your-davix-h2i-host' });
18
+
19
+ const res = await h2i.images.resize({ images: './photo.jpg', width: 800, resizeMode: enums.ResizeFit.COVER });
20
+ console.log(res.data, res.requestId);
21
+ ```
22
+
23
+ ## Authentication
24
+ The key is sent only in the `X-Api-Key` header. It is never put in a URL or body. The SDK never holds signing secrets: signed download URLs are produced by the server.
25
+
26
+ ## Uploads
27
+ A file field accepts a path string, `Buffer`/`Uint8Array`, `Blob`/`File`, a readable stream, or `{ data, filename, contentType }`. Path strings are read from disk **only** for fields the contract declares as files.
28
+
29
+ ## Metadata (bundled vs live)
30
+ ```js
31
+ h2i.schema('images.resize').fields.quality; // type, minimum, maximum, default, enum, behavior (clamp/reject/fallback/unspecified)
32
+ h2i.capabilities.static(); // from the bundled contract, no request
33
+ await h2i.capabilities(); // RUNTIME: what this deployment has installed
34
+ await h2i.capabilities.account(); // ACCOUNT: plan, limits, usage of this key
35
+ await h2i.refreshContract(); // switch schema() to the live contract (GET /v1/contract)
36
+ ```
37
+ `h2i.contract.bundled` is what this SDK was generated from; `h2i.contract.live` is what the server reported. They are never mixed silently.
38
+
39
+ ## Errors
40
+ Every failure is a `DavixH2IError` subclass with `status`, `code`, `requestId`, `hint`, `details`, `renewalUrl` and `retryable`. Compare codes with `ErrorCodes`.
41
+
42
+ ## Retries and idempotency
43
+ Only retryable errors are retried, and only for safe methods or calls that carry an idempotency key. Pass `idempotencyKey` yourself; the SDK never invents a key for a caller who did not ask for one (one per logical call is reused across its own retries).
44
+
45
+ ## Escape hatch
46
+ `h2i.request('POST', '/v1/…', { json })` works for any `/v1/` path but refuses `/internal`, admin and anything outside the contract's request policy.
47
+
48
+ ## Live slices
49
+ `h2i.contract.endpoint('images.optimize')`, `.field(id, name)`, `.enum(name)`, `.error(code)`, `.categories()` and `h2i.capabilities.section('pdfs')` / `.feature('pdfs', 'ocr')` fetch just the piece you need (one small cacheable GET, no API key required by the server).
50
+
51
+ ## Development
52
+ `npm test` (conformance suite against a mock server) · `npm run typecheck`. Do not edit `src/generated` or `index.d.ts`; run `npm run contract:build` in the server repo.
53
+
54
+ ## Naming your app in the History
55
+ Every processing call takes an optional `app`, shown under each result in your History: `await h2i.images.resize({ images: './photo.jpg', width: 800, app: 'My shop importer' })`.