@haau3/sdk 0.0.0 → 0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Brian K. Fung Media LLC, doing business as haau3
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,9 +1,134 @@
1
1
  # @haau3/sdk
2
2
 
3
- This version, 0.0.0, is an empty placeholder. Install 0.1.0 or newer:
3
+ The TypeScript SDK for the [haau3 platform API](https://docs.haau3.com): scheduling, the provider
4
+ directory, terminology, questionnaires, plan benefits and MedList, as typed calls.
5
+
6
+ The haau3 platform API is in preview: it may change as we build, usually to add features or improve performance.
7
+
8
+ ## Install
4
9
 
5
10
  ```sh
6
11
  npm install @haau3/sdk
7
12
  ```
8
13
 
9
- The SDK's source is [github.com/haau3/haau3-node](https://github.com/haau3/haau3-node).
14
+ Node 22 or newer. The SDK runs on a server only: it refuses to start in a browser, where your API
15
+ key would be public.
16
+
17
+ ## Authenticate
18
+
19
+ Create an API key on [platform.haau3.com](https://platform.haau3.com), then set it as
20
+ `HAAU3_API_KEY` or pass it as `apiKey`.
21
+
22
+ ```ts
23
+ import { Haau3 } from "@haau3/sdk";
24
+
25
+ const haau3 = new Haau3(); // reads HAAU3_API_KEY
26
+ ```
27
+
28
+ ## A first call
29
+
30
+ ```ts
31
+ const plan = await haau3.readInsurancePlan("H2406-013-000");
32
+ console.log(plan.name);
33
+
34
+ const { providerLocations } = await haau3.searchProviderLocations({ state: "MA", limit: 10 });
35
+ ```
36
+
37
+ Every operation in the [API reference](https://docs.haau3.com) is a method named by its
38
+ operationId, with its parameters and its answer typed from the published spec. FHIR answers are
39
+ [@types/fhir](https://www.npmjs.com/package/@types/fhir)'s R4 types, also exported as `fhir4`:
40
+
41
+ ```ts
42
+ import type { fhir4 } from "@haau3/sdk";
43
+
44
+ const bundle: fhir4.Bundle = await haau3.searchPractitioner({ identifier: "http://hl7.org/fhir/sid/us-npi|1518929058" });
45
+ ```
46
+
47
+ ## Options
48
+
49
+ | Option | Default | |
50
+ |---|---|---|
51
+ | `apiKey` | `process.env.HAAU3_API_KEY` | Your platform API key. |
52
+ | `baseURL` | `https://api.haau3.com` | Where the API is. |
53
+ | `timeout` | `65000` | Milliseconds one attempt may take. |
54
+ | `maxRetries` | `1` | Retries after a timeout, a network failure, a 429 or a 5xx. |
55
+ | `fetch` | the global `fetch` | The fetch to send requests with. |
56
+
57
+ Each call takes `{ timeout, maxRetries, signal, headers }` as its last argument, for that call only:
58
+
59
+ ```ts
60
+ await haau3.searchSlots({ state: "MA" }, { timeout: 10_000, maxRetries: 0 });
61
+ ```
62
+
63
+ A retry waits a short, growing interval, or what the API's `Retry-After` header says when that is
64
+ 60 seconds or less. A longer `Retry-After` fails at once, carrying it.
65
+
66
+ ## Errors
67
+
68
+ Every error is a `Haau3Error`, with the `requestId` the API answered with. There are three kinds:
69
+
70
+ ```ts
71
+ import { AuthError, NoAnswerError, RefusedError } from "@haau3/sdk";
72
+
73
+ try {
74
+ await haau3.readInsurancePlan(id);
75
+ } catch (error) {
76
+ if (error instanceof RefusedError) {
77
+ error.status; // 400, 404, 410 and so on
78
+ error.outcome; // the OperationOutcome; Scheduling's errors carry `problem`
79
+ } else if (error instanceof NoAnswerError) {
80
+ error.reason; // "timeout", "network", "rate-limited", "unavailable", "server-error" or "unreadable"
81
+ error.retryAfter; // seconds, when the API said
82
+ } else if (error instanceof AuthError) {
83
+ // the key was missing, unknown or revoked
84
+ }
85
+ }
86
+ ```
87
+
88
+ No answer is never reported as an empty result, and an empty result is never an error. An error's
89
+ message never includes the body the API answered with, and the body (`outcome` or `problem`) is
90
+ never printed when the error is logged.
91
+
92
+ ## Paging
93
+
94
+ `pages()` yields a FHIR search's first page and every page after it:
95
+
96
+ ```ts
97
+ const first = await haau3.searchInsurancePlan({ "coverage-area-state": "NC" });
98
+ for await (const page of haau3.pages(first)) {
99
+ for (const entry of page.entry ?? []) console.log(entry.resource?.id);
100
+ }
101
+ ```
102
+
103
+ Scheduling's searches page with `limit` and `offset`, and answer with a `total`.
104
+
105
+ ## Several requests in one
106
+
107
+ ```ts
108
+ const answers = await haau3.fhirBatch({
109
+ resourceType: "Bundle",
110
+ type: "batch",
111
+ entry: [
112
+ { request: { method: "GET", url: "CodeSystem/$lookup?system=http://loinc.org&code=2345-7" } },
113
+ { request: { method: "GET", url: "InsurancePlan/$counties?state=NC" } },
114
+ ],
115
+ });
116
+ ```
117
+
118
+ ## Any request
119
+
120
+ `request()` sends a request as you give it and returns what the API answered, whatever the
121
+ status, with its headers, request id, attempts and duration:
122
+
123
+ ```ts
124
+ const { status, body, requestId } = await haau3.request({ method: "GET", path: "/v1/scheduling/publishers" });
125
+ ```
126
+
127
+ ## Versions
128
+
129
+ The SDK is `0.y.z` while the API is in preview: a minor release may change what a method takes or
130
+ answers, and a patch release never does.
131
+
132
+ ## License
133
+
134
+ [MIT](LICENSE)