v0-sdk 0.0.6 → 0.0.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/README.md +25 -209
- package/dist/index.cjs +110 -61
- package/dist/index.d.ts +172 -130
- package/dist/index.js +110 -61
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
# v0
|
|
1
|
+
# v0 SDK
|
|
2
2
|
|
|
3
|
-
|
|
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
|
|
|
@@ -37,15 +39,6 @@ const chat = await v0.chats.create({
|
|
|
37
39
|
})
|
|
38
40
|
|
|
39
41
|
console.log(`Chat created: ${chat.url}`)
|
|
40
|
-
console.log(`Generated code: ${chat.files?.length} files`)
|
|
41
|
-
|
|
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
|
-
})
|
|
47
|
-
|
|
48
|
-
console.log(`AI response: ${response.text}`)
|
|
49
42
|
```
|
|
50
43
|
|
|
51
44
|
## Authentication
|
|
@@ -85,33 +78,6 @@ const result = await v0.chats.create({
|
|
|
85
78
|
|
|
86
79
|
```typescript
|
|
87
80
|
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
81
|
```
|
|
116
82
|
|
|
117
83
|
#### Add Messages to Chat
|
|
@@ -120,128 +86,65 @@ const project = await v0.chats.getProject({ chatId: 'chat_id' })
|
|
|
120
86
|
const response = await v0.chats.createMessage({
|
|
121
87
|
chatId: 'chat_id',
|
|
122
88
|
message: 'Add password strength indicator',
|
|
123
|
-
attachments: [{ url: 'https://example.com/mockup.jpg' }],
|
|
124
|
-
modelConfiguration: {
|
|
125
|
-
imageGenerations: true
|
|
126
|
-
},
|
|
127
89
|
})
|
|
128
90
|
```
|
|
129
91
|
|
|
130
|
-
####
|
|
92
|
+
#### Other Chat Operations
|
|
131
93
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
})
|
|
137
|
-
|
|
94
|
+
- `v0.chats.find()` - Get chat history
|
|
95
|
+
- `v0.chats.delete({ chatId })` - Delete a chat
|
|
96
|
+
- `v0.chats.favorite({ chatId })` - Favorite a chat
|
|
97
|
+
- `v0.chats.unfavorite({ chatId })` - Unfavorite a chat
|
|
98
|
+
- `v0.chats.getProject({ chatId })` - Get chat's associated project
|
|
99
|
+
- `v0.chats.getVersionFrameToken({ chatId, versionId })` - Get version frame token
|
|
138
100
|
|
|
139
101
|
### Project Operations
|
|
140
102
|
|
|
141
|
-
#### Create a Project
|
|
142
|
-
|
|
143
103
|
```typescript
|
|
104
|
+
// Create a project
|
|
144
105
|
const project = await v0.projects.create({
|
|
145
106
|
name: 'My New Project',
|
|
146
107
|
description: 'A sample project',
|
|
147
|
-
environmentVariables: [
|
|
148
|
-
{ key: 'API_KEY', value: 'secret_value' }
|
|
149
|
-
],
|
|
150
|
-
icon: 'https://example.com/icon.png'
|
|
151
108
|
})
|
|
152
|
-
```
|
|
153
109
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
```typescript
|
|
110
|
+
// Find projects
|
|
157
111
|
const projects = await v0.projects.find()
|
|
158
112
|
```
|
|
159
113
|
|
|
160
114
|
### Vercel Integration
|
|
161
115
|
|
|
162
|
-
#### Create Vercel Integration Project
|
|
163
|
-
|
|
164
116
|
```typescript
|
|
117
|
+
// Create Vercel integration project
|
|
165
118
|
const integration = await v0.integrations.vercel.projects.create({
|
|
166
119
|
projectId: 'vercel_project_id',
|
|
167
|
-
name: 'project_name'
|
|
120
|
+
name: 'project_name',
|
|
168
121
|
})
|
|
169
|
-
```
|
|
170
|
-
|
|
171
|
-
#### Find Vercel Projects
|
|
172
122
|
|
|
173
|
-
|
|
123
|
+
// Find Vercel projects
|
|
174
124
|
const projects = await v0.integrations.vercel.projects.find()
|
|
175
125
|
```
|
|
176
126
|
|
|
177
127
|
### User Management
|
|
178
128
|
|
|
179
|
-
#### Get User Information
|
|
180
|
-
|
|
181
129
|
```typescript
|
|
130
|
+
// Get user information
|
|
182
131
|
const userResponse = await v0.user.get()
|
|
183
|
-
console.log(userResponse.user.name, userResponse.user.email)
|
|
184
|
-
```
|
|
185
|
-
|
|
186
|
-
#### Get User Plan and Billing
|
|
187
132
|
|
|
188
|
-
|
|
133
|
+
// Get user plan and billing
|
|
189
134
|
const planResponse = await v0.user.getPlan()
|
|
190
|
-
console.log(planResponse.plan, planResponse.balance)
|
|
191
|
-
```
|
|
192
|
-
|
|
193
|
-
### Deployment and Monitoring
|
|
194
135
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
```typescript
|
|
198
|
-
const logs = await v0.deployments.findLogs({
|
|
199
|
-
deploymentId: 'deployment_id'
|
|
200
|
-
})
|
|
136
|
+
// Get user scopes
|
|
137
|
+
const scopesResponse = await v0.user.getScopes()
|
|
201
138
|
```
|
|
202
139
|
|
|
203
|
-
###
|
|
204
|
-
|
|
205
|
-
#### Find Scopes
|
|
140
|
+
### Other Operations
|
|
206
141
|
|
|
207
142
|
```typescript
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
```
|
|
143
|
+
// Find deployment logs
|
|
144
|
+
const logs = await v0.deployments.findLogs({ deploymentId: 'deployment_id' })
|
|
211
145
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
```typescript
|
|
146
|
+
// Check rate limits
|
|
215
147
|
const rateLimits = await v0.rateLimits.find()
|
|
216
|
-
console.log(rateLimits.remaining, rateLimits.reset)
|
|
217
|
-
```
|
|
218
|
-
|
|
219
|
-
## Working with Attachments
|
|
220
|
-
|
|
221
|
-
The SDK supports URL and base64-encoded attachments:
|
|
222
|
-
|
|
223
|
-
```typescript
|
|
224
|
-
// URL attachment
|
|
225
|
-
const response = await v0.chats.create({
|
|
226
|
-
message: 'Create a component based on this design',
|
|
227
|
-
attachments: [{ url: 'https://example.com/design.png' }],
|
|
228
|
-
})
|
|
229
|
-
|
|
230
|
-
// Base64 attachment
|
|
231
|
-
const handleFileUpload = async (file: File) => {
|
|
232
|
-
const reader = new FileReader()
|
|
233
|
-
|
|
234
|
-
reader.onload = async () => {
|
|
235
|
-
const response = await v0.chats.create({
|
|
236
|
-
message: 'Create a component based on this image',
|
|
237
|
-
attachments: [{ url: reader.result as string }],
|
|
238
|
-
})
|
|
239
|
-
|
|
240
|
-
console.log(response)
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
reader.readAsDataURL(file)
|
|
244
|
-
}
|
|
245
148
|
```
|
|
246
149
|
|
|
247
150
|
## TypeScript Support
|
|
@@ -249,19 +152,12 @@ const handleFileUpload = async (file: File) => {
|
|
|
249
152
|
The SDK includes complete type definitions for all API operations:
|
|
250
153
|
|
|
251
154
|
```typescript
|
|
252
|
-
import type {
|
|
155
|
+
import type {
|
|
253
156
|
ChatsCreateRequest,
|
|
254
157
|
ChatsCreateResponse,
|
|
255
158
|
User,
|
|
256
159
|
Project,
|
|
257
|
-
ScopeSummary
|
|
258
160
|
} from 'v0-sdk'
|
|
259
|
-
|
|
260
|
-
// All request and response types are fully typed
|
|
261
|
-
const createChatRequest: ChatsCreateRequest = {
|
|
262
|
-
message: 'Create a component',
|
|
263
|
-
system: 'You are a helpful assistant',
|
|
264
|
-
}
|
|
265
161
|
```
|
|
266
162
|
|
|
267
163
|
## Error Handling
|
|
@@ -278,8 +174,6 @@ try {
|
|
|
278
174
|
console.error('Authentication error:', error.message)
|
|
279
175
|
} else if (error.status === 429) {
|
|
280
176
|
console.error('Rate limit exceeded:', error.message)
|
|
281
|
-
} else {
|
|
282
|
-
console.error('API error:', error.message)
|
|
283
177
|
}
|
|
284
178
|
}
|
|
285
179
|
```
|
|
@@ -292,39 +186,6 @@ The SDK includes comprehensive test coverage. Run tests with:
|
|
|
292
186
|
npm test
|
|
293
187
|
```
|
|
294
188
|
|
|
295
|
-
### Test Structure
|
|
296
|
-
|
|
297
|
-
Tests are organized by functionality:
|
|
298
|
-
|
|
299
|
-
```
|
|
300
|
-
tests/
|
|
301
|
-
├── chats/
|
|
302
|
-
│ ├── create.test.ts
|
|
303
|
-
│ ├── find.test.ts
|
|
304
|
-
│ ├── delete.test.ts
|
|
305
|
-
│ ├── getById.test.ts
|
|
306
|
-
│ ├── favorite.test.ts
|
|
307
|
-
│ ├── unfavorite.test.ts
|
|
308
|
-
│ ├── getProject.test.ts
|
|
309
|
-
│ ├── createMessage.test.ts
|
|
310
|
-
│ └── getVersionFrameToken.test.ts
|
|
311
|
-
├── projects/
|
|
312
|
-
│ ├── create.test.ts
|
|
313
|
-
│ └── find.test.ts
|
|
314
|
-
├── integrations/vercel/projects/
|
|
315
|
-
│ ├── create.test.ts
|
|
316
|
-
│ └── find.test.ts
|
|
317
|
-
├── user/
|
|
318
|
-
│ ├── get.test.ts
|
|
319
|
-
│ └── getPlan.test.ts
|
|
320
|
-
├── deployments/
|
|
321
|
-
│ └── findLogs.test.ts
|
|
322
|
-
├── scopes/
|
|
323
|
-
│ └── find.test.ts
|
|
324
|
-
└── rateLimits/
|
|
325
|
-
└── find.test.ts
|
|
326
|
-
```
|
|
327
|
-
|
|
328
189
|
## Development
|
|
329
190
|
|
|
330
191
|
### Building
|
|
@@ -347,51 +208,6 @@ npm run generate
|
|
|
347
208
|
npm test
|
|
348
209
|
```
|
|
349
210
|
|
|
350
|
-
## Advanced Usage
|
|
351
|
-
|
|
352
|
-
### Custom Configuration
|
|
353
|
-
|
|
354
|
-
```typescript
|
|
355
|
-
const client = new V0Client('your_api_key', 'https://custom-api.example.com', {
|
|
356
|
-
timeout: 30000,
|
|
357
|
-
retries: 3
|
|
358
|
-
})
|
|
359
|
-
```
|
|
360
|
-
|
|
361
|
-
### Team Collaboration
|
|
362
|
-
|
|
363
|
-
Share chats with your team:
|
|
364
|
-
|
|
365
|
-
```typescript
|
|
366
|
-
const chat = await v0.chats.create({
|
|
367
|
-
message: 'Create a component for our design system',
|
|
368
|
-
chatPrivacy: 'team-edit',
|
|
369
|
-
teamId: 'your-team-id',
|
|
370
|
-
})
|
|
371
|
-
|
|
372
|
-
// Now team members can view and edit this chat
|
|
373
|
-
console.log(`Team chat URL: ${chat.url}`)
|
|
374
|
-
```
|
|
375
|
-
|
|
376
|
-
## Troubleshooting
|
|
377
|
-
|
|
378
|
-
### Rate Limiting
|
|
379
|
-
|
|
380
|
-
The API has rate limits. Check your current limits:
|
|
381
|
-
|
|
382
|
-
```typescript
|
|
383
|
-
const limits = await v0.rateLimits.find()
|
|
384
|
-
console.log(`Remaining requests: ${limits.remaining}`)
|
|
385
|
-
```
|
|
386
|
-
|
|
387
|
-
### Common Errors
|
|
388
|
-
|
|
389
|
-
- **403 Forbidden**: Check your API key and ensure you have a valid subscription
|
|
390
|
-
- **400 Bad Request**: Verify your request parameters match the API requirements
|
|
391
|
-
- **404 Not Found**: Ensure the resource ID exists and is accessible to your API key
|
|
392
|
-
- **413 Payload Too Large**: Reduce attachment size (max 10MB per attachment)
|
|
393
|
-
- **429 Too Many Requests**: You've hit the rate limit, wait before making more requests
|
|
394
|
-
|
|
395
211
|
## Resources
|
|
396
212
|
|
|
397
213
|
- [v0 Documentation](https://v0.dev/docs)
|
package/dist/index.cjs
CHANGED
|
@@ -10,7 +10,7 @@ async function fetcher(url, method, params = {}) {
|
|
|
10
10
|
}
|
|
11
11
|
const hasBody = method !== 'GET' && params.body;
|
|
12
12
|
const headers = {
|
|
13
|
-
|
|
13
|
+
Authorization: `Bearer ${apiKey}`,
|
|
14
14
|
...params.headers
|
|
15
15
|
};
|
|
16
16
|
if (hasBody) {
|
|
@@ -37,15 +37,24 @@ const v0 = {
|
|
|
37
37
|
system: params.system,
|
|
38
38
|
chatPrivacy: params.chatPrivacy,
|
|
39
39
|
projectId: params.projectId,
|
|
40
|
-
modelConfiguration: params.modelConfiguration
|
|
41
|
-
chatId: params.chatId
|
|
40
|
+
modelConfiguration: params.modelConfiguration
|
|
42
41
|
};
|
|
43
42
|
return fetcher(`/chats`, 'POST', {
|
|
44
43
|
body
|
|
45
44
|
});
|
|
46
45
|
},
|
|
47
|
-
async find () {
|
|
48
|
-
|
|
46
|
+
async find (params) {
|
|
47
|
+
const query = params ? Object.fromEntries(Object.entries({
|
|
48
|
+
limit: params.limit,
|
|
49
|
+
offset: params.offset,
|
|
50
|
+
isFavorite: params.isFavorite
|
|
51
|
+
}).filter(([_, value])=>value !== undefined)) : {};
|
|
52
|
+
const hasQuery = Object.keys(query).length > 0;
|
|
53
|
+
return fetcher(`/chats`, 'GET', {
|
|
54
|
+
...hasQuery ? {
|
|
55
|
+
query
|
|
56
|
+
} : {}
|
|
57
|
+
});
|
|
49
58
|
},
|
|
50
59
|
async delete (params) {
|
|
51
60
|
const pathParams = {
|
|
@@ -61,26 +70,38 @@ const v0 = {
|
|
|
61
70
|
return fetcher(`/chats/${pathParams.chatId}`, 'GET', {
|
|
62
71
|
});
|
|
63
72
|
},
|
|
64
|
-
async
|
|
73
|
+
async update (params) {
|
|
65
74
|
const pathParams = {
|
|
66
75
|
chatId: params.chatId
|
|
67
76
|
};
|
|
68
|
-
|
|
69
|
-
|
|
77
|
+
const body = {
|
|
78
|
+
privacy: params.privacy
|
|
79
|
+
};
|
|
80
|
+
return fetcher(`/chats/${pathParams.chatId}`, 'PATCH', {
|
|
81
|
+
body
|
|
82
|
+
});
|
|
70
83
|
},
|
|
71
|
-
async
|
|
84
|
+
async favorite (params) {
|
|
72
85
|
const pathParams = {
|
|
73
86
|
chatId: params.chatId
|
|
74
87
|
};
|
|
75
|
-
|
|
76
|
-
|
|
88
|
+
const body = {
|
|
89
|
+
isFavorite: params.isFavorite
|
|
90
|
+
};
|
|
91
|
+
return fetcher(`/chats/${pathParams.chatId}/favorite`, 'PUT', {
|
|
92
|
+
body
|
|
93
|
+
});
|
|
77
94
|
},
|
|
78
|
-
async
|
|
95
|
+
async fork (params) {
|
|
79
96
|
const pathParams = {
|
|
80
97
|
chatId: params.chatId
|
|
81
98
|
};
|
|
82
|
-
|
|
83
|
-
|
|
99
|
+
const body = {
|
|
100
|
+
versionId: params.versionId
|
|
101
|
+
};
|
|
102
|
+
return fetcher(`/chats/${pathParams.chatId}/fork`, 'POST', {
|
|
103
|
+
body
|
|
104
|
+
});
|
|
84
105
|
},
|
|
85
106
|
async createMessage (params) {
|
|
86
107
|
const pathParams = {
|
|
@@ -95,6 +116,14 @@ const v0 = {
|
|
|
95
116
|
body
|
|
96
117
|
});
|
|
97
118
|
},
|
|
119
|
+
async findIframe (params) {
|
|
120
|
+
const pathParams = {
|
|
121
|
+
chatId: params.chatId,
|
|
122
|
+
versionId: params.versionId
|
|
123
|
+
};
|
|
124
|
+
return fetcher(`/chats/${pathParams.chatId}/versions/${pathParams.versionId}/iframe`, 'GET', {
|
|
125
|
+
});
|
|
126
|
+
},
|
|
98
127
|
async getVersionFrameToken (params) {
|
|
99
128
|
const pathParams = {
|
|
100
129
|
chatId: params.chatId,
|
|
@@ -110,17 +139,6 @@ const v0 = {
|
|
|
110
139
|
return fetcher(`/chats/${pathParams.chatId}/metadata`, 'GET', {
|
|
111
140
|
});
|
|
112
141
|
},
|
|
113
|
-
async setPrivacy (params) {
|
|
114
|
-
const pathParams = {
|
|
115
|
-
chatId: params.chatId
|
|
116
|
-
};
|
|
117
|
-
const body = {
|
|
118
|
-
privacy: params.privacy
|
|
119
|
-
};
|
|
120
|
-
return fetcher(`/chats/${pathParams.chatId}/privacy`, 'POST', {
|
|
121
|
-
body
|
|
122
|
-
});
|
|
123
|
-
},
|
|
124
142
|
async upload (params) {
|
|
125
143
|
const pathParams = {
|
|
126
144
|
chatId: params.chatId
|
|
@@ -141,41 +159,14 @@ const v0 = {
|
|
|
141
159
|
});
|
|
142
160
|
}
|
|
143
161
|
},
|
|
144
|
-
|
|
145
|
-
async
|
|
162
|
+
projects: {
|
|
163
|
+
async getByChatId (params) {
|
|
146
164
|
const pathParams = {
|
|
147
|
-
|
|
165
|
+
chatId: params.chatId
|
|
148
166
|
};
|
|
149
|
-
return fetcher(`/
|
|
167
|
+
return fetcher(`/chats/${pathParams.chatId}/project`, 'GET', {
|
|
150
168
|
});
|
|
151
169
|
},
|
|
152
|
-
async findErrors (params) {
|
|
153
|
-
const pathParams = {
|
|
154
|
-
deploymentId: params.deploymentId
|
|
155
|
-
};
|
|
156
|
-
return fetcher(`/deployments/${pathParams.deploymentId}/errors`, 'GET', {
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
},
|
|
160
|
-
integrations: {
|
|
161
|
-
vercel: {
|
|
162
|
-
projects: {
|
|
163
|
-
async find () {
|
|
164
|
-
return fetcher(`/integrations/vercel/projects`, 'GET', {});
|
|
165
|
-
},
|
|
166
|
-
async create (params) {
|
|
167
|
-
const body = {
|
|
168
|
-
projectId: params.projectId,
|
|
169
|
-
name: params.name
|
|
170
|
-
};
|
|
171
|
-
return fetcher(`/integrations/vercel/projects`, 'POST', {
|
|
172
|
-
body
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
},
|
|
178
|
-
projects: {
|
|
179
170
|
async find () {
|
|
180
171
|
return fetcher(`/projects`, 'GET', {});
|
|
181
172
|
},
|
|
@@ -203,22 +194,80 @@ const v0 = {
|
|
|
203
194
|
});
|
|
204
195
|
}
|
|
205
196
|
},
|
|
206
|
-
|
|
207
|
-
async
|
|
208
|
-
|
|
197
|
+
deployments: {
|
|
198
|
+
async findLogs (params) {
|
|
199
|
+
const pathParams = {
|
|
200
|
+
deploymentId: params.deploymentId
|
|
201
|
+
};
|
|
202
|
+
const query = Object.fromEntries(Object.entries({
|
|
203
|
+
since: params.since
|
|
204
|
+
}).filter(([_, value])=>value !== undefined));
|
|
205
|
+
const hasQuery = Object.keys(query).length > 0;
|
|
206
|
+
return fetcher(`/deployments/${pathParams.deploymentId}/logs`, 'GET', {
|
|
207
|
+
...hasQuery ? {
|
|
208
|
+
query
|
|
209
|
+
} : {}
|
|
210
|
+
});
|
|
211
|
+
},
|
|
212
|
+
async findErrors (params) {
|
|
213
|
+
const pathParams = {
|
|
214
|
+
deploymentId: params.deploymentId
|
|
215
|
+
};
|
|
216
|
+
return fetcher(`/deployments/${pathParams.deploymentId}/errors`, 'GET', {
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
},
|
|
220
|
+
integrations: {
|
|
221
|
+
vercel: {
|
|
222
|
+
projects: {
|
|
223
|
+
async find () {
|
|
224
|
+
return fetcher(`/integrations/vercel/projects`, 'GET', {});
|
|
225
|
+
},
|
|
226
|
+
async create (params) {
|
|
227
|
+
const body = {
|
|
228
|
+
projectId: params.projectId,
|
|
229
|
+
name: params.name
|
|
230
|
+
};
|
|
231
|
+
return fetcher(`/integrations/vercel/projects`, 'POST', {
|
|
232
|
+
body
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
}
|
|
209
236
|
}
|
|
210
237
|
},
|
|
211
238
|
rateLimits: {
|
|
212
|
-
async find () {
|
|
213
|
-
|
|
239
|
+
async find (params) {
|
|
240
|
+
const query = params ? Object.fromEntries(Object.entries({
|
|
241
|
+
scope: params.scope
|
|
242
|
+
}).filter(([_, value])=>value !== undefined)) : {};
|
|
243
|
+
const hasQuery = Object.keys(query).length > 0;
|
|
244
|
+
return fetcher(`/rate-limits`, 'GET', {
|
|
245
|
+
...hasQuery ? {
|
|
246
|
+
query
|
|
247
|
+
} : {}
|
|
248
|
+
});
|
|
214
249
|
}
|
|
215
250
|
},
|
|
216
251
|
user: {
|
|
217
252
|
async get () {
|
|
218
253
|
return fetcher(`/user`, 'GET', {});
|
|
219
254
|
},
|
|
255
|
+
async getBilling (params) {
|
|
256
|
+
const query = params ? Object.fromEntries(Object.entries({
|
|
257
|
+
scope: params.scope
|
|
258
|
+
}).filter(([_, value])=>value !== undefined)) : {};
|
|
259
|
+
const hasQuery = Object.keys(query).length > 0;
|
|
260
|
+
return fetcher(`/user/billing`, 'GET', {
|
|
261
|
+
...hasQuery ? {
|
|
262
|
+
query
|
|
263
|
+
} : {}
|
|
264
|
+
});
|
|
265
|
+
},
|
|
220
266
|
async getPlan () {
|
|
221
267
|
return fetcher(`/user/plan`, 'GET', {});
|
|
268
|
+
},
|
|
269
|
+
async getScopes () {
|
|
270
|
+
return fetcher(`/user/scopes`, 'GET', {});
|
|
222
271
|
}
|
|
223
272
|
}
|
|
224
273
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,73 @@
|
|
|
1
|
+
type ChatDetail = {
|
|
2
|
+
id: string;
|
|
3
|
+
object: 'chat';
|
|
4
|
+
url: string;
|
|
5
|
+
shareable: boolean;
|
|
6
|
+
privacy?: 'public' | 'private' | 'team' | 'team-edit' | 'unlisted';
|
|
7
|
+
title?: string;
|
|
8
|
+
updatedAt?: string;
|
|
9
|
+
favorite: boolean;
|
|
10
|
+
authorId: string;
|
|
11
|
+
latestBlockId?: string;
|
|
12
|
+
messages: {
|
|
13
|
+
id: string;
|
|
14
|
+
object: 'message';
|
|
15
|
+
content: string;
|
|
16
|
+
createdAt: string;
|
|
17
|
+
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
|
+
}[];
|
|
19
|
+
};
|
|
20
|
+
interface ChatSummary {
|
|
21
|
+
id: string;
|
|
22
|
+
object: 'chat';
|
|
23
|
+
shareable: boolean;
|
|
24
|
+
privacy: string;
|
|
25
|
+
title?: string;
|
|
26
|
+
updatedAt: string;
|
|
27
|
+
favorite: boolean;
|
|
28
|
+
authorId: string;
|
|
29
|
+
latestVersionId?: string;
|
|
30
|
+
}
|
|
31
|
+
type MessageDetail = {
|
|
32
|
+
id: string;
|
|
33
|
+
object: 'message';
|
|
34
|
+
chatId: string;
|
|
35
|
+
url: string;
|
|
36
|
+
files?: {
|
|
37
|
+
lang: string;
|
|
38
|
+
meta: Record<string, any>;
|
|
39
|
+
source: string;
|
|
40
|
+
}[];
|
|
41
|
+
demo?: string;
|
|
42
|
+
text: string;
|
|
43
|
+
modelConfiguration: {
|
|
44
|
+
modelId: 'v0-1.5-sm' | 'v0-1.5-md' | 'v0-1.5-lg';
|
|
45
|
+
imageGenerations?: boolean;
|
|
46
|
+
thinking?: boolean;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
interface ProjectDetail {
|
|
50
|
+
id: string;
|
|
51
|
+
object: 'project';
|
|
52
|
+
name: string;
|
|
53
|
+
vercelProjectId?: string;
|
|
54
|
+
}
|
|
1
55
|
interface ScopeSummary {
|
|
2
56
|
id: string;
|
|
57
|
+
object: 'scope';
|
|
3
58
|
name?: string;
|
|
4
59
|
}
|
|
5
|
-
interface
|
|
60
|
+
interface UserDetail {
|
|
6
61
|
id: string;
|
|
62
|
+
object: 'user';
|
|
7
63
|
name?: string;
|
|
8
64
|
email: string;
|
|
9
65
|
avatar: string;
|
|
10
|
-
|
|
66
|
+
}
|
|
67
|
+
interface VercelProjectDetail {
|
|
68
|
+
id: string;
|
|
69
|
+
object: 'vercel_project';
|
|
70
|
+
name: string;
|
|
11
71
|
}
|
|
12
72
|
interface ChatsCreateRequest {
|
|
13
73
|
message: string;
|
|
@@ -22,10 +82,10 @@ interface ChatsCreateRequest {
|
|
|
22
82
|
imageGenerations?: boolean;
|
|
23
83
|
thinking?: boolean;
|
|
24
84
|
};
|
|
25
|
-
chatId?: string;
|
|
26
85
|
}
|
|
27
86
|
type ChatsCreateResponse = {
|
|
28
|
-
|
|
87
|
+
id: string;
|
|
88
|
+
object: 'chat';
|
|
29
89
|
url: string;
|
|
30
90
|
files?: {
|
|
31
91
|
lang: string;
|
|
@@ -39,62 +99,34 @@ type ChatsCreateResponse = {
|
|
|
39
99
|
imageGenerations?: boolean;
|
|
40
100
|
thinking?: boolean;
|
|
41
101
|
};
|
|
42
|
-
_deprecation?: {
|
|
43
|
-
message: string;
|
|
44
|
-
migration: string;
|
|
45
|
-
sunset: string;
|
|
46
|
-
};
|
|
47
102
|
};
|
|
48
103
|
interface ChatsFindResponse {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
shareable: boolean;
|
|
52
|
-
privacy: string;
|
|
53
|
-
title: string;
|
|
54
|
-
updatedAt: string;
|
|
55
|
-
favorite: boolean;
|
|
56
|
-
authorId: string;
|
|
57
|
-
}[];
|
|
58
|
-
history: {
|
|
59
|
-
chatId: string;
|
|
60
|
-
shareable: boolean;
|
|
61
|
-
privacy: string;
|
|
62
|
-
title: string;
|
|
63
|
-
updatedAt: string;
|
|
64
|
-
}[];
|
|
104
|
+
object: 'list';
|
|
105
|
+
data: ChatSummary[];
|
|
65
106
|
}
|
|
66
107
|
interface ChatsDeleteResponse {
|
|
67
|
-
|
|
108
|
+
id: string;
|
|
109
|
+
object: 'chat';
|
|
110
|
+
deleted: true;
|
|
68
111
|
}
|
|
69
|
-
type ChatsGetByIdResponse =
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
messages: {
|
|
73
|
-
messageId: string;
|
|
74
|
-
content: string;
|
|
75
|
-
createdAt: string;
|
|
76
|
-
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';
|
|
77
|
-
}[];
|
|
78
|
-
};
|
|
79
|
-
type ChatsFavoriteResponse = {
|
|
80
|
-
success: boolean;
|
|
81
|
-
} | {
|
|
82
|
-
error: string;
|
|
83
|
-
success?: any;
|
|
84
|
-
};
|
|
85
|
-
type ChatsUnfavoriteResponse = {
|
|
86
|
-
success: boolean;
|
|
87
|
-
} | {
|
|
88
|
-
error: string;
|
|
89
|
-
success?: any;
|
|
90
|
-
};
|
|
91
|
-
interface ChatsGetProjectResponse {
|
|
92
|
-
project: {
|
|
93
|
-
id: string;
|
|
94
|
-
name: string;
|
|
95
|
-
url: string;
|
|
96
|
-
};
|
|
112
|
+
type ChatsGetByIdResponse = ChatDetail;
|
|
113
|
+
interface ChatsUpdateRequest {
|
|
114
|
+
privacy?: 'public' | 'private' | 'team' | 'team-edit' | 'unlisted';
|
|
97
115
|
}
|
|
116
|
+
type ChatsUpdateResponse = ChatDetail;
|
|
117
|
+
interface ChatsFavoriteRequest {
|
|
118
|
+
isFavorite: boolean;
|
|
119
|
+
}
|
|
120
|
+
interface ChatsFavoriteResponse {
|
|
121
|
+
id: string;
|
|
122
|
+
object: 'chat';
|
|
123
|
+
favorited: boolean;
|
|
124
|
+
}
|
|
125
|
+
interface ChatsForkRequest {
|
|
126
|
+
versionId: string;
|
|
127
|
+
}
|
|
128
|
+
type ChatsForkResponse = ChatDetail;
|
|
129
|
+
type ProjectsGetByChatIdResponse = ProjectDetail;
|
|
98
130
|
interface ChatsCreateMessageRequest {
|
|
99
131
|
message: string;
|
|
100
132
|
attachments?: {
|
|
@@ -106,22 +138,12 @@ interface ChatsCreateMessageRequest {
|
|
|
106
138
|
thinking?: boolean;
|
|
107
139
|
};
|
|
108
140
|
}
|
|
109
|
-
type ChatsCreateMessageResponse =
|
|
110
|
-
|
|
141
|
+
type ChatsCreateMessageResponse = MessageDetail;
|
|
142
|
+
interface ChatsFindIframeResponse {
|
|
143
|
+
id: string;
|
|
144
|
+
object: 'iframe';
|
|
111
145
|
url: string;
|
|
112
|
-
|
|
113
|
-
lang: string;
|
|
114
|
-
meta: Record<string, any>;
|
|
115
|
-
source: string;
|
|
116
|
-
}[];
|
|
117
|
-
demo?: string;
|
|
118
|
-
text: string;
|
|
119
|
-
modelConfiguration: {
|
|
120
|
-
modelId: 'v0-1.5-sm' | 'v0-1.5-md' | 'v0-1.5-lg';
|
|
121
|
-
imageGenerations?: boolean;
|
|
122
|
-
thinking?: boolean;
|
|
123
|
-
};
|
|
124
|
-
};
|
|
146
|
+
}
|
|
125
147
|
interface ChatsGetVersionFrameTokenResponse {
|
|
126
148
|
token: string;
|
|
127
149
|
}
|
|
@@ -139,28 +161,13 @@ interface ChatsGetMetadataResponse {
|
|
|
139
161
|
url: string;
|
|
140
162
|
};
|
|
141
163
|
}
|
|
142
|
-
interface ChatsSetPrivacyRequest {
|
|
143
|
-
privacy: 'public' | 'private' | 'team' | 'team-edit' | 'unlisted';
|
|
144
|
-
}
|
|
145
|
-
type ChatsSetPrivacyResponse = {
|
|
146
|
-
success: 'true';
|
|
147
|
-
} | {
|
|
148
|
-
error: string;
|
|
149
|
-
};
|
|
150
164
|
interface ChatsUploadRequest {
|
|
151
165
|
file: any;
|
|
152
166
|
}
|
|
153
167
|
interface ChatsUploadResponse {
|
|
154
168
|
url: string;
|
|
155
169
|
}
|
|
156
|
-
|
|
157
|
-
message: {
|
|
158
|
-
id: string;
|
|
159
|
-
content: string;
|
|
160
|
-
createdAt: string;
|
|
161
|
-
finishReason?: string;
|
|
162
|
-
};
|
|
163
|
-
}
|
|
170
|
+
type ChatsResumeResponse = MessageDetail;
|
|
164
171
|
interface DeploymentsFindLogsResponse {
|
|
165
172
|
error?: string;
|
|
166
173
|
logs: string[];
|
|
@@ -173,24 +180,17 @@ interface DeploymentsFindErrorsResponse {
|
|
|
173
180
|
formattedError?: string;
|
|
174
181
|
}
|
|
175
182
|
interface IntegrationsVercelProjectsFindResponse {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
name: string;
|
|
179
|
-
url: string;
|
|
180
|
-
}[];
|
|
183
|
+
object: 'list';
|
|
184
|
+
data: VercelProjectDetail[];
|
|
181
185
|
}
|
|
182
186
|
interface IntegrationsVercelProjectsCreateRequest {
|
|
183
187
|
projectId: string;
|
|
184
188
|
name: string;
|
|
185
189
|
}
|
|
186
|
-
|
|
187
|
-
success: boolean;
|
|
188
|
-
}
|
|
190
|
+
type IntegrationsVercelProjectsCreateResponse = VercelProjectDetail;
|
|
189
191
|
interface ProjectsFindResponse {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
url: string;
|
|
193
|
-
env: string[];
|
|
192
|
+
object: 'list';
|
|
193
|
+
data: ProjectDetail[];
|
|
194
194
|
}
|
|
195
195
|
interface ProjectsCreateRequest {
|
|
196
196
|
name: string;
|
|
@@ -202,29 +202,55 @@ interface ProjectsCreateRequest {
|
|
|
202
202
|
}[];
|
|
203
203
|
instructions?: string;
|
|
204
204
|
}
|
|
205
|
-
|
|
206
|
-
id: string;
|
|
207
|
-
name: string;
|
|
208
|
-
vercelProjectId?: string;
|
|
209
|
-
}
|
|
205
|
+
type ProjectsCreateResponse = ProjectDetail;
|
|
210
206
|
interface ProjectsAssignRequest {
|
|
211
207
|
chatId: string;
|
|
212
208
|
}
|
|
213
209
|
interface ProjectsAssignResponse {
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
scopes: ScopeSummary[];
|
|
210
|
+
object: 'project';
|
|
211
|
+
id: string;
|
|
212
|
+
assigned: true;
|
|
218
213
|
}
|
|
219
214
|
interface RateLimitsFindResponse {
|
|
220
215
|
remaining?: number;
|
|
221
216
|
reset?: number;
|
|
222
217
|
limit: number;
|
|
223
218
|
}
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
219
|
+
type UserGetResponse = UserDetail;
|
|
220
|
+
type UserGetBillingResponse = {
|
|
221
|
+
billingType: 'token';
|
|
222
|
+
data: {
|
|
223
|
+
plan: string;
|
|
224
|
+
billingMode?: 'test';
|
|
225
|
+
role: string;
|
|
226
|
+
billingCycle: {
|
|
227
|
+
start: number;
|
|
228
|
+
end: number;
|
|
229
|
+
};
|
|
230
|
+
balance: {
|
|
231
|
+
remaining: number;
|
|
232
|
+
total: number;
|
|
233
|
+
};
|
|
234
|
+
onDemand: {
|
|
235
|
+
balance: number;
|
|
236
|
+
blocks?: {
|
|
237
|
+
expirationDate?: number;
|
|
238
|
+
effectiveDate: number;
|
|
239
|
+
originalBalance: number;
|
|
240
|
+
currentBalance: number;
|
|
241
|
+
}[];
|
|
242
|
+
};
|
|
243
|
+
};
|
|
244
|
+
} | {
|
|
245
|
+
billingType: 'legacy';
|
|
246
|
+
data: {
|
|
247
|
+
remaining?: number;
|
|
248
|
+
reset?: number;
|
|
249
|
+
limit: number;
|
|
250
|
+
};
|
|
251
|
+
};
|
|
227
252
|
interface UserGetPlanResponse {
|
|
253
|
+
object: 'plan';
|
|
228
254
|
plan: string;
|
|
229
255
|
billingCycle: {
|
|
230
256
|
start: number;
|
|
@@ -235,28 +261,40 @@ interface UserGetPlanResponse {
|
|
|
235
261
|
total: number;
|
|
236
262
|
};
|
|
237
263
|
}
|
|
264
|
+
interface UserGetScopesResponse {
|
|
265
|
+
object: 'list';
|
|
266
|
+
data: ScopeSummary[];
|
|
267
|
+
}
|
|
238
268
|
declare const v0: {
|
|
239
269
|
chats: {
|
|
240
270
|
create(params: ChatsCreateRequest): Promise<ChatsCreateResponse>;
|
|
241
|
-
find(
|
|
271
|
+
find(params?: {
|
|
272
|
+
limit?: string;
|
|
273
|
+
offset?: string;
|
|
274
|
+
isFavorite?: string;
|
|
275
|
+
}): Promise<ChatsFindResponse>;
|
|
242
276
|
delete(params: {
|
|
243
277
|
chatId: string;
|
|
244
278
|
}): Promise<ChatsDeleteResponse>;
|
|
245
279
|
getById(params: {
|
|
246
280
|
chatId: string;
|
|
247
281
|
}): Promise<ChatsGetByIdResponse>;
|
|
248
|
-
|
|
282
|
+
update(params: {
|
|
249
283
|
chatId: string;
|
|
250
|
-
}): Promise<
|
|
251
|
-
|
|
284
|
+
} & ChatsUpdateRequest): Promise<ChatsUpdateResponse>;
|
|
285
|
+
favorite(params: {
|
|
252
286
|
chatId: string;
|
|
253
|
-
}): Promise<
|
|
254
|
-
|
|
287
|
+
} & ChatsFavoriteRequest): Promise<ChatsFavoriteResponse>;
|
|
288
|
+
fork(params: {
|
|
255
289
|
chatId: string;
|
|
256
|
-
}): Promise<
|
|
290
|
+
} & ChatsForkRequest): Promise<ChatsForkResponse>;
|
|
257
291
|
createMessage(params: {
|
|
258
292
|
chatId: string;
|
|
259
293
|
} & ChatsCreateMessageRequest): Promise<ChatsCreateMessageResponse>;
|
|
294
|
+
findIframe(params: {
|
|
295
|
+
chatId: string;
|
|
296
|
+
versionId: string;
|
|
297
|
+
}): Promise<ChatsFindIframeResponse>;
|
|
260
298
|
getVersionFrameToken(params: {
|
|
261
299
|
chatId: string;
|
|
262
300
|
versionId: string;
|
|
@@ -264,9 +302,6 @@ declare const v0: {
|
|
|
264
302
|
getMetadata(params: {
|
|
265
303
|
chatId: string;
|
|
266
304
|
}): Promise<ChatsGetMetadataResponse>;
|
|
267
|
-
setPrivacy(params: {
|
|
268
|
-
chatId: string;
|
|
269
|
-
} & ChatsSetPrivacyRequest): Promise<ChatsSetPrivacyResponse>;
|
|
270
305
|
upload(params: {
|
|
271
306
|
chatId: string;
|
|
272
307
|
} & ChatsUploadRequest): Promise<ChatsUploadResponse>;
|
|
@@ -275,9 +310,20 @@ declare const v0: {
|
|
|
275
310
|
messageId: string;
|
|
276
311
|
}): Promise<ChatsResumeResponse>;
|
|
277
312
|
};
|
|
313
|
+
projects: {
|
|
314
|
+
getByChatId(params: {
|
|
315
|
+
chatId: string;
|
|
316
|
+
}): Promise<ProjectsGetByChatIdResponse>;
|
|
317
|
+
find(): Promise<ProjectsFindResponse>;
|
|
318
|
+
create(params: ProjectsCreateRequest): Promise<ProjectsCreateResponse>;
|
|
319
|
+
assign(params: {
|
|
320
|
+
projectId: string;
|
|
321
|
+
} & ProjectsAssignRequest): Promise<ProjectsAssignResponse>;
|
|
322
|
+
};
|
|
278
323
|
deployments: {
|
|
279
324
|
findLogs(params: {
|
|
280
325
|
deploymentId: string;
|
|
326
|
+
since?: string;
|
|
281
327
|
}): Promise<DeploymentsFindLogsResponse>;
|
|
282
328
|
findErrors(params: {
|
|
283
329
|
deploymentId: string;
|
|
@@ -291,22 +337,18 @@ declare const v0: {
|
|
|
291
337
|
};
|
|
292
338
|
};
|
|
293
339
|
};
|
|
294
|
-
projects: {
|
|
295
|
-
find(): Promise<ProjectsFindResponse>;
|
|
296
|
-
create(params: ProjectsCreateRequest): Promise<ProjectsCreateResponse>;
|
|
297
|
-
assign(params: {
|
|
298
|
-
projectId: string;
|
|
299
|
-
} & ProjectsAssignRequest): Promise<ProjectsAssignResponse>;
|
|
300
|
-
};
|
|
301
|
-
scopes: {
|
|
302
|
-
find(): Promise<ScopesFindResponse>;
|
|
303
|
-
};
|
|
304
340
|
rateLimits: {
|
|
305
|
-
find(
|
|
341
|
+
find(params?: {
|
|
342
|
+
scope?: string;
|
|
343
|
+
}): Promise<RateLimitsFindResponse>;
|
|
306
344
|
};
|
|
307
345
|
user: {
|
|
308
346
|
get(): Promise<UserGetResponse>;
|
|
347
|
+
getBilling(params?: {
|
|
348
|
+
scope?: string;
|
|
349
|
+
}): Promise<UserGetBillingResponse>;
|
|
309
350
|
getPlan(): Promise<UserGetPlanResponse>;
|
|
351
|
+
getScopes(): Promise<UserGetScopesResponse>;
|
|
310
352
|
};
|
|
311
353
|
};
|
|
312
354
|
|
package/dist/index.js
CHANGED
|
@@ -8,7 +8,7 @@ async function fetcher(url, method, params = {}) {
|
|
|
8
8
|
}
|
|
9
9
|
const hasBody = method !== 'GET' && params.body;
|
|
10
10
|
const headers = {
|
|
11
|
-
|
|
11
|
+
Authorization: `Bearer ${apiKey}`,
|
|
12
12
|
...params.headers
|
|
13
13
|
};
|
|
14
14
|
if (hasBody) {
|
|
@@ -35,15 +35,24 @@ const v0 = {
|
|
|
35
35
|
system: params.system,
|
|
36
36
|
chatPrivacy: params.chatPrivacy,
|
|
37
37
|
projectId: params.projectId,
|
|
38
|
-
modelConfiguration: params.modelConfiguration
|
|
39
|
-
chatId: params.chatId
|
|
38
|
+
modelConfiguration: params.modelConfiguration
|
|
40
39
|
};
|
|
41
40
|
return fetcher(`/chats`, 'POST', {
|
|
42
41
|
body
|
|
43
42
|
});
|
|
44
43
|
},
|
|
45
|
-
async find () {
|
|
46
|
-
|
|
44
|
+
async find (params) {
|
|
45
|
+
const query = params ? Object.fromEntries(Object.entries({
|
|
46
|
+
limit: params.limit,
|
|
47
|
+
offset: params.offset,
|
|
48
|
+
isFavorite: params.isFavorite
|
|
49
|
+
}).filter(([_, value])=>value !== undefined)) : {};
|
|
50
|
+
const hasQuery = Object.keys(query).length > 0;
|
|
51
|
+
return fetcher(`/chats`, 'GET', {
|
|
52
|
+
...hasQuery ? {
|
|
53
|
+
query
|
|
54
|
+
} : {}
|
|
55
|
+
});
|
|
47
56
|
},
|
|
48
57
|
async delete (params) {
|
|
49
58
|
const pathParams = {
|
|
@@ -59,26 +68,38 @@ const v0 = {
|
|
|
59
68
|
return fetcher(`/chats/${pathParams.chatId}`, 'GET', {
|
|
60
69
|
});
|
|
61
70
|
},
|
|
62
|
-
async
|
|
71
|
+
async update (params) {
|
|
63
72
|
const pathParams = {
|
|
64
73
|
chatId: params.chatId
|
|
65
74
|
};
|
|
66
|
-
|
|
67
|
-
|
|
75
|
+
const body = {
|
|
76
|
+
privacy: params.privacy
|
|
77
|
+
};
|
|
78
|
+
return fetcher(`/chats/${pathParams.chatId}`, 'PATCH', {
|
|
79
|
+
body
|
|
80
|
+
});
|
|
68
81
|
},
|
|
69
|
-
async
|
|
82
|
+
async favorite (params) {
|
|
70
83
|
const pathParams = {
|
|
71
84
|
chatId: params.chatId
|
|
72
85
|
};
|
|
73
|
-
|
|
74
|
-
|
|
86
|
+
const body = {
|
|
87
|
+
isFavorite: params.isFavorite
|
|
88
|
+
};
|
|
89
|
+
return fetcher(`/chats/${pathParams.chatId}/favorite`, 'PUT', {
|
|
90
|
+
body
|
|
91
|
+
});
|
|
75
92
|
},
|
|
76
|
-
async
|
|
93
|
+
async fork (params) {
|
|
77
94
|
const pathParams = {
|
|
78
95
|
chatId: params.chatId
|
|
79
96
|
};
|
|
80
|
-
|
|
81
|
-
|
|
97
|
+
const body = {
|
|
98
|
+
versionId: params.versionId
|
|
99
|
+
};
|
|
100
|
+
return fetcher(`/chats/${pathParams.chatId}/fork`, 'POST', {
|
|
101
|
+
body
|
|
102
|
+
});
|
|
82
103
|
},
|
|
83
104
|
async createMessage (params) {
|
|
84
105
|
const pathParams = {
|
|
@@ -93,6 +114,14 @@ const v0 = {
|
|
|
93
114
|
body
|
|
94
115
|
});
|
|
95
116
|
},
|
|
117
|
+
async findIframe (params) {
|
|
118
|
+
const pathParams = {
|
|
119
|
+
chatId: params.chatId,
|
|
120
|
+
versionId: params.versionId
|
|
121
|
+
};
|
|
122
|
+
return fetcher(`/chats/${pathParams.chatId}/versions/${pathParams.versionId}/iframe`, 'GET', {
|
|
123
|
+
});
|
|
124
|
+
},
|
|
96
125
|
async getVersionFrameToken (params) {
|
|
97
126
|
const pathParams = {
|
|
98
127
|
chatId: params.chatId,
|
|
@@ -108,17 +137,6 @@ const v0 = {
|
|
|
108
137
|
return fetcher(`/chats/${pathParams.chatId}/metadata`, 'GET', {
|
|
109
138
|
});
|
|
110
139
|
},
|
|
111
|
-
async setPrivacy (params) {
|
|
112
|
-
const pathParams = {
|
|
113
|
-
chatId: params.chatId
|
|
114
|
-
};
|
|
115
|
-
const body = {
|
|
116
|
-
privacy: params.privacy
|
|
117
|
-
};
|
|
118
|
-
return fetcher(`/chats/${pathParams.chatId}/privacy`, 'POST', {
|
|
119
|
-
body
|
|
120
|
-
});
|
|
121
|
-
},
|
|
122
140
|
async upload (params) {
|
|
123
141
|
const pathParams = {
|
|
124
142
|
chatId: params.chatId
|
|
@@ -139,41 +157,14 @@ const v0 = {
|
|
|
139
157
|
});
|
|
140
158
|
}
|
|
141
159
|
},
|
|
142
|
-
|
|
143
|
-
async
|
|
160
|
+
projects: {
|
|
161
|
+
async getByChatId (params) {
|
|
144
162
|
const pathParams = {
|
|
145
|
-
|
|
163
|
+
chatId: params.chatId
|
|
146
164
|
};
|
|
147
|
-
return fetcher(`/
|
|
165
|
+
return fetcher(`/chats/${pathParams.chatId}/project`, 'GET', {
|
|
148
166
|
});
|
|
149
167
|
},
|
|
150
|
-
async findErrors (params) {
|
|
151
|
-
const pathParams = {
|
|
152
|
-
deploymentId: params.deploymentId
|
|
153
|
-
};
|
|
154
|
-
return fetcher(`/deployments/${pathParams.deploymentId}/errors`, 'GET', {
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
},
|
|
158
|
-
integrations: {
|
|
159
|
-
vercel: {
|
|
160
|
-
projects: {
|
|
161
|
-
async find () {
|
|
162
|
-
return fetcher(`/integrations/vercel/projects`, 'GET', {});
|
|
163
|
-
},
|
|
164
|
-
async create (params) {
|
|
165
|
-
const body = {
|
|
166
|
-
projectId: params.projectId,
|
|
167
|
-
name: params.name
|
|
168
|
-
};
|
|
169
|
-
return fetcher(`/integrations/vercel/projects`, 'POST', {
|
|
170
|
-
body
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
},
|
|
176
|
-
projects: {
|
|
177
168
|
async find () {
|
|
178
169
|
return fetcher(`/projects`, 'GET', {});
|
|
179
170
|
},
|
|
@@ -201,22 +192,80 @@ const v0 = {
|
|
|
201
192
|
});
|
|
202
193
|
}
|
|
203
194
|
},
|
|
204
|
-
|
|
205
|
-
async
|
|
206
|
-
|
|
195
|
+
deployments: {
|
|
196
|
+
async findLogs (params) {
|
|
197
|
+
const pathParams = {
|
|
198
|
+
deploymentId: params.deploymentId
|
|
199
|
+
};
|
|
200
|
+
const query = Object.fromEntries(Object.entries({
|
|
201
|
+
since: params.since
|
|
202
|
+
}).filter(([_, value])=>value !== undefined));
|
|
203
|
+
const hasQuery = Object.keys(query).length > 0;
|
|
204
|
+
return fetcher(`/deployments/${pathParams.deploymentId}/logs`, 'GET', {
|
|
205
|
+
...hasQuery ? {
|
|
206
|
+
query
|
|
207
|
+
} : {}
|
|
208
|
+
});
|
|
209
|
+
},
|
|
210
|
+
async findErrors (params) {
|
|
211
|
+
const pathParams = {
|
|
212
|
+
deploymentId: params.deploymentId
|
|
213
|
+
};
|
|
214
|
+
return fetcher(`/deployments/${pathParams.deploymentId}/errors`, 'GET', {
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
},
|
|
218
|
+
integrations: {
|
|
219
|
+
vercel: {
|
|
220
|
+
projects: {
|
|
221
|
+
async find () {
|
|
222
|
+
return fetcher(`/integrations/vercel/projects`, 'GET', {});
|
|
223
|
+
},
|
|
224
|
+
async create (params) {
|
|
225
|
+
const body = {
|
|
226
|
+
projectId: params.projectId,
|
|
227
|
+
name: params.name
|
|
228
|
+
};
|
|
229
|
+
return fetcher(`/integrations/vercel/projects`, 'POST', {
|
|
230
|
+
body
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
}
|
|
207
234
|
}
|
|
208
235
|
},
|
|
209
236
|
rateLimits: {
|
|
210
|
-
async find () {
|
|
211
|
-
|
|
237
|
+
async find (params) {
|
|
238
|
+
const query = params ? Object.fromEntries(Object.entries({
|
|
239
|
+
scope: params.scope
|
|
240
|
+
}).filter(([_, value])=>value !== undefined)) : {};
|
|
241
|
+
const hasQuery = Object.keys(query).length > 0;
|
|
242
|
+
return fetcher(`/rate-limits`, 'GET', {
|
|
243
|
+
...hasQuery ? {
|
|
244
|
+
query
|
|
245
|
+
} : {}
|
|
246
|
+
});
|
|
212
247
|
}
|
|
213
248
|
},
|
|
214
249
|
user: {
|
|
215
250
|
async get () {
|
|
216
251
|
return fetcher(`/user`, 'GET', {});
|
|
217
252
|
},
|
|
253
|
+
async getBilling (params) {
|
|
254
|
+
const query = params ? Object.fromEntries(Object.entries({
|
|
255
|
+
scope: params.scope
|
|
256
|
+
}).filter(([_, value])=>value !== undefined)) : {};
|
|
257
|
+
const hasQuery = Object.keys(query).length > 0;
|
|
258
|
+
return fetcher(`/user/billing`, 'GET', {
|
|
259
|
+
...hasQuery ? {
|
|
260
|
+
query
|
|
261
|
+
} : {}
|
|
262
|
+
});
|
|
263
|
+
},
|
|
218
264
|
async getPlan () {
|
|
219
265
|
return fetcher(`/user/plan`, 'GET', {});
|
|
266
|
+
},
|
|
267
|
+
async getScopes () {
|
|
268
|
+
return fetcher(`/user/scopes`, 'GET', {});
|
|
220
269
|
}
|
|
221
270
|
}
|
|
222
271
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "v0-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"description": "TypeScript SDK for the v0 Chats API",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
"type-check": "tsc --noEmit",
|
|
20
20
|
"type-check:go": "tsgo --noEmit",
|
|
21
21
|
"build": "bunchee",
|
|
22
|
-
"generate": "tsx src/scripts/generate.ts",
|
|
22
|
+
"generate": "tsx src/scripts/generate.ts && pnpm format",
|
|
23
|
+
"format": "prettier --write \"**/*.{ts,tsx,md}\"",
|
|
23
24
|
"test": "vitest"
|
|
24
25
|
},
|
|
25
26
|
"keywords": [
|
|
@@ -35,6 +36,7 @@
|
|
|
35
36
|
"@types/node": "22.5.5",
|
|
36
37
|
"@typescript/native-preview": "7.0.0-dev.20250613.1",
|
|
37
38
|
"bunchee": "^6.5.2",
|
|
39
|
+
"prettier": "^3.3.3",
|
|
38
40
|
"tsx": "^4.19.2",
|
|
39
41
|
"typescript": "5.7.3"
|
|
40
42
|
}
|