@ai-sdk/svelte 3.0.0-alpha.7 → 3.0.0-alpha.8

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,16 @@
1
1
  # @ai-sdk/svelte
2
2
 
3
+ ## 3.0.0-alpha.8
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [4fef487]
8
+ - Updated dependencies [6b1c55c]
9
+ - Updated dependencies [2e4f9e4]
10
+ - Updated dependencies [c25cbce]
11
+ - @ai-sdk/provider-utils@3.0.0-alpha.8
12
+ - ai@5.0.0-alpha.8
13
+
3
14
  ## 3.0.0-alpha.7
4
15
 
5
16
  ### Patch Changes
@@ -1,7 +1,8 @@
1
- import { type FetchFunction } from '@ai-sdk/provider-utils';
1
+ import { type FetchFunction, type InferSchema } from '@ai-sdk/provider-utils';
2
2
  import { type DeepPartial, type Schema } from 'ai';
3
- import { type z } from 'zod';
4
- export type Experimental_StructuredObjectOptions<RESULT> = {
3
+ import type * as z3 from 'zod/v3';
4
+ import type * as z4 from 'zod/v4/core';
5
+ export type Experimental_StructuredObjectOptions<SCHEMA extends z3.Schema | z4.$ZodType | Schema, RESULT = InferSchema<SCHEMA>> = {
5
6
  /**
6
7
  * The API endpoint. It should stream JSON that matches the schema as chunked text.
7
8
  */
@@ -9,7 +10,7 @@ export type Experimental_StructuredObjectOptions<RESULT> = {
9
10
  /**
10
11
  * A Zod schema that defines the shape of the complete object.
11
12
  */
12
- schema: z.Schema<RESULT, z.ZodTypeDef, unknown> | Schema<RESULT>;
13
+ schema: SCHEMA;
13
14
  /**
14
15
  * An unique identifier. If not provided, a random one will be
15
16
  * generated. When provided, the `useObject` hook with the same `id` will
@@ -54,7 +55,7 @@ export type Experimental_StructuredObjectOptions<RESULT> = {
54
55
  */
55
56
  credentials?: RequestCredentials;
56
57
  };
57
- export declare class StructuredObject<RESULT, INPUT = unknown> {
58
+ export declare class StructuredObject<SCHEMA extends z3.Schema | z4.$ZodType | Schema, RESULT = InferSchema<SCHEMA>, INPUT = unknown> {
58
59
  #private;
59
60
  /**
60
61
  * The current value for the generated object. Updated as the API streams JSON chunks.
@@ -66,7 +67,7 @@ export declare class StructuredObject<RESULT, INPUT = unknown> {
66
67
  * Flag that indicates whether an API request is in progress.
67
68
  */
68
69
  get loading(): boolean;
69
- constructor(options: Experimental_StructuredObjectOptions<RESULT>);
70
+ constructor(options: Experimental_StructuredObjectOptions<SCHEMA, RESULT>);
70
71
  /**
71
72
  * Abort the current request immediately, keep the current partial object if any.
72
73
  */
@@ -1 +1 @@
1
- {"version":3,"file":"structured-object.svelte.d.ts","sourceRoot":"","sources":["../src/structured-object.svelte.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,aAAa,EACnB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAIL,KAAK,WAAW,EAChB,KAAK,MAAM,EACZ,MAAM,IAAI,CAAC;AACZ,OAAO,EAAE,KAAK,CAAC,EAAE,MAAM,KAAK,CAAC;AAQ7B,MAAM,MAAM,oCAAoC,CAAC,MAAM,IAAI;IACzD;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IAEZ;;OAEG;IACH,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,UAAU,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;IAEjE;;;;OAIG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;IAEZ;;OAEG;IACH,YAAY,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAEnC;;;OAGG;IACH,KAAK,CAAC,EAAE,aAAa,CAAC;IAEtB;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE;QACjB;;;WAGG;QACH,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;QAE3B;;WAEG;QACH,KAAK,EAAE,KAAK,GAAG,SAAS,CAAC;KAC1B,KAAK,OAAO,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AEZ;;OAEG;IACH,YAAY,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAEnC;;;OAGG;IACH,KAAK,CAAC,EAAE,aAAa,CAAC;IAEtB;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE;QACjB;;;WAGG;QACH,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;QAE3B;;WAEG;QACH,KAAK,EAAE,KAAK,GAAG,SAAS,CAAC;KAC1B,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IAE3B;;OAEG;IACH,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IAEjC;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC;IAE3C;;;;OAIG;IACH,WAAW,CAAC,EAAE,kBAAkB,CAAC;CAClC,CAAC;AAEF,qBAAa,gBAAgB,CAC3B,MAAM,SAAS,EAAE,CAAC,MAAM,GAAG,EAAE,CAAC,QAAQ,GAAG,MAAM,EAC/C,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC,EAC5B,KAAK,GAAG,OAAO;;IAWf;;OAEG;IACH,IAAI,MAAM,IAAI,WAAW,CAAC,MAAM,CAAC,GAAG,SAAS,CAE5C;IAKD,0CAA0C;IAC1C,IAAI,KAAK,sBAER;IAED;;OAEG;IACH,IAAI,OAAO,YAEV;gBAEW,OAAO,EAAE,oCAAoC,CAAC,MAAM,EAAE,MAAM,CAAC;IAUzE;;OAEG;IACH,IAAI,aASF;IAEF;;OAEG;IACH,MAAM,UAAiB,KAAK,mBAqF1B;CACH"}
@@ -1,6 +1,5 @@
1
1
  import { generateId, isAbortError, safeValidateTypes, } from '@ai-sdk/provider-utils';
2
2
  import { asSchema, isDeepEqualData, parsePartialJson, } from 'ai';
3
- import {} from 'zod';
4
3
  import { getStructuredObjectContext, hasStructuredObjectContext, KeyedStructuredObjectStore, } from './structured-object-context.svelte.js';
5
4
  export class StructuredObject {
6
5
  #options = {};
@@ -11,8 +11,8 @@ declare class __sveltets_Render<RESULT> {
11
11
  slots(): {};
12
12
  bindings(): "";
13
13
  exports(): {
14
- object1: StructuredObject<RESULT, unknown>;
15
- object2: StructuredObject<RESULT, unknown>;
14
+ object1: StructuredObject<z.ZodType<RESULT, z.ZodTypeDef, unknown> | Schema<RESULT>, RESULT, unknown>;
15
+ object2: StructuredObject<z.ZodType<RESULT, z.ZodTypeDef, unknown> | Schema<RESULT>, RESULT, unknown>;
16
16
  };
17
17
  }
18
18
  interface $$IsomorphicComponent {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/svelte",
3
- "version": "3.0.0-alpha.7",
3
+ "version": "3.0.0-alpha.8",
4
4
  "license": "Apache-2.0",
5
5
  "files": [
6
6
  "dist",
@@ -28,7 +28,7 @@
28
28
  },
29
29
  "peerDependencies": {
30
30
  "svelte": "^5.31.0",
31
- "zod": "^3.23.8"
31
+ "zod": "^3.25.46"
32
32
  },
33
33
  "peerDependenciesMeta": {
34
34
  "zod": {
@@ -36,8 +36,8 @@
36
36
  }
37
37
  },
38
38
  "dependencies": {
39
- "@ai-sdk/provider-utils": "3.0.0-alpha.7",
40
- "ai": "5.0.0-alpha.7"
39
+ "@ai-sdk/provider-utils": "3.0.0-alpha.8",
40
+ "ai": "5.0.0-alpha.8"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@types/node": "20.17.24",
@@ -58,7 +58,7 @@
58
58
  "typescript-eslint": "^8.20.0",
59
59
  "vite": "^6.0.0",
60
60
  "vitest": "^3.0.0",
61
- "zod": "3.24.4",
61
+ "zod": "3.25.46",
62
62
  "@vercel/ai-tsconfig": "0.0.0"
63
63
  },
64
64
  "homepage": "https://ai-sdk.dev/docs",
@@ -3,6 +3,7 @@ import {
3
3
  isAbortError,
4
4
  safeValidateTypes,
5
5
  type FetchFunction,
6
+ type InferSchema,
6
7
  } from '@ai-sdk/provider-utils';
7
8
  import {
8
9
  asSchema,
@@ -11,7 +12,8 @@ import {
11
12
  type DeepPartial,
12
13
  type Schema,
13
14
  } from 'ai';
14
- import { type z } from 'zod';
15
+ import type * as z3 from 'zod/v3';
16
+ import type * as z4 from 'zod/v4/core';
15
17
  import {
16
18
  getStructuredObjectContext,
17
19
  hasStructuredObjectContext,
@@ -19,7 +21,10 @@ import {
19
21
  type StructuredObjectStore,
20
22
  } from './structured-object-context.svelte.js';
21
23
 
22
- export type Experimental_StructuredObjectOptions<RESULT> = {
24
+ export type Experimental_StructuredObjectOptions<
25
+ SCHEMA extends z3.Schema | z4.$ZodType | Schema,
26
+ RESULT = InferSchema<SCHEMA>,
27
+ > = {
23
28
  /**
24
29
  * The API endpoint. It should stream JSON that matches the schema as chunked text.
25
30
  */
@@ -28,7 +33,7 @@ export type Experimental_StructuredObjectOptions<RESULT> = {
28
33
  /**
29
34
  * A Zod schema that defines the shape of the complete object.
30
35
  */
31
- schema: z.Schema<RESULT, z.ZodTypeDef, unknown> | Schema<RESULT>;
36
+ schema: SCHEMA;
32
37
 
33
38
  /**
34
39
  * An unique identifier. If not provided, a random one will be
@@ -82,9 +87,13 @@ export type Experimental_StructuredObjectOptions<RESULT> = {
82
87
  credentials?: RequestCredentials;
83
88
  };
84
89
 
85
- export class StructuredObject<RESULT, INPUT = unknown> {
86
- #options: Experimental_StructuredObjectOptions<RESULT> =
87
- {} as Experimental_StructuredObjectOptions<RESULT>;
90
+ export class StructuredObject<
91
+ SCHEMA extends z3.Schema | z4.$ZodType | Schema,
92
+ RESULT = InferSchema<SCHEMA>,
93
+ INPUT = unknown,
94
+ > {
95
+ #options: Experimental_StructuredObjectOptions<SCHEMA, RESULT> =
96
+ {} as Experimental_StructuredObjectOptions<SCHEMA, RESULT>;
88
97
  readonly #id = $derived(this.#options.id ?? generateId());
89
98
  readonly #keyedStore = $state<KeyedStructuredObjectStore>()!;
90
99
  readonly #store = $derived(
@@ -114,7 +123,7 @@ export class StructuredObject<RESULT, INPUT = unknown> {
114
123
  return this.#store.loading;
115
124
  }
116
125
 
117
- constructor(options: Experimental_StructuredObjectOptions<RESULT>) {
126
+ constructor(options: Experimental_StructuredObjectOptions<SCHEMA, RESULT>) {
118
127
  if (hasStructuredObjectContext()) {
119
128
  this.#keyedStore = getStructuredObjectContext();
120
129
  } else {