@ai-sdk/provider-utils 5.0.24 → 5.0.26

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 CHANGED
@@ -1,5 +1,19 @@
1
1
  # @ai-sdk/provider-utils
2
2
 
3
+ ## 5.0.26
4
+
5
+ ### Patch Changes
6
+
7
+ - 401a4ba: fix(provider-utils): allow imports in runtimes without a global fetch function
8
+
9
+ ## 5.0.25
10
+
11
+ ### Patch Changes
12
+
13
+ - 81cd026: Reduce bundle size by making internal Zod v4 imports tree-shakeable.
14
+ - Updated dependencies [ad6a650]
15
+ - @ai-sdk/provider@4.0.7
16
+
3
17
  ## 5.0.24
4
18
 
5
19
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -3,7 +3,7 @@ export { getErrorMessage } from '@ai-sdk/provider';
3
3
  import { StandardSchemaV1, StandardJSONSchemaV1 } from '@standard-schema/spec';
4
4
  export * from '@standard-schema/spec';
5
5
  import * as z3 from 'zod/v3';
6
- import * as z4 from 'zod/v4';
6
+ import { $ZodType } from 'zod/v4/core';
7
7
  export { WORKFLOW_DESERIALIZE, WORKFLOW_SERIALIZE } from '@workflow/serde';
8
8
  export { EventSourceMessage, EventSourceParserStream } from 'eventsource-parser/stream';
9
9
 
@@ -992,7 +992,7 @@ type Schema<OBJECT = unknown> = {
992
992
  */
993
993
  declare function lazySchema<SCHEMA>(createSchema: () => Schema<SCHEMA>): LazySchema<SCHEMA>;
994
994
  type LazySchema<SCHEMA> = () => Schema<SCHEMA>;
995
- type ZodSchema<SCHEMA = any> = z3.Schema<SCHEMA, z3.ZodTypeDef, any> | z4.core.$ZodType<SCHEMA, any>;
995
+ type ZodSchema<SCHEMA = any> = z3.Schema<SCHEMA, z3.ZodTypeDef, any> | $ZodType<SCHEMA, any>;
996
996
  type StandardSchema<SCHEMA = any> = StandardSchemaV1<unknown, SCHEMA> & {
997
997
  readonly '~standard': StandardSchemaV1.Props<unknown, SCHEMA> & {
998
998
  readonly jsonSchema?: StandardJSONSchemaV1.Converter;
@@ -1010,7 +1010,7 @@ declare function jsonSchema<OBJECT = unknown>(jsonSchema: JSONSchema7 | PromiseL
1010
1010
  validate?: (value: unknown) => ValidationResult<OBJECT> | PromiseLike<ValidationResult<OBJECT>>;
1011
1011
  }): Schema<OBJECT>;
1012
1012
  declare function asSchema<OBJECT>(schema: FlexibleSchema<OBJECT> | undefined): Schema<OBJECT>;
1013
- declare function zodSchema<OBJECT>(zodSchema: z4.core.$ZodType<OBJECT, any> | z3.Schema<OBJECT, z3.ZodTypeDef, any>, options?: {
1013
+ declare function zodSchema<OBJECT>(zodSchema: $ZodType<OBJECT, any> | z3.Schema<OBJECT, z3.ZodTypeDef, any>, options?: {
1014
1014
  /**
1015
1015
  * Enables support for references in the schema.
1016
1016
  * This is required for recursive schemas, e.g. with `z.lazy`.
package/dist/index.js CHANGED
@@ -922,6 +922,9 @@ async function getDefaultDownloadFetch() {
922
922
  return safeNodeFetchPromise != null ? safeNodeFetchPromise : safeNodeFetchPromise = Promise.resolve().then(createSafeNodeFetch);
923
923
  }
924
924
  function isNodeDefaultFetch(fetch) {
925
+ if (typeof fetch !== "function") {
926
+ return false;
927
+ }
925
928
  const source = Function.prototype.toString.call(fetch);
926
929
  return source.includes("internal/deps/undici") || source.includes("lazy loading of undici");
927
930
  }
@@ -1325,7 +1328,7 @@ function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
1325
1328
  }
1326
1329
 
1327
1330
  // src/version.ts
1328
- var VERSION = true ? "5.0.24" : "0.0.0-test";
1331
+ var VERSION = true ? "5.0.26" : "0.0.0-test";
1329
1332
 
1330
1333
  // src/get-from-api.ts
1331
1334
  var getOriginalFetch = () => globalThis.fetch;
@@ -1724,7 +1727,8 @@ import {
1724
1727
 
1725
1728
  // src/schema.ts
1726
1729
  import { TypeValidationError } from "@ai-sdk/provider";
1727
- import * as z4 from "zod/v4";
1730
+ import { safeParseAsync } from "zod/v4";
1731
+ import { toJSONSchema } from "zod/v4/core";
1728
1732
 
1729
1733
  // src/add-additional-properties-to-json-schema.ts
1730
1734
  function addAdditionalPropertiesToJsonSchema(jsonSchema2) {
@@ -3025,7 +3029,7 @@ function zod4Schema(zodSchema2, options) {
3025
3029
  return jsonSchema(
3026
3030
  // defer json schema creation to avoid unnecessary computation when only validation is needed
3027
3031
  () => addAdditionalPropertiesToJsonSchema(
3028
- z4.toJSONSchema(zodSchema2, {
3032
+ toJSONSchema(zodSchema2, {
3029
3033
  target: "draft-7",
3030
3034
  io: "input",
3031
3035
  reused: useReferences ? "ref" : "inline"
@@ -3033,7 +3037,7 @@ function zod4Schema(zodSchema2, options) {
3033
3037
  ),
3034
3038
  {
3035
3039
  validate: async (value) => {
3036
- const result = await z4.safeParseAsync(zodSchema2, value);
3040
+ const result = await safeParseAsync(zodSchema2, value);
3037
3041
  return result.success ? { success: true, value: result.data } : { success: false, error: result.error };
3038
3042
  }
3039
3043
  }