@ai-sdk/provider-utils 3.0.0-canary.0 → 3.0.0-canary.10
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 +99 -0
- package/dist/index.d.mts +33 -10
- package/dist/index.d.ts +33 -10
- package/dist/index.js +106 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +102 -5
- package/dist/index.mjs.map +1 -1
- package/{test/dist → dist/test}/index.d.mts +5 -40
- package/{test/dist → dist/test}/index.d.ts +5 -40
- package/{test/dist → dist/test}/index.js +69 -228
- package/dist/test/index.js.map +1 -0
- package/{test/dist → dist/test}/index.mjs +67 -225
- package/dist/test/index.mjs.map +1 -0
- package/package.json +13 -14
- 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,5 +1,104 @@
|
|
1
1
|
# @ai-sdk/provider-utils
|
2
2
|
|
3
|
+
## 3.0.0-canary.10
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- Updated dependencies [e86be6f]
|
8
|
+
- @ai-sdk/provider@2.0.0-canary.9
|
9
|
+
|
10
|
+
## 3.0.0-canary.9
|
11
|
+
|
12
|
+
### Patch Changes
|
13
|
+
|
14
|
+
- Updated dependencies [95857aa]
|
15
|
+
- Updated dependencies [7ea4132]
|
16
|
+
- @ai-sdk/provider@2.0.0-canary.8
|
17
|
+
|
18
|
+
## 3.0.0-canary.8
|
19
|
+
|
20
|
+
### Major Changes
|
21
|
+
|
22
|
+
- 5d142ab: remove deprecated `CoreToolCall` and `CoreToolResult` types
|
23
|
+
|
24
|
+
### Patch Changes
|
25
|
+
|
26
|
+
- Updated dependencies [b6b43c7]
|
27
|
+
- Updated dependencies [8aa9e20]
|
28
|
+
- Updated dependencies [3795467]
|
29
|
+
- @ai-sdk/provider@2.0.0-canary.7
|
30
|
+
|
31
|
+
## 3.0.0-canary.7
|
32
|
+
|
33
|
+
### Patch Changes
|
34
|
+
|
35
|
+
- Updated dependencies [26735b5]
|
36
|
+
- Updated dependencies [443d8ec]
|
37
|
+
- Updated dependencies [14c9410]
|
38
|
+
- Updated dependencies [d9c98f4]
|
39
|
+
- Updated dependencies [c4a2fec]
|
40
|
+
- Updated dependencies [0054544]
|
41
|
+
- Updated dependencies [9e9c809]
|
42
|
+
- Updated dependencies [32831c6]
|
43
|
+
- Updated dependencies [d0f9495]
|
44
|
+
- Updated dependencies [fd65bc6]
|
45
|
+
- Updated dependencies [393138b]
|
46
|
+
- Updated dependencies [7182d14]
|
47
|
+
- @ai-sdk/provider@2.0.0-canary.6
|
48
|
+
|
49
|
+
## 3.0.0-canary.6
|
50
|
+
|
51
|
+
### Patch Changes
|
52
|
+
|
53
|
+
- Updated dependencies [411e483]
|
54
|
+
- Updated dependencies [79457bd]
|
55
|
+
- Updated dependencies [ad80501]
|
56
|
+
- Updated dependencies [1766ede]
|
57
|
+
- Updated dependencies [f10304b]
|
58
|
+
- @ai-sdk/provider@2.0.0-canary.5
|
59
|
+
|
60
|
+
## 3.0.0-canary.5
|
61
|
+
|
62
|
+
### Patch Changes
|
63
|
+
|
64
|
+
- Updated dependencies [6f6bb89]
|
65
|
+
- @ai-sdk/provider@2.0.0-canary.4
|
66
|
+
|
67
|
+
## 3.0.0-canary.4
|
68
|
+
|
69
|
+
### Patch Changes
|
70
|
+
|
71
|
+
- Updated dependencies [d1a1aa1]
|
72
|
+
- @ai-sdk/provider@2.0.0-canary.3
|
73
|
+
|
74
|
+
## 3.0.0-canary.3
|
75
|
+
|
76
|
+
### Patch Changes
|
77
|
+
|
78
|
+
- a166433: feat: add transcription with experimental_transcribe
|
79
|
+
- 9f95b35: refactor (provider-utils): copy relevant code from `secure-json-parse` into codebase
|
80
|
+
- Updated dependencies [a166433]
|
81
|
+
- Updated dependencies [abf9a79]
|
82
|
+
- Updated dependencies [0a87932]
|
83
|
+
- Updated dependencies [6dc848c]
|
84
|
+
- @ai-sdk/provider@2.0.0-canary.2
|
85
|
+
|
86
|
+
## 3.0.0-canary.2
|
87
|
+
|
88
|
+
### Patch Changes
|
89
|
+
|
90
|
+
- Updated dependencies [c57e248]
|
91
|
+
- Updated dependencies [33f4a6a]
|
92
|
+
- @ai-sdk/provider@2.0.0-canary.1
|
93
|
+
|
94
|
+
## 3.0.0-canary.1
|
95
|
+
|
96
|
+
### Patch Changes
|
97
|
+
|
98
|
+
- 060370c: feat(provider-utils): add TestServerCall#requestCredentials
|
99
|
+
- 0c0c0b3: refactor (provider-utils): move `customAlphabet()` method from `nanoid` into codebase
|
100
|
+
- 63d791d: chore (utils): remove unused test helpers
|
101
|
+
|
3
102
|
## 3.0.0-canary.0
|
4
103
|
|
5
104
|
### Major Changes
|
package/dist/index.d.mts
CHANGED
@@ -190,6 +190,23 @@ declare const getFromApi: <T>({ url, headers, successfulResponseHandler, failedR
|
|
190
190
|
|
191
191
|
declare function isAbortError(error: unknown): error is Error;
|
192
192
|
|
193
|
+
/**
|
194
|
+
* Checks if the given URL is supported natively by the model.
|
195
|
+
*
|
196
|
+
* @param mediaType - The media type of the URL. Case-sensitive.
|
197
|
+
* @param url - The URL to check.
|
198
|
+
* @param supportedUrls - A record where keys are case-sensitive media types (or '*')
|
199
|
+
* and values are arrays of RegExp patterns for URLs.
|
200
|
+
*
|
201
|
+
* @returns `true` if the URL matches a pattern under the specific media type
|
202
|
+
* or the wildcard '*', `false` otherwise.
|
203
|
+
*/
|
204
|
+
declare function isUrlSupported({ mediaType, url, supportedUrls, }: {
|
205
|
+
mediaType: string;
|
206
|
+
url: string;
|
207
|
+
supportedUrls: Record<string, RegExp[]>;
|
208
|
+
}): boolean;
|
209
|
+
|
193
210
|
declare function loadApiKey({ apiKey, environmentVariableName, apiKeyParameterName, description, }: {
|
194
211
|
apiKey: string | undefined;
|
195
212
|
environmentVariableName: string;
|
@@ -244,6 +261,19 @@ declare const postJsonToApi: <T>({ url, headers, body, failedResponseHandler, su
|
|
244
261
|
rawValue?: unknown;
|
245
262
|
responseHeaders?: Record<string, string>;
|
246
263
|
}>;
|
264
|
+
declare const postFormDataToApi: <T>({ url, headers, formData, failedResponseHandler, successfulResponseHandler, abortSignal, fetch, }: {
|
265
|
+
url: string;
|
266
|
+
headers?: Record<string, string | undefined>;
|
267
|
+
formData: FormData;
|
268
|
+
failedResponseHandler: ResponseHandler<APICallError>;
|
269
|
+
successfulResponseHandler: ResponseHandler<T>;
|
270
|
+
abortSignal?: AbortSignal;
|
271
|
+
fetch?: FetchFunction;
|
272
|
+
}) => Promise<{
|
273
|
+
value: T;
|
274
|
+
rawValue?: unknown;
|
275
|
+
responseHeaders?: Record<string, string>;
|
276
|
+
}>;
|
247
277
|
declare const postToApi: <T>({ url, headers, body, successfulResponseHandler, failedResponseHandler, abortSignal, fetch, }: {
|
248
278
|
url: string;
|
249
279
|
headers?: Record<string, string | undefined>;
|
@@ -275,8 +305,9 @@ type Resolvable<T> = T | Promise<T> | (() => T) | (() => Promise<T>);
|
|
275
305
|
*/
|
276
306
|
declare function resolve<T>(value: Resolvable<T>): Promise<T>;
|
277
307
|
|
278
|
-
declare function convertBase64ToUint8Array(base64String: string): Uint8Array
|
308
|
+
declare function convertBase64ToUint8Array(base64String: string): Uint8Array<ArrayBuffer>;
|
279
309
|
declare function convertUint8ArrayToBase64(array: Uint8Array): string;
|
310
|
+
declare function convertToBase64(value: string | Uint8Array): string;
|
280
311
|
|
281
312
|
/**
|
282
313
|
* Validates the types of an unknown object using a schema and
|
@@ -331,10 +362,6 @@ interface ToolCall<NAME extends string, ARGS> {
|
|
331
362
|
*/
|
332
363
|
args: ARGS;
|
333
364
|
}
|
334
|
-
/**
|
335
|
-
* @deprecated Use `ToolCall` instead.
|
336
|
-
*/
|
337
|
-
type CoreToolCall<NAME extends string, ARGS> = ToolCall<NAME, ARGS>;
|
338
365
|
|
339
366
|
/**
|
340
367
|
Typed tool result that is returned by `generateText` and `streamText`.
|
@@ -358,9 +385,5 @@ interface ToolResult<NAME extends string, ARGS, RESULT> {
|
|
358
385
|
*/
|
359
386
|
result: RESULT;
|
360
387
|
}
|
361
|
-
/**
|
362
|
-
* @deprecated Use `ToolResult` instead.
|
363
|
-
*/
|
364
|
-
type CoreToolResult<NAME extends string, ARGS, RESULT> = ToolResult<NAME, ARGS, RESULT>;
|
365
388
|
|
366
|
-
export { type
|
389
|
+
export { type EventSourceChunk, type FetchFunction, type IDGenerator, type ParseResult, type Resolvable, type ResponseHandler, type ToolCall, type ToolResult, type ValidationResult, type Validator, asValidator, combineHeaders, convertAsyncIteratorToReadableStream, convertBase64ToUint8Array, convertToBase64, convertUint8ArrayToBase64, createBinaryResponseHandler, createEventSourceParserStream, createEventSourceResponseHandler, createIdGenerator, createJsonErrorResponseHandler, createJsonResponseHandler, createJsonStreamResponseHandler, createStatusCodeErrorResponseHandler, delay, extractResponseHeaders, generateId, getErrorMessage, getFromApi, isAbortError, isParsableJson, isUrlSupported, isValidator, loadApiKey, loadOptionalSetting, loadSetting, parseJSON, parseProviderOptions, postFormDataToApi, postJsonToApi, postToApi, removeUndefinedEntries, resolve, safeParseJSON, safeValidateTypes, validateTypes, validator, validatorSymbol, withoutTrailingSlash, zodValidator };
|
package/dist/index.d.ts
CHANGED
@@ -190,6 +190,23 @@ declare const getFromApi: <T>({ url, headers, successfulResponseHandler, failedR
|
|
190
190
|
|
191
191
|
declare function isAbortError(error: unknown): error is Error;
|
192
192
|
|
193
|
+
/**
|
194
|
+
* Checks if the given URL is supported natively by the model.
|
195
|
+
*
|
196
|
+
* @param mediaType - The media type of the URL. Case-sensitive.
|
197
|
+
* @param url - The URL to check.
|
198
|
+
* @param supportedUrls - A record where keys are case-sensitive media types (or '*')
|
199
|
+
* and values are arrays of RegExp patterns for URLs.
|
200
|
+
*
|
201
|
+
* @returns `true` if the URL matches a pattern under the specific media type
|
202
|
+
* or the wildcard '*', `false` otherwise.
|
203
|
+
*/
|
204
|
+
declare function isUrlSupported({ mediaType, url, supportedUrls, }: {
|
205
|
+
mediaType: string;
|
206
|
+
url: string;
|
207
|
+
supportedUrls: Record<string, RegExp[]>;
|
208
|
+
}): boolean;
|
209
|
+
|
193
210
|
declare function loadApiKey({ apiKey, environmentVariableName, apiKeyParameterName, description, }: {
|
194
211
|
apiKey: string | undefined;
|
195
212
|
environmentVariableName: string;
|
@@ -244,6 +261,19 @@ declare const postJsonToApi: <T>({ url, headers, body, failedResponseHandler, su
|
|
244
261
|
rawValue?: unknown;
|
245
262
|
responseHeaders?: Record<string, string>;
|
246
263
|
}>;
|
264
|
+
declare const postFormDataToApi: <T>({ url, headers, formData, failedResponseHandler, successfulResponseHandler, abortSignal, fetch, }: {
|
265
|
+
url: string;
|
266
|
+
headers?: Record<string, string | undefined>;
|
267
|
+
formData: FormData;
|
268
|
+
failedResponseHandler: ResponseHandler<APICallError>;
|
269
|
+
successfulResponseHandler: ResponseHandler<T>;
|
270
|
+
abortSignal?: AbortSignal;
|
271
|
+
fetch?: FetchFunction;
|
272
|
+
}) => Promise<{
|
273
|
+
value: T;
|
274
|
+
rawValue?: unknown;
|
275
|
+
responseHeaders?: Record<string, string>;
|
276
|
+
}>;
|
247
277
|
declare const postToApi: <T>({ url, headers, body, successfulResponseHandler, failedResponseHandler, abortSignal, fetch, }: {
|
248
278
|
url: string;
|
249
279
|
headers?: Record<string, string | undefined>;
|
@@ -275,8 +305,9 @@ type Resolvable<T> = T | Promise<T> | (() => T) | (() => Promise<T>);
|
|
275
305
|
*/
|
276
306
|
declare function resolve<T>(value: Resolvable<T>): Promise<T>;
|
277
307
|
|
278
|
-
declare function convertBase64ToUint8Array(base64String: string): Uint8Array
|
308
|
+
declare function convertBase64ToUint8Array(base64String: string): Uint8Array<ArrayBuffer>;
|
279
309
|
declare function convertUint8ArrayToBase64(array: Uint8Array): string;
|
310
|
+
declare function convertToBase64(value: string | Uint8Array): string;
|
280
311
|
|
281
312
|
/**
|
282
313
|
* Validates the types of an unknown object using a schema and
|
@@ -331,10 +362,6 @@ interface ToolCall<NAME extends string, ARGS> {
|
|
331
362
|
*/
|
332
363
|
args: ARGS;
|
333
364
|
}
|
334
|
-
/**
|
335
|
-
* @deprecated Use `ToolCall` instead.
|
336
|
-
*/
|
337
|
-
type CoreToolCall<NAME extends string, ARGS> = ToolCall<NAME, ARGS>;
|
338
365
|
|
339
366
|
/**
|
340
367
|
Typed tool result that is returned by `generateText` and `streamText`.
|
@@ -358,9 +385,5 @@ interface ToolResult<NAME extends string, ARGS, RESULT> {
|
|
358
385
|
*/
|
359
386
|
result: RESULT;
|
360
387
|
}
|
361
|
-
/**
|
362
|
-
* @deprecated Use `ToolResult` instead.
|
363
|
-
*/
|
364
|
-
type CoreToolResult<NAME extends string, ARGS, RESULT> = ToolResult<NAME, ARGS, RESULT>;
|
365
388
|
|
366
|
-
export { type
|
389
|
+
export { type EventSourceChunk, type FetchFunction, type IDGenerator, type ParseResult, type Resolvable, type ResponseHandler, type ToolCall, type ToolResult, type ValidationResult, type Validator, asValidator, combineHeaders, convertAsyncIteratorToReadableStream, convertBase64ToUint8Array, convertToBase64, convertUint8ArrayToBase64, createBinaryResponseHandler, createEventSourceParserStream, createEventSourceResponseHandler, createIdGenerator, createJsonErrorResponseHandler, createJsonResponseHandler, createJsonStreamResponseHandler, createStatusCodeErrorResponseHandler, delay, extractResponseHeaders, generateId, getErrorMessage, getFromApi, isAbortError, isParsableJson, isUrlSupported, isValidator, loadApiKey, loadOptionalSetting, loadSetting, parseJSON, parseProviderOptions, postFormDataToApi, postJsonToApi, postToApi, removeUndefinedEntries, resolve, safeParseJSON, safeValidateTypes, validateTypes, validator, validatorSymbol, withoutTrailingSlash, zodValidator };
|
package/dist/index.js
CHANGED
@@ -1,9 +1,7 @@
|
|
1
1
|
"use strict";
|
2
|
-
var __create = Object.create;
|
3
2
|
var __defProp = Object.defineProperty;
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
8
6
|
var __export = (target, all) => {
|
9
7
|
for (var name in all)
|
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
17
15
|
}
|
18
16
|
return to;
|
19
17
|
};
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
26
|
-
mod
|
27
|
-
));
|
28
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
29
19
|
|
30
20
|
// src/index.ts
|
@@ -34,6 +24,7 @@ __export(src_exports, {
|
|
34
24
|
combineHeaders: () => combineHeaders,
|
35
25
|
convertAsyncIteratorToReadableStream: () => convertAsyncIteratorToReadableStream,
|
36
26
|
convertBase64ToUint8Array: () => convertBase64ToUint8Array,
|
27
|
+
convertToBase64: () => convertToBase64,
|
37
28
|
convertUint8ArrayToBase64: () => convertUint8ArrayToBase64,
|
38
29
|
createBinaryResponseHandler: () => createBinaryResponseHandler,
|
39
30
|
createEventSourceParserStream: () => createEventSourceParserStream,
|
@@ -50,12 +41,14 @@ __export(src_exports, {
|
|
50
41
|
getFromApi: () => getFromApi,
|
51
42
|
isAbortError: () => isAbortError,
|
52
43
|
isParsableJson: () => isParsableJson,
|
44
|
+
isUrlSupported: () => isUrlSupported,
|
53
45
|
isValidator: () => isValidator,
|
54
46
|
loadApiKey: () => loadApiKey,
|
55
47
|
loadOptionalSetting: () => loadOptionalSetting,
|
56
48
|
loadSetting: () => loadSetting,
|
57
49
|
parseJSON: () => parseJSON,
|
58
50
|
parseProviderOptions: () => parseProviderOptions,
|
51
|
+
postFormDataToApi: () => postFormDataToApi,
|
59
52
|
postJsonToApi: () => postJsonToApi,
|
60
53
|
postToApi: () => postToApi,
|
61
54
|
removeUndefinedEntries: () => removeUndefinedEntries,
|
@@ -218,14 +211,27 @@ function extractResponseHeaders(response) {
|
|
218
211
|
|
219
212
|
// src/generate-id.ts
|
220
213
|
var import_provider = require("@ai-sdk/provider");
|
221
|
-
|
214
|
+
|
215
|
+
// src/generate-id-custom-alphabet.ts
|
216
|
+
function customAlphabet(alphabet, defaultSize) {
|
217
|
+
return (size = defaultSize) => {
|
218
|
+
let id = "";
|
219
|
+
let i = size | 0;
|
220
|
+
while (i--) {
|
221
|
+
id += alphabet[Math.random() * alphabet.length | 0];
|
222
|
+
}
|
223
|
+
return id;
|
224
|
+
};
|
225
|
+
}
|
226
|
+
|
227
|
+
// src/generate-id.ts
|
222
228
|
var createIdGenerator = ({
|
223
229
|
prefix,
|
224
230
|
size: defaultSize = 16,
|
225
231
|
alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
|
226
232
|
separator = "-"
|
227
233
|
} = {}) => {
|
228
|
-
const generator =
|
234
|
+
const generator = customAlphabet(alphabet, defaultSize);
|
229
235
|
if (prefix == null) {
|
230
236
|
return generator;
|
231
237
|
}
|
@@ -349,6 +355,20 @@ var getFromApi = async ({
|
|
349
355
|
}
|
350
356
|
};
|
351
357
|
|
358
|
+
// src/is-url-supported.ts
|
359
|
+
function isUrlSupported({
|
360
|
+
mediaType,
|
361
|
+
url,
|
362
|
+
supportedUrls
|
363
|
+
}) {
|
364
|
+
url = url.toLowerCase();
|
365
|
+
mediaType = mediaType.toLowerCase();
|
366
|
+
return Object.entries(supportedUrls).map(([key, value]) => {
|
367
|
+
const mediaType2 = key.toLowerCase();
|
368
|
+
return mediaType2 === "*" || mediaType2 === "*/*" ? { mediaTypePrefix: "", regexes: value } : { mediaTypePrefix: mediaType2.replace(/\*/, ""), regexes: value };
|
369
|
+
}).filter(({ mediaTypePrefix }) => mediaType.startsWith(mediaTypePrefix)).flatMap(({ regexes }) => regexes).some((pattern) => pattern.test(url));
|
370
|
+
}
|
371
|
+
|
352
372
|
// src/load-api-key.ts
|
353
373
|
var import_provider3 = require("@ai-sdk/provider");
|
354
374
|
function loadApiKey({
|
@@ -439,7 +459,51 @@ function loadSetting({
|
|
439
459
|
|
440
460
|
// src/parse-json.ts
|
441
461
|
var import_provider6 = require("@ai-sdk/provider");
|
442
|
-
|
462
|
+
|
463
|
+
// src/secure-json-parse.ts
|
464
|
+
var suspectProtoRx = /"__proto__"\s*:/;
|
465
|
+
var suspectConstructorRx = /"constructor"\s*:/;
|
466
|
+
function _parse(text) {
|
467
|
+
const obj = JSON.parse(text);
|
468
|
+
if (obj === null || typeof obj !== "object") {
|
469
|
+
return obj;
|
470
|
+
}
|
471
|
+
if (suspectProtoRx.test(text) === false && suspectConstructorRx.test(text) === false) {
|
472
|
+
return obj;
|
473
|
+
}
|
474
|
+
return filter(obj);
|
475
|
+
}
|
476
|
+
function filter(obj) {
|
477
|
+
let next = [obj];
|
478
|
+
while (next.length) {
|
479
|
+
const nodes = next;
|
480
|
+
next = [];
|
481
|
+
for (const node of nodes) {
|
482
|
+
if (Object.prototype.hasOwnProperty.call(node, "__proto__")) {
|
483
|
+
throw new SyntaxError("Object contains forbidden prototype property");
|
484
|
+
}
|
485
|
+
if (Object.prototype.hasOwnProperty.call(node, "constructor") && Object.prototype.hasOwnProperty.call(node.constructor, "prototype")) {
|
486
|
+
throw new SyntaxError("Object contains forbidden prototype property");
|
487
|
+
}
|
488
|
+
for (const key in node) {
|
489
|
+
const value = node[key];
|
490
|
+
if (value && typeof value === "object") {
|
491
|
+
next.push(value);
|
492
|
+
}
|
493
|
+
}
|
494
|
+
}
|
495
|
+
}
|
496
|
+
return obj;
|
497
|
+
}
|
498
|
+
function secureJsonParse(text) {
|
499
|
+
const { stackTraceLimit } = Error;
|
500
|
+
Error.stackTraceLimit = 0;
|
501
|
+
try {
|
502
|
+
return _parse(text);
|
503
|
+
} finally {
|
504
|
+
Error.stackTraceLimit = stackTraceLimit;
|
505
|
+
}
|
506
|
+
}
|
443
507
|
|
444
508
|
// src/validate-types.ts
|
445
509
|
var import_provider5 = require("@ai-sdk/provider");
|
@@ -504,7 +568,7 @@ function parseJSON({
|
|
504
568
|
schema
|
505
569
|
}) {
|
506
570
|
try {
|
507
|
-
const value =
|
571
|
+
const value = secureJsonParse(text);
|
508
572
|
if (schema == null) {
|
509
573
|
return value;
|
510
574
|
}
|
@@ -521,7 +585,7 @@ function safeParseJSON({
|
|
521
585
|
schema
|
522
586
|
}) {
|
523
587
|
try {
|
524
|
-
const value =
|
588
|
+
const value = secureJsonParse(text);
|
525
589
|
if (schema == null) {
|
526
590
|
return { success: true, value, rawValue: value };
|
527
591
|
}
|
@@ -536,7 +600,7 @@ function safeParseJSON({
|
|
536
600
|
}
|
537
601
|
function isParsableJson(input) {
|
538
602
|
try {
|
539
|
-
|
603
|
+
secureJsonParse(input);
|
540
604
|
return true;
|
541
605
|
} catch (e) {
|
542
606
|
return false;
|
@@ -593,6 +657,26 @@ var postJsonToApi = async ({
|
|
593
657
|
abortSignal,
|
594
658
|
fetch
|
595
659
|
});
|
660
|
+
var postFormDataToApi = async ({
|
661
|
+
url,
|
662
|
+
headers,
|
663
|
+
formData,
|
664
|
+
failedResponseHandler,
|
665
|
+
successfulResponseHandler,
|
666
|
+
abortSignal,
|
667
|
+
fetch
|
668
|
+
}) => postToApi({
|
669
|
+
url,
|
670
|
+
headers,
|
671
|
+
body: {
|
672
|
+
content: formData,
|
673
|
+
values: Object.fromEntries(formData.entries())
|
674
|
+
},
|
675
|
+
failedResponseHandler,
|
676
|
+
successfulResponseHandler,
|
677
|
+
abortSignal,
|
678
|
+
fetch
|
679
|
+
});
|
596
680
|
var postToApi = async ({
|
597
681
|
url,
|
598
682
|
headers = {},
|
@@ -874,6 +958,9 @@ function convertUint8ArrayToBase64(array) {
|
|
874
958
|
}
|
875
959
|
return btoa(latin1string);
|
876
960
|
}
|
961
|
+
function convertToBase64(value) {
|
962
|
+
return value instanceof Uint8Array ? convertUint8ArrayToBase64(value) : value;
|
963
|
+
}
|
877
964
|
|
878
965
|
// src/without-trailing-slash.ts
|
879
966
|
function withoutTrailingSlash(url) {
|
@@ -885,6 +972,7 @@ function withoutTrailingSlash(url) {
|
|
885
972
|
combineHeaders,
|
886
973
|
convertAsyncIteratorToReadableStream,
|
887
974
|
convertBase64ToUint8Array,
|
975
|
+
convertToBase64,
|
888
976
|
convertUint8ArrayToBase64,
|
889
977
|
createBinaryResponseHandler,
|
890
978
|
createEventSourceParserStream,
|
@@ -901,12 +989,14 @@ function withoutTrailingSlash(url) {
|
|
901
989
|
getFromApi,
|
902
990
|
isAbortError,
|
903
991
|
isParsableJson,
|
992
|
+
isUrlSupported,
|
904
993
|
isValidator,
|
905
994
|
loadApiKey,
|
906
995
|
loadOptionalSetting,
|
907
996
|
loadSetting,
|
908
997
|
parseJSON,
|
909
998
|
parseProviderOptions,
|
999
|
+
postFormDataToApi,
|
910
1000
|
postJsonToApi,
|
911
1001
|
postToApi,
|
912
1002
|
removeUndefinedEntries,
|