v0-sdk 0.0.11 → 0.0.12
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/dist/index.cjs +259 -225
- package/dist/index.d.ts +102 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +259 -226
- package/package.json +2 -3
package/dist/index.cjs
CHANGED
|
@@ -1,248 +1,282 @@
|
|
|
1
1
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const finalUrl = BASE_URL + url + queryString;
|
|
7
|
-
const apiKey = process.env.V0_API_KEY;
|
|
3
|
+
function createFetcher(config = {}) {
|
|
4
|
+
const baseUrl = config.baseUrl || 'https://api.v0.dev/v1';
|
|
5
|
+
const apiKey = config.apiKey || process.env.V0_API_KEY;
|
|
8
6
|
if (!apiKey) {
|
|
9
|
-
throw new Error('V0_API_KEY environment variable
|
|
7
|
+
throw new Error('API key is required. Provide it via config.apiKey or V0_API_KEY environment variable');
|
|
10
8
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
return async function fetcher(url, method, params = {}) {
|
|
10
|
+
const queryString = params.query ? '?' + new URLSearchParams(params.query).toString() : '';
|
|
11
|
+
const finalUrl = baseUrl + url + queryString;
|
|
12
|
+
const hasBody = method !== 'GET' && params.body;
|
|
13
|
+
const headers = {
|
|
14
|
+
Authorization: `Bearer ${apiKey}`,
|
|
15
|
+
...params.headers
|
|
16
|
+
};
|
|
17
|
+
if (hasBody) {
|
|
18
|
+
headers['Content-Type'] = 'application/json';
|
|
19
|
+
}
|
|
20
|
+
const res = await fetch(finalUrl, {
|
|
21
|
+
method,
|
|
22
|
+
headers,
|
|
23
|
+
body: hasBody ? JSON.stringify(params.body) : undefined
|
|
24
|
+
});
|
|
25
|
+
if (!res.ok) {
|
|
26
|
+
const text = await res.text();
|
|
27
|
+
throw new Error(`HTTP ${res.status}: ${text}`);
|
|
28
|
+
}
|
|
29
|
+
return res.json();
|
|
15
30
|
};
|
|
16
|
-
if (hasBody) {
|
|
17
|
-
headers['Content-Type'] = 'application/json';
|
|
18
|
-
}
|
|
19
|
-
const res = await fetch(finalUrl, {
|
|
20
|
-
method,
|
|
21
|
-
headers,
|
|
22
|
-
body: hasBody ? JSON.stringify(params.body) : undefined
|
|
23
|
-
});
|
|
24
|
-
if (!res.ok) {
|
|
25
|
-
const text = await res.text();
|
|
26
|
-
throw new Error(`HTTP ${res.status}: ${text}`);
|
|
27
|
-
}
|
|
28
|
-
return res.json();
|
|
29
31
|
}
|
|
30
32
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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
|
-
});
|
|
58
|
-
},
|
|
59
|
-
async delete (params) {
|
|
60
|
-
const pathParams = {
|
|
61
|
-
chatId: params.chatId
|
|
62
|
-
};
|
|
63
|
-
return fetcher(`/chats/${pathParams.chatId}`, 'DELETE', {
|
|
33
|
+
function createClient(config = {}) {
|
|
34
|
+
const fetcher = createFetcher(config);
|
|
35
|
+
return {
|
|
36
|
+
chats: {
|
|
37
|
+
async create (params) {
|
|
38
|
+
const body = {
|
|
39
|
+
message: params.message,
|
|
40
|
+
attachments: params.attachments,
|
|
41
|
+
system: params.system,
|
|
42
|
+
chatPrivacy: params.chatPrivacy,
|
|
43
|
+
projectId: params.projectId,
|
|
44
|
+
modelConfiguration: params.modelConfiguration
|
|
45
|
+
};
|
|
46
|
+
return fetcher(`/chats`, 'POST', {
|
|
47
|
+
body
|
|
64
48
|
});
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
49
|
+
},
|
|
50
|
+
async find (params) {
|
|
51
|
+
const query = params ? Object.fromEntries(Object.entries({
|
|
52
|
+
limit: params.limit,
|
|
53
|
+
offset: params.offset,
|
|
54
|
+
isFavorite: params.isFavorite
|
|
55
|
+
}).filter(([_, value])=>value !== undefined)) : {};
|
|
56
|
+
const hasQuery = Object.keys(query).length > 0;
|
|
57
|
+
return fetcher(`/chats`, 'GET', {
|
|
58
|
+
...hasQuery ? {
|
|
59
|
+
query
|
|
60
|
+
} : {}
|
|
71
61
|
});
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
};
|
|
80
|
-
return fetcher(`/chats/${pathParams.chatId}`, 'PATCH', {
|
|
81
|
-
body
|
|
82
|
-
});
|
|
83
|
-
},
|
|
84
|
-
async favorite (params) {
|
|
85
|
-
const pathParams = {
|
|
86
|
-
chatId: params.chatId
|
|
87
|
-
};
|
|
88
|
-
const body = {
|
|
89
|
-
isFavorite: params.isFavorite
|
|
90
|
-
};
|
|
91
|
-
return fetcher(`/chats/${pathParams.chatId}/favorite`, 'PUT', {
|
|
92
|
-
body
|
|
93
|
-
});
|
|
94
|
-
},
|
|
95
|
-
async fork (params) {
|
|
96
|
-
const pathParams = {
|
|
97
|
-
chatId: params.chatId
|
|
98
|
-
};
|
|
99
|
-
const body = {
|
|
100
|
-
versionId: params.versionId
|
|
101
|
-
};
|
|
102
|
-
return fetcher(`/chats/${pathParams.chatId}/fork`, 'POST', {
|
|
103
|
-
body
|
|
104
|
-
});
|
|
105
|
-
},
|
|
106
|
-
async createMessage (params) {
|
|
107
|
-
const pathParams = {
|
|
108
|
-
chatId: params.chatId
|
|
109
|
-
};
|
|
110
|
-
const body = {
|
|
111
|
-
message: params.message,
|
|
112
|
-
attachments: params.attachments,
|
|
113
|
-
modelConfiguration: params.modelConfiguration
|
|
114
|
-
};
|
|
115
|
-
return fetcher(`/chats/${pathParams.chatId}/messages`, 'POST', {
|
|
116
|
-
body
|
|
117
|
-
});
|
|
118
|
-
},
|
|
119
|
-
async getMetadata (params) {
|
|
120
|
-
const pathParams = {
|
|
121
|
-
chatId: params.chatId
|
|
122
|
-
};
|
|
123
|
-
return fetcher(`/chats/${pathParams.chatId}/metadata`, 'GET', {
|
|
62
|
+
},
|
|
63
|
+
async delete (params) {
|
|
64
|
+
const pathParams = {
|
|
65
|
+
chatId: params.chatId
|
|
66
|
+
};
|
|
67
|
+
return fetcher(`/chats/${pathParams.chatId}`, 'DELETE', {
|
|
68
|
+
pathParams
|
|
124
69
|
});
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
70
|
+
},
|
|
71
|
+
async getById (params) {
|
|
72
|
+
const pathParams = {
|
|
73
|
+
chatId: params.chatId
|
|
74
|
+
};
|
|
75
|
+
return fetcher(`/chats/${pathParams.chatId}`, 'GET', {
|
|
76
|
+
pathParams
|
|
132
77
|
});
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
78
|
+
},
|
|
79
|
+
async update (params) {
|
|
80
|
+
const pathParams = {
|
|
81
|
+
chatId: params.chatId
|
|
82
|
+
};
|
|
83
|
+
const body = {
|
|
84
|
+
privacy: params.privacy
|
|
85
|
+
};
|
|
86
|
+
return fetcher(`/chats/${pathParams.chatId}`, 'PATCH', {
|
|
87
|
+
pathParams,
|
|
88
|
+
body
|
|
141
89
|
});
|
|
90
|
+
},
|
|
91
|
+
async favorite (params) {
|
|
92
|
+
const pathParams = {
|
|
93
|
+
chatId: params.chatId
|
|
94
|
+
};
|
|
95
|
+
const body = {
|
|
96
|
+
isFavorite: params.isFavorite
|
|
97
|
+
};
|
|
98
|
+
return fetcher(`/chats/${pathParams.chatId}/favorite`, 'PUT', {
|
|
99
|
+
pathParams,
|
|
100
|
+
body
|
|
101
|
+
});
|
|
102
|
+
},
|
|
103
|
+
async fork (params) {
|
|
104
|
+
const pathParams = {
|
|
105
|
+
chatId: params.chatId
|
|
106
|
+
};
|
|
107
|
+
const body = {
|
|
108
|
+
versionId: params.versionId
|
|
109
|
+
};
|
|
110
|
+
return fetcher(`/chats/${pathParams.chatId}/fork`, 'POST', {
|
|
111
|
+
pathParams,
|
|
112
|
+
body
|
|
113
|
+
});
|
|
114
|
+
},
|
|
115
|
+
async createMessage (params) {
|
|
116
|
+
const pathParams = {
|
|
117
|
+
chatId: params.chatId
|
|
118
|
+
};
|
|
119
|
+
const body = {
|
|
120
|
+
message: params.message,
|
|
121
|
+
attachments: params.attachments,
|
|
122
|
+
modelConfiguration: params.modelConfiguration
|
|
123
|
+
};
|
|
124
|
+
return fetcher(`/chats/${pathParams.chatId}/messages`, 'POST', {
|
|
125
|
+
pathParams,
|
|
126
|
+
body
|
|
127
|
+
});
|
|
128
|
+
},
|
|
129
|
+
async getMetadata (params) {
|
|
130
|
+
const pathParams = {
|
|
131
|
+
chatId: params.chatId
|
|
132
|
+
};
|
|
133
|
+
return fetcher(`/chats/${pathParams.chatId}/metadata`, 'GET', {
|
|
134
|
+
pathParams
|
|
135
|
+
});
|
|
136
|
+
},
|
|
137
|
+
async resume (params) {
|
|
138
|
+
const pathParams = {
|
|
139
|
+
chatId: params.chatId,
|
|
140
|
+
messageId: params.messageId
|
|
141
|
+
};
|
|
142
|
+
return fetcher(`/chats/${pathParams.chatId}/messages/${pathParams.messageId}/resume`, 'POST', {
|
|
143
|
+
pathParams
|
|
144
|
+
});
|
|
145
|
+
}
|
|
142
146
|
},
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
return fetcher(`/deployments/${pathParams.deploymentId}/logs`, 'GET', {
|
|
180
|
-
...hasQuery ? {
|
|
181
|
-
query
|
|
182
|
-
} : {}
|
|
183
|
-
});
|
|
147
|
+
projects: {
|
|
148
|
+
async getByChatId (params) {
|
|
149
|
+
const pathParams = {
|
|
150
|
+
chatId: params.chatId
|
|
151
|
+
};
|
|
152
|
+
return fetcher(`/chats/${pathParams.chatId}/project`, 'GET', {
|
|
153
|
+
pathParams
|
|
154
|
+
});
|
|
155
|
+
},
|
|
156
|
+
async find () {
|
|
157
|
+
return fetcher(`/projects`, 'GET', {});
|
|
158
|
+
},
|
|
159
|
+
async create (params) {
|
|
160
|
+
const body = {
|
|
161
|
+
name: params.name,
|
|
162
|
+
description: params.description,
|
|
163
|
+
icon: params.icon,
|
|
164
|
+
environmentVariables: params.environmentVariables,
|
|
165
|
+
instructions: params.instructions
|
|
166
|
+
};
|
|
167
|
+
return fetcher(`/projects`, 'POST', {
|
|
168
|
+
body
|
|
169
|
+
});
|
|
170
|
+
},
|
|
171
|
+
async assign (params) {
|
|
172
|
+
const pathParams = {
|
|
173
|
+
projectId: params.projectId
|
|
174
|
+
};
|
|
175
|
+
const body = {
|
|
176
|
+
chatId: params.chatId
|
|
177
|
+
};
|
|
178
|
+
return fetcher(`/projects/${pathParams.projectId}/assign`, 'POST', {
|
|
179
|
+
pathParams,
|
|
180
|
+
body
|
|
181
|
+
});
|
|
182
|
+
}
|
|
184
183
|
},
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
184
|
+
deployments: {
|
|
185
|
+
async findLogs (params) {
|
|
186
|
+
const pathParams = {
|
|
187
|
+
deploymentId: params.deploymentId
|
|
188
|
+
};
|
|
189
|
+
const query = Object.fromEntries(Object.entries({
|
|
190
|
+
since: params.since
|
|
191
|
+
}).filter(([_, value])=>value !== undefined));
|
|
192
|
+
const hasQuery = Object.keys(query).length > 0;
|
|
193
|
+
return fetcher(`/deployments/${pathParams.deploymentId}/logs`, 'GET', {
|
|
194
|
+
pathParams,
|
|
195
|
+
...hasQuery ? {
|
|
196
|
+
query
|
|
197
|
+
} : {}
|
|
190
198
|
});
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
}
|
|
199
|
+
},
|
|
200
|
+
async findErrors (params) {
|
|
201
|
+
const pathParams = {
|
|
202
|
+
deploymentId: params.deploymentId
|
|
203
|
+
};
|
|
204
|
+
return fetcher(`/deployments/${pathParams.deploymentId}/errors`, 'GET', {
|
|
205
|
+
pathParams
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
},
|
|
209
|
+
integrations: {
|
|
210
|
+
vercel: {
|
|
211
|
+
projects: {
|
|
212
|
+
async find () {
|
|
213
|
+
return fetcher(`/integrations/vercel/projects`, 'GET', {});
|
|
214
|
+
},
|
|
215
|
+
async create (params) {
|
|
216
|
+
const body = {
|
|
217
|
+
projectId: params.projectId,
|
|
218
|
+
name: params.name
|
|
219
|
+
};
|
|
220
|
+
return fetcher(`/integrations/vercel/projects`, 'POST', {
|
|
221
|
+
body
|
|
222
|
+
});
|
|
223
|
+
}
|
|
207
224
|
}
|
|
208
225
|
}
|
|
209
|
-
}
|
|
210
|
-
},
|
|
211
|
-
rateLimits: {
|
|
212
|
-
async find (params) {
|
|
213
|
-
const query = params ? Object.fromEntries(Object.entries({
|
|
214
|
-
scope: params.scope
|
|
215
|
-
}).filter(([_, value])=>value !== undefined)) : {};
|
|
216
|
-
const hasQuery = Object.keys(query).length > 0;
|
|
217
|
-
return fetcher(`/rate-limits`, 'GET', {
|
|
218
|
-
...hasQuery ? {
|
|
219
|
-
query
|
|
220
|
-
} : {}
|
|
221
|
-
});
|
|
222
|
-
}
|
|
223
|
-
},
|
|
224
|
-
user: {
|
|
225
|
-
async get () {
|
|
226
|
-
return fetcher(`/user`, 'GET', {});
|
|
227
226
|
},
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
227
|
+
rateLimits: {
|
|
228
|
+
async find (params) {
|
|
229
|
+
const query = params ? Object.fromEntries(Object.entries({
|
|
230
|
+
scope: params.scope
|
|
231
|
+
}).filter(([_, value])=>value !== undefined)) : {};
|
|
232
|
+
const hasQuery = Object.keys(query).length > 0;
|
|
233
|
+
return fetcher(`/rate-limits`, 'GET', {
|
|
234
|
+
...hasQuery ? {
|
|
235
|
+
query
|
|
236
|
+
} : {}
|
|
237
|
+
});
|
|
238
|
+
}
|
|
238
239
|
},
|
|
239
|
-
|
|
240
|
-
|
|
240
|
+
user: {
|
|
241
|
+
async get () {
|
|
242
|
+
return fetcher(`/user`, 'GET', {});
|
|
243
|
+
},
|
|
244
|
+
async getBilling (params) {
|
|
245
|
+
const query = params ? Object.fromEntries(Object.entries({
|
|
246
|
+
scope: params.scope
|
|
247
|
+
}).filter(([_, value])=>value !== undefined)) : {};
|
|
248
|
+
const hasQuery = Object.keys(query).length > 0;
|
|
249
|
+
return fetcher(`/user/billing`, 'GET', {
|
|
250
|
+
...hasQuery ? {
|
|
251
|
+
query
|
|
252
|
+
} : {}
|
|
253
|
+
});
|
|
254
|
+
},
|
|
255
|
+
async getPlan () {
|
|
256
|
+
return fetcher(`/user/plan`, 'GET', {});
|
|
257
|
+
},
|
|
258
|
+
async getScopes () {
|
|
259
|
+
return fetcher(`/user/scopes`, 'GET', {});
|
|
260
|
+
}
|
|
241
261
|
},
|
|
242
|
-
|
|
243
|
-
|
|
262
|
+
notifications: {
|
|
263
|
+
deviceToken: {
|
|
264
|
+
deviceId: {
|
|
265
|
+
async delete (params) {
|
|
266
|
+
const pathParams = {
|
|
267
|
+
deviceId: params.deviceId
|
|
268
|
+
};
|
|
269
|
+
return fetcher(`/notifications/device-token/${pathParams.deviceId}`, 'DELETE', {
|
|
270
|
+
pathParams
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}
|
|
244
275
|
}
|
|
245
|
-
}
|
|
246
|
-
}
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
// Default client for backward compatibility
|
|
279
|
+
const v0 = createClient();
|
|
247
280
|
|
|
281
|
+
exports.createClient = createClient;
|
|
248
282
|
exports.v0 = v0;
|
package/dist/index.d.ts
CHANGED
|
@@ -258,6 +258,97 @@ interface UserGetScopesResponse {
|
|
|
258
258
|
object: 'list';
|
|
259
259
|
data: ScopeSummary[];
|
|
260
260
|
}
|
|
261
|
+
interface NotificationsDeviceTokenDeviceIdDeleteResponse {
|
|
262
|
+
success: boolean;
|
|
263
|
+
}
|
|
264
|
+
interface V0ClientConfig {
|
|
265
|
+
apiKey?: string;
|
|
266
|
+
baseUrl?: string;
|
|
267
|
+
}
|
|
268
|
+
declare function createClient(config?: V0ClientConfig): {
|
|
269
|
+
chats: {
|
|
270
|
+
create(params: ChatsCreateRequest): Promise<ChatsCreateResponse>;
|
|
271
|
+
find(params?: {
|
|
272
|
+
limit?: string;
|
|
273
|
+
offset?: string;
|
|
274
|
+
isFavorite?: string;
|
|
275
|
+
}): Promise<ChatsFindResponse>;
|
|
276
|
+
delete(params: {
|
|
277
|
+
chatId: string;
|
|
278
|
+
}): Promise<ChatsDeleteResponse>;
|
|
279
|
+
getById(params: {
|
|
280
|
+
chatId: string;
|
|
281
|
+
}): Promise<ChatsGetByIdResponse>;
|
|
282
|
+
update(params: {
|
|
283
|
+
chatId: string;
|
|
284
|
+
} & ChatsUpdateRequest): Promise<ChatsUpdateResponse>;
|
|
285
|
+
favorite(params: {
|
|
286
|
+
chatId: string;
|
|
287
|
+
} & ChatsFavoriteRequest): Promise<ChatsFavoriteResponse>;
|
|
288
|
+
fork(params: {
|
|
289
|
+
chatId: string;
|
|
290
|
+
} & ChatsForkRequest): Promise<ChatsForkResponse>;
|
|
291
|
+
createMessage(params: {
|
|
292
|
+
chatId: string;
|
|
293
|
+
} & ChatsCreateMessageRequest): Promise<ChatsCreateMessageResponse>;
|
|
294
|
+
getMetadata(params: {
|
|
295
|
+
chatId: string;
|
|
296
|
+
}): Promise<ChatsGetMetadataResponse>;
|
|
297
|
+
resume(params: {
|
|
298
|
+
chatId: string;
|
|
299
|
+
messageId: string;
|
|
300
|
+
}): Promise<ChatsResumeResponse>;
|
|
301
|
+
};
|
|
302
|
+
projects: {
|
|
303
|
+
getByChatId(params: {
|
|
304
|
+
chatId: string;
|
|
305
|
+
}): Promise<ProjectsGetByChatIdResponse>;
|
|
306
|
+
find(): Promise<ProjectsFindResponse>;
|
|
307
|
+
create(params: ProjectsCreateRequest): Promise<ProjectsCreateResponse>;
|
|
308
|
+
assign(params: {
|
|
309
|
+
projectId: string;
|
|
310
|
+
} & ProjectsAssignRequest): Promise<ProjectsAssignResponse>;
|
|
311
|
+
};
|
|
312
|
+
deployments: {
|
|
313
|
+
findLogs(params: {
|
|
314
|
+
deploymentId: string;
|
|
315
|
+
since?: string;
|
|
316
|
+
}): Promise<DeploymentsFindLogsResponse>;
|
|
317
|
+
findErrors(params: {
|
|
318
|
+
deploymentId: string;
|
|
319
|
+
}): Promise<DeploymentsFindErrorsResponse>;
|
|
320
|
+
};
|
|
321
|
+
integrations: {
|
|
322
|
+
vercel: {
|
|
323
|
+
projects: {
|
|
324
|
+
find(): Promise<IntegrationsVercelProjectsFindResponse>;
|
|
325
|
+
create(params: IntegrationsVercelProjectsCreateRequest): Promise<IntegrationsVercelProjectsCreateResponse>;
|
|
326
|
+
};
|
|
327
|
+
};
|
|
328
|
+
};
|
|
329
|
+
rateLimits: {
|
|
330
|
+
find(params?: {
|
|
331
|
+
scope?: string;
|
|
332
|
+
}): Promise<RateLimitsFindResponse>;
|
|
333
|
+
};
|
|
334
|
+
user: {
|
|
335
|
+
get(): Promise<UserGetResponse>;
|
|
336
|
+
getBilling(params?: {
|
|
337
|
+
scope?: string;
|
|
338
|
+
}): Promise<UserGetBillingResponse>;
|
|
339
|
+
getPlan(): Promise<UserGetPlanResponse>;
|
|
340
|
+
getScopes(): Promise<UserGetScopesResponse>;
|
|
341
|
+
};
|
|
342
|
+
notifications: {
|
|
343
|
+
deviceToken: {
|
|
344
|
+
deviceId: {
|
|
345
|
+
delete(params: {
|
|
346
|
+
deviceId: string;
|
|
347
|
+
}): Promise<NotificationsDeviceTokenDeviceIdDeleteResponse>;
|
|
348
|
+
};
|
|
349
|
+
};
|
|
350
|
+
};
|
|
351
|
+
};
|
|
261
352
|
declare const v0: {
|
|
262
353
|
chats: {
|
|
263
354
|
create(params: ChatsCreateRequest): Promise<ChatsCreateResponse>;
|
|
@@ -332,7 +423,17 @@ declare const v0: {
|
|
|
332
423
|
getPlan(): Promise<UserGetPlanResponse>;
|
|
333
424
|
getScopes(): Promise<UserGetScopesResponse>;
|
|
334
425
|
};
|
|
426
|
+
notifications: {
|
|
427
|
+
deviceToken: {
|
|
428
|
+
deviceId: {
|
|
429
|
+
delete(params: {
|
|
430
|
+
deviceId: string;
|
|
431
|
+
}): Promise<NotificationsDeviceTokenDeviceIdDeleteResponse>;
|
|
432
|
+
};
|
|
433
|
+
};
|
|
434
|
+
};
|
|
335
435
|
};
|
|
336
436
|
|
|
337
|
-
export { v0 };
|
|
437
|
+
export { createClient, v0 };
|
|
438
|
+
export type { V0ClientConfig };
|
|
338
439
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +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 demo?: 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 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 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 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 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;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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;;"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sources":["../src/sdk/v0.ts"],"sourcesContent":["import { createFetcher } from './core'\n\nexport type ChatDetail = {\n id: string\n object: 'chat'\n url: string\n demo?: 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 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 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 interface NotificationsDeviceTokenDeviceIdDeleteResponse {\n success: boolean\n}\n\nexport interface V0ClientConfig {\n apiKey?: string\n baseUrl?: string\n}\n\nexport function createClient(config: V0ClientConfig = {}) {\n const fetcher = createFetcher(config)\n\n return {\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 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 resume(params: {\n chatId: string\n messageId: string\n }): Promise<ChatsResumeResponse> {\n const pathParams = {\n chatId: params.chatId,\n messageId: params.messageId,\n }\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(\n `/deployments/${pathParams.deploymentId}/errors`,\n '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', {\n ...(hasQuery ? { query } : {}),\n })\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', {\n ...(hasQuery ? { query } : {}),\n })\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 notifications: {\n deviceToken: {\n deviceId: {\n async delete(params: {\n deviceId: string\n }): Promise<NotificationsDeviceTokenDeviceIdDeleteResponse> {\n const pathParams = { deviceId: params.deviceId }\n return fetcher(\n `/notifications/device-token/${pathParams.deviceId}`,\n 'DELETE',\n { pathParams },\n )\n },\n },\n },\n },\n }\n}\n\n// Default client for backward compatibility\nexport const v0 = createClient()\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;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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;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;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;;;"}
|
package/dist/index.js
CHANGED
|
@@ -1,246 +1,279 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
const finalUrl = BASE_URL + url + queryString;
|
|
5
|
-
const apiKey = process.env.V0_API_KEY;
|
|
1
|
+
function createFetcher(config = {}) {
|
|
2
|
+
const baseUrl = config.baseUrl || 'https://api.v0.dev/v1';
|
|
3
|
+
const apiKey = config.apiKey || process.env.V0_API_KEY;
|
|
6
4
|
if (!apiKey) {
|
|
7
|
-
throw new Error('V0_API_KEY environment variable
|
|
5
|
+
throw new Error('API key is required. Provide it via config.apiKey or V0_API_KEY environment variable');
|
|
8
6
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
return async function fetcher(url, method, params = {}) {
|
|
8
|
+
const queryString = params.query ? '?' + new URLSearchParams(params.query).toString() : '';
|
|
9
|
+
const finalUrl = baseUrl + url + queryString;
|
|
10
|
+
const hasBody = method !== 'GET' && params.body;
|
|
11
|
+
const headers = {
|
|
12
|
+
Authorization: `Bearer ${apiKey}`,
|
|
13
|
+
...params.headers
|
|
14
|
+
};
|
|
15
|
+
if (hasBody) {
|
|
16
|
+
headers['Content-Type'] = 'application/json';
|
|
17
|
+
}
|
|
18
|
+
const res = await fetch(finalUrl, {
|
|
19
|
+
method,
|
|
20
|
+
headers,
|
|
21
|
+
body: hasBody ? JSON.stringify(params.body) : undefined
|
|
22
|
+
});
|
|
23
|
+
if (!res.ok) {
|
|
24
|
+
const text = await res.text();
|
|
25
|
+
throw new Error(`HTTP ${res.status}: ${text}`);
|
|
26
|
+
}
|
|
27
|
+
return res.json();
|
|
13
28
|
};
|
|
14
|
-
if (hasBody) {
|
|
15
|
-
headers['Content-Type'] = 'application/json';
|
|
16
|
-
}
|
|
17
|
-
const res = await fetch(finalUrl, {
|
|
18
|
-
method,
|
|
19
|
-
headers,
|
|
20
|
-
body: hasBody ? JSON.stringify(params.body) : undefined
|
|
21
|
-
});
|
|
22
|
-
if (!res.ok) {
|
|
23
|
-
const text = await res.text();
|
|
24
|
-
throw new Error(`HTTP ${res.status}: ${text}`);
|
|
25
|
-
}
|
|
26
|
-
return res.json();
|
|
27
29
|
}
|
|
28
30
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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
|
-
});
|
|
56
|
-
},
|
|
57
|
-
async delete (params) {
|
|
58
|
-
const pathParams = {
|
|
59
|
-
chatId: params.chatId
|
|
60
|
-
};
|
|
61
|
-
return fetcher(`/chats/${pathParams.chatId}`, 'DELETE', {
|
|
31
|
+
function createClient(config = {}) {
|
|
32
|
+
const fetcher = createFetcher(config);
|
|
33
|
+
return {
|
|
34
|
+
chats: {
|
|
35
|
+
async create (params) {
|
|
36
|
+
const body = {
|
|
37
|
+
message: params.message,
|
|
38
|
+
attachments: params.attachments,
|
|
39
|
+
system: params.system,
|
|
40
|
+
chatPrivacy: params.chatPrivacy,
|
|
41
|
+
projectId: params.projectId,
|
|
42
|
+
modelConfiguration: params.modelConfiguration
|
|
43
|
+
};
|
|
44
|
+
return fetcher(`/chats`, 'POST', {
|
|
45
|
+
body
|
|
62
46
|
});
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
47
|
+
},
|
|
48
|
+
async find (params) {
|
|
49
|
+
const query = params ? Object.fromEntries(Object.entries({
|
|
50
|
+
limit: params.limit,
|
|
51
|
+
offset: params.offset,
|
|
52
|
+
isFavorite: params.isFavorite
|
|
53
|
+
}).filter(([_, value])=>value !== undefined)) : {};
|
|
54
|
+
const hasQuery = Object.keys(query).length > 0;
|
|
55
|
+
return fetcher(`/chats`, 'GET', {
|
|
56
|
+
...hasQuery ? {
|
|
57
|
+
query
|
|
58
|
+
} : {}
|
|
69
59
|
});
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
};
|
|
78
|
-
return fetcher(`/chats/${pathParams.chatId}`, 'PATCH', {
|
|
79
|
-
body
|
|
80
|
-
});
|
|
81
|
-
},
|
|
82
|
-
async favorite (params) {
|
|
83
|
-
const pathParams = {
|
|
84
|
-
chatId: params.chatId
|
|
85
|
-
};
|
|
86
|
-
const body = {
|
|
87
|
-
isFavorite: params.isFavorite
|
|
88
|
-
};
|
|
89
|
-
return fetcher(`/chats/${pathParams.chatId}/favorite`, 'PUT', {
|
|
90
|
-
body
|
|
91
|
-
});
|
|
92
|
-
},
|
|
93
|
-
async fork (params) {
|
|
94
|
-
const pathParams = {
|
|
95
|
-
chatId: params.chatId
|
|
96
|
-
};
|
|
97
|
-
const body = {
|
|
98
|
-
versionId: params.versionId
|
|
99
|
-
};
|
|
100
|
-
return fetcher(`/chats/${pathParams.chatId}/fork`, 'POST', {
|
|
101
|
-
body
|
|
102
|
-
});
|
|
103
|
-
},
|
|
104
|
-
async createMessage (params) {
|
|
105
|
-
const pathParams = {
|
|
106
|
-
chatId: params.chatId
|
|
107
|
-
};
|
|
108
|
-
const body = {
|
|
109
|
-
message: params.message,
|
|
110
|
-
attachments: params.attachments,
|
|
111
|
-
modelConfiguration: params.modelConfiguration
|
|
112
|
-
};
|
|
113
|
-
return fetcher(`/chats/${pathParams.chatId}/messages`, 'POST', {
|
|
114
|
-
body
|
|
115
|
-
});
|
|
116
|
-
},
|
|
117
|
-
async getMetadata (params) {
|
|
118
|
-
const pathParams = {
|
|
119
|
-
chatId: params.chatId
|
|
120
|
-
};
|
|
121
|
-
return fetcher(`/chats/${pathParams.chatId}/metadata`, 'GET', {
|
|
60
|
+
},
|
|
61
|
+
async delete (params) {
|
|
62
|
+
const pathParams = {
|
|
63
|
+
chatId: params.chatId
|
|
64
|
+
};
|
|
65
|
+
return fetcher(`/chats/${pathParams.chatId}`, 'DELETE', {
|
|
66
|
+
pathParams
|
|
122
67
|
});
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
68
|
+
},
|
|
69
|
+
async getById (params) {
|
|
70
|
+
const pathParams = {
|
|
71
|
+
chatId: params.chatId
|
|
72
|
+
};
|
|
73
|
+
return fetcher(`/chats/${pathParams.chatId}`, 'GET', {
|
|
74
|
+
pathParams
|
|
130
75
|
});
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
76
|
+
},
|
|
77
|
+
async update (params) {
|
|
78
|
+
const pathParams = {
|
|
79
|
+
chatId: params.chatId
|
|
80
|
+
};
|
|
81
|
+
const body = {
|
|
82
|
+
privacy: params.privacy
|
|
83
|
+
};
|
|
84
|
+
return fetcher(`/chats/${pathParams.chatId}`, 'PATCH', {
|
|
85
|
+
pathParams,
|
|
86
|
+
body
|
|
139
87
|
});
|
|
88
|
+
},
|
|
89
|
+
async favorite (params) {
|
|
90
|
+
const pathParams = {
|
|
91
|
+
chatId: params.chatId
|
|
92
|
+
};
|
|
93
|
+
const body = {
|
|
94
|
+
isFavorite: params.isFavorite
|
|
95
|
+
};
|
|
96
|
+
return fetcher(`/chats/${pathParams.chatId}/favorite`, 'PUT', {
|
|
97
|
+
pathParams,
|
|
98
|
+
body
|
|
99
|
+
});
|
|
100
|
+
},
|
|
101
|
+
async fork (params) {
|
|
102
|
+
const pathParams = {
|
|
103
|
+
chatId: params.chatId
|
|
104
|
+
};
|
|
105
|
+
const body = {
|
|
106
|
+
versionId: params.versionId
|
|
107
|
+
};
|
|
108
|
+
return fetcher(`/chats/${pathParams.chatId}/fork`, 'POST', {
|
|
109
|
+
pathParams,
|
|
110
|
+
body
|
|
111
|
+
});
|
|
112
|
+
},
|
|
113
|
+
async createMessage (params) {
|
|
114
|
+
const pathParams = {
|
|
115
|
+
chatId: params.chatId
|
|
116
|
+
};
|
|
117
|
+
const body = {
|
|
118
|
+
message: params.message,
|
|
119
|
+
attachments: params.attachments,
|
|
120
|
+
modelConfiguration: params.modelConfiguration
|
|
121
|
+
};
|
|
122
|
+
return fetcher(`/chats/${pathParams.chatId}/messages`, 'POST', {
|
|
123
|
+
pathParams,
|
|
124
|
+
body
|
|
125
|
+
});
|
|
126
|
+
},
|
|
127
|
+
async getMetadata (params) {
|
|
128
|
+
const pathParams = {
|
|
129
|
+
chatId: params.chatId
|
|
130
|
+
};
|
|
131
|
+
return fetcher(`/chats/${pathParams.chatId}/metadata`, 'GET', {
|
|
132
|
+
pathParams
|
|
133
|
+
});
|
|
134
|
+
},
|
|
135
|
+
async resume (params) {
|
|
136
|
+
const pathParams = {
|
|
137
|
+
chatId: params.chatId,
|
|
138
|
+
messageId: params.messageId
|
|
139
|
+
};
|
|
140
|
+
return fetcher(`/chats/${pathParams.chatId}/messages/${pathParams.messageId}/resume`, 'POST', {
|
|
141
|
+
pathParams
|
|
142
|
+
});
|
|
143
|
+
}
|
|
140
144
|
},
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
return fetcher(`/deployments/${pathParams.deploymentId}/logs`, 'GET', {
|
|
178
|
-
...hasQuery ? {
|
|
179
|
-
query
|
|
180
|
-
} : {}
|
|
181
|
-
});
|
|
145
|
+
projects: {
|
|
146
|
+
async getByChatId (params) {
|
|
147
|
+
const pathParams = {
|
|
148
|
+
chatId: params.chatId
|
|
149
|
+
};
|
|
150
|
+
return fetcher(`/chats/${pathParams.chatId}/project`, 'GET', {
|
|
151
|
+
pathParams
|
|
152
|
+
});
|
|
153
|
+
},
|
|
154
|
+
async find () {
|
|
155
|
+
return fetcher(`/projects`, 'GET', {});
|
|
156
|
+
},
|
|
157
|
+
async create (params) {
|
|
158
|
+
const body = {
|
|
159
|
+
name: params.name,
|
|
160
|
+
description: params.description,
|
|
161
|
+
icon: params.icon,
|
|
162
|
+
environmentVariables: params.environmentVariables,
|
|
163
|
+
instructions: params.instructions
|
|
164
|
+
};
|
|
165
|
+
return fetcher(`/projects`, 'POST', {
|
|
166
|
+
body
|
|
167
|
+
});
|
|
168
|
+
},
|
|
169
|
+
async assign (params) {
|
|
170
|
+
const pathParams = {
|
|
171
|
+
projectId: params.projectId
|
|
172
|
+
};
|
|
173
|
+
const body = {
|
|
174
|
+
chatId: params.chatId
|
|
175
|
+
};
|
|
176
|
+
return fetcher(`/projects/${pathParams.projectId}/assign`, 'POST', {
|
|
177
|
+
pathParams,
|
|
178
|
+
body
|
|
179
|
+
});
|
|
180
|
+
}
|
|
182
181
|
},
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
182
|
+
deployments: {
|
|
183
|
+
async findLogs (params) {
|
|
184
|
+
const pathParams = {
|
|
185
|
+
deploymentId: params.deploymentId
|
|
186
|
+
};
|
|
187
|
+
const query = Object.fromEntries(Object.entries({
|
|
188
|
+
since: params.since
|
|
189
|
+
}).filter(([_, value])=>value !== undefined));
|
|
190
|
+
const hasQuery = Object.keys(query).length > 0;
|
|
191
|
+
return fetcher(`/deployments/${pathParams.deploymentId}/logs`, 'GET', {
|
|
192
|
+
pathParams,
|
|
193
|
+
...hasQuery ? {
|
|
194
|
+
query
|
|
195
|
+
} : {}
|
|
188
196
|
});
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
}
|
|
197
|
+
},
|
|
198
|
+
async findErrors (params) {
|
|
199
|
+
const pathParams = {
|
|
200
|
+
deploymentId: params.deploymentId
|
|
201
|
+
};
|
|
202
|
+
return fetcher(`/deployments/${pathParams.deploymentId}/errors`, 'GET', {
|
|
203
|
+
pathParams
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
},
|
|
207
|
+
integrations: {
|
|
208
|
+
vercel: {
|
|
209
|
+
projects: {
|
|
210
|
+
async find () {
|
|
211
|
+
return fetcher(`/integrations/vercel/projects`, 'GET', {});
|
|
212
|
+
},
|
|
213
|
+
async create (params) {
|
|
214
|
+
const body = {
|
|
215
|
+
projectId: params.projectId,
|
|
216
|
+
name: params.name
|
|
217
|
+
};
|
|
218
|
+
return fetcher(`/integrations/vercel/projects`, 'POST', {
|
|
219
|
+
body
|
|
220
|
+
});
|
|
221
|
+
}
|
|
205
222
|
}
|
|
206
223
|
}
|
|
207
|
-
}
|
|
208
|
-
},
|
|
209
|
-
rateLimits: {
|
|
210
|
-
async find (params) {
|
|
211
|
-
const query = params ? Object.fromEntries(Object.entries({
|
|
212
|
-
scope: params.scope
|
|
213
|
-
}).filter(([_, value])=>value !== undefined)) : {};
|
|
214
|
-
const hasQuery = Object.keys(query).length > 0;
|
|
215
|
-
return fetcher(`/rate-limits`, 'GET', {
|
|
216
|
-
...hasQuery ? {
|
|
217
|
-
query
|
|
218
|
-
} : {}
|
|
219
|
-
});
|
|
220
|
-
}
|
|
221
|
-
},
|
|
222
|
-
user: {
|
|
223
|
-
async get () {
|
|
224
|
-
return fetcher(`/user`, 'GET', {});
|
|
225
224
|
},
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
225
|
+
rateLimits: {
|
|
226
|
+
async find (params) {
|
|
227
|
+
const query = params ? Object.fromEntries(Object.entries({
|
|
228
|
+
scope: params.scope
|
|
229
|
+
}).filter(([_, value])=>value !== undefined)) : {};
|
|
230
|
+
const hasQuery = Object.keys(query).length > 0;
|
|
231
|
+
return fetcher(`/rate-limits`, 'GET', {
|
|
232
|
+
...hasQuery ? {
|
|
233
|
+
query
|
|
234
|
+
} : {}
|
|
235
|
+
});
|
|
236
|
+
}
|
|
236
237
|
},
|
|
237
|
-
|
|
238
|
-
|
|
238
|
+
user: {
|
|
239
|
+
async get () {
|
|
240
|
+
return fetcher(`/user`, 'GET', {});
|
|
241
|
+
},
|
|
242
|
+
async getBilling (params) {
|
|
243
|
+
const query = params ? Object.fromEntries(Object.entries({
|
|
244
|
+
scope: params.scope
|
|
245
|
+
}).filter(([_, value])=>value !== undefined)) : {};
|
|
246
|
+
const hasQuery = Object.keys(query).length > 0;
|
|
247
|
+
return fetcher(`/user/billing`, 'GET', {
|
|
248
|
+
...hasQuery ? {
|
|
249
|
+
query
|
|
250
|
+
} : {}
|
|
251
|
+
});
|
|
252
|
+
},
|
|
253
|
+
async getPlan () {
|
|
254
|
+
return fetcher(`/user/plan`, 'GET', {});
|
|
255
|
+
},
|
|
256
|
+
async getScopes () {
|
|
257
|
+
return fetcher(`/user/scopes`, 'GET', {});
|
|
258
|
+
}
|
|
239
259
|
},
|
|
240
|
-
|
|
241
|
-
|
|
260
|
+
notifications: {
|
|
261
|
+
deviceToken: {
|
|
262
|
+
deviceId: {
|
|
263
|
+
async delete (params) {
|
|
264
|
+
const pathParams = {
|
|
265
|
+
deviceId: params.deviceId
|
|
266
|
+
};
|
|
267
|
+
return fetcher(`/notifications/device-token/${pathParams.deviceId}`, 'DELETE', {
|
|
268
|
+
pathParams
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
}
|
|
242
273
|
}
|
|
243
|
-
}
|
|
244
|
-
}
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
// Default client for backward compatibility
|
|
277
|
+
const v0 = createClient();
|
|
245
278
|
|
|
246
|
-
export { v0 };
|
|
279
|
+
export { createClient, v0 };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "v0-sdk",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "TypeScript SDK for the v0
|
|
3
|
+
"version": "0.0.12",
|
|
4
|
+
"description": "TypeScript SDK for the v0 Platform API",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -30,7 +30,6 @@
|
|
|
30
30
|
"chat",
|
|
31
31
|
"sdk"
|
|
32
32
|
],
|
|
33
|
-
"author": "",
|
|
34
33
|
"license": "MIT",
|
|
35
34
|
"devDependencies": {
|
|
36
35
|
"@types/node": "22.5.5",
|