@ai-sdk/provider-utils 4.0.7 → 4.0.9

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.
Files changed (55) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/index.js +1 -1
  3. package/dist/index.mjs +1 -1
  4. package/package.json +6 -2
  5. package/src/__snapshots__/schema.test.ts.snap +0 -346
  6. package/src/add-additional-properties-to-json-schema.test.ts +0 -289
  7. package/src/convert-async-iterator-to-readable-stream.test.ts +0 -78
  8. package/src/convert-image-model-file-to-data-uri.test.ts +0 -85
  9. package/src/convert-to-form-data.test.ts +0 -167
  10. package/src/create-tool-name-mapping.test.ts +0 -163
  11. package/src/delay.test.ts +0 -212
  12. package/src/delayed-promise.test.ts +0 -132
  13. package/src/download-blob.test.ts +0 -145
  14. package/src/generate-id.test.ts +0 -31
  15. package/src/get-from-api.test.ts +0 -199
  16. package/src/get-runtime-environment-user-agent.test.ts +0 -47
  17. package/src/inject-json-instruction.test.ts +0 -404
  18. package/src/is-url-supported.test.ts +0 -282
  19. package/src/media-type-to-extension.test.ts +0 -26
  20. package/src/normalize-headers.test.ts +0 -64
  21. package/src/parse-json.test.ts +0 -191
  22. package/src/remove-undefined-entries.test.ts +0 -57
  23. package/src/resolve.test.ts +0 -125
  24. package/src/response-handler.test.ts +0 -89
  25. package/src/schema.test-d.ts +0 -11
  26. package/src/schema.test.ts +0 -502
  27. package/src/secure-json-parse.test.ts +0 -59
  28. package/src/to-json-schema/zod3-to-json-schema/parse-def.test.ts +0 -224
  29. package/src/to-json-schema/zod3-to-json-schema/parsers/array.test.ts +0 -98
  30. package/src/to-json-schema/zod3-to-json-schema/parsers/bigint.test.ts +0 -51
  31. package/src/to-json-schema/zod3-to-json-schema/parsers/branded.test.ts +0 -16
  32. package/src/to-json-schema/zod3-to-json-schema/parsers/catch.test.ts +0 -15
  33. package/src/to-json-schema/zod3-to-json-schema/parsers/date.test.ts +0 -97
  34. package/src/to-json-schema/zod3-to-json-schema/parsers/default.test.ts +0 -54
  35. package/src/to-json-schema/zod3-to-json-schema/parsers/effects.test.ts +0 -41
  36. package/src/to-json-schema/zod3-to-json-schema/parsers/intersection.test.ts +0 -92
  37. package/src/to-json-schema/zod3-to-json-schema/parsers/map.test.ts +0 -48
  38. package/src/to-json-schema/zod3-to-json-schema/parsers/native-enum.test.ts +0 -102
  39. package/src/to-json-schema/zod3-to-json-schema/parsers/nullable.test.ts +0 -67
  40. package/src/to-json-schema/zod3-to-json-schema/parsers/number.test.ts +0 -65
  41. package/src/to-json-schema/zod3-to-json-schema/parsers/object.test.ts +0 -149
  42. package/src/to-json-schema/zod3-to-json-schema/parsers/optional.test.ts +0 -147
  43. package/src/to-json-schema/zod3-to-json-schema/parsers/pipe.test.ts +0 -35
  44. package/src/to-json-schema/zod3-to-json-schema/parsers/promise.test.ts +0 -15
  45. package/src/to-json-schema/zod3-to-json-schema/parsers/readonly.test.ts +0 -20
  46. package/src/to-json-schema/zod3-to-json-schema/parsers/record.test.ts +0 -108
  47. package/src/to-json-schema/zod3-to-json-schema/parsers/set.test.ts +0 -20
  48. package/src/to-json-schema/zod3-to-json-schema/parsers/string.test.ts +0 -438
  49. package/src/to-json-schema/zod3-to-json-schema/parsers/tuple.test.ts +0 -33
  50. package/src/to-json-schema/zod3-to-json-schema/parsers/union.test.ts +0 -226
  51. package/src/to-json-schema/zod3-to-json-schema/refs.test.ts +0 -919
  52. package/src/to-json-schema/zod3-to-json-schema/zod3-to-json-schema.test.ts +0 -862
  53. package/src/types/tool.test-d.ts +0 -228
  54. package/src/validate-types.test.ts +0 -105
  55. package/src/with-user-agent-suffix.test.ts +0 -84
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # @ai-sdk/provider-utils
2
2
 
