@astroway/sdk 1.5.1 → 1.6.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 +16 -16
- package/dist/namespaces.generated.d.ts +311 -281
- package/dist/namespaces.generated.d.ts.map +1 -1
- package/dist/namespaces.generated.js +70 -55
- package/dist/namespaces.generated.js.map +1 -1
- package/dist/types.generated.d.ts +44642 -10486
- package/dist/types.generated.d.ts.map +1 -1
- package/package.json +6 -5
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @astroway/sdk
|
|
2
2
|
|
|
3
|
-
> Official TypeScript SDK for the [AstroWay API](https://api.astroway.info)
|
|
3
|
+
> Official TypeScript SDK for the [AstroWay API](https://api.astroway.info): natal charts, synastry, transits, Vedic dashas, Tarot, Numerology, Human Design, AI horoscopes. Type-safe end to end, generated from the OpenAPI 3.1 spec.
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/@astroway/sdk)
|
|
6
6
|
[](https://www.npmjs.com/package/@astroway/sdk)
|
|
@@ -18,7 +18,7 @@ npm install @astroway/sdk
|
|
|
18
18
|
# or yarn add @astroway/sdk
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
Get an API key at <https://api.astroway.info/dashboard/sign-up
|
|
21
|
+
Get an API key at <https://api.astroway.info/dashboard/sign-up>: **10,000 credits/month free**, no card required. Each endpoint costs 5–500 credits depending on what it computes ([pricing](https://api.astroway.info/pricing/)).
|
|
22
22
|
|
|
23
23
|
---
|
|
24
24
|
|
|
@@ -48,9 +48,9 @@ console.log(`Sun: ${chart.planets[0].longitude.toFixed(2)}°`); // Sun: 111.77
|
|
|
48
48
|
|
|
49
49
|
`/chart` returns positions, not labels: `houses.ascendant` and every `planets[].longitude` are ecliptic longitudes in degrees, so a sign name is `Math.floor(longitude / 30)` into the list above and the degree within it is `longitude % 30`.
|
|
50
50
|
|
|
51
|
-
The SDK exposes **94 typed namespaces / 623 methods** auto-generated from the OpenAPI spec
|
|
51
|
+
The SDK exposes **94 typed namespaces / 623 methods** auto-generated from the OpenAPI spec: `aw.synastry.aspectGrid({...})`, `aw.bazi.dayMaster({...})`, `aw.vedic.dashasVimshottariMaha({...})`, etc. Path autocomplete and body/response types come straight from your IDE; the `{ ok, data, error }` envelope is unwrapped for you.
|
|
52
52
|
|
|
53
|
-
Need a raw response or an endpoint not yet covered by namespaces? `aw.client` is the underlying [`openapi-fetch`](https://openapi-ts.dev/openapi-fetch/) instance
|
|
53
|
+
Need a raw response or an endpoint not yet covered by namespaces? `aw.client` is the underlying [`openapi-fetch`](https://openapi-ts.dev/openapi-fetch/) instance: `aw.client.POST('/chart', { body })` returns the full envelope with the same typing.
|
|
54
54
|
|
|
55
55
|
---
|
|
56
56
|
|
|
@@ -103,7 +103,7 @@ const spread = await aw.tarot.riderWaiteSpread({ spreadType: 'three-card', seed:
|
|
|
103
103
|
const hd = await aw.humanDesign.compute({
|
|
104
104
|
date: '1990-07-14', time: '14:30:00', timezoneOffset: 3, latitude: 50.45, longitude: 30.52,
|
|
105
105
|
});
|
|
106
|
-
console.log(`${hd.type}
|
|
106
|
+
console.log(`${hd.type} - ${hd.strategy} - ${hd.authority}`);
|
|
107
107
|
```
|
|
108
108
|
|
|
109
109
|
### White-label PDF report
|
|
@@ -132,7 +132,7 @@ Pass `whitelabel: true` instead of an object to pull branding from your account'
|
|
|
132
132
|
|
|
133
133
|
## Error handling
|
|
134
134
|
|
|
135
|
-
The SDK throws typed subclasses of `ApiError`. Catch order matters
|
|
135
|
+
The SDK throws typed subclasses of `ApiError`. Catch order matters, most specific first:
|
|
136
136
|
|
|
137
137
|
```ts
|
|
138
138
|
import { Astroway, ApiError, AuthenticationError, RateLimitError, BadRequestError } from '@astroway/sdk';
|
|
@@ -189,7 +189,7 @@ The default retry honors `Retry-After` (seconds or HTTP-date) on 429 responses.
|
|
|
189
189
|
Every POST request gets a fresh UUIDv4 `Idempotency-Key` header so a network-blip retry never double-bills:
|
|
190
190
|
|
|
191
191
|
```ts
|
|
192
|
-
// Auto: every POST gets a new key (default
|
|
192
|
+
// Auto: every POST gets a new key (default, recommended for credit-metered POSTs).
|
|
193
193
|
const aw = new Astroway({ apiKey });
|
|
194
194
|
|
|
195
195
|
// Override per call when retrying manually:
|
|
@@ -202,16 +202,16 @@ const aw = new Astroway({ apiKey, idempotency: 'off' });
|
|
|
202
202
|
const aw = new Astroway({ apiKey, idempotency: { generator: () => myUlid() } });
|
|
203
203
|
```
|
|
204
204
|
|
|
205
|
-
The header fails open
|
|
205
|
+
The header fails open: older backend versions ignore it without breaking anything.
|
|
206
206
|
|
|
207
207
|
---
|
|
208
208
|
|
|
209
209
|
## Authentication
|
|
210
210
|
|
|
211
|
-
The SDK supports two equivalent auth schemes
|
|
211
|
+
The SDK supports two equivalent auth schemes, pick whichever your stack prefers:
|
|
212
212
|
|
|
213
|
-
- **Header (default):** `X-Api-Key: aw_live_
|
|
214
|
-
- **Bearer:** `Authorization: Bearer aw_live_
|
|
213
|
+
- **Header (default):** `X-Api-Key: aw_live_...`, the same convention as `curl`/Postman examples.
|
|
214
|
+
- **Bearer:** `Authorization: Bearer aw_live_...`, the same convention as Stripe/OpenAI/Anthropic SDKs.
|
|
215
215
|
|
|
216
216
|
Set via `authScheme: 'bearer'` in the constructor.
|
|
217
217
|
|
|
@@ -228,7 +228,7 @@ type ChartBody = paths['/chart']['post']['requestBody']['content']['application/
|
|
|
228
228
|
type ChartResponse = paths['/chart']['post']['responses'][200]['content']['application/json'];
|
|
229
229
|
```
|
|
230
230
|
|
|
231
|
-
Path autocomplete and body validation work out of the box
|
|
231
|
+
Path autocomplete and body validation work out of the box, no separate `@types` package needed.
|
|
232
232
|
|
|
233
233
|
---
|
|
234
234
|
|
|
@@ -257,17 +257,17 @@ Since **`1.0.0` (2026-05-11)** this package follows strict SemVer:
|
|
|
257
257
|
|
|
258
258
|
### Migration from `0.1.0-alpha.x` / `0.1.0-beta.x` / `0.1.0-rc.x` to `0.1.0`
|
|
259
259
|
|
|
260
|
-
`0.1.0` freezes the public surface. **No breaking changes** vs `0.1.0-rc.2
|
|
260
|
+
`0.1.0` freezes the public surface. **No breaking changes** vs `0.1.0-rc.2`: every export, namespace, error class, and option added across alphas/betas/RCs ships unchanged. The freeze means future `0.1.x` patches will not narrow types or remove exports; that level of change requires a `0.2.0` minor bump.
|
|
261
261
|
|
|
262
262
|
| Coming from | Action |
|
|
263
263
|
|---|---|
|
|
264
|
-
| `0.1.0-alpha.1` / `0.1.0-alpha.2` (manual `aw.client.POST(path, body)` + retry) | Switch to typed namespaces
|
|
264
|
+
| `0.1.0-alpha.1` / `0.1.0-alpha.2` (manual `aw.client.POST(path, body)` + retry) | Switch to typed namespaces: `aw.chart.compute(body)`, `aw.synastry.aspectGrid(body)`, etc. The escape hatch (`aw.client.POST`) still works. |
|
|
265
265
|
| `0.1.0-alpha.3` … `alpha.6` (no idempotency / errors / helpers) | Pick up automatic `Idempotency-Key` on POSTs, `error.requestId` / `error.creditsRemaining` getters, `BirthDateTime.fromCity()` helpers in the `/helpers` subpath. |
|
|
266
266
|
| `0.1.0-beta.1` … `beta.3` (no streaming / cache) | Use `aw.streamSSE('/horoscope/daily', body)` for AI streams. Opt into caching via `new Astroway({ cache: 'memory' })`. |
|
|
267
267
|
| `0.1.0-rc.1` (no test client) | `import { MockAstroway } from '@astroway/sdk/testing'` for unit tests. |
|
|
268
268
|
| `0.1.0-rc.2` (no transport tuning) | Optional: pass `dispatcher` (undici Agent) and per-call `timeoutMs` for heavy workloads. |
|
|
269
269
|
|
|
270
|
-
A type-stability test suite (`tests/types.test.ts`) using vitest's `expectTypeOf` locks the surface
|
|
270
|
+
A type-stability test suite (`tests/types.test.ts`) using vitest's `expectTypeOf` locks the surface: any future PR that breaks the public types fails CI before reaching npm.
|
|
271
271
|
|
|
272
272
|
---
|
|
273
273
|
|
|
@@ -284,4 +284,4 @@ A type-stability test suite (`tests/types.test.ts`) using vitest's `expectTypeOf
|
|
|
284
284
|
|
|
285
285
|
## License
|
|
286
286
|
|
|
287
|
-
MIT
|
|
287
|
+
MIT, see [LICENSE](LICENSE).
|