@vercel/blob
Advanced tools
Comparing version 0.18.0 to 0.19.0-8de77fbc-20240116145546
@@ -1,2 +0,2 @@ | ||
import { a as PutBody, b as PutBlobResult, B as BlobCommandOptions } from './put-hUZhqbLn.js'; | ||
import { b as PutBody, c as PutBlobResult, a as BlobCommandOptions } from './put-H7iomtQN.js'; | ||
import { IncomingMessage } from 'node:http'; | ||
@@ -18,2 +18,7 @@ import 'stream'; | ||
multipart?: boolean; | ||
/** | ||
* The amount of times to retry the API requests if they fail. | ||
* @defaultvalue 10 | ||
*/ | ||
retries?: number; | ||
} | ||
@@ -20,0 +25,0 @@ interface ClientPutCommandOptions extends CommonCreateBlobCommandOptions { |
@@ -5,3 +5,3 @@ import { | ||
getTokenFromOptionsOrEnv | ||
} from "./chunk-MF6Y4API.js"; | ||
} from "./chunk-AE6X2Y6H.js"; | ||
@@ -8,0 +8,0 @@ // src/client.ts |
@@ -1,5 +0,23 @@ | ||
import { B as BlobCommandOptions, C as CreateBlobCommandOptions, P as PutCommandOptions, a as PutBody, b as PutBlobResult } from './put-hUZhqbLn.js'; | ||
export { c as BlobAccessError, d as BlobError, e as BlobNotFoundError, i as BlobServiceNotAvailable, f as BlobStoreNotFoundError, g as BlobStoreSuspendedError, h as BlobUnknownError } from './put-hUZhqbLn.js'; | ||
import { B as BlobError, a as BlobCommandOptions, C as CreateBlobCommandOptions, P as PutCommandOptions, b as PutBody, c as PutBlobResult } from './put-H7iomtQN.js'; | ||
import 'stream'; | ||
declare class BlobAccessError extends BlobError { | ||
constructor(); | ||
} | ||
declare class BlobStoreNotFoundError extends BlobError { | ||
constructor(); | ||
} | ||
declare class BlobStoreSuspendedError extends BlobError { | ||
constructor(); | ||
} | ||
declare class BlobUnknownError extends BlobError { | ||
constructor(); | ||
} | ||
declare class BlobNotFoundError extends BlobError { | ||
constructor(); | ||
} | ||
declare class BlobServiceNotAvailable extends BlobError { | ||
constructor(); | ||
} | ||
/** | ||
@@ -108,2 +126,2 @@ * Deletes one or multiple blobs from your store. | ||
export { type CopyBlobResult, type CopyCommandOptions, type HeadBlobResult, type ListBlobResult, type ListBlobResultBlob, type ListCommandOptions, type ListFoldedBlobResult, PutBlobResult, PutCommandOptions, copy, del, head, list, put }; | ||
export { BlobAccessError, BlobError, BlobNotFoundError, BlobServiceNotAvailable, BlobStoreNotFoundError, BlobStoreSuspendedError, BlobUnknownError, type CopyBlobResult, type CopyCommandOptions, type HeadBlobResult, type ListBlobResult, type ListBlobResultBlob, type ListCommandOptions, type ListFoldedBlobResult, PutBlobResult, PutCommandOptions, copy, del, head, list, put }; |
@@ -10,39 +10,27 @@ import { | ||
createPutMethod, | ||
getApiUrl, | ||
getApiVersionHeader, | ||
getTokenFromOptionsOrEnv, | ||
validateBlobApiResponse | ||
} from "./chunk-MF6Y4API.js"; | ||
requestApi | ||
} from "./chunk-AE6X2Y6H.js"; | ||
// src/del.ts | ||
import { fetch } from "undici"; | ||
async function del(url, options) { | ||
const blobApiResponse = await fetch(getApiUrl("/delete"), { | ||
method: "POST", | ||
headers: { | ||
...getApiVersionHeader(), | ||
authorization: `Bearer ${getTokenFromOptionsOrEnv(options)}`, | ||
"content-type": "application/json" | ||
await requestApi( | ||
"/delete", | ||
{ | ||
method: "POST", | ||
headers: { "content-type": "application/json" }, | ||
body: JSON.stringify({ urls: Array.isArray(url) ? url : [url] }) | ||
}, | ||
body: JSON.stringify({ urls: Array.isArray(url) ? url : [url] }) | ||
}); | ||
await validateBlobApiResponse(blobApiResponse); | ||
await blobApiResponse.json(); | ||
options | ||
); | ||
} | ||
// src/head.ts | ||
import { fetch as fetch2 } from "undici"; | ||
async function head(url, options) { | ||
const headApiUrl = new URL(getApiUrl()); | ||
headApiUrl.searchParams.set("url", url); | ||
const blobApiResponse = await fetch2(headApiUrl, { | ||
method: "GET", | ||
const searchParams = new URLSearchParams({ url }); | ||
const headResult = await requestApi( | ||
`?${searchParams.toString()}`, | ||
// HEAD can't have body as a response, so we use GET | ||
headers: { | ||
...getApiVersionHeader(), | ||
authorization: `Bearer ${getTokenFromOptionsOrEnv(options)}` | ||
} | ||
}); | ||
await validateBlobApiResponse(blobApiResponse); | ||
const headResult = await blobApiResponse.json(); | ||
{ method: "GET" }, | ||
options | ||
); | ||
return mapBlobResult(headResult); | ||
@@ -58,27 +46,22 @@ } | ||
// src/list.ts | ||
import { fetch as fetch3 } from "undici"; | ||
async function list(options) { | ||
var _a; | ||
const listApiUrl = new URL(getApiUrl()); | ||
const searchParams = new URLSearchParams(); | ||
if (options == null ? void 0 : options.limit) { | ||
listApiUrl.searchParams.set("limit", options.limit.toString()); | ||
searchParams.set("limit", options.limit.toString()); | ||
} | ||
if (options == null ? void 0 : options.prefix) { | ||
listApiUrl.searchParams.set("prefix", options.prefix); | ||
searchParams.set("prefix", options.prefix); | ||
} | ||
if (options == null ? void 0 : options.cursor) { | ||
listApiUrl.searchParams.set("cursor", options.cursor); | ||
searchParams.set("cursor", options.cursor); | ||
} | ||
if (options == null ? void 0 : options.mode) { | ||
listApiUrl.searchParams.set("mode", options.mode); | ||
searchParams.set("mode", options.mode); | ||
} | ||
const blobApiResponse = await fetch3(listApiUrl, { | ||
method: "GET", | ||
headers: { | ||
...getApiVersionHeader(), | ||
authorization: `Bearer ${getTokenFromOptionsOrEnv(options)}` | ||
} | ||
}); | ||
await validateBlobApiResponse(blobApiResponse); | ||
const results = await blobApiResponse.json(); | ||
const results = await requestApi( | ||
`?${searchParams.toString()}`, | ||
{ method: "GET" }, | ||
options | ||
); | ||
if ((options == null ? void 0 : options.mode) === "folded") { | ||
@@ -106,3 +89,2 @@ return { | ||
// src/copy.ts | ||
import { fetch as fetch4 } from "undici"; | ||
async function copy(fromUrl, toPathname, options) { | ||
@@ -115,6 +97,3 @@ if (!options) { | ||
} | ||
const headers = { | ||
...getApiVersionHeader(), | ||
authorization: `Bearer ${getTokenFromOptionsOrEnv(options)}` | ||
}; | ||
const headers = {}; | ||
if (options.addRandomSuffix !== void 0) { | ||
@@ -129,8 +108,7 @@ headers["x-add-random-suffix"] = options.addRandomSuffix ? "1" : "0"; | ||
} | ||
const blobApiResponse = await fetch4( | ||
getApiUrl(`/${toPathname}?fromUrl=${fromUrl}`), | ||
{ method: "PUT", headers } | ||
return requestApi( | ||
`/${toPathname}?fromUrl=${fromUrl}`, | ||
{ method: "PUT", headers }, | ||
options | ||
); | ||
await validateBlobApiResponse(blobApiResponse); | ||
return await blobApiResponse.json(); | ||
} | ||
@@ -137,0 +115,0 @@ |
{ | ||
"name": "@vercel/blob", | ||
"version": "0.18.0", | ||
"version": "0.19.0-8de77fbc-20240116145546", | ||
"description": "The Vercel Blob JavaScript API client", | ||
@@ -65,4 +65,4 @@ "homepage": "https://vercel.com/storage/blob", | ||
"tsup": "8.0.1", | ||
"eslint-config-custom": "0.0.0", | ||
"tsconfig": "0.0.0" | ||
"tsconfig": "0.0.0", | ||
"eslint-config-custom": "0.0.0" | ||
}, | ||
@@ -69,0 +69,0 @@ "engines": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3
225090
2040