@ai-sdk/rsc 2.0.47 → 2.0.49

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,22 @@
1
1
  # @ai-sdk/rsc
2
2
 
3
+ ## 2.0.49
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [ded661b]
8
+ - ai@6.0.49
9
+
10
+ ## 2.0.48
11
+
12
+ ### Patch Changes
13
+
14
+ - 4de5a1d: chore: excluded tests from src folder in npm package
15
+ - Updated dependencies [4de5a1d]
16
+ - ai@6.0.48
17
+ - @ai-sdk/provider@3.0.5
18
+ - @ai-sdk/provider-utils@4.0.9
19
+
3
20
  ## 2.0.47
4
21
 
5
22
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/rsc",
3
- "version": "2.0.47",
3
+ "version": "2.0.49",
4
4
  "license": "Apache-2.0",
5
5
  "sideEffects": false,
6
6
  "main": "./dist/rsc-client.mjs",
@@ -18,14 +18,19 @@
18
18
  "files": [
19
19
  "dist/**/*",
20
20
  "src",
21
+ "!src/**/*.test.ts",
22
+ "!src/**/*.test.tsx",
23
+ "!src/**/*.test-d.ts",
24
+ "!src/**/__snapshots__",
25
+ "!src/**/__fixtures__",
21
26
  "CHANGELOG.md",
22
27
  "README.md"
23
28
  ],
24
29
  "dependencies": {
25
30
  "jsondiffpatch": "0.7.3",
26
- "ai": "6.0.47",
27
- "@ai-sdk/provider": "3.0.4",
28
- "@ai-sdk/provider-utils": "4.0.8"
31
+ "ai": "6.0.49",
32
+ "@ai-sdk/provider-utils": "4.0.9",
33
+ "@ai-sdk/provider": "3.0.5"
29
34
  },
