v0-sdk 0.0.11 → 0.1.0
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 +52 -18
- 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/README.md
CHANGED
|
@@ -4,17 +4,6 @@
|
|
|
4
4
|
|
|
5
5
|
A TypeScript SDK for interacting with the v0 Platform API to create and manage AI-powered chat conversations, projects, integrations, and more.
|
|
6
6
|
|
|
7
|
-
## Features
|
|
8
|
-
|
|
9
|
-
- Full TypeScript support with complete type definitions
|
|
10
|
-
- Chat management - Create, manage, and interact with AI chats
|
|
11
|
-
- Project operations - Create and manage v0 projects
|
|
12
|
-
- Vercel integrations - Seamless Vercel project integration
|
|
13
|
-
- User management - Access user information and billing
|
|
14
|
-
- Deployment logs - Monitor and retrieve deployment information
|
|
15
|
-
- Comprehensive testing - Extensive test coverage for all functions
|
|
16
|
-
- Error handling - Robust error handling with detailed error types
|
|
17
|
-
|
|
18
7
|
## Installation
|
|
19
8
|
|
|
20
9
|
```bash
|
|
@@ -29,6 +18,8 @@ pnpm add v0-sdk
|
|
|
29
18
|
|
|
30
19
|
Get your API key from [v0.dev/chat/settings/keys](https://v0.dev/chat/settings/keys).
|
|
31
20
|
|
|
21
|
+
Set `V0_API_KEY` environment variable.
|
|
22
|
+
|
|
32
23
|
### Create Chat and Generate Code
|
|
33
24
|
|
|
34
25
|
```typescript
|
|
@@ -48,16 +39,50 @@ console.log(`Preview URL: ${chat.demo}`)
|
|
|
48
39
|
const previewHtml = `<iframe src="${chat.demo}" width="100%" height="600px"></iframe>`
|
|
49
40
|
```
|
|
50
41
|
|
|
51
|
-
##
|
|
42
|
+
## Features
|
|
43
|
+
|
|
44
|
+
- Full TypeScript support with complete type definitions
|
|
45
|
+
- Chat management - Create, manage, and interact with AI chats
|
|
46
|
+
- Project operations - Create and manage v0 projects
|
|
47
|
+
- Vercel integrations - Seamless Vercel project integration
|
|
48
|
+
- User management - Access user information and billing
|
|
49
|
+
- Deployment logs - Monitor and retrieve deployment information
|
|
50
|
+
- Comprehensive testing - Extensive test coverage for all functions
|
|
51
|
+
- Error handling - Robust error handling with detailed error types
|
|
52
|
+
|
|
53
|
+
## Configuration
|
|
54
|
+
|
|
55
|
+
The SDK supports two ways to create a client:
|
|
56
|
+
|
|
57
|
+
### Default Client
|
|
58
|
+
|
|
59
|
+
Use the default client with environment variables:
|
|
60
|
+
|
|
61
|
+
```typescript
|
|
62
|
+
import { v0 } from 'v0-sdk'
|
|
63
|
+
|
|
64
|
+
// Uses V0_API_KEY environment variable
|
|
65
|
+
const chat = await v0.chats.create({
|
|
66
|
+
message: 'Create a responsive navbar with Tailwind CSS',
|
|
67
|
+
})
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Custom Client
|
|
52
71
|
|
|
53
|
-
|
|
72
|
+
Create a custom client with specific configuration:
|
|
54
73
|
|
|
55
74
|
```typescript
|
|
56
|
-
|
|
57
|
-
|
|
75
|
+
import { createClient } from 'v0-sdk'
|
|
76
|
+
|
|
77
|
+
// Create client with custom API key
|
|
78
|
+
const v0 = createClient({
|
|
79
|
+
apiKey: process.env.V0_API_KEY_FOR_MY_ORG,
|
|
80
|
+
})
|
|
58
81
|
|
|
59
|
-
//
|
|
60
|
-
|
|
82
|
+
// Use the custom client
|
|
83
|
+
const chat = await v0.chats.create({
|
|
84
|
+
message: 'Create a login form',
|
|
85
|
+
})
|
|
61
86
|
```
|
|
62
87
|
|
|
63
88
|
## API Reference
|
|
@@ -90,7 +115,7 @@ const chat = await v0.chats.getById({ chatId: 'chat_id' })
|
|
|
90
115
|
#### Add Messages to Chat
|
|
91
116
|
|
|
92
117
|
```typescript
|
|
93
|
-
const response = await v0.chats.
|
|
118
|
+
const response = await v0.chats.sendMessage({
|
|
94
119
|
chatId: 'chat_id',
|
|
95
120
|
message: 'Add password strength indicator',
|
|
96
121
|
})
|
|
@@ -163,7 +188,16 @@ import type {
|
|
|
163
188
|
ChatsCreateResponse,
|
|
164
189
|
User,
|
|
165
190
|
Project,
|
|
191
|
+
V0ClientConfig,
|
|
166
192
|
} from 'v0-sdk'
|
|
193
|
+
|
|
194
|
+
// Type-safe client configuration
|
|
195
|
+
const config: V0ClientConfig = {
|
|
196
|
+
apiKey: 'your_api_key',
|
|
197
|
+
baseUrl: 'https://api.v0.dev/v1', // optional
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
const v0 = createClient(config)
|
|
167
201
|
```
|
|
168
202
|
|
|
169
203
|
## Error Handling
|
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;
|