v0-sdk 0.0.7 → 0.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.
package/README.md CHANGED
@@ -1,6 +1,8 @@
1
- # v0 Chat SDK
1
+ # v0 SDK
2
2
 
3
- A TypeScript SDK for interacting with the v0 API to create and manage AI-powered chat conversations, projects, integrations, and more.
3
+ > **⚠️ Developer Preview**: This SDK is currently in beta and is subject to change. Use in production at your own risk.
4
+
5
+ A TypeScript SDK for interacting with the v0 Platform API to create and manage AI-powered chat conversations, projects, integrations, and more.
4
6
 
5
7
  ## Features
6
8
 
@@ -27,6 +29,8 @@ pnpm add v0-sdk
27
29
 
28
30
  Get your API key from [v0.dev/chat/settings/keys](https://v0.dev/chat/settings/keys).
29
31
 
32
+ ### Create Chat and Generate Code
33
+
30
34
  ```typescript
31
35
  import { v0 } from 'v0-sdk'
32
36
 
@@ -37,15 +41,25 @@ const chat = await v0.chats.create({
37
41
  })
38
42
 
39
43
  console.log(`Chat created: ${chat.url}`)
40
- console.log(`Generated code: ${chat.files?.length} files`)
44
+ ```
41
45
 
42
- // Add a message to the chat
43
- const response = await v0.chats.createMessage({
44
- chatId: chat.chatId,
45
- message: 'Add a dropdown menu to the navbar',
46
+ ### Preview Generated Code
47
+
48
+ ```typescript
49
+ // Get the latest version for live preview
50
+ const latestMessage = chat.messages[chat.messages.length - 1]
51
+ const versionId = latestMessage.id
52
+
53
+ // Get the iframe URL for live preview
54
+ const iframe = await v0.chats.findIframe({
55
+ chatId: chat.id,
56
+ versionId: versionId,
46
57
  })
47
58
 
48
- console.log(`AI response: ${response.text}`)
59
+ console.log(`Preview URL: ${iframe.url}`)
60
+
61
+ // Use in your application
62
+ const previewHtml = `<iframe src="${iframe.url}" width="100%" height="600px"></iframe>`
49
63
  ```
50
64
 
51
65
  ## Authentication
@@ -85,33 +99,6 @@ const result = await v0.chats.create({
85
99
 
86
100
  ```typescript
87
101
  const chat = await v0.chats.getById({ chatId: 'chat_id' })
88
- console.log(chat.messages) // Fully typed message array
89
- ```
90
-
91
- #### Manage Chat Favorites
92
-
93
- ```typescript
94
- // Favorite a chat
95
- await v0.chats.favorite({ chatId: 'chat_id' })
96
-
97
- // Unfavorite a chat
98
- await v0.chats.unfavorite({ chatId: 'chat_id' })
99
-
100
- // Get favorite chats
101
- const favorites = await v0.chats.find()
102
- ```
103
-
104
- #### Chat History and Management
105
-
106
- ```typescript
107
- // Get chat history
108
- const chats = await v0.chats.find()
109
-
110
- // Delete a chat
111
- await v0.chats.delete({ chatId: 'chat_id' })
112
-
113
- // Get chat's associated project
114
- const project = await v0.chats.getProject({ chatId: 'chat_id' })
115
102
  ```
116
103
 
117
104
  #### Add Messages to Chat
@@ -120,126 +107,91 @@ const project = await v0.chats.getProject({ chatId: 'chat_id' })
120
107
  const response = await v0.chats.createMessage({
121
108
  chatId: 'chat_id',
122
109
  message: 'Add password strength indicator',
123
- attachments: [{ url: 'https://example.com/mockup.jpg' }],
124
- modelConfiguration: {
125
- imageGenerations: true,
126
- },
127
110
  })
128
111
  ```
129
112
 
130
- #### Get Version Frame Token
113
+ ### Live Preview with iframes
114
+
115
+ One of the most powerful features of the v0 SDK is the ability to render live previews of generated code using iframes. This allows you to see the AI-generated components and applications running in real-time.
131
116
 
132
117
  ```typescript
133
- const token = await v0.chats.getVersionFrameToken({
134
- chatId: 'chat_id',
135
- versionId: 'version_id',
118
+ // Create a chat and get the generated code
119
+ const chat = await v0.chats.create({
120
+ message: 'Create a todo app with React',
136
121
  })
122
+
123
+ // Get the latest version from the chat messages
124
+ const latestMessage = chat.messages[chat.messages.length - 1]
125
+ const versionId = latestMessage.id // or extract from chat.latestBlockId
126
+
127
+ // Get the iframe URL for live preview
128
+ const iframe = await v0.chats.findIframe({
129
+ chatId: chat.id,
130
+ versionId: versionId,
131
+ })
132
+
133
+ console.log(`Preview URL: ${iframe.url}`)
134
+
135
+ // Use in your application
136
+ const previewHtml = `<iframe src="${iframe.url}" width="100%" height="600px"></iframe>`
137
137
  ```
138
138
 
139
- ### Project Operations
139
+ #### Other Chat Operations
140
140
 
141
- #### Create a Project
141
+ - `v0.chats.find()` - Get chat history
142
+ - `v0.chats.delete({ chatId })` - Delete a chat
143
+ - `v0.chats.favorite({ chatId })` - Favorite a chat
144
+ - `v0.chats.unfavorite({ chatId })` - Unfavorite a chat
145
+ - `v0.chats.getProject({ chatId })` - Get chat's associated project
146
+ - `v0.chats.getVersionFrameToken({ chatId, versionId })` - Get version frame token
147
+
148
+ ### Project Operations
142
149
 
143
150
  ```typescript
151
+ // Create a project
144
152
  const project = await v0.projects.create({
145
153
  name: 'My New Project',
146
154
  description: 'A sample project',
147
- environmentVariables: [{ key: 'API_KEY', value: 'secret_value' }],
148
- icon: 'https://example.com/icon.png',
149
155
  })
150
- ```
151
156
 
152
- #### Find Projects
153
-
154
- ```typescript
157
+ // Find projects
155
158
  const projects = await v0.projects.find()
156
159
  ```
157
160
 
158
161
  ### Vercel Integration
159
162
 
160
- #### Create Vercel Integration Project
161
-
162
163
  ```typescript
164
+ // Create Vercel integration project
163
165
  const integration = await v0.integrations.vercel.projects.create({
164
166
  projectId: 'vercel_project_id',
165
167
  name: 'project_name',
166
168
  })
167
- ```
168
-
169
- #### Find Vercel Projects
170
169
 
171
- ```typescript
170
+ // Find Vercel projects
172
171
  const projects = await v0.integrations.vercel.projects.find()
173
172
  ```
174
173
 
175
174
  ### User Management
176
175
 
177
- #### Get User Information
178
-
179
176
  ```typescript
177
+ // Get user information
180
178
  const userResponse = await v0.user.get()
181
- console.log(userResponse.user.name, userResponse.user.email)
182
- ```
183
-
184
- #### Get User Plan and Billing
185
179
 
186
- ```typescript
180
+ // Get user plan and billing
187
181
  const planResponse = await v0.user.getPlan()
188
- console.log(planResponse.plan, planResponse.balance)
189
- ```
190
-
191
- ### Deployment and Monitoring
192
182
 
193
- #### Find Deployment Logs
194
-
195
- ```typescript
196
- const logs = await v0.deployments.findLogs({
197
- deploymentId: 'deployment_id',
198
- })
183
+ // Get user scopes
184
+ const scopesResponse = await v0.user.getScopes()
199
185
  ```
200
186
 
201
- ### Scopes and Rate Limits
202
-
203
- #### Find Scopes
187
+ ### Other Operations
204
188
 
205
189
  ```typescript
206
- const scopesResponse = await v0.scopes.find()
207
- console.log(scopesResponse.scopes)
208
- ```
190
+ // Find deployment logs
191
+ const logs = await v0.deployments.findLogs({ deploymentId: 'deployment_id' })
209
192
 
210
- #### Check Rate Limits
211
-
212
- ```typescript
193
+ // Check rate limits
213
194
  const rateLimits = await v0.rateLimits.find()
214
- console.log(rateLimits.remaining, rateLimits.reset)
215
- ```
216
-
217
- ## Working with Attachments
218
-
219
- The SDK supports URL and base64-encoded attachments:
220
-
221
- ```typescript
222
- // URL attachment
223
- const response = await v0.chats.create({
224
- message: 'Create a component based on this design',
225
- attachments: [{ url: 'https://example.com/design.png' }],
226
- })
227
-
228
- // Base64 attachment
229
- const handleFileUpload = async (file: File) => {
230
- const reader = new FileReader()
231
-
232
- reader.onload = async () => {
233
- const response = await v0.chats.create({
234
- message: 'Create a component based on this image',
235
- attachments: [{ url: reader.result as string }],
236
- })
237
-
238
- console.log(response)
239
- }
240
-
241
- reader.readAsDataURL(file)
242
- }
243
195
  ```
244
196
 
245
197
  ## TypeScript Support
@@ -252,14 +204,7 @@ import type {
252
204
  ChatsCreateResponse,
253
205
  User,
254
206
  Project,
255
- ScopeSummary,
256
207
  } from 'v0-sdk'
257
-
258
- // All request and response types are fully typed
259
- const createChatRequest: ChatsCreateRequest = {
260
- message: 'Create a component',
261
- system: 'You are a helpful assistant',
262
- }
263
208
  ```
264
209
 
265
210
  ## Error Handling
@@ -276,8 +221,6 @@ try {
276
221
  console.error('Authentication error:', error.message)
277
222
  } else if (error.status === 429) {
278
223
  console.error('Rate limit exceeded:', error.message)
279
- } else {
280
- console.error('API error:', error.message)
281
224
  }
282
225
  }
283
226
  ```
@@ -290,39 +233,6 @@ The SDK includes comprehensive test coverage. Run tests with:
290
233
  npm test
291
234
  ```
292
235
 
293
- ### Test Structure
294
-
295
- Tests are organized by functionality:
296
-
297
- ```
298
- tests/
299
- ├── chats/
300
- │ ├── create.test.ts
301
- │ ├── find.test.ts
302
- │ ├── delete.test.ts
303
- │ ├── getById.test.ts
304
- │ ├── favorite.test.ts
305
- │ ├── unfavorite.test.ts
306
- │ ├── getProject.test.ts
307
- │ ├── createMessage.test.ts
308
- │ └── getVersionFrameToken.test.ts
309
- ├── projects/
310
- │ ├── create.test.ts
311
- │ └── find.test.ts
312
- ├── integrations/vercel/projects/
313
- │ ├── create.test.ts
314
- │ └── find.test.ts
315
- ├── user/
316
- │ ├── get.test.ts
317
- │ └── getPlan.test.ts
318
- ├── deployments/
319
- │ └── findLogs.test.ts
320
- ├── scopes/
321
- │ └── find.test.ts
322
- └── rateLimits/
323
- └── find.test.ts
324
- ```
325
-
326
236
  ## Development
327
237
 
328
238
  ### Building
@@ -345,51 +255,6 @@ npm run generate
345
255
  npm test
346
256
  ```
347
257
 
348
- ## Advanced Usage
349
-
350
- ### Custom Configuration
351
-
352
- ```typescript
353
- const client = new V0Client('your_api_key', 'https://custom-api.example.com', {
354
- timeout: 30000,
355
- retries: 3,
356
- })
357
- ```
358
-
359
- ### Team Collaboration
360
-
361
- Share chats with your team:
362
-
363
- ```typescript
364
- const chat = await v0.chats.create({
365
- message: 'Create a component for our design system',
366
- chatPrivacy: 'team-edit',
367
- teamId: 'your-team-id',
368
- })
369
-
370
- // Now team members can view and edit this chat
371
- console.log(`Team chat URL: ${chat.url}`)
372
- ```
373
-
374
- ## Troubleshooting
375
-
376
- ### Rate Limiting
377
-
378
- The API has rate limits. Check your current limits:
379
-
380
- ```typescript
381
- const limits = await v0.rateLimits.find()
382
- console.log(`Remaining requests: ${limits.remaining}`)
383
- ```
384
-
385
- ### Common Errors
386
-
387
- - **403 Forbidden**: Check your API key and ensure you have a valid subscription
388
- - **400 Bad Request**: Verify your request parameters match the API requirements
389
- - **404 Not Found**: Ensure the resource ID exists and is accessible to your API key
390
- - **413 Payload Too Large**: Reduce attachment size (max 10MB per attachment)
391
- - **429 Too Many Requests**: You've hit the rate limit, wait before making more requests
392
-
393
258
  ## Resources
394
259
 
395
260
  - [v0 Documentation](https://v0.dev/docs)
package/dist/index.d.ts CHANGED
@@ -8,7 +8,10 @@ type ChatDetail = {
8
8
  updatedAt?: string;
9
9
  favorite: boolean;
10
10
  authorId: string;
11
- latestBlockId?: string;
11
+ latestVersion?: {
12
+ id: string;
13
+ status: 'pending' | 'completed' | 'failed';
14
+ };
12
15
  messages: {
13
16
  id: string;
14
17
  object: 'message';
@@ -17,7 +20,7 @@ type ChatDetail = {
17
20
  type: 'message' | 'refinement' | 'forked-block' | 'forked-chat' | 'open-in-v0' | 'added-environment-variables' | 'added-integration' | 'deleted-file' | 'moved-file' | 'renamed-file' | 'edited-file' | 'replace-src' | 'reverted-block' | 'fix-with-v0' | 'sync-git';
18
21
  }[];
19
22
  };
20
- interface ChatSummary {
23
+ type ChatSummary = {
21
24
  id: string;
22
25
  object: 'chat';
23
26
  shareable: boolean;
@@ -26,8 +29,11 @@ interface ChatSummary {
26
29
  updatedAt: string;
27
30
  favorite: boolean;
28
31
  authorId: string;
29
- latestVersionId?: string;
30
- }
32
+ latestVersion?: {
33
+ id: string;
34
+ status: 'pending' | 'completed' | 'failed';
35
+ };
36
+ };
31
37
  type MessageDetail = {
32
38
  id: string;
33
39
  object: 'message';
@@ -123,7 +129,7 @@ interface ChatsFavoriteResponse {
123
129
  favorited: boolean;
124
130
  }
125
131
  interface ChatsForkRequest {
126
- versionId: string;
132
+ versionId?: string;
127
133
  }
128
134
  type ChatsForkResponse = ChatDetail;
129
135
  type ProjectsGetByChatIdResponse = ProjectDetail;
@@ -353,3 +359,4 @@ declare const v0: {
353
359
  };
354
360
 
355
361
  export { v0 };
362
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sources":["../src/sdk/v0.ts"],"sourcesContent":["import { fetcher } from './core'\n\nexport type ChatDetail = {\n id: string\n object: 'chat'\n url: string\n shareable: boolean\n privacy?: 'public' | 'private' | 'team' | 'team-edit' | 'unlisted'\n title?: string\n updatedAt?: string\n favorite: boolean\n authorId: string\n latestVersion?: {\n id: string\n status: 'pending' | 'completed' | 'failed'\n }\n messages: {\n id: string\n object: 'message'\n content: string\n createdAt: string\n type:\n | 'message'\n | 'refinement'\n | 'forked-block'\n | 'forked-chat'\n | 'open-in-v0'\n | 'added-environment-variables'\n | 'added-integration'\n | 'deleted-file'\n | 'moved-file'\n | 'renamed-file'\n | 'edited-file'\n | 'replace-src'\n | 'reverted-block'\n | 'fix-with-v0'\n | 'sync-git'\n }[]\n}\n\nexport type ChatSummary = {\n id: string\n object: 'chat'\n shareable: boolean\n privacy: string\n title?: string\n updatedAt: string\n favorite: boolean\n authorId: string\n latestVersion?: {\n id: string\n status: 'pending' | 'completed' | 'failed'\n }\n}\n\nexport type MessageDetail = {\n id: string\n object: 'message'\n chatId: string\n url: string\n files?: {\n lang: string\n meta: Record<string, any>\n source: string\n }[]\n demo?: string\n text: string\n modelConfiguration: {\n modelId: 'v0-1.5-sm' | 'v0-1.5-md' | 'v0-1.5-lg'\n imageGenerations?: boolean\n thinking?: boolean\n }\n}\n\nexport interface ProjectDetail {\n id: string\n object: 'project'\n name: string\n vercelProjectId?: string\n}\n\nexport interface ProjectSummary {\n id: string\n object: 'project'\n name: string\n vercelProjectId?: string\n}\n\nexport interface ScopeSummary {\n id: string\n object: 'scope'\n name?: string\n}\n\nexport interface UserDetail {\n id: string\n object: 'user'\n name?: string\n email: string\n avatar: string\n}\n\nexport interface VercelProjectDetail {\n id: string\n object: 'vercel_project'\n name: string\n}\n\nexport interface ChatsCreateRequest {\n message: string\n attachments?: {\n url: string\n }[]\n system?: string\n chatPrivacy?: 'public' | 'private' | 'team-edit' | 'team' | 'unlisted'\n projectId?: string\n modelConfiguration?: {\n modelId: 'v0-1.5-sm' | 'v0-1.5-md' | 'v0-1.5-lg'\n imageGenerations?: boolean\n thinking?: boolean\n }\n}\n\nexport type ChatsCreateResponse = {\n id: string\n object: 'chat'\n url: string\n files?: {\n lang: string\n meta: Record<string, any>\n source: string\n }[]\n demo?: string\n text: string\n modelConfiguration: {\n modelId: 'v0-1.5-sm' | 'v0-1.5-md' | 'v0-1.5-lg'\n imageGenerations?: boolean\n thinking?: boolean\n }\n}\n\nexport interface ChatsFindResponse {\n object: 'list'\n data: ChatSummary[]\n}\n\nexport interface ChatsDeleteResponse {\n id: string\n object: 'chat'\n deleted: true\n}\n\nexport type ChatsGetByIdResponse = ChatDetail\n\nexport interface ChatsUpdateRequest {\n privacy?: 'public' | 'private' | 'team' | 'team-edit' | 'unlisted'\n}\n\nexport type ChatsUpdateResponse = ChatDetail\n\nexport interface ChatsFavoriteRequest {\n isFavorite: boolean\n}\n\nexport interface ChatsFavoriteResponse {\n id: string\n object: 'chat'\n favorited: boolean\n}\n\nexport interface ChatsForkRequest {\n versionId?: string\n}\n\nexport type ChatsForkResponse = ChatDetail\n\nexport type ProjectsGetByChatIdResponse = ProjectDetail\n\nexport interface ChatsCreateMessageRequest {\n message: string\n attachments?: {\n url: string\n }[]\n modelConfiguration?: {\n modelId: 'v0-1.5-sm' | 'v0-1.5-md' | 'v0-1.5-lg'\n imageGenerations?: boolean\n thinking?: boolean\n }\n}\n\nexport type ChatsCreateMessageResponse = MessageDetail\n\nexport interface ChatsFindIframeResponse {\n id: string\n object: 'iframe'\n url: string\n}\n\nexport interface ChatsGetVersionFrameTokenResponse {\n token: string\n}\n\nexport interface ChatsGetMetadataResponse {\n git: {\n branch: string\n commit: string\n }\n deployment: {\n id: string\n }\n project: {\n id: string\n name: string\n url: string\n }\n}\n\nexport interface ChatsUploadRequest {\n file: any\n}\n\nexport interface ChatsUploadResponse {\n url: string\n}\n\nexport type ChatsResumeResponse = MessageDetail\n\nexport interface DeploymentsFindLogsResponse {\n error?: string\n logs: string[]\n nextSince?: number\n}\n\nexport interface DeploymentsFindErrorsResponse {\n error?: string\n fullErrorText?: string\n errorType?: string\n formattedError?: string\n}\n\nexport interface IntegrationsVercelProjectsFindResponse {\n object: 'list'\n data: VercelProjectDetail[]\n}\n\nexport interface IntegrationsVercelProjectsCreateRequest {\n projectId: string\n name: string\n}\n\nexport type IntegrationsVercelProjectsCreateResponse = VercelProjectDetail\n\nexport interface ProjectsFindResponse {\n object: 'list'\n data: ProjectDetail[]\n}\n\nexport interface ProjectsCreateRequest {\n name: string\n description?: string\n icon?: string\n environmentVariables?: {\n key: string\n value: string\n }[]\n instructions?: string\n}\n\nexport type ProjectsCreateResponse = ProjectDetail\n\nexport interface ProjectsAssignRequest {\n chatId: string\n}\n\nexport interface ProjectsAssignResponse {\n object: 'project'\n id: string\n assigned: true\n}\n\nexport interface RateLimitsFindResponse {\n remaining?: number\n reset?: number\n limit: number\n}\n\nexport type UserGetResponse = UserDetail\n\nexport type UserGetBillingResponse =\n | {\n billingType: 'token'\n data: {\n plan: string\n billingMode?: 'test'\n role: string\n billingCycle: {\n start: number\n end: number\n }\n balance: {\n remaining: number\n total: number\n }\n onDemand: {\n balance: number\n blocks?: {\n expirationDate?: number\n effectiveDate: number\n originalBalance: number\n currentBalance: number\n }[]\n }\n }\n }\n | {\n billingType: 'legacy'\n data: {\n remaining?: number\n reset?: number\n limit: number\n }\n }\n\nexport interface UserGetPlanResponse {\n object: 'plan'\n plan: string\n billingCycle: {\n start: number\n end: number\n }\n balance: {\n remaining: number\n total: number\n }\n}\n\nexport interface UserGetScopesResponse {\n object: 'list'\n data: ScopeSummary[]\n}\n\nexport const v0 = {\n chats: {\n async create(params: ChatsCreateRequest): Promise<ChatsCreateResponse> {\n const body = {\n message: params.message,\n attachments: params.attachments,\n system: params.system,\n chatPrivacy: params.chatPrivacy,\n projectId: params.projectId,\n modelConfiguration: params.modelConfiguration,\n }\n return fetcher(`/chats`, 'POST', { body })\n },\n\n async find(params?: {\n limit?: string\n offset?: string\n isFavorite?: string\n }): Promise<ChatsFindResponse> {\n const query = params\n ? (Object.fromEntries(\n Object.entries({\n limit: params.limit,\n offset: params.offset,\n isFavorite: params.isFavorite,\n }).filter(([_, value]) => value !== undefined),\n ) as Record<string, string>)\n : {}\n const hasQuery = Object.keys(query).length > 0\n return fetcher(`/chats`, 'GET', { ...(hasQuery ? { query } : {}) })\n },\n\n async delete(params: { chatId: string }): Promise<ChatsDeleteResponse> {\n const pathParams = { chatId: params.chatId }\n return fetcher(`/chats/${pathParams.chatId}`, 'DELETE', { pathParams })\n },\n\n async getById(params: { chatId: string }): Promise<ChatsGetByIdResponse> {\n const pathParams = { chatId: params.chatId }\n return fetcher(`/chats/${pathParams.chatId}`, 'GET', { pathParams })\n },\n\n async update(\n params: { chatId: string } & ChatsUpdateRequest,\n ): Promise<ChatsUpdateResponse> {\n const pathParams = { chatId: params.chatId }\n const body = { privacy: params.privacy }\n return fetcher(`/chats/${pathParams.chatId}`, 'PATCH', {\n pathParams,\n body,\n })\n },\n\n async favorite(\n params: { chatId: string } & ChatsFavoriteRequest,\n ): Promise<ChatsFavoriteResponse> {\n const pathParams = { chatId: params.chatId }\n const body = { isFavorite: params.isFavorite }\n return fetcher(`/chats/${pathParams.chatId}/favorite`, 'PUT', {\n pathParams,\n body,\n })\n },\n\n async fork(\n params: { chatId: string } & ChatsForkRequest,\n ): Promise<ChatsForkResponse> {\n const pathParams = { chatId: params.chatId }\n const body = { versionId: params.versionId }\n return fetcher(`/chats/${pathParams.chatId}/fork`, 'POST', {\n pathParams,\n body,\n })\n },\n\n async createMessage(\n params: { chatId: string } & ChatsCreateMessageRequest,\n ): Promise<ChatsCreateMessageResponse> {\n const pathParams = { chatId: params.chatId }\n const body = {\n message: params.message,\n attachments: params.attachments,\n modelConfiguration: params.modelConfiguration,\n }\n return fetcher(`/chats/${pathParams.chatId}/messages`, 'POST', {\n pathParams,\n body,\n })\n },\n\n async findIframe(params: {\n chatId: string\n versionId: string\n }): Promise<ChatsFindIframeResponse> {\n const pathParams = { chatId: params.chatId, versionId: params.versionId }\n return fetcher(\n `/chats/${pathParams.chatId}/versions/${pathParams.versionId}/iframe`,\n 'GET',\n { pathParams },\n )\n },\n\n async getVersionFrameToken(params: {\n chatId: string\n versionId: string\n }): Promise<ChatsGetVersionFrameTokenResponse> {\n const pathParams = { chatId: params.chatId, versionId: params.versionId }\n return fetcher(\n `/chats/${pathParams.chatId}/versions/${pathParams.versionId}/frame-token`,\n 'GET',\n { pathParams },\n )\n },\n\n async getMetadata(params: {\n chatId: string\n }): Promise<ChatsGetMetadataResponse> {\n const pathParams = { chatId: params.chatId }\n return fetcher(`/chats/${pathParams.chatId}/metadata`, 'GET', {\n pathParams,\n })\n },\n\n async upload(\n params: { chatId: string } & ChatsUploadRequest,\n ): Promise<ChatsUploadResponse> {\n const pathParams = { chatId: params.chatId }\n const body = { file: params.file }\n return fetcher(`/chats/${pathParams.chatId}/upload`, 'POST', {\n pathParams,\n body,\n })\n },\n\n async resume(params: {\n chatId: string\n messageId: string\n }): Promise<ChatsResumeResponse> {\n const pathParams = { chatId: params.chatId, messageId: params.messageId }\n return fetcher(\n `/chats/${pathParams.chatId}/messages/${pathParams.messageId}/resume`,\n 'POST',\n { pathParams },\n )\n },\n },\n\n projects: {\n async getByChatId(params: {\n chatId: string\n }): Promise<ProjectsGetByChatIdResponse> {\n const pathParams = { chatId: params.chatId }\n return fetcher(`/chats/${pathParams.chatId}/project`, 'GET', {\n pathParams,\n })\n },\n\n async find(): Promise<ProjectsFindResponse> {\n return fetcher(`/projects`, 'GET', {})\n },\n\n async create(\n params: ProjectsCreateRequest,\n ): Promise<ProjectsCreateResponse> {\n const body = {\n name: params.name,\n description: params.description,\n icon: params.icon,\n environmentVariables: params.environmentVariables,\n instructions: params.instructions,\n }\n return fetcher(`/projects`, 'POST', { body })\n },\n\n async assign(\n params: { projectId: string } & ProjectsAssignRequest,\n ): Promise<ProjectsAssignResponse> {\n const pathParams = { projectId: params.projectId }\n const body = { chatId: params.chatId }\n return fetcher(`/projects/${pathParams.projectId}/assign`, 'POST', {\n pathParams,\n body,\n })\n },\n },\n\n deployments: {\n async findLogs(params: {\n deploymentId: string\n since?: string\n }): Promise<DeploymentsFindLogsResponse> {\n const pathParams = { deploymentId: params.deploymentId }\n const query = Object.fromEntries(\n Object.entries({\n since: params.since,\n }).filter(([_, value]) => value !== undefined),\n ) as Record<string, string>\n const hasQuery = Object.keys(query).length > 0\n return fetcher(`/deployments/${pathParams.deploymentId}/logs`, 'GET', {\n pathParams,\n ...(hasQuery ? { query } : {}),\n })\n },\n\n async findErrors(params: {\n deploymentId: string\n }): Promise<DeploymentsFindErrorsResponse> {\n const pathParams = { deploymentId: params.deploymentId }\n return fetcher(`/deployments/${pathParams.deploymentId}/errors`, 'GET', {\n pathParams,\n })\n },\n },\n\n integrations: {\n vercel: {\n projects: {\n async find(): Promise<IntegrationsVercelProjectsFindResponse> {\n return fetcher(`/integrations/vercel/projects`, 'GET', {})\n },\n\n async create(\n params: IntegrationsVercelProjectsCreateRequest,\n ): Promise<IntegrationsVercelProjectsCreateResponse> {\n const body = { projectId: params.projectId, name: params.name }\n return fetcher(`/integrations/vercel/projects`, 'POST', { body })\n },\n },\n },\n },\n\n rateLimits: {\n async find(params?: { scope?: string }): Promise<RateLimitsFindResponse> {\n const query = params\n ? (Object.fromEntries(\n Object.entries({\n scope: params.scope,\n }).filter(([_, value]) => value !== undefined),\n ) as Record<string, string>)\n : {}\n const hasQuery = Object.keys(query).length > 0\n return fetcher(`/rate-limits`, 'GET', { ...(hasQuery ? { query } : {}) })\n },\n },\n\n user: {\n async get(): Promise<UserGetResponse> {\n return fetcher(`/user`, 'GET', {})\n },\n\n async getBilling(params?: {\n scope?: string\n }): Promise<UserGetBillingResponse> {\n const query = params\n ? (Object.fromEntries(\n Object.entries({\n scope: params.scope,\n }).filter(([_, value]) => value !== undefined),\n ) as Record<string, string>)\n : {}\n const hasQuery = Object.keys(query).length > 0\n return fetcher(`/user/billing`, 'GET', { ...(hasQuery ? { query } : {}) })\n },\n\n async getPlan(): Promise<UserGetPlanResponse> {\n return fetcher(`/user/plan`, 'GET', {})\n },\n\n async getScopes(): Promise<UserGetScopesResponse> {\n return fetcher(`/user/scopes`, 'GET', {})\n },\n },\n}\n"],"names":[],"mappings":"AAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO;AACP;AACA;AACA;AACA;AACA;AAOO;AACP;AACA;AACA;AACA;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACO;AACP;AACA;AACA;AACA;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO;AACP;AACA;AACA;AACO;AACP;AACA;AACA;AACA;AACO;AACA;AACP;AACA;AACO;AACA;AACP;AACA;AACO;AACP;AACA;AACA;AACA;AACO;AACP;AACA;AACO;AACA;AACA;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO;AACA;AACP;AACA;AACA;AACA;AACO;AACP;AACA;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO;AACP;AACA;AACO;AACP;AACA;AACO;AACA;AACP;AACA;AACA;AACA;AACO;AACP;AACA;AACA;AACA;AACA;AACO;AACP;AACA;AACA;AACO;AACP;AACA;AACA;AACO;AACA;AACP;AACA;AACA;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO;AACA;AACP;AACA;AACO;AACP;AACA;AACA;AACA;AACO;AACP;AACA;AACA;AACA;AACO;AACA;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO;AACP;AACA;AACA;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "v0-sdk",
3
- "version": "0.0.7",
3
+ "version": "0.0.9",
4
4
  "description": "TypeScript SDK for the v0 Chats API",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -38,6 +38,12 @@
38
38
  "bunchee": "^6.5.2",
39
39
  "prettier": "^3.3.3",
40
40
  "tsx": "^4.19.2",
41
- "typescript": "5.7.3"
41
+ "typescript": "5.7.3",
42
+ "vitest": "^3.2.4"
43
+ },
44
+ "prettier": {
45
+ "semi": false,
46
+ "singleQuote": true,
47
+ "trailingComma": "all"
42
48
  }
43
49
  }