(artifacts)
- recordEvents - Record an artifacts cache usage event
- status - Get status of Remote Caching for this principal
- uploadArtifact - Upload a cache artifact
- downloadArtifact - Download a cache artifact
- artifactExists - Check if a cache artifact exists
- artifactQuery - Query information about an artifact
Records an artifacts cache usage event. The body of this request is an array of cache usage events. The supported event types are HIT
and MISS
. The source is either LOCAL
the cache event was on the users filesystem cache or REMOTE
if the cache event is for a remote cache. When the event is a HIT
the request also accepts a number duration
which is the time taken to generate the artifact in the cache.
import { Vercel } from "@vercel/sdk";
const vercel = new Vercel({
bearerToken: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
await vercel.artifacts.recordEvents({
xArtifactClientCi: "VERCEL",
xArtifactClientInteractive: 0,
requestBody: [
{
sessionId: "<id>",
source: "LOCAL",
event: "HIT",
hash: "12HKQaOmR5t5Uy6vdcQsNIiZgHGB",
duration: 400,
},
],
});
}
run();
The standalone function version of this method:
import { VercelCore } from "@vercel/sdk/core.js";
import { artifactsRecordEvents } from "@vercel/sdk/funcs/artifactsRecordEvents.js";
// Use `VercelCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const vercel = new VercelCore({
bearerToken: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const res = await artifactsRecordEvents(vercel, {
xArtifactClientCi: "VERCEL",
xArtifactClientInteractive: 0,
requestBody: [
{
sessionId: "<id>",
source: "LOCAL",
event: "HIT",
hash: "12HKQaOmR5t5Uy6vdcQsNIiZgHGB",
duration: 400,
},
],
});
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
request |
models.RecordEventsRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body , are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<void>
Error Type | Status Code | Content Type |
---|---|---|
models.VercelBadRequestError | 400 | application/json |
models.VercelForbiddenError | 401 | application/json |
models.SDKError | 4XX, 5XX | */* |
Check the status of Remote Caching for this principal. Returns a JSON-encoded status indicating if Remote Caching is enabled, disabled, or disabled due to usage limits.
import { Vercel } from "@vercel/sdk";
const vercel = new Vercel({
bearerToken: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await vercel.artifacts.status({});
// Handle the result
console.log(result);
}
run();
The standalone function version of this method:
import { VercelCore } from "@vercel/sdk/core.js";
import { artifactsStatus } from "@vercel/sdk/funcs/artifactsStatus.js";
// Use `VercelCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const vercel = new VercelCore({
bearerToken: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const res = await artifactsStatus(vercel, {});
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result);
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
request |
models.StatusRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body , are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<models.StatusResponseBody>
Error Type | Status Code | Content Type |
---|---|---|
models.VercelBadRequestError | 400 | application/json |
models.VercelForbiddenError | 401 | application/json |
models.SDKError | 4XX, 5XX | */* |
Uploads a cache artifact identified by the hash
specified on the path. The cache artifact can then be downloaded with the provided hash
.
import { Vercel } from "@vercel/sdk";
import { openAsBlob } from "node:fs";
const vercel = new Vercel({
bearerToken: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await vercel.artifacts.uploadArtifact({
contentLength: 4504.13,
xArtifactDuration: 400,
xArtifactClientCi: "VERCEL",
xArtifactClientInteractive: 0,
xArtifactTag: "Tc0BmHvJYMIYJ62/zx87YqO0Flxk+5Ovip25NY825CQ=",
hash: "12HKQaOmR5t5Uy6vdcQsNIiZgHGB",
requestBody: await openAsBlob("example.file"),
});
// Handle the result
console.log(result);
}
run();
The standalone function version of this method:
import { VercelCore } from "@vercel/sdk/core.js";
import { artifactsUploadArtifact } from "@vercel/sdk/funcs/artifactsUploadArtifact.js";
import { openAsBlob } from "node:fs";
// Use `VercelCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const vercel = new VercelCore({
bearerToken: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const res = await artifactsUploadArtifact(vercel, {
contentLength: 4504.13,
xArtifactDuration: 400,
xArtifactClientCi: "VERCEL",
xArtifactClientInteractive: 0,
xArtifactTag: "Tc0BmHvJYMIYJ62/zx87YqO0Flxk+5Ovip25NY825CQ=",
hash: "12HKQaOmR5t5Uy6vdcQsNIiZgHGB",
requestBody: await openAsBlob("example.file"),
});
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result);
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
request |
models.UploadArtifactRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body , are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<models.UploadArtifactResponseBody>
Error Type | Status Code | Content Type |
---|---|---|
models.VercelBadRequestError | 400 | application/json |
models.VercelForbiddenError | 401 | application/json |
models.SDKError | 4XX, 5XX | */* |
Downloads a cache artifact indentified by its hash
specified on the request path. The artifact is downloaded as an octet-stream. The client should verify the content-length header and response body.
import { Vercel } from "@vercel/sdk";
const vercel = new Vercel({
bearerToken: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await vercel.artifacts.downloadArtifact({
xArtifactClientCi: "VERCEL",
xArtifactClientInteractive: 0,
hash: "12HKQaOmR5t5Uy6vdcQsNIiZgHGB",
});
// Handle the result
console.log(result);
}
run();
The standalone function version of this method:
import { VercelCore } from "@vercel/sdk/core.js";
import { artifactsDownloadArtifact } from "@vercel/sdk/funcs/artifactsDownloadArtifact.js";
// Use `VercelCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const vercel = new VercelCore({
bearerToken: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const res = await artifactsDownloadArtifact(vercel, {
xArtifactClientCi: "VERCEL",
xArtifactClientInteractive: 0,
hash: "12HKQaOmR5t5Uy6vdcQsNIiZgHGB",
});
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result);
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
request |
models.DownloadArtifactRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body , are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<ReadableStream>
Error Type | Status Code | Content Type |
---|---|---|
models.VercelBadRequestError | 400 | application/json |
models.VercelForbiddenError | 401 | application/json |
models.VercelNotFoundError | 404 | application/json |
models.SDKError | 4XX, 5XX | */* |
Check that a cache artifact with the given hash
exists. This request returns response headers only and is equivalent to a GET
request to this endpoint where the response contains no body.
import { Vercel } from "@vercel/sdk";
const vercel = new Vercel({
bearerToken: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
await vercel.artifacts.artifactExists({
hash: "12HKQaOmR5t5Uy6vdcQsNIiZgHGB",
});
}
run();
The standalone function version of this method:
import { VercelCore } from "@vercel/sdk/core.js";
import { artifactsArtifactExists } from "@vercel/sdk/funcs/artifactsArtifactExists.js";
// Use `VercelCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const vercel = new VercelCore({
bearerToken: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const res = await artifactsArtifactExists(vercel, {
hash: "12HKQaOmR5t5Uy6vdcQsNIiZgHGB",
});
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
request |
models.ArtifactExistsRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body , are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<void>
Error Type | Status Code | Content Type |
---|---|---|
models.VercelBadRequestError | 400 | application/json |
models.VercelForbiddenError | 401 | application/json |
models.VercelNotFoundError | 404 | application/json |
models.SDKError | 4XX, 5XX | */* |
Query information about an array of artifacts.
import { Vercel } from "@vercel/sdk";
const vercel = new Vercel({
bearerToken: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await vercel.artifacts.artifactQuery({
requestBody: {
hashes: [
"<value>",
"<value>",
"<value>",
],
},
});
// Handle the result
console.log(result);
}
run();
The standalone function version of this method:
import { VercelCore } from "@vercel/sdk/core.js";
import { artifactsArtifactQuery } from "@vercel/sdk/funcs/artifactsArtifactQuery.js";
// Use `VercelCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const vercel = new VercelCore({
bearerToken: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const res = await artifactsArtifactQuery(vercel, {
requestBody: {
hashes: [
"<value>",
"<value>",
"<value>",
],
},
});
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result);
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
request |
models.ArtifactQueryRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body , are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<{ [k: string]: models.ResponseBody }>
Error Type | Status Code | Content Type |
---|---|---|
models.VercelBadRequestError | 400 | application/json |
models.VercelForbiddenError | 401 | application/json |
models.SDKError | 4XX, 5XX | */* |