30
35
  "devDependencies": {
31
36
  "@testing-library/jest-dom": "^6.6.3",
@@ -1,146 +0,0 @@
1
- import { describe, it, expect, vi, beforeEach } from 'vitest';
2
- import {
3
- withAIState,
4
- getAIState,
5
- getMutableAIState,
6
- sealMutableAIState,
7
- getAIStateDeltaPromise,
8
- } from './ai-state';
9
-
10
- describe('AI State Management', () => {
11
- beforeEach(() => {
12
- vi.resetAllMocks();
13
- });
14
-
15
- it('should get the current AI state', () => {
16
- const initialState = { foo: 'bar' };
17
- const result = withAIState({ state: initialState, options: {} }, () => {
18
- return getAIState();
19
- });
20
- expect(result).toEqual(initialState);
21
- });
22
-
23
- it('should get a specific key from the AI state', () => {
24
- const initialState = { foo: 'bar', baz: 'qux' };
25
- const result = withAIState({ state: initialState, options: {} }, () => {
26
- return getAIState('foo');
27
- });
28
- expect(result).toBe('bar');
29
- });
30
-
31
- it('should update the AI state', () => {
32
- const initialState = { foo: 'bar' };
33
- withAIState({ state: initialState, options: {} }, () => {
34
- const mutableState = getMutableAIState();
35
- mutableState.update({ foo: 'baz' });
36
- expect(getAIState()).toEqual({ foo: 'baz' });
37
- });
38
- });
39
-
40
- it('should update a specific key in the AI state', () => {
41
- const initialState = { foo: 'bar', baz: 'qux' };
42
- withAIState({ state: initialState, options: {} }, () => {
43
- const mutableState = getMutableAIState('foo');
44
- mutableState.update('newValue');
45
- expect(getAIState()).toEqual({ foo: 'newValue', baz: 'qux' });
46
- });
47
- });
48
-
49
- it('should throw an error when accessing AI state outside of withAIState', () => {
50
- expect(() => getAIState()).toThrow(
51
- '`getAIState` must be called within an AI Action.',
52
- );
53
- });
54
-
55
- it('should throw an error when updating AI state after it has been sealed', () => {
56
- withAIState({ state: {}, options: {} }, () => {
57
- sealMutableAIState();
58
- expect(() => getMutableAIState()).toThrow(
59
- '`getMutableAIState` must be called before returning from an AI Action.',
60
- );
61
- });
62
- });
63
-
64
- it('should call onSetAIState when updating state', () => {
65
- const onSetAIState = vi.fn();
66
- const initialState = { foo: 'bar' };
67
- withAIState({ state: initialState, options: { onSetAIState } }, () => {
68
- const mutableState = getMutableAIState();
69
- mutableState.update({ foo: 'baz' });
70
- mutableState.done({ foo: 'baz' });
71
- });
72
- expect(onSetAIState).toHaveBeenCalledWith(
73
- expect.objectContaining({
74
- state: { foo: 'baz' },
75
- done: true,
76
- }),
77
- );
78
- });
79
-
80
- it('should handle updates with and without key', async () => {
81
- type Message = { role: string; content: string };
82
-
83
- type AIState = {
84
- chatId: string;
85
- messages: Array<Message>;
86
- };
87
-
88
- const initialState: AIState = {
89
- chatId: '123',
90
- messages: [],
91
- };
92
-
93
- await withAIState({ state: initialState, options: {} }, async () => {
94
- // Test with getMutableState()
95
- const stateWithoutKey = getMutableAIState();
96
-
97
- stateWithoutKey.update((current: AIState) => ({
98
- ...current,
99
- messages: [...current.messages, { role: 'user', content: 'Hello!' }],
100
- }));
101
-
102
- stateWithoutKey.done((current: AIState) => ({
103
- ...current,
104
- messages: [
105
- ...current.messages,
106
- { role: 'assistant', content: 'Hello! How can I assist you today?' },
107
- ],
108
- }));
109
-
110
- const deltaWithoutKey = await getAIStateDeltaPromise();
111
- expect(deltaWithoutKey).toBeDefined();
112
- expect(getAIState()).toEqual({
113
- chatId: '123',
114
- messages: [
115
- { role: 'user', content: 'Hello!' },
116
- { role: 'assistant', content: 'Hello! How can I assist you today?' },
117
- ],
118
- });
119
- });
120
-
121
- await withAIState({ state: initialState, options: {} }, async () => {
122
- // Test with getMutableState('messages')
123
- const stateWithKey = getMutableAIState('messages');
124
-
125
- stateWithKey.update((current: Array<Message>) => [
126
- ...current,
127
- { role: 'user', content: 'Hello!' },
128
- ]);
129
-
130
- stateWithKey.done((current: Array<Message>) => [
131
- ...current,
132
- { role: 'assistant', content: 'Hello! How can I assist you today?' },
133
- ]);
134
-
135
- const deltaWithKey = await getAIStateDeltaPromise();
136
- expect(deltaWithKey).toBeDefined();
137
- expect(getAIState()).toEqual({
138
- chatId: '123',
139
- messages: [
140
- { role: 'user', content: 'Hello!' },
141
- { role: 'assistant', content: 'Hello! How can I assist you today?' },
142
- ],
143
- });
144
- });
145
- });
146
- });
@@ -1,91 +0,0 @@
1
- // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2
-
3
- exports[`should emit React Nodes with async render function 1`] = `
4
- {
5
- "children": {
6
- "children": {},
7
- "props": {
8
- "c": undefined,
9
- "n": {
10
- "done": false,
11
- "next": {
12
- "done": true,
13
- "value": <div>
14
- Weather
15
- </div>,
16
- },
17
- "value": <div>
18
- Weather
19
- </div>,
20
- },
21
- },
22
- "type": "",
23
- },
24
- "props": {
25
- "fallback": undefined,
26
- },
27
- "type": "Symbol(react.suspense)",
28
- }
29
- `;
30
-
31
- exports[`should emit React Nodes with generator render function 1`] = `
32
- {
33
- "children": {
34
- "children": {},
35
- "props": {
36
- "c": undefined,
37
- "n": {
38
- "done": false,
39
- "next": {
40
- "done": false,
41
- "next": {
42
- "done": true,
43
- "value": <div>
44
- Weather
45
- </div>,
46
- },
47
- "value": <div>
48
- Weather
49
- </div>,
50
- },
51
- "value": <div>
52
- Loading...
53
- </div>,
54
- },
55
- },
56
- "type": "",
57
- },
58
- "props": {
59
- "fallback": undefined,
60
- },
61
- "type": "Symbol(react.suspense)",
62
- }
63
- `;
64
-
65
- exports[`should emit React Nodes with sync render function 1`] = `
66
- {
67
- "children": {
68
- "children": {},
69
- "props": {
70
- "c": undefined,
71
- "n": {
72
- "done": false,
73
- "next": {
74
- "done": true,
75
- "value": <div>
76
- Weather
77
- </div>,
78
- },
79
- "value": <div>
80
- Weather
81
- </div>,
82
- },
83
- },
84
- "type": "",
85
- },
86
- "props": {
87
- "fallback": undefined,
88
- },
89
- "type": "Symbol(react.suspense)",
90
- }
91
- `;
@@ -1,213 +0,0 @@
1
- // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2
-
3
- exports[`options.headers > should pass headers to model 1`] = `
4
- {
5
- "children": {
6
- "children": {},
7
- "props": {
8
- "c": undefined,
9
- "n": {
10
- "done": false,
11
- "next": {
12
- "done": true,
13
- "value": "{ "content": "headers test" }",
14
- },
15
- "value": "{ "content": "headers test" }",
16
- },
17
- },
18
- "type": "",
19
- },
20
- "props": {
21
- "fallback": undefined,
22
- },
23
- "type": "Symbol(react.suspense)",
24
- }
25
- `;
26
-
27
- exports[`options.providerMetadata > should pass provider metadata to model 1`] = `
28
- {
29
- "children": {
30
- "children": {},
31
- "props": {
32
- "c": undefined,
33
- "n": {
34
- "done": false,
35
- "next": {
36
- "done": true,
37
- "value": "{ "content": "provider metadata test" }",
38
- },
39
- "value": "{ "content": "provider metadata test" }",
40
- },
41
- },
42
- "type": "",
43
- },
44
- "props": {
45
- "fallback": undefined,
46
- },
47
- "type": "Symbol(react.suspense)",
48
- }
49
- `;
50
-
51
- exports[`result.value > should render text 1`] = `
52
- {
53
- "children": {
54
- "children": {},
55
- "props": {
56
- "c": undefined,
57
- "n": {
58
- "done": false,
59
- "next": {
60
- "done": false,
61
- "next": {
62
- "done": false,
63
- "next": {
64
- "done": false,
65
- "next": {
66
- "done": false,
67
- "next": {
68
- "done": false,
69
- "next": {
70
- "done": true,
71
- "value": "{ "content": "Hello, world!" }",
72
- },
73
- "value": "{ "content": "Hello, world!" }",
74
- },
75
- "value": "{ "content": "Hello, world!"",
76
- },
77
- "value": "{ "content": "Hello, world",
78
- },
79
- "value": "{ "content": "Hello, ",
80
- },
81
- "value": "{ "content": ",
82
- },
83
- "value": "{ ",
84
- },
85
- },
86
- "type": "",
87
- },
88
- "props": {
89
- "fallback": undefined,
90
- },
91
- "type": "Symbol(react.suspense)",
92
- }
93
- `;
94
-
95
- exports[`result.value > should render text function returned ui 1`] = `
96
- {
97
- "children": {
98
- "children": {},
99
- "props": {
100
- "c": undefined,
101
- "n": {
102
- "done": false,
103
- "next": {
104
- "done": false,
105
- "next": {
106
- "done": false,
107
- "next": {
108
- "done": false,
109
- "next": {
110
- "done": false,
111
- "next": {
112
- "done": false,
113
- "next": {
114
- "done": true,
115
- "value": <h1>
116
- { "content": "Hello, world!" }
117
- </h1>,
118
- },
119
- "value": <h1>
120
- { "content": "Hello, world!" }
121
- </h1>,
122
- },
123
- "value": <h1>
124
- { "content": "Hello, world!"
125
- </h1>,
126
- },
127
- "value": <h1>
128
- { "content": "Hello, world
129
- </h1>,
130
- },
131
- "value": <h1>
132
- { "content": "Hello,
133
- </h1>,
134
- },
135
- "value": <h1>
136
- { "content":
137
- </h1>,
138
- },
139
- "value": <h1>
140
- {
141
- </h1>,
142
- },
143
- },
144
- "type": "",
145
- },
146
- "props": {
147
- "fallback": undefined,
148
- },
149
- "type": "Symbol(react.suspense)",
150
- }
151
- `;
152
-
153
- exports[`result.value > should render tool call results 1`] = `
154
- {
155
- "children": {
156
- "children": {},
157
- "props": {
158
- "c": undefined,
159
- "n": {
160
- "done": true,
161
- "value": <div>
162
- tool1:
163
- value
164
- </div>,
165
- },
166
- },
167
- "type": "",
168
- },
169
- "props": {
170
- "fallback": undefined,
171
- },
172
- "type": "Symbol(react.suspense)",
173
- }
174
- `;
175
-
176
- exports[`result.value > should render tool call results with generator render function 1`] = `
177
- {
178
- "children": {
179
- "children": {},
180
- "props": {
181
- "c": undefined,
182
- "n": {
183
- "done": false,
184
- "next": {
185
- "done": true,
186
- "value": <div>
187
- tool:
188
- value
189
- </div>,
190
- },
191
- "value": <div>
192
- Loading...
193
- </div>,
194
- },
195
- },
196
- "type": "",
197
- },
198
- "props": {
199
- "fallback": undefined,
200
- },
201
- "type": "Symbol(react.suspense)",
202
- }
203
- `;
204
-
205
- exports[`result.value > should show better error messages if legacy options are passed 1`] = `[Error: Tool definition in \`streamUI\` should not have \`render\` property. Use \`generate\` instead. Found in tool: tool1]`;
206
-
207
- exports[`rsc - streamUI() onFinish callback > should contain final React node 1`] = `
208
- <React.Suspense>
209
- <Unknown
210
- n={Promise {}}
211
- />
212
- </React.Suspense>
213
- `;