vslides 1.0.26 → 1.0.28

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 +185 -8
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -3467,6 +3467,24 @@ async function getLibraryImportBundle(id) {
3467
3467
  async function getLibraryTags() {
3468
3468
  return request("/api/library/tags", { skipAuthCheck: true });
3469
3469
  }
3470
+ async function supersedeLibraryItem(token, oldId, newId) {
3471
+ return request(`/api/library/${oldId}/supersede`, {
3472
+ method: "POST",
3473
+ headers: {
3474
+ "Content-Type": "application/json",
3475
+ "X-CLI-Auth-Token": token
3476
+ },
3477
+ body: JSON.stringify({ supersededBy: newId })
3478
+ });
3479
+ }
3480
+ async function removeSupersession(token, id) {
3481
+ return request(`/api/library/${id}/supersede`, {
3482
+ method: "DELETE",
3483
+ headers: {
3484
+ "X-CLI-Auth-Token": token
3485
+ }
3486
+ });
3487
+ }
3470
3488
 
3471
3489
  // src/lib/config.ts
3472
3490
  var import_node_fs2 = require("node:fs");
@@ -5069,7 +5087,7 @@ function writeLibraryConfig(config) {
5069
5087
  const configPath = (0, import_node_path7.join)(process.cwd(), LIBRARY_CONFIG_FILE);
5070
5088
  (0, import_node_fs8.writeFileSync)(configPath, JSON.stringify(config, null, 2) + "\n");
5071
5089
  }
5072
- async function libraryImport(id) {
5090
+ async function libraryImport(id, options = {}) {
5073
5091
  info(`Fetching library item: ${id}`);
5074
5092
  const result = await getLibraryImportBundle(id);
5075
5093
  if (!result.ok) {
@@ -5080,7 +5098,23 @@ async function libraryImport(id) {
5080
5098
  }
5081
5099
  process.exit(ExitCode.NetworkError);
5082
5100
  }
5083
- const bundle = result.data;
5101
+ let bundle = result.data;
5102
+ if (bundle.supersededBy && bundle.latestId && options.followSupersede !== false) {
5103
+ warning(`This item has been superseded by "${bundle.supersededBy.name}"`);
5104
+ info(` Importing latest: ${bundle.latestId}`);
5105
+ newline();
5106
+ const latestResult = await getLibraryImportBundle(bundle.latestId);
5107
+ if (!latestResult.ok) {
5108
+ error("Failed to fetch latest item");
5109
+ process.exit(ExitCode.NetworkError);
5110
+ }
5111
+ bundle = latestResult.data;
5112
+ id = bundle.id;
5113
+ } else if (bundle.supersededBy && options.followSupersede === false) {
5114
+ warning(`This item has been superseded by "${bundle.supersededBy.name}"`);
5115
+ info(" Importing original as requested (--no-follow-supersede)");
5116
+ newline();
5117
+ }
5084
5118
  const libraryDir = (0, import_node_path7.join)(process.cwd(), "library");
5085
5119
  if (!(0, import_node_fs8.existsSync)(libraryDir)) {
5086
5120
  (0, import_node_fs8.mkdirSync)(libraryDir, { recursive: true });
@@ -5102,7 +5136,7 @@ async function libraryImport(id) {
5102
5136
  newline();
5103
5137
  info("Import complete!");
5104
5138
  newline();
5105
- info("Add to your slides.md:");
5139
+ info("Add to your slides.md (after your title slide):");
5106
5140
  info(` ---`);
5107
5141
  info(` src: ./library/${filename}`);
5108
5142
  info(` ---`);
@@ -5138,6 +5172,14 @@ async function libraryStatus() {
5138
5172
  continue;
5139
5173
  }
5140
5174
  const item = result.data;
5175
+ if (item.supersededByItem) {
5176
+ info(`${item.name} (${id})`);
5177
+ info(` [SUPERSEDED] Replaced by "${item.supersededByItem.name}" (${item.supersededByItem.id})`);
5178
+ info(` Local: ${info2.localPath}`);
5179
+ info(` Run: vslides library upgrade ${id}`);
5180
+ newline();
5181
+ continue;
5182
+ }
5141
5183
  const isUpToDate = item.version === info2.version;
5142
5184
  const status2 = isUpToDate ? `v${info2.version} (current)` : `v${info2.version} -> v${item.version} available`;
5143
5185
  info(`${item.name} (${id})`);
@@ -5176,6 +5218,7 @@ async function libraryUpgrade(id, options) {
5176
5218
  }
5177
5219
  let upgraded = 0;
5178
5220
  let skipped = 0;
5221
+ let superseded = 0;
5179
5222
  for (const itemId of idsToUpgrade) {
5180
5223
  const info2 = config.imports[itemId];
5181
5224
  const itemResult = await getLibraryItem(itemId);
@@ -5184,6 +5227,50 @@ async function libraryUpgrade(id, options) {
5184
5227
  continue;
5185
5228
  }
5186
5229
  const item = itemResult.data;
5230
+ if (item.supersededByItem && options.followSupersede !== false) {
5231
+ const latestResult = await getLibraryImportBundle(item.supersededByItem.id);
5232
+ if (!latestResult.ok) {
5233
+ error(`Failed to fetch superseding item ${item.supersededByItem.id}`);
5234
+ continue;
5235
+ }
5236
+ const latestBundle = latestResult.data;
5237
+ const latestId = latestBundle.latestId || item.supersededByItem.id;
5238
+ let finalBundle = latestBundle;
5239
+ if (latestBundle.latestId && latestBundle.latestId !== item.supersededByItem.id) {
5240
+ const finalResult = await getLibraryImportBundle(latestBundle.latestId);
5241
+ if (finalResult.ok) {
5242
+ finalBundle = finalResult.data;
5243
+ } else {
5244
+ warning(`Could not fetch final chain item ${latestBundle.latestId}, using ${item.supersededByItem.id}`);
5245
+ }
5246
+ }
5247
+ info(`${item.name} (${itemId})`);
5248
+ info(` [SUPERSEDED] Replaced by "${finalBundle.name}" (${latestId})`);
5249
+ info(` Upgrading: ${itemId} -> ${latestId}`);
5250
+ const newSlug = finalBundle.name.toLowerCase().replace(/\s+/g, "-");
5251
+ const newLocalPath = `library/${newSlug}.md`;
5252
+ const dir = (0, import_node_path9.dirname)((0, import_node_path9.join)(process.cwd(), newLocalPath));
5253
+ if (!(0, import_node_fs10.existsSync)(dir)) {
5254
+ (0, import_node_fs10.mkdirSync)(dir, { recursive: true });
5255
+ }
5256
+ (0, import_node_fs10.writeFileSync)((0, import_node_path9.join)(process.cwd(), newLocalPath), finalBundle.markdown);
5257
+ delete config.imports[itemId];
5258
+ config.imports[latestId] = {
5259
+ version: finalBundle.version,
5260
+ importedAt: Date.now(),
5261
+ localPath: newLocalPath
5262
+ };
5263
+ success(`Upgraded to "${finalBundle.name}" v${finalBundle.version}`);
5264
+ info(` New local path: ${newLocalPath}`);
5265
+ info(` Update your slides.md: src: ./${newLocalPath}`);
5266
+ superseded++;
5267
+ continue;
5268
+ }
5269
+ if (item.supersededByItem && options.followSupersede === false) {
5270
+ info(`${item.name}: superseded by "${item.supersededByItem.name}" (use default to follow)`);
5271
+ skipped++;
5272
+ continue;
5273
+ }
5187
5274
  if (item.version === info2.version) {
5188
5275
  info(`${item.name}: already up to date (v${item.version})`);
5189
5276
  skipped++;
@@ -5204,7 +5291,11 @@ async function libraryUpgrade(id, options) {
5204
5291
  }
5205
5292
  (0, import_node_fs10.writeFileSync)(configPath, JSON.stringify(config, null, 2) + "\n");
5206
5293
  newline();
5207
- info(`Upgraded: ${upgraded}, Skipped: ${skipped}`);
5294
+ if (superseded > 0) {
5295
+ info(`Upgraded: ${upgraded}, Superseded: ${superseded}, Skipped: ${skipped}`);
5296
+ } else {
5297
+ info(`Upgraded: ${upgraded}, Skipped: ${skipped}`);
5298
+ }
5208
5299
  }
5209
5300
 
5210
5301
  // src/commands/library-tags.ts
@@ -5246,7 +5337,12 @@ async function libraryInfo(id) {
5246
5337
  ${item.name}
5247
5338
  `);
5248
5339
  info(`ID: ${item.id}`);
5249
- info(`Status: ${item.status}`);
5340
+ if (item.supersededByItem) {
5341
+ info(`Status: ${item.status} (superseded)`);
5342
+ warning(`Superseded by: ${item.supersededByItem.name} (${item.supersededByItem.id})`);
5343
+ } else {
5344
+ info(`Status: ${item.status}`);
5345
+ }
5250
5346
  info(`Version: ${item.version}`);
5251
5347
  info(`Department: ${item.department.name}`);
5252
5348
  info(`Audiences: ${item.audiences.map((a) => a.name).join(", ")}`);
@@ -5259,14 +5355,94 @@ ${item.name}
5259
5355
  if (item.lastVerified) {
5260
5356
  info(`Last Verified: ${new Date(item.lastVerified).toLocaleDateString()}`);
5261
5357
  }
5358
+ if (item.supersedesItems && item.supersedesItems.length > 0) {
5359
+ newline();
5360
+ info(`Supersedes:`);
5361
+ for (const superseded of item.supersedesItems) {
5362
+ info(` - ${superseded.name} (${superseded.id})`);
5363
+ }
5364
+ }
5262
5365
  if (item.description) {
5263
5366
  newline();
5264
5367
  info(`Description:
5265
5368
  ${item.description}`);
5266
5369
  }
5267
5370
  newline();
5268
- info(`Import: vslides library import ${item.id}`);
5371
+ if (item.supersededByItem) {
5372
+ info(`Import latest: vslides library import ${item.supersededByItem.id}`);
5373
+ info(`Import this: vslides library import ${item.id} --no-follow-supersede`);
5374
+ } else {
5375
+ info(`Import: vslides library import ${item.id}`);
5376
+ }
5377
+ newline();
5378
+ }
5379
+
5380
+ // src/commands/library-supersede.ts
5381
+ async function librarySupersede(id, options) {
5382
+ const auth = getCachedAuth();
5383
+ if (!auth) {
5384
+ error("Not logged in");
5385
+ instructions(["Run `vslides login` to authenticate"]);
5386
+ process.exit(ExitCode.AuthRequired);
5387
+ }
5388
+ if (!isAuthValid(auth)) {
5389
+ error("Login expired");
5390
+ instructions(["Run `vslides login` to re-authenticate"]);
5391
+ process.exit(ExitCode.AuthRequired);
5392
+ }
5393
+ if (options.remove) {
5394
+ const result2 = await removeSupersession(auth.token, id);
5395
+ if (!result2.ok) {
5396
+ const errorData = result2.data;
5397
+ error(errorData.message || "Failed to remove supersession");
5398
+ if (result2.status === 401 || result2.status === 403) {
5399
+ process.exit(ExitCode.AuthRequired);
5400
+ } else if (result2.status === 400 || result2.status === 404) {
5401
+ process.exit(ExitCode.ValidationError);
5402
+ } else {
5403
+ process.exit(ExitCode.NetworkError);
5404
+ }
5405
+ }
5406
+ const data2 = result2.data;
5407
+ success(data2.message);
5408
+ return;
5409
+ }
5410
+ if (!options.by) {
5411
+ error("Missing required option: --by <new-id>");
5412
+ instructions([
5413
+ "Usage: vslides library supersede <old-id> --by <new-id>",
5414
+ " vslides library supersede <id> --remove"
5415
+ ]);
5416
+ process.exit(ExitCode.UsageError);
5417
+ }
5418
+ const oldItemResult = await getLibraryItem(id);
5419
+ if (!oldItemResult.ok) {
5420
+ error(`Item not found: ${id}`);
5421
+ process.exit(ExitCode.ValidationError);
5422
+ }
5423
+ const newItemResult = await getLibraryItem(options.by);
5424
+ if (!newItemResult.ok) {
5425
+ error(`Superseding item not found: ${options.by}`);
5426
+ process.exit(ExitCode.ValidationError);
5427
+ }
5428
+ info(`Superseding "${oldItemResult.data.name}" with "${newItemResult.data.name}"...`);
5429
+ const result = await supersedeLibraryItem(auth.token, id, options.by);
5430
+ if (!result.ok) {
5431
+ const errorData = result.data;
5432
+ error(errorData.message || "Failed to supersede item");
5433
+ if (result.status === 401 || result.status === 403) {
5434
+ process.exit(ExitCode.AuthRequired);
5435
+ } else if (result.status === 400 || result.status === 404) {
5436
+ process.exit(ExitCode.ValidationError);
5437
+ } else {
5438
+ process.exit(ExitCode.NetworkError);
5439
+ }
5440
+ }
5441
+ const data = result.data;
5442
+ success(data.message);
5269
5443
  newline();
5444
+ info(`"${oldItemResult.data.name}" is now superseded by "${data.supersededBy.name}"`);
5445
+ info("Users with existing imports will be prompted to upgrade.");
5270
5446
  }
5271
5447
 
5272
5448
  // src/cli.ts
@@ -5319,9 +5495,10 @@ var library = program.command("library").description("Manage slide library");
5319
5495
  library.command("list").description("List library items").option("-d, --department <name>", "Filter by department").option("-a, --audience <name>", "Filter by audience").option("-p, --product <name>", "Filter by product").option("--all", "Include drafts and deprecated").option("-l, --limit <number>", "Number of results", "20").action(wrapCommand((options) => libraryList(options)));
5320
5496
  library.command("search <query>").description("Search library items").option("-l, --limit <number>", "Number of results", "20").action(wrapCommand((query, options) => librarySearch(query, options)));
5321
5497
  library.command("publish").description("Publish current presentation to library").option("-n, --name <name>", "Library item name").option("-d, --description <desc>", "Description").option("--department <name>", "Department").option("--audience <name...>", "Audiences").option("--product <name...>", "Products").option("--update <id>", "Update existing library item").option("--draft", "Create as draft (do not publish)").action(wrapCommand((options) => libraryPublish(options)));
5322
- library.command("import <id>").description("Import library item into current project").action(wrapCommand((id) => libraryImport(id)));
5498
+ library.command("import <id>").description("Import library item into current project").option("--no-follow-supersede", "Do not follow supersession chain").action(wrapCommand((id, options) => libraryImport(id, options)));
5323
5499
  library.command("status").description("Check status of imported library items").action(wrapCommand(libraryStatus));
5324
- library.command("upgrade [id]").description("Upgrade imported library items").option("--all", "Upgrade all imports").action(wrapCommand((id, options) => libraryUpgrade(id, options)));
5500
+ library.command("upgrade [id]").description("Upgrade imported library items").option("--all", "Upgrade all imports").option("--no-follow-supersede", "Do not follow supersession chain").action(wrapCommand((id, options) => libraryUpgrade(id, options)));
5325
5501
  library.command("tags").description("List available taxonomy values").action(wrapCommand(libraryTags));
5326
5502
  library.command("info <id>").description("Show details of a library item").action(wrapCommand((id) => libraryInfo(id)));
5503
+ library.command("supersede <id>").description("Mark a library item as superseded by another").option("--by <new-id>", "ID of the item that supersedes this one").option("--remove", "Remove the supersession").action(wrapCommand((id, options) => librarySupersede(id, options)));
5327
5504
  program.parse();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vslides",
3
- "version": "1.0.26",
3
+ "version": "1.0.28",
4
4
  "description": "CLI for Vercel Slides API",
5
5
  "license": "MIT",
6
6
  "author": "Vercel",