chub-dev 0.1.0 → 0.1.2-beta.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 +55 -0
- package/bin/chub-mcp +2 -0
- package/dist/airtable/docs/database/javascript/DOC.md +1437 -0
- package/dist/airtable/docs/database/python/DOC.md +1735 -0
- package/dist/amplitude/docs/analytics/javascript/DOC.md +1282 -0
- package/dist/amplitude/docs/analytics/python/DOC.md +1199 -0
- package/dist/anthropic/docs/claude-api/javascript/DOC.md +503 -0
- package/dist/anthropic/docs/claude-api/python/DOC.md +389 -0
- package/dist/asana/docs/tasks/DOC.md +1396 -0
- package/dist/assemblyai/docs/transcription/DOC.md +1043 -0
- package/dist/atlassian/docs/confluence/javascript/DOC.md +1347 -0
- package/dist/atlassian/docs/confluence/python/DOC.md +1604 -0
- package/dist/auth0/docs/identity/javascript/DOC.md +968 -0
- package/dist/auth0/docs/identity/python/DOC.md +1199 -0
- package/dist/aws/docs/s3/javascript/DOC.md +1773 -0
- package/dist/aws/docs/s3/python/DOC.md +1807 -0
- package/dist/binance/docs/trading/javascript/DOC.md +1315 -0
- package/dist/binance/docs/trading/python/DOC.md +1454 -0
- package/dist/braintree/docs/gateway/javascript/DOC.md +1278 -0
- package/dist/braintree/docs/gateway/python/DOC.md +1179 -0
- package/dist/chromadb/docs/embeddings-db/javascript/DOC.md +1263 -0
- package/dist/chromadb/docs/embeddings-db/python/DOC.md +1707 -0
- package/dist/clerk/docs/auth/javascript/DOC.md +1220 -0
- package/dist/clerk/docs/auth/python/DOC.md +274 -0
- package/dist/cloudflare/docs/workers/javascript/DOC.md +918 -0
- package/dist/cloudflare/docs/workers/python/DOC.md +994 -0
- package/dist/cockroachdb/docs/distributed-db/DOC.md +1500 -0
- package/dist/cohere/docs/llm/DOC.md +1335 -0
- package/dist/datadog/docs/monitoring/javascript/DOC.md +1740 -0
- package/dist/datadog/docs/monitoring/python/DOC.md +1815 -0
- package/dist/deepgram/docs/speech/javascript/DOC.md +885 -0
- package/dist/deepgram/docs/speech/python/DOC.md +685 -0
- package/dist/deepl/docs/translation/javascript/DOC.md +887 -0
- package/dist/deepl/docs/translation/python/DOC.md +944 -0
- package/dist/deepseek/docs/llm/DOC.md +1220 -0
- package/dist/directus/docs/headless-cms/javascript/DOC.md +1128 -0
- package/dist/directus/docs/headless-cms/python/DOC.md +1276 -0
- package/dist/discord/docs/bot/javascript/DOC.md +1090 -0
- package/dist/discord/docs/bot/python/DOC.md +1130 -0
- package/dist/elasticsearch/docs/search/DOC.md +1634 -0
- package/dist/elevenlabs/docs/text-to-speech/javascript/DOC.md +336 -0
- package/dist/elevenlabs/docs/text-to-speech/python/DOC.md +552 -0
- package/dist/firebase/docs/auth/DOC.md +1015 -0
- package/dist/gemini/docs/genai/javascript/DOC.md +691 -0
- package/dist/gemini/docs/genai/python/DOC.md +555 -0
- package/dist/github/docs/octokit/DOC.md +1560 -0
- package/dist/google/docs/bigquery/javascript/DOC.md +1688 -0
- package/dist/google/docs/bigquery/python/DOC.md +1503 -0
- package/dist/hubspot/docs/crm/javascript/DOC.md +1805 -0
- package/dist/hubspot/docs/crm/python/DOC.md +2033 -0
- package/dist/huggingface/docs/transformers/DOC.md +948 -0
- package/dist/intercom/docs/messaging/javascript/DOC.md +1844 -0
- package/dist/intercom/docs/messaging/python/DOC.md +1797 -0
- package/dist/jira/docs/issues/javascript/DOC.md +1420 -0
- package/dist/jira/docs/issues/python/DOC.md +1492 -0
- package/dist/kafka/docs/streaming/javascript/DOC.md +1671 -0
- package/dist/kafka/docs/streaming/python/DOC.md +1464 -0
- package/dist/landingai-ade/docs/api/DOC.md +620 -0
- package/dist/landingai-ade/docs/sdk/python/DOC.md +489 -0
- package/dist/landingai-ade/docs/sdk/typescript/DOC.md +542 -0
- package/dist/landingai-ade/skills/SKILL.md +489 -0
- package/dist/launchdarkly/docs/feature-flags/javascript/DOC.md +1191 -0
- package/dist/launchdarkly/docs/feature-flags/python/DOC.md +1671 -0
- package/dist/linear/docs/tracker/DOC.md +1554 -0
- package/dist/livekit/docs/realtime/javascript/DOC.md +303 -0
- package/dist/livekit/docs/realtime/python/DOC.md +163 -0
- package/dist/mailchimp/docs/marketing/DOC.md +1420 -0
- package/dist/meilisearch/docs/search/DOC.md +1241 -0
- package/dist/microsoft/docs/onedrive/javascript/DOC.md +1421 -0
- package/dist/microsoft/docs/onedrive/python/DOC.md +1549 -0
- package/dist/mongodb/docs/atlas/DOC.md +2041 -0
- package/dist/notion/docs/workspace-api/javascript/DOC.md +1435 -0
- package/dist/notion/docs/workspace-api/python/DOC.md +1400 -0
- package/dist/okta/docs/identity/javascript/DOC.md +1171 -0
- package/dist/okta/docs/identity/python/DOC.md +1401 -0
- package/dist/openai/docs/chat/javascript/DOC.md +407 -0
- package/dist/openai/docs/chat/python/DOC.md +568 -0
- package/dist/paypal/docs/checkout/DOC.md +278 -0
- package/dist/pinecone/docs/sdk/javascript/DOC.md +984 -0
- package/dist/pinecone/docs/sdk/python/DOC.md +1395 -0
- package/dist/plaid/docs/banking/javascript/DOC.md +1163 -0
- package/dist/plaid/docs/banking/python/DOC.md +1203 -0
- package/dist/playwright-community/skills/login-flows/SKILL.md +108 -0
- package/dist/postmark/docs/transactional-email/DOC.md +1168 -0
- package/dist/prisma/docs/orm/javascript/DOC.md +1419 -0
- package/dist/prisma/docs/orm/python/DOC.md +1317 -0
- package/dist/qdrant/docs/vector-search/javascript/DOC.md +1221 -0
- package/dist/qdrant/docs/vector-search/python/DOC.md +1653 -0
- package/dist/rabbitmq/docs/message-queue/javascript/DOC.md +1193 -0
- package/dist/rabbitmq/docs/message-queue/python/DOC.md +1243 -0
- package/dist/razorpay/docs/payments/javascript/DOC.md +1219 -0
- package/dist/razorpay/docs/payments/python/DOC.md +1330 -0
- package/dist/redis/docs/key-value/javascript/DOC.md +1851 -0
- package/dist/redis/docs/key-value/python/DOC.md +2054 -0
- package/dist/registry.json +2817 -0
- package/dist/replicate/docs/model-hosting/DOC.md +1318 -0
- package/dist/resend/docs/email/DOC.md +1271 -0
- package/dist/salesforce/docs/crm/javascript/DOC.md +1241 -0
- package/dist/salesforce/docs/crm/python/DOC.md +1183 -0
- package/dist/search-index.json +1 -0
- package/dist/sendgrid/docs/email-api/javascript/DOC.md +371 -0
- package/dist/sendgrid/docs/email-api/python/DOC.md +656 -0
- package/dist/sentry/docs/error-tracking/javascript/DOC.md +1073 -0
- package/dist/sentry/docs/error-tracking/python/DOC.md +1309 -0
- package/dist/shopify/docs/storefront/DOC.md +457 -0
- package/dist/slack/docs/workspace/javascript/DOC.md +933 -0
- package/dist/slack/docs/workspace/python/DOC.md +271 -0
- package/dist/square/docs/payments/javascript/DOC.md +1855 -0
- package/dist/square/docs/payments/python/DOC.md +1728 -0
- package/dist/stripe/docs/api/DOC.md +1727 -0
- package/dist/stripe/docs/payments/DOC.md +1726 -0
- package/dist/stytch/docs/auth/javascript/DOC.md +1813 -0
- package/dist/stytch/docs/auth/python/DOC.md +1962 -0
- package/dist/supabase/docs/client/DOC.md +1606 -0
- package/dist/twilio/docs/messaging/python/DOC.md +469 -0
- package/dist/twilio/docs/messaging/typescript/DOC.md +946 -0
- package/dist/vercel/docs/platform/DOC.md +1940 -0
- package/dist/weaviate/docs/vector-db/javascript/DOC.md +1268 -0
- package/dist/weaviate/docs/vector-db/python/DOC.md +1388 -0
- package/dist/zendesk/docs/support/javascript/DOC.md +2150 -0
- package/dist/zendesk/docs/support/python/DOC.md +2297 -0
- package/package.json +22 -6
- package/skills/get-api-docs/SKILL.md +84 -0
- package/src/commands/annotate.js +83 -0
- package/src/commands/build.js +12 -1
- package/src/commands/feedback.js +150 -0
- package/src/commands/get.js +83 -42
- package/src/commands/search.js +7 -0
- package/src/index.js +43 -17
- package/src/lib/analytics.js +90 -0
- package/src/lib/annotations.js +57 -0
- package/src/lib/bm25.js +170 -0
- package/src/lib/cache.js +69 -6
- package/src/lib/config.js +8 -3
- package/src/lib/identity.js +99 -0
- package/src/lib/registry.js +103 -20
- package/src/lib/telemetry.js +86 -0
- package/src/mcp/server.js +177 -0
- package/src/mcp/tools.js +251 -0
|
@@ -0,0 +1,1940 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: platform
|
|
3
|
+
description: "Vercel SDK for deploying, managing, and interacting with the Vercel platform via its official JavaScript/TypeScript API."
|
|
4
|
+
metadata:
|
|
5
|
+
languages: "javascript"
|
|
6
|
+
versions: "1.16.0"
|
|
7
|
+
updated-on: "2026-03-01"
|
|
8
|
+
source: maintainer
|
|
9
|
+
tags: "vercel,deployment,platform,serverless,edge"
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# Vercel SDK JavaScript/TypeScript Coding Guidelines
|
|
13
|
+
|
|
14
|
+
You are a Vercel API coding expert. Help me with writing code using the Vercel API calling the official libraries and SDKs.
|
|
15
|
+
|
|
16
|
+
You can find the official SDK documentation and code samples here:
|
|
17
|
+
https://vercel.com/docs/rest-api/reference/sdk
|
|
18
|
+
|
|
19
|
+
## Golden Rule: Use the Correct and Current SDK
|
|
20
|
+
|
|
21
|
+
Always use the Vercel SDK to interact with the Vercel platform, which is the official library for all Vercel API interactions. Do not use legacy libraries or unofficial SDKs.
|
|
22
|
+
|
|
23
|
+
- **Library Name:** Vercel SDK
|
|
24
|
+
- **NPM Package:** `@vercel/sdk`
|
|
25
|
+
- **Legacy Libraries**: Other unofficial packages are not recommended
|
|
26
|
+
|
|
27
|
+
**Installation:**
|
|
28
|
+
|
|
29
|
+
- **Correct:** `npm install @vercel/sdk`
|
|
30
|
+
- **Correct:** `pnpm add @vercel/sdk`
|
|
31
|
+
- **Correct:** `yarn add @vercel/sdk`
|
|
32
|
+
|
|
33
|
+
**APIs and Usage:**
|
|
34
|
+
|
|
35
|
+
- **Correct:** `import { Vercel } from '@vercel/sdk'`
|
|
36
|
+
- **Correct:** `const vercel = new Vercel({ bearerToken: '...' })`
|
|
37
|
+
- **Correct:** `await vercel.deployments.getDeployments(...)`
|
|
38
|
+
- **Correct:** `await vercel.projects.updateProject(...)`
|
|
39
|
+
- **Incorrect:** `VercelClient` or `VercelAPI`
|
|
40
|
+
- **Incorrect:** Using unofficial REST API wrappers
|
|
41
|
+
|
|
42
|
+
**Important Notes:**
|
|
43
|
+
|
|
44
|
+
- This SDK is in beta, and there may be breaking changes between versions without a major version update
|
|
45
|
+
- Recommend pinning usage to a specific package version
|
|
46
|
+
- This is an ES Module (ESM) only package
|
|
47
|
+
- CommonJS users should use `await import("@vercel/sdk")`
|
|
48
|
+
|
|
49
|
+
## Initialization and API Key
|
|
50
|
+
|
|
51
|
+
The `@vercel/sdk` library requires creating a `Vercel` instance for all API calls.
|
|
52
|
+
|
|
53
|
+
- Always use `const vercel = new Vercel({ bearerToken: '...' })` to create an instance
|
|
54
|
+
- Set the `VERCEL_TOKEN` or `VERCEL_BEARER_TOKEN` environment variable, which will be picked up automatically
|
|
55
|
+
- Access tokens must be created in the Vercel dashboard with appropriate scopes
|
|
56
|
+
|
|
57
|
+
```javascript
|
|
58
|
+
import { Vercel } from '@vercel/sdk';
|
|
59
|
+
|
|
60
|
+
// Uses environment variable if bearerToken not specified
|
|
61
|
+
const vercel = new Vercel({
|
|
62
|
+
bearerToken: process.env.VERCEL_TOKEN,
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
// Or pass the bearer token directly
|
|
66
|
+
// const vercel = new Vercel({ bearerToken: 'your_token_here' });
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Creating Access Tokens
|
|
70
|
+
|
|
71
|
+
1. Navigate to your Vercel account settings
|
|
72
|
+
2. Go to the Tokens section
|
|
73
|
+
3. Create a new token with the required scopes
|
|
74
|
+
4. Optionally scope the token to specific teams
|
|
75
|
+
5. Store the token securely as `VERCEL_TOKEN` environment variable
|
|
76
|
+
|
|
77
|
+
```javascript
|
|
78
|
+
// Example .env file
|
|
79
|
+
VERCEL_TOKEN=your_access_token_here
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Common Authentication Errors
|
|
83
|
+
|
|
84
|
+
Permission errors (403) may occur due to:
|
|
85
|
+
|
|
86
|
+
- **Expired tokens** - Verify expiration dates in your dashboard
|
|
87
|
+
- **Insufficient scope access** - Ensure the token has appropriate team or account-level permissions
|
|
88
|
+
- **Feature unavailability** - Some features like AccessGroups require Enterprise plans
|
|
89
|
+
|
|
90
|
+
## Working with Teams
|
|
91
|
+
|
|
92
|
+
Many API operations require specifying a team. You can provide team information using either `teamId` or `slug`:
|
|
93
|
+
|
|
94
|
+
```javascript
|
|
95
|
+
// Using team ID
|
|
96
|
+
const result = await vercel.projects.getProjects({
|
|
97
|
+
teamId: 'team_1a2b3c4d5e6f7g8h9i0j1k2l',
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
// Using team slug
|
|
101
|
+
const result = await vercel.projects.getProjects({
|
|
102
|
+
slug: 'my-team-url-slug',
|
|
103
|
+
});
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
To find your team ID:
|
|
107
|
+
|
|
108
|
+
```javascript
|
|
109
|
+
const teams = await vercel.teams.listTeams();
|
|
110
|
+
console.log(teams.teams);
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Deployments
|
|
114
|
+
|
|
115
|
+
The Vercel SDK provides comprehensive deployment management capabilities.
|
|
116
|
+
|
|
117
|
+
### Listing Deployments
|
|
118
|
+
|
|
119
|
+
```javascript
|
|
120
|
+
import { Vercel } from '@vercel/sdk';
|
|
121
|
+
|
|
122
|
+
const vercel = new Vercel({
|
|
123
|
+
bearerToken: process.env.VERCEL_TOKEN,
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
async function listDeployments() {
|
|
127
|
+
const result = await vercel.deployments.getDeployments({
|
|
128
|
+
limit: 10,
|
|
129
|
+
teamId: 'team_1a2b3c4d5e6f7g8h9i0j1k2l',
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
console.log(result.deployments);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
listDeployments();
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### Filter Deployments by Target
|
|
139
|
+
|
|
140
|
+
```javascript
|
|
141
|
+
const result = await vercel.deployments.getDeployments({
|
|
142
|
+
limit: 20,
|
|
143
|
+
target: 'production',
|
|
144
|
+
teamId: 'team_1a2b3c4d5e6f7g8h9i0j1k2l',
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
console.log(result.deployments);
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### Filter Deployments by Project
|
|
151
|
+
|
|
152
|
+
```javascript
|
|
153
|
+
const result = await vercel.deployments.getDeployments({
|
|
154
|
+
projectId: 'prj_12HKQaOmR5t5Uy6vdcQsNIiZgHGB',
|
|
155
|
+
teamId: 'team_1a2b3c4d5e6f7g8h9i0j1k2l',
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
console.log(result.deployments);
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### Get a Single Deployment
|
|
162
|
+
|
|
163
|
+
```javascript
|
|
164
|
+
async function getDeployment(deploymentId) {
|
|
165
|
+
const result = await vercel.deployments.getDeployment({
|
|
166
|
+
idOrUrl: deploymentId,
|
|
167
|
+
teamId: 'team_1a2b3c4d5e6f7g8h9i0j1k2l',
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
console.log(result);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
getDeployment('dpl_abc123xyz');
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### Cancel a Deployment
|
|
177
|
+
|
|
178
|
+
```javascript
|
|
179
|
+
async function cancelDeployment(deploymentId) {
|
|
180
|
+
const result = await vercel.deployments.cancelDeployment({
|
|
181
|
+
id: deploymentId,
|
|
182
|
+
teamId: 'team_1a2b3c4d5e6f7g8h9i0j1k2l',
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
console.log('Deployment cancelled:', result);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
cancelDeployment('dpl_abc123xyz');
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### Delete a Deployment
|
|
192
|
+
|
|
193
|
+
```javascript
|
|
194
|
+
async function deleteDeployment(deploymentId) {
|
|
195
|
+
const result = await vercel.deployments.deleteDeployment({
|
|
196
|
+
id: deploymentId,
|
|
197
|
+
teamId: 'team_1a2b3c4d5e6f7g8h9i0j1k2l',
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
console.log('Deployment deleted:', result);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
deleteDeployment('dpl_abc123xyz');
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
### Upload Files for Deployment
|
|
207
|
+
|
|
208
|
+
Before creating a deployment, you need to upload the required files:
|
|
209
|
+
|
|
210
|
+
```javascript
|
|
211
|
+
import { Vercel } from '@vercel/sdk';
|
|
212
|
+
import fs from 'fs';
|
|
213
|
+
|
|
214
|
+
const vercel = new Vercel({
|
|
215
|
+
bearerToken: process.env.VERCEL_TOKEN,
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
async function uploadFile() {
|
|
219
|
+
const fileContent = fs.readFileSync('./index.html', 'utf-8');
|
|
220
|
+
|
|
221
|
+
const result = await vercel.deployments.uploadFile({
|
|
222
|
+
teamId: 'team_1a2b3c4d5e6f7g8h9i0j1k2l',
|
|
223
|
+
requestBody: {
|
|
224
|
+
file: fileContent,
|
|
225
|
+
},
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
console.log('File hash:', result);
|
|
229
|
+
return result;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
uploadFile();
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
### Create a Deployment
|
|
236
|
+
|
|
237
|
+
```javascript
|
|
238
|
+
async function createDeployment() {
|
|
239
|
+
// First upload files (as shown above), then create deployment
|
|
240
|
+
const deployment = await vercel.deployments.createDeployment({
|
|
241
|
+
teamId: 'team_1a2b3c4d5e6f7g8h9i0j1k2l',
|
|
242
|
+
requestBody: {
|
|
243
|
+
name: 'my-project',
|
|
244
|
+
files: [
|
|
245
|
+
{
|
|
246
|
+
file: 'index.html',
|
|
247
|
+
sha: 'file_sha_from_upload',
|
|
248
|
+
size: 1234,
|
|
249
|
+
},
|
|
250
|
+
],
|
|
251
|
+
target: 'production',
|
|
252
|
+
},
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
console.log('Deployment created:', deployment);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
createDeployment();
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
### Get Deployment Files
|
|
262
|
+
|
|
263
|
+
```javascript
|
|
264
|
+
async function getDeploymentFiles(deploymentId) {
|
|
265
|
+
const result = await vercel.deployments.getDeploymentFiles({
|
|
266
|
+
idOrUrl: deploymentId,
|
|
267
|
+
teamId: 'team_1a2b3c4d5e6f7g8h9i0j1k2l',
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
console.log(result.files);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
getDeploymentFiles('dpl_abc123xyz');
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
### Get Deployment File Contents
|
|
277
|
+
|
|
278
|
+
```javascript
|
|
279
|
+
async function getFileContents(deploymentId, fileId) {
|
|
280
|
+
const result = await vercel.deployments.getDeploymentFileContents({
|
|
281
|
+
idOrUrl: deploymentId,
|
|
282
|
+
fileId: fileId,
|
|
283
|
+
teamId: 'team_1a2b3c4d5e6f7g8h9i0j1k2l',
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
console.log(result);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
getFileContents('dpl_abc123xyz', 'file_abc123');
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
### Get Deployment Events
|
|
293
|
+
|
|
294
|
+
```javascript
|
|
295
|
+
async function getDeploymentEvents(deploymentId) {
|
|
296
|
+
const result = await vercel.deployments.getDeploymentEvents({
|
|
297
|
+
idOrUrl: deploymentId,
|
|
298
|
+
teamId: 'team_1a2b3c4d5e6f7g8h9i0j1k2l',
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
console.log(result);
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
getDeploymentEvents('dpl_abc123xyz');
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
## Projects
|
|
308
|
+
|
|
309
|
+
The SDK provides comprehensive project management capabilities.
|
|
310
|
+
|
|
311
|
+
### List Projects
|
|
312
|
+
|
|
313
|
+
```javascript
|
|
314
|
+
import { Vercel } from '@vercel/sdk';
|
|
315
|
+
|
|
316
|
+
const vercel = new Vercel({
|
|
317
|
+
bearerToken: process.env.VERCEL_TOKEN,
|
|
318
|
+
});
|
|
319
|
+
|
|
320
|
+
async function listProjects() {
|
|
321
|
+
const result = await vercel.projects.getProjects({
|
|
322
|
+
teamId: 'team_1a2b3c4d5e6f7g8h9i0j1k2l',
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
console.log(result.projects);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
listProjects();
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
### Get a Single Project
|
|
332
|
+
|
|
333
|
+
```javascript
|
|
334
|
+
async function getProject(projectName) {
|
|
335
|
+
const result = await vercel.projects.getProject({
|
|
336
|
+
idOrName: projectName,
|
|
337
|
+
teamId: 'team_1a2b3c4d5e6f7g8h9i0j1k2l',
|
|
338
|
+
});
|
|
339
|
+
|
|
340
|
+
console.log(result);
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
getProject('my-project');
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
### Create a Project
|
|
347
|
+
|
|
348
|
+
```javascript
|
|
349
|
+
async function createProject() {
|
|
350
|
+
const result = await vercel.projects.createProject({
|
|
351
|
+
teamId: 'team_1a2b3c4d5e6f7g8h9i0j1k2l',
|
|
352
|
+
requestBody: {
|
|
353
|
+
name: 'my-new-project',
|
|
354
|
+
framework: 'nextjs',
|
|
355
|
+
buildCommand: 'npm run build',
|
|
356
|
+
outputDirectory: '.next',
|
|
357
|
+
installCommand: 'npm install',
|
|
358
|
+
devCommand: 'npm run dev',
|
|
359
|
+
},
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
console.log('Project created:', result);
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
createProject();
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
### Update a Project
|
|
369
|
+
|
|
370
|
+
```javascript
|
|
371
|
+
async function updateProject(projectId) {
|
|
372
|
+
const result = await vercel.projects.updateProject({
|
|
373
|
+
idOrName: projectId,
|
|
374
|
+
teamId: 'team_1a2b3c4d5e6f7g8h9i0j1k2l',
|
|
375
|
+
requestBody: {
|
|
376
|
+
name: 'updated-project-name',
|
|
377
|
+
framework: 'nextjs',
|
|
378
|
+
buildCommand: 'pnpm build',
|
|
379
|
+
},
|
|
380
|
+
});
|
|
381
|
+
|
|
382
|
+
console.log('Project updated:', result);
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
updateProject('prj_12HKQaOmR5t5Uy6vdcQsNIiZgHGB');
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
### Delete a Project
|
|
389
|
+
|
|
390
|
+
```javascript
|
|
391
|
+
async function deleteProject(projectId) {
|
|
392
|
+
const result = await vercel.projects.deleteProject({
|
|
393
|
+
idOrName: projectId,
|
|
394
|
+
teamId: 'team_1a2b3c4d5e6f7g8h9i0j1k2l',
|
|
395
|
+
});
|
|
396
|
+
|
|
397
|
+
console.log('Project deleted:', result);
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
deleteProject('prj_12HKQaOmR5t5Uy6vdcQsNIiZgHGB');
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
### Link Project to Git Repository
|
|
404
|
+
|
|
405
|
+
```javascript
|
|
406
|
+
async function linkGitRepository(projectId) {
|
|
407
|
+
const result = await vercel.projects.updateProject({
|
|
408
|
+
idOrName: projectId,
|
|
409
|
+
teamId: 'team_1a2b3c4d5e6f7g8h9i0j1k2l',
|
|
410
|
+
requestBody: {
|
|
411
|
+
link: {
|
|
412
|
+
type: 'github',
|
|
413
|
+
repo: 'username/repository-name',
|
|
414
|
+
repoId: 123456789,
|
|
415
|
+
gitBranch: 'main',
|
|
416
|
+
},
|
|
417
|
+
},
|
|
418
|
+
});
|
|
419
|
+
|
|
420
|
+
console.log('Git repository linked:', result);
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
linkGitRepository('prj_12HKQaOmR5t5Uy6vdcQsNIiZgHGB');
|
|
424
|
+
```
|
|
425
|
+
|
|
426
|
+
## Domains
|
|
427
|
+
|
|
428
|
+
Manage custom domains for your projects.
|
|
429
|
+
|
|
430
|
+
### Add a Domain to a Project
|
|
431
|
+
|
|
432
|
+
```javascript
|
|
433
|
+
import { Vercel } from '@vercel/sdk';
|
|
434
|
+
|
|
435
|
+
const vercel = new Vercel({
|
|
436
|
+
bearerToken: process.env.VERCEL_TOKEN,
|
|
437
|
+
});
|
|
438
|
+
|
|
439
|
+
async function addDomain(projectId) {
|
|
440
|
+
const result = await vercel.projects.addProjectDomain({
|
|
441
|
+
idOrName: projectId,
|
|
442
|
+
teamId: 'team_1a2b3c4d5e6f7g8h9i0j1k2l',
|
|
443
|
+
requestBody: {
|
|
444
|
+
name: 'www.example.com',
|
|
445
|
+
},
|
|
446
|
+
});
|
|
447
|
+
|
|
448
|
+
console.log('Domain added:', result);
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
addDomain('prj_12HKQaOmR5t5Uy6vdcQsNIiZgHGB');
|
|
452
|
+
```
|
|
453
|
+
|
|
454
|
+
### Add Domain with Redirect
|
|
455
|
+
|
|
456
|
+
```javascript
|
|
457
|
+
async function addDomainWithRedirect(projectId) {
|
|
458
|
+
const result = await vercel.projects.addProjectDomain({
|
|
459
|
+
idOrName: projectId,
|
|
460
|
+
teamId: 'team_1a2b3c4d5e6f7g8h9i0j1k2l',
|
|
461
|
+
requestBody: {
|
|
462
|
+
name: 'www.example.com',
|
|
463
|
+
redirect: 'example.com',
|
|
464
|
+
redirectStatusCode: 308,
|
|
465
|
+
},
|
|
466
|
+
});
|
|
467
|
+
|
|
468
|
+
console.log('Domain added with redirect:', result);
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
addDomainWithRedirect('prj_12HKQaOmR5t5Uy6vdcQsNIiZgHGB');
|
|
472
|
+
```
|
|
473
|
+
|
|
474
|
+
### Add Domain for Specific Git Branch
|
|
475
|
+
|
|
476
|
+
```javascript
|
|
477
|
+
async function addBranchDomain(projectId) {
|
|
478
|
+
const result = await vercel.projects.addProjectDomain({
|
|
479
|
+
idOrName: projectId,
|
|
480
|
+
teamId: 'team_1a2b3c4d5e6f7g8h9i0j1k2l',
|
|
481
|
+
requestBody: {
|
|
482
|
+
name: 'staging.example.com',
|
|
483
|
+
gitBranch: 'staging',
|
|
484
|
+
},
|
|
485
|
+
});
|
|
486
|
+
|
|
487
|
+
console.log('Branch domain added:', result);
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
addBranchDomain('prj_12HKQaOmR5t5Uy6vdcQsNIiZgHGB');
|
|
491
|
+
```
|
|
492
|
+
|
|
493
|
+
### Get Project Domains
|
|
494
|
+
|
|
495
|
+
```javascript
|
|
496
|
+
async function getProjectDomains(projectId) {
|
|
497
|
+
const result = await vercel.projects.getProjectDomains({
|
|
498
|
+
idOrName: projectId,
|
|
499
|
+
teamId: 'team_1a2b3c4d5e6f7g8h9i0j1k2l',
|
|
500
|
+
});
|
|
501
|
+
|
|
502
|
+
console.log(result.domains);
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
getProjectDomains('prj_12HKQaOmR5t5Uy6vdcQsNIiZgHGB');
|
|
506
|
+
```
|
|
507
|
+
|
|
508
|
+
### Update a Project Domain
|
|
509
|
+
|
|
510
|
+
```javascript
|
|
511
|
+
async function updateProjectDomain(projectId, domainName) {
|
|
512
|
+
const result = await vercel.projects.updateProjectDomain({
|
|
513
|
+
idOrName: projectId,
|
|
514
|
+
domain: domainName,
|
|
515
|
+
teamId: 'team_1a2b3c4d5e6f7g8h9i0j1k2l',
|
|
516
|
+
requestBody: {
|
|
517
|
+
redirect: 'new-redirect.com',
|
|
518
|
+
redirectStatusCode: 307,
|
|
519
|
+
},
|
|
520
|
+
});
|
|
521
|
+
|
|
522
|
+
console.log('Domain updated:', result);
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
updateProjectDomain('prj_12HKQaOmR5t5Uy6vdcQsNIiZgHGB', 'www.example.com');
|
|
526
|
+
```
|
|
527
|
+
|
|
528
|
+
### Remove a Domain from a Project
|
|
529
|
+
|
|
530
|
+
```javascript
|
|
531
|
+
async function removeDomain(projectId, domainName) {
|
|
532
|
+
const result = await vercel.projects.removeProjectDomain({
|
|
533
|
+
idOrName: projectId,
|
|
534
|
+
domain: domainName,
|
|
535
|
+
teamId: 'team_1a2b3c4d5e6f7g8h9i0j1k2l',
|
|
536
|
+
});
|
|
537
|
+
|
|
538
|
+
console.log('Domain removed:', result);
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
removeDomain('prj_12HKQaOmR5t5Uy6vdcQsNIiZgHGB', 'www.example.com');
|
|
542
|
+
```
|
|
543
|
+
|
|
544
|
+
### Verify a Project Domain
|
|
545
|
+
|
|
546
|
+
```javascript
|
|
547
|
+
async function verifyDomain(projectId, domainName) {
|
|
548
|
+
const result = await vercel.projects.verifyProjectDomain({
|
|
549
|
+
idOrName: projectId,
|
|
550
|
+
domain: domainName,
|
|
551
|
+
teamId: 'team_1a2b3c4d5e6f7g8h9i0j1k2l',
|
|
552
|
+
});
|
|
553
|
+
|
|
554
|
+
console.log('Domain verification result:', result);
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
verifyDomain('prj_12HKQaOmR5t5Uy6vdcQsNIiZgHGB', 'www.example.com');
|
|
558
|
+
```
|
|
559
|
+
|
|
560
|
+
### List All Domains
|
|
561
|
+
|
|
562
|
+
```javascript
|
|
563
|
+
async function listDomains() {
|
|
564
|
+
const result = await vercel.domains.listDomains({
|
|
565
|
+
teamId: 'team_1a2b3c4d5e6f7g8h9i0j1k2l',
|
|
566
|
+
});
|
|
567
|
+
|
|
568
|
+
console.log(result.domains);
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
listDomains();
|
|
572
|
+
```
|
|
573
|
+
|
|
574
|
+
### Get Domain Information
|
|
575
|
+
|
|
576
|
+
```javascript
|
|
577
|
+
async function getDomain(domainName) {
|
|
578
|
+
const result = await vercel.domains.getDomain({
|
|
579
|
+
domain: domainName,
|
|
580
|
+
teamId: 'team_1a2b3c4d5e6f7g8h9i0j1k2l',
|
|
581
|
+
});
|
|
582
|
+
|
|
583
|
+
console.log(result);
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
getDomain('example.com');
|
|
587
|
+
```
|
|
588
|
+
|
|
589
|
+
### Buy a Domain
|
|
590
|
+
|
|
591
|
+
```javascript
|
|
592
|
+
async function buyDomain() {
|
|
593
|
+
const result = await vercel.domains.createOrTransferDomain({
|
|
594
|
+
teamId: 'team_1a2b3c4d5e6f7g8h9i0j1k2l',
|
|
595
|
+
requestBody: {
|
|
596
|
+
name: 'example.com',
|
|
597
|
+
},
|
|
598
|
+
});
|
|
599
|
+
|
|
600
|
+
console.log('Domain purchased:', result);
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
buyDomain();
|
|
604
|
+
```
|
|
605
|
+
|
|
606
|
+
### Delete a Domain
|
|
607
|
+
|
|
608
|
+
```javascript
|
|
609
|
+
async function deleteDomain(domainName) {
|
|
610
|
+
const result = await vercel.domains.deleteDomain({
|
|
611
|
+
domain: domainName,
|
|
612
|
+
teamId: 'team_1a2b3c4d5e6f7g8h9i0j1k2l',
|
|
613
|
+
});
|
|
614
|
+
|
|
615
|
+
console.log('Domain deleted:', result);
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
deleteDomain('example.com');
|
|
619
|
+
```
|
|
620
|
+
|
|
621
|
+
## DNS Records
|
|
622
|
+
|
|
623
|
+
Manage DNS records for your domains.
|
|
624
|
+
|
|
625
|
+
### Get DNS Records
|
|
626
|
+
|
|
627
|
+
```javascript
|
|
628
|
+
import { Vercel } from '@vercel/sdk';
|
|
629
|
+
|
|
630
|
+
const vercel = new Vercel({
|
|
631
|
+
bearerToken: process.env.VERCEL_TOKEN,
|
|
632
|
+
});
|
|
633
|
+
|
|
634
|
+
async function getDnsRecords(domainName) {
|
|
635
|
+
const result = await vercel.dns.getDnsRecords({
|
|
636
|
+
domain: domainName,
|
|
637
|
+
teamId: 'team_1a2b3c4d5e6f7g8h9i0j1k2l',
|
|
638
|
+
});
|
|
639
|
+
|
|
640
|
+
console.log(result.records);
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
getDnsRecords('example.com');
|
|
644
|
+
```
|
|
645
|
+
|
|
646
|
+
### Create a DNS Record
|
|
647
|
+
|
|
648
|
+
```javascript
|
|
649
|
+
async function createDnsRecord(domainName) {
|
|
650
|
+
const result = await vercel.dns.createDnsRecord({
|
|
651
|
+
domain: domainName,
|
|
652
|
+
teamId: 'team_1a2b3c4d5e6f7g8h9i0j1k2l',
|
|
653
|
+
requestBody: {
|
|
654
|
+
name: 'subdomain',
|
|
655
|
+
type: 'A',
|
|
656
|
+
value: '192.0.2.1',
|
|
657
|
+
ttl: 60,
|
|
658
|
+
},
|
|
659
|
+
});
|
|
660
|
+
|
|
661
|
+
console.log('DNS record created:', result);
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
createDnsRecord('example.com');
|
|
665
|
+
```
|
|
666
|
+
|
|
667
|
+
### Create CNAME Record
|
|
668
|
+
|
|
669
|
+
```javascript
|
|
670
|
+
async function createCnameRecord(domainName) {
|
|
671
|
+
const result = await vercel.dns.createDnsRecord({
|
|
672
|
+
domain: domainName,
|
|
673
|
+
teamId: 'team_1a2b3c4d5e6f7g8h9i0j1k2l',
|
|
674
|
+
requestBody: {
|
|
675
|
+
name: 'www',
|
|
676
|
+
type: 'CNAME',
|
|
677
|
+
value: 'example.com',
|
|
678
|
+
ttl: 60,
|
|
679
|
+
},
|
|
680
|
+
});
|
|
681
|
+
|
|
682
|
+
console.log('CNAME record created:', result);
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
createCnameRecord('example.com');
|
|
686
|
+
```
|
|
687
|
+
|
|
688
|
+
### Create MX Record
|
|
689
|
+
|
|
690
|
+
```javascript
|
|
691
|
+
async function createMxRecord(domainName) {
|
|
692
|
+
const result = await vercel.dns.createDnsRecord({
|
|
693
|
+
domain: domainName,
|
|
694
|
+
teamId: 'team_1a2b3c4d5e6f7g8h9i0j1k2l',
|
|
695
|
+
requestBody: {
|
|
696
|
+
name: '@',
|
|
697
|
+
type: 'MX',
|
|
698
|
+
value: 'mail.example.com',
|
|
699
|
+
mxPriority: 10,
|
|
700
|
+
ttl: 60,
|
|
701
|
+
},
|
|
702
|
+
});
|
|
703
|
+
|
|
704
|
+
console.log('MX record created:', result);
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
createMxRecord('example.com');
|
|
708
|
+
```
|
|
709
|
+
|
|
710
|
+
### Update a DNS Record
|
|
711
|
+
|
|
712
|
+
```javascript
|
|
713
|
+
async function updateDnsRecord(domainName, recordId) {
|
|
714
|
+
const result = await vercel.dns.patchDnsRecord({
|
|
715
|
+
domain: domainName,
|
|
716
|
+
recordId: recordId,
|
|
717
|
+
teamId: 'team_1a2b3c4d5e6f7g8h9i0j1k2l',
|
|
718
|
+
requestBody: {
|
|
719
|
+
value: '192.0.2.2',
|
|
720
|
+
ttl: 120,
|
|
721
|
+
},
|
|
722
|
+
});
|
|
723
|
+
|
|
724
|
+
console.log('DNS record updated:', result);
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
updateDnsRecord('example.com', 'rec_abc123');
|
|
728
|
+
```
|
|
729
|
+
|
|
730
|
+
### Delete a DNS Record
|
|
731
|
+
|
|
732
|
+
```javascript
|
|
733
|
+
async function deleteDnsRecord(domainName, recordId) {
|
|
734
|
+
const result = await vercel.dns.deleteDnsRecord({
|
|
735
|
+
domain: domainName,
|
|
736
|
+
recordId: recordId,
|
|
737
|
+
teamId: 'team_1a2b3c4d5e6f7g8h9i0j1k2l',
|
|
738
|
+
});
|
|
739
|
+
|
|
740
|
+
console.log('DNS record deleted:', result);
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
deleteDnsRecord('example.com', 'rec_abc123');
|
|
744
|
+
```
|
|
745
|
+
|
|
746
|
+
## Environment Variables
|
|
747
|
+
|
|
748
|
+
Manage environment variables for your projects.
|
|
749
|
+
|
|
750
|
+
### Get Project Environment Variables
|
|
751
|
+
|
|
752
|
+
```javascript
|
|
753
|
+
import { Vercel } from '@vercel/sdk';
|
|
754
|
+
|
|
755
|
+
const vercel = new Vercel({
|
|
756
|
+
bearerToken: process.env.VERCEL_TOKEN,
|
|
757
|
+
});
|
|
758
|
+
|
|
759
|
+
async function getEnvVars(projectId) {
|
|
760
|
+
const result = await vercel.projects.getProjectEnvs({
|
|
761
|
+
idOrName: projectId,
|
|
762
|
+
teamId: 'team_1a2b3c4d5e6f7g8h9i0j1k2l',
|
|
763
|
+
});
|
|
764
|
+
|
|
765
|
+
console.log(result.envs);
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
getEnvVars('prj_12HKQaOmR5t5Uy6vdcQsNIiZgHGB');
|
|
769
|
+
```
|
|
770
|
+
|
|
771
|
+
### Create Environment Variables
|
|
772
|
+
|
|
773
|
+
```javascript
|
|
774
|
+
async function createEnvVars(projectId) {
|
|
775
|
+
const result = await vercel.projects.createProjectEnv({
|
|
776
|
+
idOrName: projectId,
|
|
777
|
+
teamId: 'team_1a2b3c4d5e6f7g8h9i0j1k2l',
|
|
778
|
+
upsert: 'true',
|
|
779
|
+
requestBody: [
|
|
780
|
+
{
|
|
781
|
+
key: 'API_KEY',
|
|
782
|
+
value: 'secret_value',
|
|
783
|
+
target: ['production', 'preview'],
|
|
784
|
+
type: 'encrypted',
|
|
785
|
+
},
|
|
786
|
+
{
|
|
787
|
+
key: 'DEBUG',
|
|
788
|
+
value: 'true',
|
|
789
|
+
target: ['development'],
|
|
790
|
+
type: 'plain',
|
|
791
|
+
},
|
|
792
|
+
],
|
|
793
|
+
});
|
|
794
|
+
|
|
795
|
+
console.log('Environment variables created:', result);
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
createEnvVars('prj_12HKQaOmR5t5Uy6vdcQsNIiZgHGB');
|
|
799
|
+
```
|
|
800
|
+
|
|
801
|
+
### Create Encrypted Environment Variable
|
|
802
|
+
|
|
803
|
+
```javascript
|
|
804
|
+
async function createSecretEnvVar(projectId) {
|
|
805
|
+
const result = await vercel.projects.createProjectEnv({
|
|
806
|
+
idOrName: projectId,
|
|
807
|
+
teamId: 'team_1a2b3c4d5e6f7g8h9i0j1k2l',
|
|
808
|
+
requestBody: [
|
|
809
|
+
{
|
|
810
|
+
key: 'DATABASE_URL',
|
|
811
|
+
value: 'postgresql://user:pass@host:5432/db',
|
|
812
|
+
target: ['production'],
|
|
813
|
+
type: 'encrypted',
|
|
814
|
+
},
|
|
815
|
+
],
|
|
816
|
+
});
|
|
817
|
+
|
|
818
|
+
console.log('Secret environment variable created:', result);
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
createSecretEnvVar('prj_12HKQaOmR5t5Uy6vdcQsNIiZgHGB');
|
|
822
|
+
```
|
|
823
|
+
|
|
824
|
+
### Create Multi-Environment Variable
|
|
825
|
+
|
|
826
|
+
```javascript
|
|
827
|
+
async function createMultiEnvVar(projectId) {
|
|
828
|
+
const result = await vercel.projects.createProjectEnv({
|
|
829
|
+
idOrName: projectId,
|
|
830
|
+
teamId: 'team_1a2b3c4d5e6f7g8h9i0j1k2l',
|
|
831
|
+
requestBody: [
|
|
832
|
+
{
|
|
833
|
+
key: 'API_URL',
|
|
834
|
+
value: 'https://api.example.com',
|
|
835
|
+
target: ['production', 'preview', 'development'],
|
|
836
|
+
type: 'plain',
|
|
837
|
+
},
|
|
838
|
+
],
|
|
839
|
+
});
|
|
840
|
+
|
|
841
|
+
console.log('Multi-environment variable created:', result);
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
createMultiEnvVar('prj_12HKQaOmR5t5Uy6vdcQsNIiZgHGB');
|
|
845
|
+
```
|
|
846
|
+
|
|
847
|
+
### Get a Single Environment Variable
|
|
848
|
+
|
|
849
|
+
```javascript
|
|
850
|
+
async function getEnvVar(projectId, envId) {
|
|
851
|
+
const result = await vercel.projects.getProjectEnv({
|
|
852
|
+
idOrName: projectId,
|
|
853
|
+
id: envId,
|
|
854
|
+
teamId: 'team_1a2b3c4d5e6f7g8h9i0j1k2l',
|
|
855
|
+
});
|
|
856
|
+
|
|
857
|
+
console.log(result);
|
|
858
|
+
}
|
|
859
|
+
|
|
860
|
+
getEnvVar('prj_12HKQaOmR5t5Uy6vdcQsNIiZgHGB', 'env_abc123');
|
|
861
|
+
```
|
|
862
|
+
|
|
863
|
+
### Edit an Environment Variable
|
|
864
|
+
|
|
865
|
+
```javascript
|
|
866
|
+
async function editEnvVar(projectId, envId) {
|
|
867
|
+
const result = await vercel.projects.editProjectEnv({
|
|
868
|
+
idOrName: projectId,
|
|
869
|
+
id: envId,
|
|
870
|
+
teamId: 'team_1a2b3c4d5e6f7g8h9i0j1k2l',
|
|
871
|
+
requestBody: {
|
|
872
|
+
value: 'new_value',
|
|
873
|
+
target: ['production', 'preview'],
|
|
874
|
+
},
|
|
875
|
+
});
|
|
876
|
+
|
|
877
|
+
console.log('Environment variable updated:', result);
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
editEnvVar('prj_12HKQaOmR5t5Uy6vdcQsNIiZgHGB', 'env_abc123');
|
|
881
|
+
```
|
|
882
|
+
|
|
883
|
+
### Delete an Environment Variable
|
|
884
|
+
|
|
885
|
+
```javascript
|
|
886
|
+
async function deleteEnvVar(projectId, envId) {
|
|
887
|
+
const result = await vercel.projects.deleteProjectEnv({
|
|
888
|
+
idOrName: projectId,
|
|
889
|
+
id: envId,
|
|
890
|
+
teamId: 'team_1a2b3c4d5e6f7g8h9i0j1k2l',
|
|
891
|
+
});
|
|
892
|
+
|
|
893
|
+
console.log('Environment variable deleted:', result);
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
deleteEnvVar('prj_12HKQaOmR5t5Uy6vdcQsNIiZgHGB', 'env_abc123');
|
|
897
|
+
```
|
|
898
|
+
|
|
899
|
+
## Teams
|
|
900
|
+
|
|
901
|
+
Manage teams and team members.
|
|
902
|
+
|
|
903
|
+
### List Teams
|
|
904
|
+
|
|
905
|
+
```javascript
|
|
906
|
+
import { Vercel } from '@vercel/sdk';
|
|
907
|
+
|
|
908
|
+
const vercel = new Vercel({
|
|
909
|
+
bearerToken: process.env.VERCEL_TOKEN,
|
|
910
|
+
});
|
|
911
|
+
|
|
912
|
+
async function listTeams() {
|
|
913
|
+
const result = await vercel.teams.listTeams();
|
|
914
|
+
console.log(result.teams);
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
listTeams();
|
|
918
|
+
```
|
|
919
|
+
|
|
920
|
+
### Get Team Information
|
|
921
|
+
|
|
922
|
+
```javascript
|
|
923
|
+
async function getTeam(teamId) {
|
|
924
|
+
const result = await vercel.teams.getTeam({
|
|
925
|
+
teamId: teamId,
|
|
926
|
+
});
|
|
927
|
+
|
|
928
|
+
console.log(result);
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
getTeam('team_1a2b3c4d5e6f7g8h9i0j1k2l');
|
|
932
|
+
```
|
|
933
|
+
|
|
934
|
+
### Create a Team
|
|
935
|
+
|
|
936
|
+
```javascript
|
|
937
|
+
async function createTeam() {
|
|
938
|
+
const result = await vercel.teams.createTeam({
|
|
939
|
+
requestBody: {
|
|
940
|
+
name: 'My New Team',
|
|
941
|
+
slug: 'my-new-team',
|
|
942
|
+
},
|
|
943
|
+
});
|
|
944
|
+
|
|
945
|
+
console.log('Team created:', result);
|
|
946
|
+
}
|
|
947
|
+
|
|
948
|
+
createTeam();
|
|
949
|
+
```
|
|
950
|
+
|
|
951
|
+
### Update Team Settings
|
|
952
|
+
|
|
953
|
+
```javascript
|
|
954
|
+
async function updateTeam(teamId) {
|
|
955
|
+
const result = await vercel.teams.updateTeam({
|
|
956
|
+
teamId: teamId,
|
|
957
|
+
requestBody: {
|
|
958
|
+
name: 'Updated Team Name',
|
|
959
|
+
description: 'This is my team description',
|
|
960
|
+
},
|
|
961
|
+
});
|
|
962
|
+
|
|
963
|
+
console.log('Team updated:', result);
|
|
964
|
+
}
|
|
965
|
+
|
|
966
|
+
updateTeam('team_1a2b3c4d5e6f7g8h9i0j1k2l');
|
|
967
|
+
```
|
|
968
|
+
|
|
969
|
+
### Delete a Team
|
|
970
|
+
|
|
971
|
+
```javascript
|
|
972
|
+
async function deleteTeam(teamId) {
|
|
973
|
+
const result = await vercel.teams.deleteTeam({
|
|
974
|
+
teamId: teamId,
|
|
975
|
+
});
|
|
976
|
+
|
|
977
|
+
console.log('Team deleted:', result);
|
|
978
|
+
}
|
|
979
|
+
|
|
980
|
+
deleteTeam('team_1a2b3c4d5e6f7g8h9i0j1k2l');
|
|
981
|
+
```
|
|
982
|
+
|
|
983
|
+
### List Team Members
|
|
984
|
+
|
|
985
|
+
```javascript
|
|
986
|
+
async function listTeamMembers(teamId) {
|
|
987
|
+
const result = await vercel.teams.getTeamMembers({
|
|
988
|
+
teamId: teamId,
|
|
989
|
+
});
|
|
990
|
+
|
|
991
|
+
console.log(result.members);
|
|
992
|
+
}
|
|
993
|
+
|
|
994
|
+
listTeamMembers('team_1a2b3c4d5e6f7g8h9i0j1k2l');
|
|
995
|
+
```
|
|
996
|
+
|
|
997
|
+
### Invite Member to Team
|
|
998
|
+
|
|
999
|
+
```javascript
|
|
1000
|
+
async function inviteTeamMember(teamId) {
|
|
1001
|
+
const result = await vercel.teams.inviteUserToTeam({
|
|
1002
|
+
teamId: teamId,
|
|
1003
|
+
requestBody: {
|
|
1004
|
+
email: 'user@example.com',
|
|
1005
|
+
role: 'MEMBER',
|
|
1006
|
+
},
|
|
1007
|
+
});
|
|
1008
|
+
|
|
1009
|
+
console.log('Team member invited:', result);
|
|
1010
|
+
}
|
|
1011
|
+
|
|
1012
|
+
inviteTeamMember('team_1a2b3c4d5e6f7g8h9i0j1k2l');
|
|
1013
|
+
```
|
|
1014
|
+
|
|
1015
|
+
### Update Team Member Role
|
|
1016
|
+
|
|
1017
|
+
```javascript
|
|
1018
|
+
async function updateMemberRole(teamId, memberId) {
|
|
1019
|
+
const result = await vercel.teams.updateTeamMember({
|
|
1020
|
+
teamId: teamId,
|
|
1021
|
+
memberId: memberId,
|
|
1022
|
+
requestBody: {
|
|
1023
|
+
role: 'OWNER',
|
|
1024
|
+
},
|
|
1025
|
+
});
|
|
1026
|
+
|
|
1027
|
+
console.log('Member role updated:', result);
|
|
1028
|
+
}
|
|
1029
|
+
|
|
1030
|
+
updateMemberRole('team_1a2b3c4d5e6f7g8h9i0j1k2l', 'member_abc123');
|
|
1031
|
+
```
|
|
1032
|
+
|
|
1033
|
+
### Remove Team Member
|
|
1034
|
+
|
|
1035
|
+
```javascript
|
|
1036
|
+
async function removeTeamMember(teamId, memberId) {
|
|
1037
|
+
const result = await vercel.teams.deleteTeamMember({
|
|
1038
|
+
teamId: teamId,
|
|
1039
|
+
memberId: memberId,
|
|
1040
|
+
});
|
|
1041
|
+
|
|
1042
|
+
console.log('Member removed:', result);
|
|
1043
|
+
}
|
|
1044
|
+
|
|
1045
|
+
removeTeamMember('team_1a2b3c4d5e6f7g8h9i0j1k2l', 'member_abc123');
|
|
1046
|
+
```
|
|
1047
|
+
|
|
1048
|
+
## Access Groups (Enterprise)
|
|
1049
|
+
|
|
1050
|
+
Access Groups is an Enterprise-only feature for advanced team management.
|
|
1051
|
+
|
|
1052
|
+
### List Access Groups
|
|
1053
|
+
|
|
1054
|
+
```javascript
|
|
1055
|
+
import { Vercel } from '@vercel/sdk';
|
|
1056
|
+
|
|
1057
|
+
const vercel = new Vercel({
|
|
1058
|
+
bearerToken: process.env.VERCEL_TOKEN,
|
|
1059
|
+
});
|
|
1060
|
+
|
|
1061
|
+
async function listAccessGroups() {
|
|
1062
|
+
const result = await vercel.accessGroups.listAccessGroups({
|
|
1063
|
+
teamId: 'team_1a2b3c4d5e6f7g8h9i0j1k2l',
|
|
1064
|
+
});
|
|
1065
|
+
|
|
1066
|
+
console.log(result.accessGroups);
|
|
1067
|
+
}
|
|
1068
|
+
|
|
1069
|
+
listAccessGroups();
|
|
1070
|
+
```
|
|
1071
|
+
|
|
1072
|
+
### Filter Access Groups by Project
|
|
1073
|
+
|
|
1074
|
+
```javascript
|
|
1075
|
+
async function getProjectAccessGroups(projectId) {
|
|
1076
|
+
const result = await vercel.accessGroups.listAccessGroups({
|
|
1077
|
+
projectId: projectId,
|
|
1078
|
+
teamId: 'team_1a2b3c4d5e6f7g8h9i0j1k2l',
|
|
1079
|
+
});
|
|
1080
|
+
|
|
1081
|
+
console.log(result.accessGroups);
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1084
|
+
getProjectAccessGroups('prj_12HKQaOmR5t5Uy6vdcQsNIiZgHGB');
|
|
1085
|
+
```
|
|
1086
|
+
|
|
1087
|
+
### Search Access Groups
|
|
1088
|
+
|
|
1089
|
+
```javascript
|
|
1090
|
+
async function searchAccessGroups(searchTerm) {
|
|
1091
|
+
const result = await vercel.accessGroups.listAccessGroups({
|
|
1092
|
+
search: searchTerm,
|
|
1093
|
+
teamId: 'team_1a2b3c4d5e6f7g8h9i0j1k2l',
|
|
1094
|
+
});
|
|
1095
|
+
|
|
1096
|
+
console.log(result.accessGroups);
|
|
1097
|
+
}
|
|
1098
|
+
|
|
1099
|
+
searchAccessGroups('engineering');
|
|
1100
|
+
```
|
|
1101
|
+
|
|
1102
|
+
### Create Access Group
|
|
1103
|
+
|
|
1104
|
+
```javascript
|
|
1105
|
+
async function createAccessGroup() {
|
|
1106
|
+
const result = await vercel.accessGroups.createAccessGroup({
|
|
1107
|
+
teamId: 'team_1a2b3c4d5e6f7g8h9i0j1k2l',
|
|
1108
|
+
requestBody: {
|
|
1109
|
+
name: 'Engineering Team',
|
|
1110
|
+
projects: ['prj_abc123', 'prj_def456'],
|
|
1111
|
+
members: ['member_123', 'member_456'],
|
|
1112
|
+
},
|
|
1113
|
+
});
|
|
1114
|
+
|
|
1115
|
+
console.log('Access group created:', result);
|
|
1116
|
+
}
|
|
1117
|
+
|
|
1118
|
+
createAccessGroup();
|
|
1119
|
+
```
|
|
1120
|
+
|
|
1121
|
+
### Update Access Group
|
|
1122
|
+
|
|
1123
|
+
```javascript
|
|
1124
|
+
async function updateAccessGroup(groupId) {
|
|
1125
|
+
const result = await vercel.accessGroups.updateAccessGroup({
|
|
1126
|
+
idOrName: groupId,
|
|
1127
|
+
teamId: 'team_1a2b3c4d5e6f7g8h9i0j1k2l',
|
|
1128
|
+
requestBody: {
|
|
1129
|
+
name: 'Updated Engineering Team',
|
|
1130
|
+
projects: ['prj_abc123', 'prj_def456', 'prj_ghi789'],
|
|
1131
|
+
},
|
|
1132
|
+
});
|
|
1133
|
+
|
|
1134
|
+
console.log('Access group updated:', result);
|
|
1135
|
+
}
|
|
1136
|
+
|
|
1137
|
+
updateAccessGroup('ag_abc123');
|
|
1138
|
+
```
|
|
1139
|
+
|
|
1140
|
+
### Delete Access Group
|
|
1141
|
+
|
|
1142
|
+
```javascript
|
|
1143
|
+
async function deleteAccessGroup(groupId) {
|
|
1144
|
+
const result = await vercel.accessGroups.deleteAccessGroup({
|
|
1145
|
+
idOrName: groupId,
|
|
1146
|
+
teamId: 'team_1a2b3c4d5e6f7g8h9i0j1k2l',
|
|
1147
|
+
});
|
|
1148
|
+
|
|
1149
|
+
console.log('Access group deleted:', result);
|
|
1150
|
+
}
|
|
1151
|
+
|
|
1152
|
+
deleteAccessGroup('ag_abc123');
|
|
1153
|
+
```
|
|
1154
|
+
|
|
1155
|
+
## Webhooks
|
|
1156
|
+
|
|
1157
|
+
Set up webhooks to receive notifications about events in your Vercel projects.
|
|
1158
|
+
|
|
1159
|
+
### List Webhooks
|
|
1160
|
+
|
|
1161
|
+
```javascript
|
|
1162
|
+
import { Vercel } from '@vercel/sdk';
|
|
1163
|
+
|
|
1164
|
+
const vercel = new Vercel({
|
|
1165
|
+
bearerToken: process.env.VERCEL_TOKEN,
|
|
1166
|
+
});
|
|
1167
|
+
|
|
1168
|
+
async function listWebhooks() {
|
|
1169
|
+
const result = await vercel.webhooks.listWebhooks({
|
|
1170
|
+
teamId: 'team_1a2b3c4d5e6f7g8h9i0j1k2l',
|
|
1171
|
+
});
|
|
1172
|
+
|
|
1173
|
+
console.log(result.webhooks);
|
|
1174
|
+
}
|
|
1175
|
+
|
|
1176
|
+
listWebhooks();
|
|
1177
|
+
```
|
|
1178
|
+
|
|
1179
|
+
### Create a Webhook
|
|
1180
|
+
|
|
1181
|
+
```javascript
|
|
1182
|
+
async function createWebhook() {
|
|
1183
|
+
const result = await vercel.webhooks.createWebhook({
|
|
1184
|
+
teamId: 'team_1a2b3c4d5e6f7g8h9i0j1k2l',
|
|
1185
|
+
requestBody: {
|
|
1186
|
+
url: 'https://example.com/webhook',
|
|
1187
|
+
events: ['deployment.created', 'deployment.succeeded'],
|
|
1188
|
+
},
|
|
1189
|
+
});
|
|
1190
|
+
|
|
1191
|
+
console.log('Webhook created:', result);
|
|
1192
|
+
}
|
|
1193
|
+
|
|
1194
|
+
createWebhook();
|
|
1195
|
+
```
|
|
1196
|
+
|
|
1197
|
+
### Create Project-Specific Webhook
|
|
1198
|
+
|
|
1199
|
+
```javascript
|
|
1200
|
+
async function createProjectWebhook(projectId) {
|
|
1201
|
+
const result = await vercel.webhooks.createWebhook({
|
|
1202
|
+
teamId: 'team_1a2b3c4d5e6f7g8h9i0j1k2l',
|
|
1203
|
+
requestBody: {
|
|
1204
|
+
url: 'https://example.com/webhook',
|
|
1205
|
+
events: ['deployment.created', 'deployment.succeeded', 'deployment.failed'],
|
|
1206
|
+
projectIds: [projectId],
|
|
1207
|
+
},
|
|
1208
|
+
});
|
|
1209
|
+
|
|
1210
|
+
console.log('Project webhook created:', result);
|
|
1211
|
+
}
|
|
1212
|
+
|
|
1213
|
+
createProjectWebhook('prj_12HKQaOmR5t5Uy6vdcQsNIiZgHGB');
|
|
1214
|
+
```
|
|
1215
|
+
|
|
1216
|
+
### Get Webhook Details
|
|
1217
|
+
|
|
1218
|
+
```javascript
|
|
1219
|
+
async function getWebhook(webhookId) {
|
|
1220
|
+
const result = await vercel.webhooks.getWebhook({
|
|
1221
|
+
id: webhookId,
|
|
1222
|
+
teamId: 'team_1a2b3c4d5e6f7g8h9i0j1k2l',
|
|
1223
|
+
});
|
|
1224
|
+
|
|
1225
|
+
console.log(result);
|
|
1226
|
+
}
|
|
1227
|
+
|
|
1228
|
+
getWebhook('hook_abc123');
|
|
1229
|
+
```
|
|
1230
|
+
|
|
1231
|
+
### Delete a Webhook
|
|
1232
|
+
|
|
1233
|
+
```javascript
|
|
1234
|
+
async function deleteWebhook(webhookId) {
|
|
1235
|
+
const result = await vercel.webhooks.deleteWebhook({
|
|
1236
|
+
id: webhookId,
|
|
1237
|
+
teamId: 'team_1a2b3c4d5e6f7g8h9i0j1k2l',
|
|
1238
|
+
});
|
|
1239
|
+
|
|
1240
|
+
console.log('Webhook deleted:', result);
|
|
1241
|
+
}
|
|
1242
|
+
|
|
1243
|
+
deleteWebhook('hook_abc123');
|
|
1244
|
+
```
|
|
1245
|
+
|
|
1246
|
+
## Artifacts (Remote Caching)
|
|
1247
|
+
|
|
1248
|
+
Manage artifact caching for build optimization.
|
|
1249
|
+
|
|
1250
|
+
### Record Artifact Cache Events
|
|
1251
|
+
|
|
1252
|
+
```javascript
|
|
1253
|
+
import { Vercel } from '@vercel/sdk';
|
|
1254
|
+
|
|
1255
|
+
const vercel = new Vercel({
|
|
1256
|
+
bearerToken: process.env.VERCEL_TOKEN,
|
|
1257
|
+
});
|
|
1258
|
+
|
|
1259
|
+
async function recordCacheEvents() {
|
|
1260
|
+
const result = await vercel.artifacts.recordEvents({
|
|
1261
|
+
teamId: 'team_1a2b3c4d5e6f7g8h9i0j1k2l',
|
|
1262
|
+
requestBody: [
|
|
1263
|
+
{
|
|
1264
|
+
sessionId: 'session_abc123',
|
|
1265
|
+
source: 'REMOTE',
|
|
1266
|
+
event: 'HIT',
|
|
1267
|
+
hash: 'hash_def456',
|
|
1268
|
+
duration: 123,
|
|
1269
|
+
},
|
|
1270
|
+
{
|
|
1271
|
+
sessionId: 'session_abc123',
|
|
1272
|
+
source: 'LOCAL',
|
|
1273
|
+
event: 'MISS',
|
|
1274
|
+
hash: 'hash_ghi789',
|
|
1275
|
+
duration: 456,
|
|
1276
|
+
},
|
|
1277
|
+
],
|
|
1278
|
+
});
|
|
1279
|
+
|
|
1280
|
+
console.log('Cache events recorded:', result);
|
|
1281
|
+
}
|
|
1282
|
+
|
|
1283
|
+
recordCacheEvents();
|
|
1284
|
+
```
|
|
1285
|
+
|
|
1286
|
+
### Get Artifact Status
|
|
1287
|
+
|
|
1288
|
+
```javascript
|
|
1289
|
+
async function getArtifactStatus(hash) {
|
|
1290
|
+
const result = await vercel.artifacts.artifactExists({
|
|
1291
|
+
hash: hash,
|
|
1292
|
+
teamId: 'team_1a2b3c4d5e6f7g8h9i0j1k2l',
|
|
1293
|
+
});
|
|
1294
|
+
|
|
1295
|
+
console.log('Artifact exists:', result);
|
|
1296
|
+
}
|
|
1297
|
+
|
|
1298
|
+
getArtifactStatus('hash_abc123');
|
|
1299
|
+
```
|
|
1300
|
+
|
|
1301
|
+
### Upload Artifact
|
|
1302
|
+
|
|
1303
|
+
```javascript
|
|
1304
|
+
import fs from 'fs';
|
|
1305
|
+
|
|
1306
|
+
async function uploadArtifact() {
|
|
1307
|
+
const fileContent = fs.readFileSync('./artifact.tar.gz');
|
|
1308
|
+
|
|
1309
|
+
const result = await vercel.artifacts.uploadArtifact({
|
|
1310
|
+
hash: 'hash_abc123',
|
|
1311
|
+
teamId: 'team_1a2b3c4d5e6f7g8h9i0j1k2l',
|
|
1312
|
+
requestBody: fileContent,
|
|
1313
|
+
});
|
|
1314
|
+
|
|
1315
|
+
console.log('Artifact uploaded:', result);
|
|
1316
|
+
}
|
|
1317
|
+
|
|
1318
|
+
uploadArtifact();
|
|
1319
|
+
```
|
|
1320
|
+
|
|
1321
|
+
### Download Artifact
|
|
1322
|
+
|
|
1323
|
+
```javascript
|
|
1324
|
+
async function downloadArtifact(hash) {
|
|
1325
|
+
const result = await vercel.artifacts.downloadArtifact({
|
|
1326
|
+
hash: hash,
|
|
1327
|
+
teamId: 'team_1a2b3c4d5e6f7g8h9i0j1k2l',
|
|
1328
|
+
});
|
|
1329
|
+
|
|
1330
|
+
console.log('Artifact downloaded:', result);
|
|
1331
|
+
}
|
|
1332
|
+
|
|
1333
|
+
downloadArtifact('hash_abc123');
|
|
1334
|
+
```
|
|
1335
|
+
|
|
1336
|
+
## Checks
|
|
1337
|
+
|
|
1338
|
+
Manage deployment checks and integration actions.
|
|
1339
|
+
|
|
1340
|
+
### Get Deployment Checks
|
|
1341
|
+
|
|
1342
|
+
```javascript
|
|
1343
|
+
import { Vercel } from '@vercel/sdk';
|
|
1344
|
+
|
|
1345
|
+
const vercel = new Vercel({
|
|
1346
|
+
bearerToken: process.env.VERCEL_TOKEN,
|
|
1347
|
+
});
|
|
1348
|
+
|
|
1349
|
+
async function getDeploymentChecks(deploymentId) {
|
|
1350
|
+
const result = await vercel.checks.listChecks({
|
|
1351
|
+
deploymentId: deploymentId,
|
|
1352
|
+
teamId: 'team_1a2b3c4d5e6f7g8h9i0j1k2l',
|
|
1353
|
+
});
|
|
1354
|
+
|
|
1355
|
+
console.log(result.checks);
|
|
1356
|
+
}
|
|
1357
|
+
|
|
1358
|
+
getDeploymentChecks('dpl_abc123xyz');
|
|
1359
|
+
```
|
|
1360
|
+
|
|
1361
|
+
### Create a Check
|
|
1362
|
+
|
|
1363
|
+
```javascript
|
|
1364
|
+
async function createCheck(deploymentId) {
|
|
1365
|
+
const result = await vercel.checks.createCheck({
|
|
1366
|
+
deploymentId: deploymentId,
|
|
1367
|
+
teamId: 'team_1a2b3c4d5e6f7g8h9i0j1k2l',
|
|
1368
|
+
requestBody: {
|
|
1369
|
+
name: 'Security Scan',
|
|
1370
|
+
path: '/',
|
|
1371
|
+
status: 'running',
|
|
1372
|
+
blocking: true,
|
|
1373
|
+
},
|
|
1374
|
+
});
|
|
1375
|
+
|
|
1376
|
+
console.log('Check created:', result);
|
|
1377
|
+
}
|
|
1378
|
+
|
|
1379
|
+
createCheck('dpl_abc123xyz');
|
|
1380
|
+
```
|
|
1381
|
+
|
|
1382
|
+
### Update a Check
|
|
1383
|
+
|
|
1384
|
+
```javascript
|
|
1385
|
+
async function updateCheck(deploymentId, checkId) {
|
|
1386
|
+
const result = await vercel.checks.updateCheck({
|
|
1387
|
+
deploymentId: deploymentId,
|
|
1388
|
+
checkId: checkId,
|
|
1389
|
+
teamId: 'team_1a2b3c4d5e6f7g8h9i0j1k2l',
|
|
1390
|
+
requestBody: {
|
|
1391
|
+
status: 'completed',
|
|
1392
|
+
conclusion: 'succeeded',
|
|
1393
|
+
output: {
|
|
1394
|
+
summary: 'Security scan passed',
|
|
1395
|
+
},
|
|
1396
|
+
},
|
|
1397
|
+
});
|
|
1398
|
+
|
|
1399
|
+
console.log('Check updated:', result);
|
|
1400
|
+
}
|
|
1401
|
+
|
|
1402
|
+
updateCheck('dpl_abc123xyz', 'check_abc123');
|
|
1403
|
+
```
|
|
1404
|
+
|
|
1405
|
+
### Rerequest a Check
|
|
1406
|
+
|
|
1407
|
+
```javascript
|
|
1408
|
+
async function rerequestCheck(deploymentId, checkId) {
|
|
1409
|
+
const result = await vercel.checks.rerequestCheck({
|
|
1410
|
+
deploymentId: deploymentId,
|
|
1411
|
+
checkId: checkId,
|
|
1412
|
+
teamId: 'team_1a2b3c4d5e6f7g8h9i0j1k2l',
|
|
1413
|
+
});
|
|
1414
|
+
|
|
1415
|
+
console.log('Check rerequested:', result);
|
|
1416
|
+
}
|
|
1417
|
+
|
|
1418
|
+
rerequestCheck('dpl_abc123xyz', 'check_abc123');
|
|
1419
|
+
```
|
|
1420
|
+
|
|
1421
|
+
## Logs
|
|
1422
|
+
|
|
1423
|
+
Access deployment and build logs.
|
|
1424
|
+
|
|
1425
|
+
### Get Deployment Logs
|
|
1426
|
+
|
|
1427
|
+
```javascript
|
|
1428
|
+
import { Vercel } from '@vercel/sdk';
|
|
1429
|
+
|
|
1430
|
+
const vercel = new Vercel({
|
|
1431
|
+
bearerToken: process.env.VERCEL_TOKEN,
|
|
1432
|
+
});
|
|
1433
|
+
|
|
1434
|
+
async function getDeploymentLogs(deploymentId) {
|
|
1435
|
+
const result = await vercel.logs.getDeploymentLogs({
|
|
1436
|
+
id: deploymentId,
|
|
1437
|
+
teamId: 'team_1a2b3c4d5e6f7g8h9i0j1k2l',
|
|
1438
|
+
});
|
|
1439
|
+
|
|
1440
|
+
console.log(result);
|
|
1441
|
+
}
|
|
1442
|
+
|
|
1443
|
+
getDeploymentLogs('dpl_abc123xyz');
|
|
1444
|
+
```
|
|
1445
|
+
|
|
1446
|
+
### Get Build Logs
|
|
1447
|
+
|
|
1448
|
+
```javascript
|
|
1449
|
+
async function getBuildLogs(deploymentId) {
|
|
1450
|
+
const result = await vercel.logs.getDeploymentLogs({
|
|
1451
|
+
id: deploymentId,
|
|
1452
|
+
teamId: 'team_1a2b3c4d5e6f7g8h9i0j1k2l',
|
|
1453
|
+
direction: 'forward',
|
|
1454
|
+
limit: 100,
|
|
1455
|
+
});
|
|
1456
|
+
|
|
1457
|
+
console.log(result);
|
|
1458
|
+
}
|
|
1459
|
+
|
|
1460
|
+
getBuildLogs('dpl_abc123xyz');
|
|
1461
|
+
```
|
|
1462
|
+
|
|
1463
|
+
### Filter Logs by Time
|
|
1464
|
+
|
|
1465
|
+
```javascript
|
|
1466
|
+
async function getLogsInTimeRange(deploymentId, since, until) {
|
|
1467
|
+
const result = await vercel.logs.getDeploymentLogs({
|
|
1468
|
+
id: deploymentId,
|
|
1469
|
+
teamId: 'team_1a2b3c4d5e6f7g8h9i0j1k2l',
|
|
1470
|
+
since: since,
|
|
1471
|
+
until: until,
|
|
1472
|
+
});
|
|
1473
|
+
|
|
1474
|
+
console.log(result);
|
|
1475
|
+
}
|
|
1476
|
+
|
|
1477
|
+
getLogsInTimeRange('dpl_abc123xyz', 1609459200000, 1609545600000);
|
|
1478
|
+
```
|
|
1479
|
+
|
|
1480
|
+
## Aliases
|
|
1481
|
+
|
|
1482
|
+
Manage deployment aliases.
|
|
1483
|
+
|
|
1484
|
+
### List Aliases
|
|
1485
|
+
|
|
1486
|
+
```javascript
|
|
1487
|
+
import { Vercel } from '@vercel/sdk';
|
|
1488
|
+
|
|
1489
|
+
const vercel = new Vercel({
|
|
1490
|
+
bearerToken: process.env.VERCEL_TOKEN,
|
|
1491
|
+
});
|
|
1492
|
+
|
|
1493
|
+
async function listAliases() {
|
|
1494
|
+
const result = await vercel.aliases.listAliases({
|
|
1495
|
+
teamId: 'team_1a2b3c4d5e6f7g8h9i0j1k2l',
|
|
1496
|
+
});
|
|
1497
|
+
|
|
1498
|
+
console.log(result.aliases);
|
|
1499
|
+
}
|
|
1500
|
+
|
|
1501
|
+
listAliases();
|
|
1502
|
+
```
|
|
1503
|
+
|
|
1504
|
+
### Assign Alias to Deployment
|
|
1505
|
+
|
|
1506
|
+
```javascript
|
|
1507
|
+
async function assignAlias(deploymentId, alias) {
|
|
1508
|
+
const result = await vercel.aliases.assignAlias({
|
|
1509
|
+
teamId: 'team_1a2b3c4d5e6f7g8h9i0j1k2l',
|
|
1510
|
+
requestBody: {
|
|
1511
|
+
alias: alias,
|
|
1512
|
+
deploymentId: deploymentId,
|
|
1513
|
+
},
|
|
1514
|
+
});
|
|
1515
|
+
|
|
1516
|
+
console.log('Alias assigned:', result);
|
|
1517
|
+
}
|
|
1518
|
+
|
|
1519
|
+
assignAlias('dpl_abc123xyz', 'my-app.example.com');
|
|
1520
|
+
```
|
|
1521
|
+
|
|
1522
|
+
### Get Alias Information
|
|
1523
|
+
|
|
1524
|
+
```javascript
|
|
1525
|
+
async function getAlias(aliasId) {
|
|
1526
|
+
const result = await vercel.aliases.getAlias({
|
|
1527
|
+
id: aliasId,
|
|
1528
|
+
teamId: 'team_1a2b3c4d5e6f7g8h9i0j1k2l',
|
|
1529
|
+
});
|
|
1530
|
+
|
|
1531
|
+
console.log(result);
|
|
1532
|
+
}
|
|
1533
|
+
|
|
1534
|
+
getAlias('alias_abc123');
|
|
1535
|
+
```
|
|
1536
|
+
|
|
1537
|
+
### Delete an Alias
|
|
1538
|
+
|
|
1539
|
+
```javascript
|
|
1540
|
+
async function deleteAlias(aliasId) {
|
|
1541
|
+
const result = await vercel.aliases.deleteAlias({
|
|
1542
|
+
id: aliasId,
|
|
1543
|
+
teamId: 'team_1a2b3c4d5e6f7g8h9i0j1k2l',
|
|
1544
|
+
});
|
|
1545
|
+
|
|
1546
|
+
console.log('Alias deleted:', result);
|
|
1547
|
+
}
|
|
1548
|
+
|
|
1549
|
+
deleteAlias('alias_abc123');
|
|
1550
|
+
```
|
|
1551
|
+
|
|
1552
|
+
## Authentication
|
|
1553
|
+
|
|
1554
|
+
Manage authentication tokens and settings.
|
|
1555
|
+
|
|
1556
|
+
### Get Current User
|
|
1557
|
+
|
|
1558
|
+
```javascript
|
|
1559
|
+
import { Vercel } from '@vercel/sdk';
|
|
1560
|
+
|
|
1561
|
+
const vercel = new Vercel({
|
|
1562
|
+
bearerToken: process.env.VERCEL_TOKEN,
|
|
1563
|
+
});
|
|
1564
|
+
|
|
1565
|
+
async function getCurrentUser() {
|
|
1566
|
+
const result = await vercel.user.getAuthUser();
|
|
1567
|
+
console.log(result);
|
|
1568
|
+
}
|
|
1569
|
+
|
|
1570
|
+
getCurrentUser();
|
|
1571
|
+
```
|
|
1572
|
+
|
|
1573
|
+
### List Access Tokens
|
|
1574
|
+
|
|
1575
|
+
```javascript
|
|
1576
|
+
async function listTokens() {
|
|
1577
|
+
const result = await vercel.authentication.listTokens({
|
|
1578
|
+
teamId: 'team_1a2b3c4d5e6f7g8h9i0j1k2l',
|
|
1579
|
+
});
|
|
1580
|
+
|
|
1581
|
+
console.log(result.tokens);
|
|
1582
|
+
}
|
|
1583
|
+
|
|
1584
|
+
listTokens();
|
|
1585
|
+
```
|
|
1586
|
+
|
|
1587
|
+
### Delete an Access Token
|
|
1588
|
+
|
|
1589
|
+
```javascript
|
|
1590
|
+
async function deleteToken(tokenId) {
|
|
1591
|
+
const result = await vercel.authentication.deleteToken({
|
|
1592
|
+
id: tokenId,
|
|
1593
|
+
teamId: 'team_1a2b3c4d5e6f7g8h9i0j1k2l',
|
|
1594
|
+
});
|
|
1595
|
+
|
|
1596
|
+
console.log('Token deleted:', result);
|
|
1597
|
+
}
|
|
1598
|
+
|
|
1599
|
+
deleteToken('token_abc123');
|
|
1600
|
+
```
|
|
1601
|
+
|
|
1602
|
+
## Edge Config
|
|
1603
|
+
|
|
1604
|
+
Manage Edge Config stores for ultra-low latency global data.
|
|
1605
|
+
|
|
1606
|
+
### List Edge Configs
|
|
1607
|
+
|
|
1608
|
+
```javascript
|
|
1609
|
+
import { Vercel } from '@vercel/sdk';
|
|
1610
|
+
|
|
1611
|
+
const vercel = new Vercel({
|
|
1612
|
+
bearerToken: process.env.VERCEL_TOKEN,
|
|
1613
|
+
});
|
|
1614
|
+
|
|
1615
|
+
async function listEdgeConfigs() {
|
|
1616
|
+
const result = await vercel.edgeConfig.getEdgeConfigs({
|
|
1617
|
+
teamId: 'team_1a2b3c4d5e6f7g8h9i0j1k2l',
|
|
1618
|
+
});
|
|
1619
|
+
|
|
1620
|
+
console.log(result.edgeConfigs);
|
|
1621
|
+
}
|
|
1622
|
+
|
|
1623
|
+
listEdgeConfigs();
|
|
1624
|
+
```
|
|
1625
|
+
|
|
1626
|
+
### Create Edge Config
|
|
1627
|
+
|
|
1628
|
+
```javascript
|
|
1629
|
+
async function createEdgeConfig() {
|
|
1630
|
+
const result = await vercel.edgeConfig.createEdgeConfig({
|
|
1631
|
+
teamId: 'team_1a2b3c4d5e6f7g8h9i0j1k2l',
|
|
1632
|
+
requestBody: {
|
|
1633
|
+
name: 'my-edge-config',
|
|
1634
|
+
},
|
|
1635
|
+
});
|
|
1636
|
+
|
|
1637
|
+
console.log('Edge Config created:', result);
|
|
1638
|
+
}
|
|
1639
|
+
|
|
1640
|
+
createEdgeConfig();
|
|
1641
|
+
```
|
|
1642
|
+
|
|
1643
|
+
### Get Edge Config
|
|
1644
|
+
|
|
1645
|
+
```javascript
|
|
1646
|
+
async function getEdgeConfig(edgeConfigId) {
|
|
1647
|
+
const result = await vercel.edgeConfig.getEdgeConfig({
|
|
1648
|
+
edgeConfigId: edgeConfigId,
|
|
1649
|
+
teamId: 'team_1a2b3c4d5e6f7g8h9i0j1k2l',
|
|
1650
|
+
});
|
|
1651
|
+
|
|
1652
|
+
console.log(result);
|
|
1653
|
+
}
|
|
1654
|
+
|
|
1655
|
+
getEdgeConfig('ecfg_abc123');
|
|
1656
|
+
```
|
|
1657
|
+
|
|
1658
|
+
### Update Edge Config Items
|
|
1659
|
+
|
|
1660
|
+
```javascript
|
|
1661
|
+
async function updateEdgeConfigItems(edgeConfigId) {
|
|
1662
|
+
const result = await vercel.edgeConfig.updateEdgeConfigItems({
|
|
1663
|
+
edgeConfigId: edgeConfigId,
|
|
1664
|
+
teamId: 'team_1a2b3c4d5e6f7g8h9i0j1k2l',
|
|
1665
|
+
requestBody: {
|
|
1666
|
+
items: [
|
|
1667
|
+
{
|
|
1668
|
+
operation: 'upsert',
|
|
1669
|
+
key: 'feature_flag_new_ui',
|
|
1670
|
+
value: true,
|
|
1671
|
+
},
|
|
1672
|
+
{
|
|
1673
|
+
operation: 'upsert',
|
|
1674
|
+
key: 'welcome_message',
|
|
1675
|
+
value: 'Hello from Edge Config!',
|
|
1676
|
+
},
|
|
1677
|
+
],
|
|
1678
|
+
},
|
|
1679
|
+
});
|
|
1680
|
+
|
|
1681
|
+
console.log('Edge Config items updated:', result);
|
|
1682
|
+
}
|
|
1683
|
+
|
|
1684
|
+
updateEdgeConfigItems('ecfg_abc123');
|
|
1685
|
+
```
|
|
1686
|
+
|
|
1687
|
+
### Delete Edge Config
|
|
1688
|
+
|
|
1689
|
+
```javascript
|
|
1690
|
+
async function deleteEdgeConfig(edgeConfigId) {
|
|
1691
|
+
const result = await vercel.edgeConfig.deleteEdgeConfig({
|
|
1692
|
+
edgeConfigId: edgeConfigId,
|
|
1693
|
+
teamId: 'team_1a2b3c4d5e6f7g8h9i0j1k2l',
|
|
1694
|
+
});
|
|
1695
|
+
|
|
1696
|
+
console.log('Edge Config deleted:', result);
|
|
1697
|
+
}
|
|
1698
|
+
|
|
1699
|
+
deleteEdgeConfig('ecfg_abc123');
|
|
1700
|
+
```
|
|
1701
|
+
|
|
1702
|
+
## Error Handling
|
|
1703
|
+
|
|
1704
|
+
The SDK provides comprehensive error handling capabilities.
|
|
1705
|
+
|
|
1706
|
+
### Basic Error Handling
|
|
1707
|
+
|
|
1708
|
+
```javascript
|
|
1709
|
+
import { Vercel } from '@vercel/sdk';
|
|
1710
|
+
|
|
1711
|
+
const vercel = new Vercel({
|
|
1712
|
+
bearerToken: process.env.VERCEL_TOKEN,
|
|
1713
|
+
});
|
|
1714
|
+
|
|
1715
|
+
try {
|
|
1716
|
+
const result = await vercel.projects.getProject({
|
|
1717
|
+
idOrName: 'my-project',
|
|
1718
|
+
teamId: 'team_1a2b3c4d5e6f7g8h9i0j1k2l',
|
|
1719
|
+
});
|
|
1720
|
+
console.log(result);
|
|
1721
|
+
} catch (error) {
|
|
1722
|
+
if (error.statusCode === 404) {
|
|
1723
|
+
console.error('Project not found');
|
|
1724
|
+
} else if (error.statusCode === 403) {
|
|
1725
|
+
console.error('Permission denied - check token scopes');
|
|
1726
|
+
} else if (error.statusCode === 401) {
|
|
1727
|
+
console.error('Authentication failed - check your token');
|
|
1728
|
+
} else {
|
|
1729
|
+
console.error('Error:', error.message);
|
|
1730
|
+
}
|
|
1731
|
+
}
|
|
1732
|
+
```
|
|
1733
|
+
|
|
1734
|
+
### Advanced Error Handling
|
|
1735
|
+
|
|
1736
|
+
```javascript
|
|
1737
|
+
async function safeApiCall() {
|
|
1738
|
+
try {
|
|
1739
|
+
const result = await vercel.deployments.getDeployments({
|
|
1740
|
+
teamId: 'team_1a2b3c4d5e6f7g8h9i0j1k2l',
|
|
1741
|
+
});
|
|
1742
|
+
return result;
|
|
1743
|
+
} catch (error) {
|
|
1744
|
+
if (error.statusCode >= 500) {
|
|
1745
|
+
console.error('Server error - retry later');
|
|
1746
|
+
} else if (error.statusCode === 429) {
|
|
1747
|
+
console.error('Rate limit exceeded - wait before retrying');
|
|
1748
|
+
} else if (error.statusCode >= 400 && error.statusCode < 500) {
|
|
1749
|
+
console.error('Client error:', error.message);
|
|
1750
|
+
}
|
|
1751
|
+
throw error;
|
|
1752
|
+
}
|
|
1753
|
+
}
|
|
1754
|
+
```
|
|
1755
|
+
|
|
1756
|
+
## Advanced Configuration
|
|
1757
|
+
|
|
1758
|
+
### Custom HTTP Client Options
|
|
1759
|
+
|
|
1760
|
+
```javascript
|
|
1761
|
+
import { Vercel } from '@vercel/sdk';
|
|
1762
|
+
|
|
1763
|
+
const vercel = new Vercel({
|
|
1764
|
+
bearerToken: process.env.VERCEL_TOKEN,
|
|
1765
|
+
serverURL: 'https://api.vercel.com',
|
|
1766
|
+
retryConfig: {
|
|
1767
|
+
strategy: 'backoff',
|
|
1768
|
+
backoff: {
|
|
1769
|
+
initialInterval: 500,
|
|
1770
|
+
maxInterval: 60000,
|
|
1771
|
+
exponent: 1.5,
|
|
1772
|
+
maxElapsedTime: 3600000,
|
|
1773
|
+
},
|
|
1774
|
+
retryConnectionErrors: true,
|
|
1775
|
+
},
|
|
1776
|
+
});
|
|
1777
|
+
```
|
|
1778
|
+
|
|
1779
|
+
### Setting Timeouts
|
|
1780
|
+
|
|
1781
|
+
```javascript
|
|
1782
|
+
import { Vercel } from '@vercel/sdk';
|
|
1783
|
+
|
|
1784
|
+
const vercel = new Vercel({
|
|
1785
|
+
bearerToken: process.env.VERCEL_TOKEN,
|
|
1786
|
+
timeoutMs: 30000, // 30 seconds
|
|
1787
|
+
});
|
|
1788
|
+
```
|
|
1789
|
+
|
|
1790
|
+
### Debug Mode
|
|
1791
|
+
|
|
1792
|
+
```javascript
|
|
1793
|
+
import { Vercel } from '@vercel/sdk';
|
|
1794
|
+
|
|
1795
|
+
const vercel = new Vercel({
|
|
1796
|
+
bearerToken: process.env.VERCEL_TOKEN,
|
|
1797
|
+
debugLogger: {
|
|
1798
|
+
log: (message) => console.log('[DEBUG]', message),
|
|
1799
|
+
},
|
|
1800
|
+
});
|
|
1801
|
+
```
|
|
1802
|
+
|
|
1803
|
+
## Pagination
|
|
1804
|
+
|
|
1805
|
+
Many API endpoints support pagination for handling large result sets.
|
|
1806
|
+
|
|
1807
|
+
### Manual Pagination
|
|
1808
|
+
|
|
1809
|
+
```javascript
|
|
1810
|
+
async function getAllProjects() {
|
|
1811
|
+
let allProjects = [];
|
|
1812
|
+
let limit = 20;
|
|
1813
|
+
let until = undefined;
|
|
1814
|
+
|
|
1815
|
+
while (true) {
|
|
1816
|
+
const result = await vercel.projects.getProjects({
|
|
1817
|
+
teamId: 'team_1a2b3c4d5e6f7g8h9i0j1k2l',
|
|
1818
|
+
limit: limit,
|
|
1819
|
+
until: until,
|
|
1820
|
+
});
|
|
1821
|
+
|
|
1822
|
+
allProjects.push(...result.projects);
|
|
1823
|
+
|
|
1824
|
+
if (!result.pagination || !result.pagination.next) {
|
|
1825
|
+
break;
|
|
1826
|
+
}
|
|
1827
|
+
|
|
1828
|
+
until = result.pagination.next;
|
|
1829
|
+
}
|
|
1830
|
+
|
|
1831
|
+
return allProjects;
|
|
1832
|
+
}
|
|
1833
|
+
```
|
|
1834
|
+
|
|
1835
|
+
### Pagination with Limit
|
|
1836
|
+
|
|
1837
|
+
```javascript
|
|
1838
|
+
async function getRecentDeployments(maxResults = 100) {
|
|
1839
|
+
const result = await vercel.deployments.getDeployments({
|
|
1840
|
+
teamId: 'team_1a2b3c4d5e6f7g8h9i0j1k2l',
|
|
1841
|
+
limit: Math.min(maxResults, 100),
|
|
1842
|
+
});
|
|
1843
|
+
|
|
1844
|
+
return result.deployments.slice(0, maxResults);
|
|
1845
|
+
}
|
|
1846
|
+
```
|
|
1847
|
+
|
|
1848
|
+
## Complete Example: Deploy a Project
|
|
1849
|
+
|
|
1850
|
+
Here's a complete example showing how to create a project, upload files, and create a deployment:
|
|
1851
|
+
|
|
1852
|
+
```javascript
|
|
1853
|
+
import { Vercel } from '@vercel/sdk';
|
|
1854
|
+
import fs from 'fs';
|
|
1855
|
+
import path from 'path';
|
|
1856
|
+
|
|
1857
|
+
const vercel = new Vercel({
|
|
1858
|
+
bearerToken: process.env.VERCEL_TOKEN,
|
|
1859
|
+
});
|
|
1860
|
+
|
|
1861
|
+
async function deployProject() {
|
|
1862
|
+
try {
|
|
1863
|
+
// 1. Create a project
|
|
1864
|
+
const project = await vercel.projects.createProject({
|
|
1865
|
+
teamId: process.env.VERCEL_TEAM_ID,
|
|
1866
|
+
requestBody: {
|
|
1867
|
+
name: 'my-app',
|
|
1868
|
+
framework: 'nextjs',
|
|
1869
|
+
},
|
|
1870
|
+
});
|
|
1871
|
+
console.log('Project created:', project.id);
|
|
1872
|
+
|
|
1873
|
+
// 2. Upload files
|
|
1874
|
+
const files = [
|
|
1875
|
+
{ path: 'index.html', content: '<html><body>Hello World</body></html>' },
|
|
1876
|
+
{ path: 'package.json', content: '{"name":"my-app","version":"1.0.0"}' },
|
|
1877
|
+
];
|
|
1878
|
+
|
|
1879
|
+
const uploadedFiles = [];
|
|
1880
|
+
for (const file of files) {
|
|
1881
|
+
const hash = await vercel.deployments.uploadFile({
|
|
1882
|
+
teamId: process.env.VERCEL_TEAM_ID,
|
|
1883
|
+
requestBody: {
|
|
1884
|
+
file: file.content,
|
|
1885
|
+
},
|
|
1886
|
+
});
|
|
1887
|
+
uploadedFiles.push({
|
|
1888
|
+
file: file.path,
|
|
1889
|
+
sha: hash,
|
|
1890
|
+
size: file.content.length,
|
|
1891
|
+
});
|
|
1892
|
+
}
|
|
1893
|
+
console.log('Files uploaded');
|
|
1894
|
+
|
|
1895
|
+
// 3. Create deployment
|
|
1896
|
+
const deployment = await vercel.deployments.createDeployment({
|
|
1897
|
+
teamId: process.env.VERCEL_TEAM_ID,
|
|
1898
|
+
requestBody: {
|
|
1899
|
+
name: 'my-app',
|
|
1900
|
+
files: uploadedFiles,
|
|
1901
|
+
projectSettings: {
|
|
1902
|
+
framework: 'nextjs',
|
|
1903
|
+
},
|
|
1904
|
+
target: 'production',
|
|
1905
|
+
},
|
|
1906
|
+
});
|
|
1907
|
+
console.log('Deployment created:', deployment.url);
|
|
1908
|
+
|
|
1909
|
+
// 4. Wait for deployment to complete
|
|
1910
|
+
let status = 'BUILDING';
|
|
1911
|
+
while (status === 'BUILDING' || status === 'QUEUED') {
|
|
1912
|
+
await new Promise((resolve) => setTimeout(resolve, 5000));
|
|
1913
|
+
const deploymentStatus = await vercel.deployments.getDeployment({
|
|
1914
|
+
idOrUrl: deployment.id,
|
|
1915
|
+
teamId: process.env.VERCEL_TEAM_ID,
|
|
1916
|
+
});
|
|
1917
|
+
status = deploymentStatus.readyState;
|
|
1918
|
+
console.log('Deployment status:', status);
|
|
1919
|
+
}
|
|
1920
|
+
|
|
1921
|
+
if (status === 'READY') {
|
|
1922
|
+
console.log('Deployment successful:', `https://${deployment.url}`);
|
|
1923
|
+
} else {
|
|
1924
|
+
console.error('Deployment failed:', status);
|
|
1925
|
+
}
|
|
1926
|
+
} catch (error) {
|
|
1927
|
+
console.error('Error:', error.message);
|
|
1928
|
+
}
|
|
1929
|
+
}
|
|
1930
|
+
|
|
1931
|
+
deployProject();
|
|
1932
|
+
```
|
|
1933
|
+
|
|
1934
|
+
## Useful Links
|
|
1935
|
+
|
|
1936
|
+
- Documentation: https://vercel.com/docs
|
|
1937
|
+
- API Reference: https://vercel.com/docs/rest-api/reference
|
|
1938
|
+
- SDK Documentation: https://vercel.com/docs/rest-api/reference/sdk
|
|
1939
|
+
- GitHub Repository: https://github.com/vercel/sdk
|
|
1940
|
+
- Support: https://vercel.com/support
|