@ai-sdk/provider-utils 2.2.8 → 3.0.0-alpha.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/CHANGELOG.md +171 -14
- package/dist/index.d.mts +140 -61
- package/dist/index.d.ts +140 -61
- package/dist/index.js +216 -73
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +188 -53
- package/dist/index.mjs.map +1 -1
- package/dist/test/index.d.mts +87 -0
- package/dist/test/index.d.ts +87 -0
- package/{test/dist → dist/test}/index.js +66 -358
- package/dist/test/index.js.map +1 -0
- package/{test/dist → dist/test}/index.mjs +64 -353
- package/dist/test/index.mjs.map +1 -0
- package/package.json +18 -16
- package/test.d.ts +1 -0
- package/test/dist/index.d.mts +0 -162
- package/test/dist/index.d.ts +0 -162
- package/test/dist/index.js.map +0 -1
- package/test/dist/index.mjs.map +0 -1
- /package/{test/dist → dist/test}/chunk-D6YTI3O5.mjs +0 -0
- /package/{test/dist → dist/test}/chunk-D6YTI3O5.mjs.map +0 -0
- /package/{test/dist → dist/test}/graphql-6JDEV3ML.mjs +0 -0
- /package/{test/dist → dist/test}/graphql-6JDEV3ML.mjs.map +0 -0
package/CHANGELOG.md
CHANGED
@@ -1,38 +1,195 @@
|
|
1
1
|
# @ai-sdk/provider-utils
|
2
2
|
|
3
|
-
##
|
3
|
+
## 3.0.0-alpha.1
|
4
4
|
|
5
5
|
### Patch Changes
|
6
6
|
|
7
|
-
-
|
7
|
+
- Updated dependencies [3f2f00c]
|
8
|
+
- @ai-sdk/provider@2.0.0-alpha.1
|
8
9
|
|
9
|
-
##
|
10
|
+
## 3.0.0-canary.19
|
10
11
|
|
11
12
|
### Patch Changes
|
12
13
|
|
13
|
-
-
|
14
|
-
- @ai-sdk/provider@1.1.3
|
14
|
+
- faf8446: chore (provider-utils): switch to standard-schema
|
15
15
|
|
16
|
-
##
|
16
|
+
## 3.0.0-canary.18
|
17
|
+
|
18
|
+
### Major Changes
|
19
|
+
|
20
|
+
- 40acf9b: feat (ui): introduce ChatStore and ChatTransport
|
21
|
+
|
22
|
+
## 3.0.0-canary.17
|
23
|
+
|
24
|
+
### Major Changes
|
25
|
+
|
26
|
+
- ea7a7c9: feat (ui): UI message metadata
|
27
|
+
|
28
|
+
## 3.0.0-canary.16
|
29
|
+
|
30
|
+
### Patch Changes
|
31
|
+
|
32
|
+
- 87b828f: fix(provider-utils): fix SSE parser bug (CRLF)
|
33
|
+
|
34
|
+
## 3.0.0-canary.15
|
35
|
+
|
36
|
+
### Major Changes
|
37
|
+
|
38
|
+
- 41fa418: chore (provider-utils): return IdGenerator interface
|
39
|
+
|
40
|
+
### Patch Changes
|
41
|
+
|
42
|
+
- a571d6e: chore(provider-utils): move ToolResultContent to provider-utils
|
43
|
+
- Updated dependencies [a8c8bd5]
|
44
|
+
- Updated dependencies [7979f7f]
|
45
|
+
- @ai-sdk/provider@2.0.0-canary.14
|
46
|
+
|
47
|
+
## 3.0.0-canary.14
|
48
|
+
|
49
|
+
### Major Changes
|
50
|
+
|
51
|
+
- 957b739: chore (provider-utils): rename TestServerCall.requestBody to requestBodyJson
|
52
|
+
|
53
|
+
### Patch Changes
|
54
|
+
|
55
|
+
- Updated dependencies [9bd5ab5]
|
56
|
+
- @ai-sdk/provider@2.0.0-canary.13
|
57
|
+
|
58
|
+
## 3.0.0-canary.13
|
59
|
+
|
60
|
+
### Patch Changes
|
61
|
+
|
62
|
+
- 0ff02bb: chore(provider-utils): move over jsonSchema
|
63
|
+
- Updated dependencies [7b3ae3f]
|
64
|
+
- @ai-sdk/provider@2.0.0-canary.12
|
65
|
+
|
66
|
+
## 3.0.0-canary.12
|
67
|
+
|
68
|
+
### Patch Changes
|
69
|
+
|
70
|
+
- Updated dependencies [9bf7291]
|
71
|
+
- Updated dependencies [4617fab]
|
72
|
+
- Updated dependencies [e030615]
|
73
|
+
- @ai-sdk/provider@2.0.0-canary.11
|
74
|
+
|
75
|
+
## 3.0.0-canary.11
|
76
|
+
|
77
|
+
### Patch Changes
|
78
|
+
|
79
|
+
- 66962ed: fix(packages): export node10 compatible types
|
80
|
+
- Updated dependencies [9301f86]
|
81
|
+
- Updated dependencies [a3f768e]
|
82
|
+
- @ai-sdk/provider@2.0.0-canary.10
|
83
|
+
|
84
|
+
## 3.0.0-canary.10
|
17
85
|
|
18
86
|
### Patch Changes
|
19
87
|
|
20
|
-
- Updated dependencies [
|
21
|
-
- @ai-sdk/provider@
|
88
|
+
- Updated dependencies [e86be6f]
|
89
|
+
- @ai-sdk/provider@2.0.0-canary.9
|
22
90
|
|
23
|
-
##
|
91
|
+
## 3.0.0-canary.9
|
24
92
|
|
25
93
|
### Patch Changes
|
26
94
|
|
27
|
-
-
|
28
|
-
- Updated dependencies [
|
29
|
-
- @ai-sdk/provider@
|
95
|
+
- Updated dependencies [95857aa]
|
96
|
+
- Updated dependencies [7ea4132]
|
97
|
+
- @ai-sdk/provider@2.0.0-canary.8
|
98
|
+
|
99
|
+
## 3.0.0-canary.8
|
100
|
+
|
101
|
+
### Major Changes
|
102
|
+
|
103
|
+
- 5d142ab: remove deprecated `CoreToolCall` and `CoreToolResult` types
|
104
|
+
|
105
|
+
### Patch Changes
|
106
|
+
|
107
|
+
- Updated dependencies [b6b43c7]
|
108
|
+
- Updated dependencies [8aa9e20]
|
109
|
+
- Updated dependencies [3795467]
|
110
|
+
- @ai-sdk/provider@2.0.0-canary.7
|
111
|
+
|
112
|
+
## 3.0.0-canary.7
|
113
|
+
|
114
|
+
### Patch Changes
|
115
|
+
|
116
|
+
- Updated dependencies [26735b5]
|
117
|
+
- Updated dependencies [443d8ec]
|
118
|
+
- Updated dependencies [14c9410]
|
119
|
+
- Updated dependencies [d9c98f4]
|
120
|
+
- Updated dependencies [c4a2fec]
|
121
|
+
- Updated dependencies [0054544]
|
122
|
+
- Updated dependencies [9e9c809]
|
123
|
+
- Updated dependencies [32831c6]
|
124
|
+
- Updated dependencies [d0f9495]
|
125
|
+
- Updated dependencies [fd65bc6]
|
126
|
+
- Updated dependencies [393138b]
|
127
|
+
- Updated dependencies [7182d14]
|
128
|
+
- @ai-sdk/provider@2.0.0-canary.6
|
129
|
+
|
130
|
+
## 3.0.0-canary.6
|
131
|
+
|
132
|
+
### Patch Changes
|
133
|
+
|
134
|
+
- Updated dependencies [411e483]
|
135
|
+
- Updated dependencies [79457bd]
|
136
|
+
- Updated dependencies [ad80501]
|
137
|
+
- Updated dependencies [1766ede]
|
138
|
+
- Updated dependencies [f10304b]
|
139
|
+
- @ai-sdk/provider@2.0.0-canary.5
|
140
|
+
|
141
|
+
## 3.0.0-canary.5
|
142
|
+
|
143
|
+
### Patch Changes
|
144
|
+
|
145
|
+
- Updated dependencies [6f6bb89]
|
146
|
+
- @ai-sdk/provider@2.0.0-canary.4
|
147
|
+
|
148
|
+
## 3.0.0-canary.4
|
149
|
+
|
150
|
+
### Patch Changes
|
151
|
+
|
152
|
+
- Updated dependencies [d1a1aa1]
|
153
|
+
- @ai-sdk/provider@2.0.0-canary.3
|
154
|
+
|
155
|
+
## 3.0.0-canary.3
|
156
|
+
|
157
|
+
### Patch Changes
|
158
|
+
|
159
|
+
- a166433: feat: add transcription with experimental_transcribe
|
160
|
+
- 9f95b35: refactor (provider-utils): copy relevant code from `secure-json-parse` into codebase
|
161
|
+
- Updated dependencies [a166433]
|
162
|
+
- Updated dependencies [abf9a79]
|
163
|
+
- Updated dependencies [0a87932]
|
164
|
+
- Updated dependencies [6dc848c]
|
165
|
+
- @ai-sdk/provider@2.0.0-canary.2
|
166
|
+
|
167
|
+
## 3.0.0-canary.2
|
168
|
+
|
169
|
+
### Patch Changes
|
170
|
+
|
171
|
+
- Updated dependencies [c57e248]
|
172
|
+
- Updated dependencies [33f4a6a]
|
173
|
+
- @ai-sdk/provider@2.0.0-canary.1
|
174
|
+
|
175
|
+
## 3.0.0-canary.1
|
176
|
+
|
177
|
+
### Patch Changes
|
178
|
+
|
179
|
+
- 060370c: feat(provider-utils): add TestServerCall#requestCredentials
|
180
|
+
- 0c0c0b3: refactor (provider-utils): move `customAlphabet()` method from `nanoid` into codebase
|
181
|
+
- 63d791d: chore (utils): remove unused test helpers
|
182
|
+
|
183
|
+
## 3.0.0-canary.0
|
184
|
+
|
185
|
+
### Major Changes
|
30
186
|
|
31
|
-
|
187
|
+
- d5f588f: AI SDK 5
|
32
188
|
|
33
189
|
### Patch Changes
|
34
190
|
|
35
|
-
-
|
191
|
+
- Updated dependencies [d5f588f]
|
192
|
+
- @ai-sdk/provider@2.0.0-canary.0
|
36
193
|
|
37
194
|
## 2.2.3
|
38
195
|
|
package/dist/index.d.mts
CHANGED
@@ -1,5 +1,7 @@
|
|
1
|
-
import { JSONValue, JSONParseError, TypeValidationError, APICallError } from '@ai-sdk/provider';
|
2
|
-
import {
|
1
|
+
import { JSONValue, JSONParseError, TypeValidationError, APICallError, JSONSchema7 } from '@ai-sdk/provider';
|
2
|
+
import { ZodSchema, z } from 'zod';
|
3
|
+
import { StandardSchemaV1 } from '@standard-schema/spec';
|
4
|
+
export * from '@standard-schema/spec';
|
3
5
|
|
4
6
|
declare function combineHeaders(...headers: Array<Record<string, string | undefined> | undefined>): Record<string, string | undefined>;
|
5
7
|
|
@@ -43,29 +45,28 @@ type FetchFunction = typeof globalThis.fetch;
|
|
43
45
|
/**
|
44
46
|
Creates an ID generator.
|
45
47
|
The total length of the ID is the sum of the prefix, separator, and random part length.
|
46
|
-
|
48
|
+
Not cryptographically secure.
|
47
49
|
|
48
50
|
@param alphabet - The alphabet to use for the ID. Default: '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.
|
49
|
-
@param prefix - The prefix of the ID to generate.
|
51
|
+
@param prefix - The prefix of the ID to generate. Optional.
|
50
52
|
@param separator - The separator between the prefix and the random part of the ID. Default: '-'.
|
51
53
|
@param size - The size of the random part of the ID to generate. Default: 16.
|
52
54
|
*/
|
53
|
-
declare const createIdGenerator: ({ prefix, size
|
55
|
+
declare const createIdGenerator: ({ prefix, size, alphabet, separator, }?: {
|
54
56
|
prefix?: string;
|
55
57
|
separator?: string;
|
56
58
|
size?: number;
|
57
59
|
alphabet?: string;
|
58
|
-
}) =>
|
60
|
+
}) => IdGenerator;
|
59
61
|
/**
|
60
62
|
A function that generates an ID.
|
61
63
|
*/
|
62
|
-
type
|
64
|
+
type IdGenerator = () => string;
|
63
65
|
/**
|
64
|
-
Generates a 16-character random string to use for IDs.
|
65
|
-
|
66
|
-
@param size - The size of the ID to generate. Default: 16.
|
66
|
+
Generates a 16-character random string to use for IDs.
|
67
|
+
Not cryptographically secure.
|
67
68
|
*/
|
68
|
-
declare const generateId:
|
69
|
+
declare const generateId: IdGenerator;
|
69
70
|
|
70
71
|
declare function getErrorMessage(error: unknown | undefined): string;
|
71
72
|
|
@@ -89,17 +90,17 @@ type Validator<OBJECT = unknown> = {
|
|
89
90
|
* Optional. Validates that the structure of a value matches this schema,
|
90
91
|
* and returns a typed version of the value if it does.
|
91
92
|
*/
|
92
|
-
readonly validate?: (value: unknown) => ValidationResult<OBJECT
|
93
|
+
readonly validate?: (value: unknown) => ValidationResult<OBJECT> | PromiseLike<ValidationResult<OBJECT>>;
|
93
94
|
};
|
94
95
|
/**
|
95
96
|
* Create a validator.
|
96
97
|
*
|
97
98
|
* @param validate A validation function for the schema.
|
98
99
|
*/
|
99
|
-
declare function validator<OBJECT>(validate?: undefined | ((value: unknown) => ValidationResult<OBJECT>)): Validator<OBJECT>;
|
100
|
+
declare function validator<OBJECT>(validate?: undefined | ((value: unknown) => ValidationResult<OBJECT> | PromiseLike<ValidationResult<OBJECT>>)): Validator<OBJECT>;
|
100
101
|
declare function isValidator(value: unknown): value is Validator;
|
101
|
-
declare function asValidator<OBJECT>(value: Validator<OBJECT> |
|
102
|
-
declare function
|
102
|
+
declare function asValidator<OBJECT>(value: Validator<OBJECT> | StandardSchemaV1<OBJECT>): Validator<OBJECT>;
|
103
|
+
declare function standardSchemaValidator<OBJECT>(standardSchema: StandardSchemaV1<OBJECT>): Validator<OBJECT>;
|
103
104
|
|
104
105
|
/**
|
105
106
|
* Parses a JSON string into an unknown object.
|
@@ -110,19 +111,19 @@ declare function zodValidator<OBJECT>(zodSchema: z.Schema<OBJECT, z.ZodTypeDef,
|
|
110
111
|
declare function parseJSON(options: {
|
111
112
|
text: string;
|
112
113
|
schema?: undefined;
|
113
|
-
}): JSONValue
|
114
|
+
}): Promise<JSONValue>;
|
114
115
|
/**
|
115
116
|
* Parses a JSON string into a strongly-typed object using the provided schema.
|
116
117
|
*
|
117
118
|
* @template T - The type of the object to parse the JSON into.
|
118
119
|
* @param {string} text - The JSON string to parse.
|
119
120
|
* @param {Validator<T>} schema - The schema to use for parsing the JSON.
|
120
|
-
* @returns {T} - The parsed object.
|
121
|
+
* @returns {Promise<T>} - The parsed object.
|
121
122
|
*/
|
122
123
|
declare function parseJSON<T>(options: {
|
123
124
|
text: string;
|
124
125
|
schema: ZodSchema<T> | Validator<T>;
|
125
|
-
}): T
|
126
|
+
}): Promise<T>;
|
126
127
|
type ParseResult<T> = {
|
127
128
|
success: true;
|
128
129
|
value: T;
|
@@ -130,17 +131,18 @@ type ParseResult<T> = {
|
|
130
131
|
} | {
|
131
132
|
success: false;
|
132
133
|
error: JSONParseError | TypeValidationError;
|
134
|
+
rawValue: unknown;
|
133
135
|
};
|
134
136
|
/**
|
135
137
|
* Safely parses a JSON string and returns the result as an object of type `unknown`.
|
136
138
|
*
|
137
139
|
* @param text - The JSON string to parse.
|
138
|
-
* @returns {object} Either an object with `success: true` and the parsed data, or an object with `success: false` and the error that occurred.
|
140
|
+
* @returns {Promise<object>} Either an object with `success: true` and the parsed data, or an object with `success: false` and the error that occurred.
|
139
141
|
*/
|
140
142
|
declare function safeParseJSON(options: {
|
141
143
|
text: string;
|
142
144
|
schema?: undefined;
|
143
|
-
}): ParseResult<JSONValue
|
145
|
+
}): Promise<ParseResult<JSONValue>>;
|
144
146
|
/**
|
145
147
|
* Safely parses a JSON string into a strongly-typed object, using a provided schema to validate the object.
|
146
148
|
*
|
@@ -152,7 +154,7 @@ declare function safeParseJSON(options: {
|
|
152
154
|
declare function safeParseJSON<T>(options: {
|
153
155
|
text: string;
|
154
156
|
schema: ZodSchema<T> | Validator<T>;
|
155
|
-
}): ParseResult<T
|
157
|
+
}): Promise<ParseResult<T>>;
|
156
158
|
declare function isParsableJson(input: string): boolean;
|
157
159
|
|
158
160
|
type ResponseHandler<RETURN_TYPE> = (options: {
|
@@ -190,6 +192,23 @@ declare const getFromApi: <T>({ url, headers, successfulResponseHandler, failedR
|
|
190
192
|
|
191
193
|
declare function isAbortError(error: unknown): error is Error;
|
192
194
|
|
195
|
+
/**
|
196
|
+
* Checks if the given URL is supported natively by the model.
|
197
|
+
*
|
198
|
+
* @param mediaType - The media type of the URL. Case-sensitive.
|
199
|
+
* @param url - The URL to check.
|
200
|
+
* @param supportedUrls - A record where keys are case-sensitive media types (or '*')
|
201
|
+
* and values are arrays of RegExp patterns for URLs.
|
202
|
+
*
|
203
|
+
* @returns `true` if the URL matches a pattern under the specific media type
|
204
|
+
* or the wildcard '*', `false` otherwise.
|
205
|
+
*/
|
206
|
+
declare function isUrlSupported({ mediaType, url, supportedUrls, }: {
|
207
|
+
mediaType: string;
|
208
|
+
url: string;
|
209
|
+
supportedUrls: Record<string, RegExp[]>;
|
210
|
+
}): boolean;
|
211
|
+
|
193
212
|
declare function loadApiKey({ apiKey, environmentVariableName, apiKeyParameterName, description, }: {
|
194
213
|
apiKey: string | undefined;
|
195
214
|
environmentVariableName: string;
|
@@ -225,11 +244,19 @@ declare function loadSetting({ settingValue, environmentVariableName, settingNam
|
|
225
244
|
description: string;
|
226
245
|
}): string;
|
227
246
|
|
247
|
+
/**
|
248
|
+
* Parses a JSON event stream into a stream of parsed JSON objects.
|
249
|
+
*/
|
250
|
+
declare function parseJsonEventStream<T>({ stream, schema, }: {
|
251
|
+
stream: ReadableStream<Uint8Array>;
|
252
|
+
schema: ZodSchema<T>;
|
253
|
+
}): ReadableStream<ParseResult<T>>;
|
254
|
+
|
228
255
|
declare function parseProviderOptions<T>({ provider, providerOptions, schema, }: {
|
229
256
|
provider: string;
|
230
257
|
providerOptions: Record<string, unknown> | undefined;
|
231
258
|
schema: z.ZodSchema<T>;
|
232
|
-
}): T | undefined
|
259
|
+
}): Promise<T | undefined>;
|
233
260
|
|
234
261
|
declare const postJsonToApi: <T>({ url, headers, body, failedResponseHandler, successfulResponseHandler, abortSignal, fetch, }: {
|
235
262
|
url: string;
|
@@ -288,43 +315,40 @@ type Resolvable<T> = T | Promise<T> | (() => T) | (() => Promise<T>);
|
|
288
315
|
*/
|
289
316
|
declare function resolve<T>(value: Resolvable<T>): Promise<T>;
|
290
317
|
|
291
|
-
declare function convertBase64ToUint8Array(base64String: string): Uint8Array;
|
292
|
-
declare function convertUint8ArrayToBase64(array: Uint8Array): string;
|
293
|
-
|
294
318
|
/**
|
295
|
-
*
|
296
|
-
* return a strongly-typed object.
|
297
|
-
*
|
298
|
-
* @template T - The type of the object to validate.
|
299
|
-
* @param {string} options.value - The object to validate.
|
300
|
-
* @param {Validator<T>} options.schema - The schema to use for validating the JSON.
|
301
|
-
* @returns {T} - The typed object.
|
319
|
+
* Used to mark schemas so we can support both Zod and custom schemas.
|
302
320
|
*/
|
303
|
-
declare
|
304
|
-
|
305
|
-
|
306
|
-
|
321
|
+
declare const schemaSymbol: unique symbol;
|
322
|
+
type Schema<OBJECT = unknown> = Validator<OBJECT> & {
|
323
|
+
/**
|
324
|
+
* Used to mark schemas so we can support both Zod and custom schemas.
|
325
|
+
*/
|
326
|
+
[schemaSymbol]: true;
|
327
|
+
/**
|
328
|
+
* Schema type for inference.
|
329
|
+
*/
|
330
|
+
_type: OBJECT;
|
331
|
+
/**
|
332
|
+
* The JSON Schema for the schema. It is passed to the providers.
|
333
|
+
*/
|
334
|
+
readonly jsonSchema: JSONSchema7;
|
335
|
+
};
|
307
336
|
/**
|
308
|
-
*
|
309
|
-
* return a strongly-typed object.
|
337
|
+
* Create a schema using a JSON Schema.
|
310
338
|
*
|
311
|
-
* @
|
312
|
-
* @param
|
313
|
-
* @param {Validator<T>} options.schema - The schema to use for validating the JSON.
|
314
|
-
* @returns An object with either a `success` flag and the parsed and typed data, or a `success` flag and an error object.
|
339
|
+
* @param jsonSchema The JSON Schema for the schema.
|
340
|
+
* @param options.validate Optional. A validation function for the schema.
|
315
341
|
*/
|
316
|
-
declare function
|
317
|
-
value: unknown
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
declare function withoutTrailingSlash(url: string | undefined): string | undefined;
|
342
|
+
declare function jsonSchema<OBJECT = unknown>(jsonSchema: JSONSchema7, { validate, }?: {
|
343
|
+
validate?: (value: unknown) => {
|
344
|
+
success: true;
|
345
|
+
value: OBJECT;
|
346
|
+
} | {
|
347
|
+
success: false;
|
348
|
+
error: Error;
|
349
|
+
};
|
350
|
+
}): Schema<OBJECT>;
|
351
|
+
declare function asSchema<OBJECT>(schema: z.Schema<OBJECT, z.ZodTypeDef, any> | Schema<OBJECT> | undefined): Schema<OBJECT>;
|
328
352
|
|
329
353
|
/**
|
330
354
|
Typed tool call that is returned by generateText and streamText.
|
@@ -344,10 +368,6 @@ interface ToolCall<NAME extends string, ARGS> {
|
|
344
368
|
*/
|
345
369
|
args: ARGS;
|
346
370
|
}
|
347
|
-
/**
|
348
|
-
* @deprecated Use `ToolCall` instead.
|
349
|
-
*/
|
350
|
-
type CoreToolCall<NAME extends string, ARGS> = ToolCall<NAME, ARGS>;
|
351
371
|
|
352
372
|
/**
|
353
373
|
Typed tool result that is returned by `generateText` and `streamText`.
|
@@ -371,9 +391,68 @@ interface ToolResult<NAME extends string, ARGS, RESULT> {
|
|
371
391
|
*/
|
372
392
|
result: RESULT;
|
373
393
|
}
|
394
|
+
type ToolResultContent = Array<{
|
395
|
+
type: 'text';
|
396
|
+
text: string;
|
397
|
+
} | {
|
398
|
+
type: 'image';
|
399
|
+
data: string;
|
400
|
+
mediaType?: string;
|
401
|
+
/**
|
402
|
+
* @deprecated Use `mediaType` instead.
|
403
|
+
*/
|
404
|
+
mimeType?: string;
|
405
|
+
}>;
|
406
|
+
|
407
|
+
declare function convertBase64ToUint8Array(base64String: string): Uint8Array<ArrayBuffer>;
|
408
|
+
declare function convertUint8ArrayToBase64(array: Uint8Array): string;
|
409
|
+
declare function convertToBase64(value: string | Uint8Array): string;
|
410
|
+
|
411
|
+
/**
|
412
|
+
* Validates the types of an unknown object using a schema and
|
413
|
+
* return a strongly-typed object.
|
414
|
+
*
|
415
|
+
* @template T - The type of the object to validate.
|
416
|
+
* @param {string} options.value - The object to validate.
|
417
|
+
* @param {Validator<T>} options.schema - The schema to use for validating the JSON.
|
418
|
+
* @returns {Promise<T>} - The typed object.
|
419
|
+
*/
|
420
|
+
declare function validateTypes<OBJECT>({ value, schema, }: {
|
421
|
+
value: unknown;
|
422
|
+
schema: StandardSchemaV1<OBJECT> | Validator<OBJECT>;
|
423
|
+
}): Promise<OBJECT>;
|
374
424
|
/**
|
375
|
-
*
|
425
|
+
* Safely validates the types of an unknown object using a schema and
|
426
|
+
* return a strongly-typed object.
|
427
|
+
*
|
428
|
+
* @template T - The type of the object to validate.
|
429
|
+
* @param {string} options.value - The JSON object to validate.
|
430
|
+
* @param {Validator<T>} options.schema - The schema to use for validating the JSON.
|
431
|
+
* @returns An object with either a `success` flag and the parsed and typed data, or a `success` flag and an error object.
|
376
432
|
*/
|
377
|
-
|
433
|
+
declare function safeValidateTypes<OBJECT>({ value, schema, }: {
|
434
|
+
value: unknown;
|
435
|
+
schema: StandardSchemaV1<OBJECT> | Validator<OBJECT>;
|
436
|
+
}): Promise<{
|
437
|
+
success: true;
|
438
|
+
value: OBJECT;
|
439
|
+
rawValue: unknown;
|
440
|
+
} | {
|
441
|
+
success: false;
|
442
|
+
error: TypeValidationError;
|
443
|
+
rawValue: unknown;
|
444
|
+
}>;
|
445
|
+
|
446
|
+
declare function withoutTrailingSlash(url: string | undefined): string | undefined;
|
447
|
+
|
448
|
+
declare function zodSchema<OBJECT>(zodSchema: z.Schema<OBJECT, z.ZodTypeDef, any>, options?: {
|
449
|
+
/**
|
450
|
+
* Enables support for references in the schema.
|
451
|
+
* This is required for recursive schemas, e.g. with `z.lazy`.
|
452
|
+
* However, not all language models and providers support such references.
|
453
|
+
* Defaults to `false`.
|
454
|
+
*/
|
455
|
+
useReferences?: boolean;
|
456
|
+
}): Schema<OBJECT>;
|
378
457
|
|
379
|
-
export { type
|
458
|
+
export { type EventSourceChunk, type FetchFunction, type IdGenerator, type ParseResult, type Resolvable, type ResponseHandler, type Schema, type ToolCall, type ToolResult, type ToolResultContent, type ValidationResult, type Validator, asSchema, asValidator, combineHeaders, convertAsyncIteratorToReadableStream, convertBase64ToUint8Array, convertToBase64, convertUint8ArrayToBase64, createBinaryResponseHandler, createEventSourceParserStream, createEventSourceResponseHandler, createIdGenerator, createJsonErrorResponseHandler, createJsonResponseHandler, createJsonStreamResponseHandler, createStatusCodeErrorResponseHandler, delay, extractResponseHeaders, generateId, getErrorMessage, getFromApi, isAbortError, isParsableJson, isUrlSupported, isValidator, jsonSchema, loadApiKey, loadOptionalSetting, loadSetting, parseJSON, parseJsonEventStream, parseProviderOptions, postFormDataToApi, postJsonToApi, postToApi, removeUndefinedEntries, resolve, safeParseJSON, safeValidateTypes, standardSchemaValidator, validateTypes, validator, validatorSymbol, withoutTrailingSlash, zodSchema };
|