3
+ ## 4.0.9
4
+
5
+ ### Patch Changes
6
+
7
+ - 4de5a1d: chore: excluded tests from src folder in npm package
8
+ - Updated dependencies [4de5a1d]
9
+ - @ai-sdk/provider@3.0.5
10
+
11
+ ## 4.0.8
12
+
13
+ ### Patch Changes
14
+
15
+ - Updated dependencies [5c090e7]
16
+ - @ai-sdk/provider@3.0.4
17
+
3
18
  ## 4.0.7
4
19
 
5
20
  ### Patch Changes
package/dist/index.js CHANGED
@@ -475,7 +475,7 @@ function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
475
475
  }
476
476
 
477
477
  // src/version.ts
478
- var VERSION = true ? "4.0.7" : "0.0.0-test";
478
+ var VERSION = true ? "4.0.9" : "0.0.0-test";
479
479
 
480
480
  // src/get-from-api.ts
481
481
  var getOriginalFetch = () => globalThis.fetch;
package/dist/index.mjs CHANGED
@@ -382,7 +382,7 @@ function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
382
382
  }
383
383
 
384
384
  // src/version.ts
385
- var VERSION = true ? "4.0.7" : "0.0.0-test";
385
+ var VERSION = true ? "4.0.9" : "0.0.0-test";
386
386
 
387
387
  // src/get-from-api.ts
388
388
  var getOriginalFetch = () => globalThis.fetch;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/provider-utils",
3
- "version": "4.0.7",
3
+ "version": "4.0.9",
4
4
  "license": "Apache-2.0",
5
5
  "sideEffects": false,
6
6
  "main": "./dist/index.js",
