@savantoai/ai-sdk 2.1.0 → 3.0.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/CHANGELOG.md +141 -0
- package/README.md +10 -0
- package/dist/index.cjs +190 -120
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +404 -103
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +404 -103
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +186 -121
- package/dist/index.mjs.map +1 -1
- package/package.json +11 -9
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `@savantoai/ai-sdk` will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is loosely based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and we follow [semantic versioning](https://semver.org/) — see _Versioning policy_
|
|
7
|
+
below for the one nuance that applies to a generated SDK.
|
|
8
|
+
|
|
9
|
+
## Versioning policy
|
|
10
|
+
|
|
11
|
+
This SDK is fully regenerated from `cloud/openapi.json` by
|
|
12
|
+
[`@hey-api/openapi-ts`](https://github.com/hey-api/openapi-ts). Generator and
|
|
13
|
+
schema changes can _both_ produce TypeScript-only breaking changes (e.g. a
|
|
14
|
+
field gains `| null`, a `body` shape narrows, a top-level helper type
|
|
15
|
+
widens) without changing any runtime behaviour. We treat those as breaking
|
|
16
|
+
under semver, meaning:
|
|
17
|
+
|
|
18
|
+
- A change that **narrows** a previously-accepted type (e.g. record →
|
|
19
|
+
concrete interface) is a major version bump.
|
|
20
|
+
- A change that **widens** a previously-non-nullable type to include `null`
|
|
21
|
+
is a major version bump.
|
|
22
|
+
- Generator-driven changes to top-level re-exports (`Client`, `Config`,
|
|
23
|
+
`Options`, `RequestResult`, `RequestOptions`) are major version bumps.
|
|
24
|
+
- Pure additions (new endpoints, new optional fields on requests,
|
|
25
|
+
newly-exported types) are minor.
|
|
26
|
+
- Internal regen with no public-surface diff is patch.
|
|
27
|
+
|
|
28
|
+
`@hey-api/openapi-ts` is pinned to `~0.97.x` (patch range only) in
|
|
29
|
+
`package.json` so generator-driven type narrowings can't slip in via a
|
|
30
|
+
caret update. Bumping that range is itself a major-version event for the
|
|
31
|
+
SDK.
|
|
32
|
+
|
|
33
|
+
## 3.0.0 — 2026-05-12
|
|
34
|
+
|
|
35
|
+
### Breaking (TypeScript)
|
|
36
|
+
|
|
37
|
+
- **`POST /threads/search` `sortBy` enum renamed.** Previously the SDK
|
|
38
|
+
emitted `'timestamp' | 'message_count' | 'token_count'`, but the
|
|
39
|
+
server-side handler routed those names through to OpenSearch
|
|
40
|
+
unchanged — and OpenSearch indexes those fields as `messageCount`
|
|
41
|
+
and `tokenCount`, so the snake_case values produced an invalid
|
|
42
|
+
sort clause that callers either silently ignored or got a 500 on.
|
|
43
|
+
The schema now matches the OpenSearch field names:
|
|
44
|
+
`'timestamp' | 'messageCount' | 'tokenCount'`.
|
|
45
|
+
**Migration**: switch `sortBy: 'message_count'` →
|
|
46
|
+
`sortBy: 'messageCount'`, `'token_count'` → `'tokenCount'`.
|
|
47
|
+
|
|
48
|
+
### Other
|
|
49
|
+
|
|
50
|
+
- `UpdateMcpConfigRequest` body has been reopened server-side to
|
|
51
|
+
accept arbitrary string-URL fields (`catchall(z.string().url())`),
|
|
52
|
+
so the generated SDK type now allows forward-compatible MCP URI
|
|
53
|
+
keys (e.g. a future `crmUri`) without an SDK regen. This restores
|
|
54
|
+
some of the pre-2.2.0 surface flagged in the 2.2.0 section below,
|
|
55
|
+
but with per-field URL/length validation instead of `passthrough()`.
|
|
56
|
+
|
|
57
|
+
## 2.2.0 — 2026-05-07
|
|
58
|
+
|
|
59
|
+
This release was published as a minor bump but **contains TypeScript-level
|
|
60
|
+
breaking changes** that, per the policy above, should have been a major
|
|
61
|
+
(`3.0.0`). It is documented here retroactively so consumers know to add
|
|
62
|
+
null-guards / update destructuring patterns when upgrading from `2.1.x`.
|
|
63
|
+
The next regeneration will be released as `3.0.0`.
|
|
64
|
+
|
|
65
|
+
### Breaking (TypeScript)
|
|
66
|
+
|
|
67
|
+
- **~30 fields gained `| null`.** The cloud OpenAPI emitter switched from
|
|
68
|
+
3.0 (`app.doc()`) to 3.1 (`app.doc31()`), so fields whose Zod schema
|
|
69
|
+
uses `.nullable()` now serialise as `type: [..., 'null']`, and the
|
|
70
|
+
generator faithfully reflects that with `T | null`. Affected fields
|
|
71
|
+
include:
|
|
72
|
+
- `ErrorResponse.error.param` (`string` → `string | null`)
|
|
73
|
+
- `Pagination.total` / `Pagination.cursor` (`number | null`,
|
|
74
|
+
`string | null`) — note that `total` lives on every paginated list
|
|
75
|
+
response in the SDK.
|
|
76
|
+
- `Product.price`, `Product.salePrice`, `Product.priceMin`,
|
|
77
|
+
`Product.priceMax`, `Product.weight`, `Product.dimensions`,
|
|
78
|
+
`Product.image`, `Product.attributes`, `Product.rating`, and their
|
|
79
|
+
`ProductInput.*` counterparts.
|
|
80
|
+
- `Post.publishedAt`, `Post.featuredImage`, `Post.attributes`.
|
|
81
|
+
- `TenantStatus.publishableKey`.
|
|
82
|
+
|
|
83
|
+
Consumer code like `product.price.toFixed(2)` or
|
|
84
|
+
`if (pagination.total > 0)` will fail TypeScript strict-mode typecheck.
|
|
85
|
+
**Migration**: add nullish guards or use `??` defaults:
|
|
86
|
+
|
|
87
|
+
```ts
|
|
88
|
+
product.price?.toFixed(2);
|
|
89
|
+
if ((pagination.total ?? 0) > 0) { /* … */ }
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
- **Five admin/tenant request bodies narrowed from open-record to concrete
|
|
93
|
+
interface.** Cloud PR #138 replaced a `genericBody` Zod schema with six
|
|
94
|
+
typed request schemas. The regenerated SDK reflects this in:
|
|
95
|
+
- `UpdateWorkspaceData.body` → `UpdateWorkspaceRequest`
|
|
96
|
+
- `GetUploadUrlData.body` → `GetUploadUrlRequest`
|
|
97
|
+
- `UpdateMcpConfigData.body` → `UpdateMcpConfigRequest` _(reopened
|
|
98
|
+
server-side after audit #153 — see Unreleased)_
|
|
99
|
+
- `StoreCredentialsData.body` → `StoreLiveAgentCredentialsRequest`
|
|
100
|
+
- `UpdateLiveAgentScheduleData.body` →
|
|
101
|
+
`UpdateLiveAgentScheduleRequest`
|
|
102
|
+
|
|
103
|
+
Callers that were passing extra forward-compatible fields will fail
|
|
104
|
+
TypeScript typecheck. **Migration**: drop the extra fields — the cloud
|
|
105
|
+
was always ignoring them; the type just no longer admits them. (The
|
|
106
|
+
one exception, `updateMcpConfig`, has been reopened server-side; see
|
|
107
|
+
_Unreleased_.)
|
|
108
|
+
|
|
109
|
+
- **`RequestResult.request` / `response` made optional.** Generator bump
|
|
110
|
+
`@hey-api/openapi-ts` `0.94.x` → `0.97.x` changed the success branch of
|
|
111
|
+
`RequestResult` from `& { request: Request; response: Response }` to
|
|
112
|
+
`& { request?: Request; response?: Response }`. The change reflects
|
|
113
|
+
that `request` / `response` can be `undefined` if the failure happened
|
|
114
|
+
before the network call (DNS, request-building, etc.). Consumer code
|
|
115
|
+
like `const { data, response } = await chat(...); response.body` will
|
|
116
|
+
fail strict typecheck. **Migration** — either:
|
|
117
|
+
|
|
118
|
+
```ts
|
|
119
|
+
// Option A — guard with `if (response)`:
|
|
120
|
+
const { data, response } = await chat({ client, body: { … } });
|
|
121
|
+
if (response) { /* response.body, response.status, etc. */ }
|
|
122
|
+
|
|
123
|
+
// Option B — opt in to `throwOnError`, which keeps response non-optional:
|
|
124
|
+
const { data, response } = await chat({
|
|
125
|
+
client,
|
|
126
|
+
body: { … },
|
|
127
|
+
throwOnError: true,
|
|
128
|
+
});
|
|
129
|
+
response.body; // typed as `Response`, not `Response | undefined`
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### Other notes
|
|
133
|
+
|
|
134
|
+
- `@hey-api/openapi-ts` was bumped from `^0.94.x` to `^0.97.1` as part of
|
|
135
|
+
this release. Subsequent versions pin to `~0.97.x` to avoid further
|
|
136
|
+
silent generator-driven type narrowings via caret updates.
|
|
137
|
+
|
|
138
|
+
## 2.1.0 and earlier
|
|
139
|
+
|
|
140
|
+
No formal changelog kept prior to 2.2.0. The git history (`sdks/javascript/`)
|
|
141
|
+
is the source of truth for older releases.
|
package/README.md
CHANGED
|
@@ -101,6 +101,9 @@ const { data: ids } = await listProductIds({ client });
|
|
|
101
101
|
```typescript
|
|
102
102
|
import { chat } from '@savantoai/ai-sdk';
|
|
103
103
|
|
|
104
|
+
// `throwOnError: true` makes `response` non-optional so `response.body` is
|
|
105
|
+
// safe to read directly. Without it (since 2.2.0) `response` is typed as
|
|
106
|
+
// `Response | undefined`. See CHANGELOG.md for details.
|
|
104
107
|
const { data, response } = await chat({
|
|
105
108
|
client,
|
|
106
109
|
body: {
|
|
@@ -108,6 +111,7 @@ const { data, response } = await chat({
|
|
|
108
111
|
threadId: 'thread-1',
|
|
109
112
|
stream: true,
|
|
110
113
|
},
|
|
114
|
+
throwOnError: true,
|
|
111
115
|
});
|
|
112
116
|
|
|
113
117
|
// For streaming (NDJSON), read the response body directly:
|
|
@@ -266,6 +270,12 @@ Full endpoint documentation with request/response schemas:
|
|
|
266
270
|
|
|
267
271
|
**[savanto.ai/docs/api](https://savanto.ai/docs/api)**
|
|
268
272
|
|
|
273
|
+
## Versioning & changelog
|
|
274
|
+
|
|
275
|
+
See [CHANGELOG.md](./CHANGELOG.md) for per-version migration notes,
|
|
276
|
+
including the TypeScript-level breaking changes in `2.2.0`. Type
|
|
277
|
+
narrowings and generator-driven shape changes are treated as major.
|
|
278
|
+
|
|
269
279
|
## Regeneration
|
|
270
280
|
|
|
271
281
|
The SDK is auto-generated from the OpenAPI spec. To regenerate after API changes:
|