vslides 1.0.13 → 1.0.14

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.
Files changed (2) hide show
  1. package/dist/cli.js +32 -15
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -3247,22 +3247,39 @@ async function getGuide() {
3247
3247
  return request("/api/slides/guide");
3248
3248
  }
3249
3249
  async function uploadAsset(slug, token, filename, content) {
3250
- const response = await fetch(`${BASE_URL}/api/slides/assets`, {
3251
- method: "POST",
3252
- headers: {
3253
- "X-Slug": slug,
3254
- "X-Session-Token": token,
3255
- "X-Filename": filename,
3256
- "Content-Type": "application/octet-stream"
3257
- },
3258
- body: content
3259
- });
3260
- if (response.status === 401) {
3261
- clearCLIAuth();
3262
- throw new AuthExpiredError();
3250
+ for (let i = 0; i < MAX_RETRIES; i++) {
3251
+ try {
3252
+ const response = await fetch(`${BASE_URL}/api/slides/assets`, {
3253
+ method: "POST",
3254
+ headers: {
3255
+ "X-Slug": slug,
3256
+ "X-Session-Token": token,
3257
+ "X-Filename": filename,
3258
+ "Content-Type": "application/octet-stream"
3259
+ },
3260
+ body: new Uint8Array(content)
3261
+ });
3262
+ if (response.status === 503) {
3263
+ console.log("Sandbox waking up...");
3264
+ await sleep(RETRY_DELAY);
3265
+ continue;
3266
+ }
3267
+ if (response.status === 401) {
3268
+ clearCLIAuth();
3269
+ throw new AuthExpiredError();
3270
+ }
3271
+ const data = await response.json();
3272
+ return { ok: response.ok, status: response.status, data };
3273
+ } catch (err) {
3274
+ if (i < MAX_RETRIES - 1) {
3275
+ console.log(`Upload failed, retrying... (${i + 1}/${MAX_RETRIES})`);
3276
+ await sleep(RETRY_DELAY);
3277
+ continue;
3278
+ }
3279
+ throw err;
3280
+ }
3263
3281
  }
3264
- const data = await response.json();
3265
- return { ok: response.ok, status: response.status, data };
3282
+ throw new Error("Upload failed after max retries");
3266
3283
  }
3267
3284
  async function exportSlides(slug, token, format) {
3268
3285
  const response = await fetch(`${BASE_URL}/api/slides/export?format=${format}`, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vslides",
3
- "version": "1.0.13",
3
+ "version": "1.0.14",
4
4
  "description": "CLI for Vercel Slides API",
5
5
  "license": "MIT",
6
6
  "author": "Vercel",