@@ -10,6 +10,10 @@
10
10
  "files": [
11
11
  "dist/**/*",
12
12
  "src",
13
+ "!src/**/*.test.ts",
14
+ "!src/**/*.test-d.ts",
15
+ "!src/**/__snapshots__",
16
+ "!src/**/__fixtures__",
13
17
  "CHANGELOG.md",
14
18
  "README.md",
15
19
  "test.d.ts"
@@ -31,7 +35,7 @@
31
35
  "dependencies": {
32
36
  "@standard-schema/spec": "^1.1.0",
33
37
  "eventsource-parser": "^3.0.6",
34
- "@ai-sdk/provider": "3.0.3"
38
+ "@ai-sdk/provider": "3.0.5"
35
39
  },
36
40
  "devDependencies": {
37
41
  "@types/node": "20.17.24",
@@ -1,346 +0,0 @@
1
- // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2
-
3
- exports[`zodSchema > zod/v4 > json schema conversion > .literal and .enum 1`] = `
4
- {
5
- "$schema": "http://json-schema.org/draft-07/schema#",
6
- "additionalProperties": false,
7
- "properties": {
8
- "number": {
9
- "enum": [
10
- "one",
11
- "two",
12
- "three",
13
- ],
14
- "type": "string",
15
- },
16
- "text": {
17
- "const": "hello",
18
- "type": "string",
19
- },
20
- },
21
- "required": [
22
- "text",
23
- "number",
24
- ],
25
- "type": "object",
26
- }
27
- `;
28
-
29
- exports[`zodSchema > zod/v4 > json schema conversion > should create a schema with simple types 1`] = `
30
- {
31
- "$schema": "http://json-schema.org/draft-07/schema#",
32
- "additionalProperties": false,
33
- "properties": {
34
- "number": {
35
- "type": "number",
36
- },
37
- "text": {
38
- "type": "string",
39
- },
40
- },
41
- "required": [
42
- "text",
43
- "number",
44
- ],
45
- "type": "object",
46
- }
47
- `;
48
-
49
- exports[`zodSchema > zod/v4 > json schema conversion > should duplicate referenced schemas (and not use references) by default 1`] = `
50
- {
51
- "$schema": "http://json-schema.org/draft-07/schema#",
52
- "additionalProperties": false,
53
- "properties": {
54
- "group1": {
55
- "items": {
56
- "additionalProperties": false,
57
- "properties": {
58
- "number": {
59
- "type": "number",
60
- },
61
- "text": {
62
- "type": "string",
63
- },
64
- },
65
- "required": [
66
- "text",
67
- "number",
68
- ],
69
- "type": "object",
70
- },
71
- "type": "array",
72
- },
73
- "group2": {
74
- "items": {
75
- "additionalProperties": false,
76
- "properties": {
77
- "number": {
78
- "type": "number",
79
- },
80
- "text": {
81
- "type": "string",
82
- },
83
- },
84
- "required": [
85
- "text",
86
- "number",
87
- ],
88
- "type": "object",
89
- },
90
- "type": "array",
91
- },
92
- },
93
- "required": [
94
- "group1",
95
- "group2",
96
- ],
97
- "type": "object",
98
- }
99
- `;
100
-
101
- exports[`zodSchema > zod/v4 > json schema conversion > should generate JSON schema for input when transform is used 1`] = `
102
- {
103
- "$schema": "http://json-schema.org/draft-07/schema#",
104
- "additionalProperties": false,
105
- "properties": {
106
- "user": {
107
- "additionalProperties": false,
108
- "properties": {
109
- "id": {
110
- "type": "string",
111
- },
112
- "name": {
113
- "type": "string",
114
- },
115
- },
116
- "required": [
117
- "id",
118
- "name",
119
- ],
120
- "type": "object",
121
- },
122
- },
123
- "required": [
124
- "user",
125
- ],
126
- "type": "object",
127
- }
128
- `;
129
-
130
- exports[`zodSchema > zod/v4 > json schema conversion > should support arrays 1`] = `
131
- {
132
- "$schema": "http://json-schema.org/draft-07/schema#",
133
- "additionalProperties": false,
134
- "properties": {
135
- "items": {
136
- "items": {
137
- "type": "string",
138
- },
139
- "type": "array",
140
- },
141
- },
142
- "required": [
143
- "items",
144
- ],
145
- "type": "object",
146
- }
147
- `;
148
-
149
- exports[`zodSchema > zod/v4 > json schema conversion > should support nullable 1`] = `
150
- {
151
- "$schema": "http://json-schema.org/draft-07/schema#",
152
- "additionalProperties": false,
153
- "properties": {
154
- "location": {
155
- "anyOf": [
156
- {
157
- "type": "string",
158
- },
159
- {
160
- "type": "null",
161
- },
162
- ],
163
- },
164
- },
165
- "required": [
166
- "location",
167
- ],
168
- "type": "object",
169
- }
170
- `;
171
-
172
- exports[`zodSchema > zod/v4 > json schema conversion > should support optional arrays 1`] = `
173
- {
174
- "$schema": "http://json-schema.org/draft-07/schema#",
175
- "additionalProperties": false,
176
- "properties": {
177
- "items": {
178
- "items": {
179
- "type": "string",
180
- },
181
- "type": "array",
182
- },
183
- },
184
- "type": "object",
185
- }
186
- `;
187
-
188
- exports[`zodSchema > zod/v4 > json schema conversion > should support optional enums 1`] = `
189
- {
190
- "$schema": "http://json-schema.org/draft-07/schema#",
191
- "additionalProperties": false,
192
- "properties": {
193
- "type": {
194
- "enum": [
195
- "a",
196
- "b",
197
- "c",
198
- ],
199
- "type": "string",
200
- },
201
- },
202
- "type": "object",
203
- }
204
- `;
205
-
206
- exports[`zodSchema > zod/v4 > json schema conversion > should support optional fields in object 1`] = `
207
- {
208
- "$schema": "http://json-schema.org/draft-07/schema#",
209
- "additionalProperties": false,
210
- "properties": {
211
- "optional": {
212
- "type": "string",
213
- },
214
- "required": {
215
- "type": "string",
216
- },
217
- },
218
- "required": [
219
- "required",
220
- ],
221
- "type": "object",
222
- }
223
- `;
224
-
225
- exports[`zodSchema > zod/v4 > json schema conversion > should support optional fields with descriptions in object 1`] = `
226
- {
227
- "$schema": "http://json-schema.org/draft-07/schema#",
228
- "additionalProperties": false,
229
- "properties": {
230
- "optional": {
231
- "description": "Optional description",
232
- "type": "string",
233
- },
234
- "required": {
235
- "description": "Required description",
236
- "type": "string",
237
- },
238
- },
239
- "required": [
240
- "required",
241
- ],
242
- "type": "object",
243
- }
244
- `;
245
-
246
- exports[`zodSchema > zod/v4 > json schema conversion > should support required enums 1`] = `
247
- {
248
- "$schema": "http://json-schema.org/draft-07/schema#",
249
- "additionalProperties": false,
250
- "properties": {
251
- "type": {
252
- "enum": [
253
- "a",
254
- "b",
255
- "c",
256
- ],
257
- "type": "string",
258
- },
259
- },
260
- "required": [
261
- "type",
262
- ],
263
- "type": "object",
264
- }
265
- `;
266
-
267
- exports[`zodSchema > zod/v4 > json schema conversion > should use recursive references with z.lazy when useReferences is true 1`] = `
268
- {
269
- "$schema": "http://json-schema.org/draft-07/schema#",
270
- "additionalProperties": false,
271
- "definitions": {
272
- "__schema0": {
273
- "additionalProperties": false,
274
- "properties": {
275
- "name": {
276
- "type": "string",
277
- },
278
- "subcategories": {
279
- "items": {
280
- "$ref": "#/definitions/__schema0",
281
- },
282
- "type": "array",
283
- },
284
- },
285
- "required": [
286
- "name",
287
- "subcategories",
288
- ],
289
- "type": "object",
290
- },
291
- },
292
- "properties": {
293
- "category": {
294
- "$ref": "#/definitions/__schema0",
295
- },
296
- },
297
- "required": [
298
- "category",
299
- ],
300
- "type": "object",
301
- }
302
- `;
303
-
304
- exports[`zodSchema > zod/v4 > json schema conversion > should use references when useReferences is true 1`] = `
305
- {
306
- "$schema": "http://json-schema.org/draft-07/schema#",
307
- "additionalProperties": false,
308
- "definitions": {
309
- "__schema0": {
310
- "additionalProperties": false,
311
- "properties": {
312
- "number": {
313
- "type": "number",
314
- },
315
- "text": {
316
- "type": "string",
317
- },
318
- },
319
- "required": [
320
- "text",
321
- "number",
322
- ],
323
- "type": "object",
324
- },
325
- },
326
- "properties": {
327
- "group1": {
328
- "items": {
329
- "$ref": "#/definitions/__schema0",
330
- },
331
- "type": "array",
332
- },
333
- "group2": {
334
- "items": {
335
- "$ref": "#/definitions/__schema0",
336
- },
337
- "type": "array",
338
- },
339
- },
340
- "required": [
341
- "group1",
342
- "group2",
343
- ],
344
- "type": "object",
345
- }
346
- `;
@@ -1,289 +0,0 @@
1
- import { JSONSchema7 } from '@ai-sdk/provider';
2
- import { describe, expect, it } from 'vitest';
3
- import { addAdditionalPropertiesToJsonSchema } from './add-additional-properties-to-json-schema';
4
-
5
- describe('addAdditionalPropertiesToJsonSchema', () => {
6
- it('adds additionalProperties: false to objects recursively', () => {
7
- const schema: JSONSchema7 = {
8
- type: 'object',
9
- properties: {
10
- user: {
11
- type: 'object',
12
- properties: {
13
- name: { type: 'string' },
14
- },
15
- },
16
- age: { type: 'number' },
17
- },
18
- };
19
-
20
- const result = addAdditionalPropertiesToJsonSchema(schema);
21
-
22
- expect(result).toEqual({
23
- type: 'object',
24
- additionalProperties: false,
25
- properties: {
26
- user: {
27
- type: 'object',
28
- additionalProperties: false,
29
- properties: {
30
- name: { type: 'string' },
31
- },
32
- },
33
- age: { type: 'number' },
34
- },
35
- });
36
- });
37
-
38
- it('adds additionalProperties: false to objects inside arrays', () => {
39
- const schema: JSONSchema7 = {
40
- type: 'object',
41
- properties: {
42
- ingredients: {
43
- type: 'array',
44
- items: {
45
- type: 'object',
46
- properties: {
47
- name: { type: 'string' },
48
- amount: { type: 'string' },
49
- },
50
- required: ['name', 'amount'],
51
- },
52
- },
53
- },
54
- required: ['ingredients'],
55
- };
56
-
57
- const result = addAdditionalPropertiesToJsonSchema(schema);
58
-
59
- expect(result).toEqual({
60
- type: 'object',
61
- additionalProperties: false,
62
- properties: {
63
- ingredients: {
64
- type: 'array',
65
- items: {
66
- type: 'object',
67
- additionalProperties: false,
68
- properties: {
69
- name: { type: 'string' },
70
- amount: { type: 'string' },
71
- },
72
- required: ['name', 'amount'],
73
- },
74
- },
75
- },
76
- required: ['ingredients'],
77
- });
78
- });
79
-
80
- it('adds additionalProperties: false when type is a union that includes "object"', () => {
81
- const schema: JSONSchema7 = {
82
- type: 'object',
83
- properties: {
84
- response: {
85
- type: ['object', 'null'],
86
- properties: {
87
- name: { type: 'string' },
88
- },
89
- },
90
- },
91
- };
92
-
93
- expect(addAdditionalPropertiesToJsonSchema(schema)).toEqual({
94
- type: 'object',
95
- additionalProperties: false,
96
- properties: {
97
- response: {
98
- type: ['object', 'null'],
99
- additionalProperties: false,
100
- properties: {
101
- name: { type: 'string' },
102
- },
103
- },
104
- },
105
- });
106
- });
107
-
108
- it('adds additionalProperties: false to objects inside anyOf', () => {
109
- const schema: JSONSchema7 = {
110
- type: 'object',
111
- properties: {
112
- response: {
113
- anyOf: [
114
- { type: 'object', properties: { name: { type: 'string' } } },
115
- { type: 'object', properties: { amount: { type: 'string' } } },
116
- ],
117
- },
118
- },
119
- };
120
-
121
- expect(addAdditionalPropertiesToJsonSchema(schema)).toEqual({
122
- type: 'object',
123
- additionalProperties: false,
124
- properties: {
125
- response: {
126
- anyOf: [
127
- {
128
- type: 'object',
129
- additionalProperties: false,
130
- properties: { name: { type: 'string' } },
131
- },
132
- {
133
- type: 'object',
134
- additionalProperties: false,
135
- properties: { amount: { type: 'string' } },
136
- },
137
- ],
138
- },
139
- },
140
- });
141
- });
142
-
143
- it('adds additionalProperties: false to objects inside allOf', () => {
144
- const schema: JSONSchema7 = {
145
- type: 'object',
146
- properties: {
147
- response: {
148
- allOf: [
149
- { type: 'object', properties: { name: { type: 'string' } } },
150
- { type: 'object', properties: { age: { type: 'number' } } },
151
- ],
152
- },
153
- },
154
- };
155
-
156
- expect(addAdditionalPropertiesToJsonSchema(schema)).toEqual({
157
- type: 'object',
158
- additionalProperties: false,
159
- properties: {
160
- response: {
161
- allOf: [
162
- {
163
- type: 'object',
164
- additionalProperties: false,
165
- properties: { name: { type: 'string' } },
166
- },
167
- {
168
- type: 'object',
169
- additionalProperties: false,
170
- properties: { age: { type: 'number' } },
171
- },
172
- ],
173
- },
174
- },
175
- });
176
- });
177
-
178
- it('adds additionalProperties: false to objects inside oneOf', () => {
179
- const schema: JSONSchema7 = {
180
- type: 'object',
181
- properties: {
182
- response: {
183
- oneOf: [
184
- { type: 'object', properties: { success: { type: 'boolean' } } },
185
- { type: 'object', properties: { error: { type: 'string' } } },
186
- ],
187
- },
188
- },
189
- };
190
-
191
- expect(addAdditionalPropertiesToJsonSchema(schema)).toEqual({
192
- type: 'object',
193
- additionalProperties: false,
194
- properties: {
195
- response: {
196
- oneOf: [
197
- {
198
- type: 'object',
199
- additionalProperties: false,
200
- properties: { success: { type: 'boolean' } },
201
- },
202
- {
203
- type: 'object',
204
- additionalProperties: false,
205
- properties: { error: { type: 'string' } },
206
- },
207
- ],
208
- },
209
- },
210
- });
211
- });
212
-
213
- it('adds additionalProperties: false to object schemas inside definitions (refs)', () => {
214
- const schema: JSONSchema7 = {
215
- type: 'object',
216
- properties: {
217
- node: { $ref: '#/definitions/Node' },
218
- },
219
- definitions: {
220
- Node: {
221
- type: 'object',
222
- properties: {
223
- value: { type: 'string' },
224
- next: { $ref: '#/definitions/Node' }, // recursive reference
225
- },
226
- },
227
- },
228
- };
229
-
230
- expect(addAdditionalPropertiesToJsonSchema(schema)).toEqual({
231
- type: 'object',
232
- additionalProperties: false,
233
- properties: {
234
- node: { $ref: '#/definitions/Node' },
235
- },
236
- definitions: {
237
- Node: {
238
- type: 'object',
239
- additionalProperties: false,
240
- properties: {
241
- value: { type: 'string' },
242
- next: { $ref: '#/definitions/Node' },
243
- },
244
- },
245
- },
246
- });
247
- });
248
-
249
- it('overwrites existing additionalProperties flags', () => {
250
- const schema: JSONSchema7 = {
251
- type: 'object',
252
- additionalProperties: true,
253
- properties: {
254
- meta: {
255
- type: 'object',
256
- additionalProperties: true,
257
- properties: {
258
- id: { type: 'string' },
259
- },
260
- },
261
- },
262
- };
263
-
264
- const result = addAdditionalPropertiesToJsonSchema(schema);
265
-
266
- expect(result).toEqual({
267
- type: 'object',
268
- additionalProperties: false,
269
- properties: {
270
- meta: {
271
- type: 'object',
272
- additionalProperties: false,
273
- properties: {
274
- id: { type: 'string' },
275
- },
276
- },
277
- },
278
- });
279
- });
280
-
281
- it('leaves non-object schemas unchanged', () => {
282
- const schema: JSONSchema7 = { type: 'string' };
283
-
284
- const result = addAdditionalPropertiesToJsonSchema(schema);
285
-
286
- expect(result).toBe(schema);
287
- expect(result).toEqual({ type: 'string' });
288
- });
289
- });