@scalar/cli 2.5.2 → 2.8.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.
Files changed (79) hide show
  1. package/README.md +319 -55
  2. package/chunks/{action-XUQ7TKKJ.js → action-354TUG4H.js} +11 -7
  3. package/chunks/{action-PHLOE27S.js → action-43YBNBDR.js} +33 -26
  4. package/chunks/{action-DGD6Q6Y5.js → action-5SK5NE7E.js} +10 -4
  5. package/chunks/{action-Y6CEKYEK.js → action-6BYGBXRC.js} +40 -23
  6. package/chunks/{action-LUVBQEIQ.js → action-7PEQXDWT.js} +4 -4
  7. package/chunks/action-AQRPFQKI.js +231 -0
  8. package/chunks/{action-RBVPKCRI.js → action-CA4QYPI6.js} +6 -6
  9. package/chunks/{action-7H3XARJP.js → action-EOAVVL52.js} +11 -5
  10. package/chunks/action-F2ZJNURT.js +72 -0
  11. package/chunks/{action-AMNYOA4B.js → action-F7A2K74G.js} +4 -4
  12. package/chunks/{action-HIL5ZFNB.js → action-FCAYFPVR.js} +5 -5
  13. package/chunks/{action-42D2C47G.js → action-GWXLHL2Z.js} +3 -3
  14. package/chunks/{action-ZWQLQENM.js → action-H6OUJWWM.js} +4 -4
  15. package/chunks/{action-TWHLZW4V.js → action-HT2DJ34Z.js} +49 -26
  16. package/chunks/{action-PAA4NWUJ.js → action-JAHFRYWZ.js} +58 -9
  17. package/chunks/{action-HXHBU7XC.js → action-KTYOCA2V.js} +37 -12
  18. package/chunks/{action-LFL3ZZKN.js → action-LEUD5P2U.js} +17 -17
  19. package/chunks/{action-FF2OMGAS.js → action-LLH4QPXM.js} +34 -20
  20. package/chunks/{action-OILGZAMK.js → action-LXGXKXZZ.js} +20 -15
  21. package/chunks/{action-W62AIEBN.js → action-NVI5DWFP.js} +6 -6
  22. package/chunks/{action-EPNE5XCM.js → action-QQZLPI42.js} +17 -17
  23. package/chunks/{action-ZLTUMRO2.js → action-UIKH4SZX.js} +25 -21
  24. package/chunks/{action-6FAJNP6C.js → action-VOFDW3U2.js} +4 -4
  25. package/chunks/{action-OK55BFGM.js → action-W3C53GPH.js} +7 -7
  26. package/chunks/{action-P7RFXIC7.js → action-WFDNRA7D.js} +32 -23
  27. package/chunks/{action-V5KYG7XD.js → action-XIUO64C7.js} +10 -10
  28. package/chunks/{action-X7TZA3RE.js → action-Y6NXJQ4H.js} +89 -14
  29. package/chunks/{action-6MZZHPVQ.js → action-Y7OUGD56.js} +27 -14
  30. package/chunks/{action-DCINFQ57.js → action-YLF2G4G5.js} +13 -13
  31. package/chunks/{action-SJYAMXYI.js → action-YRX6SN5F.js} +10 -4
  32. package/chunks/actions-OGIVBQC7.js +158 -0
  33. package/chunks/{agent-JAXLLDPE.js → agent-ASPV3R5U.js} +4 -4
  34. package/chunks/{asyncapi-P6Y3L7RG.js → asyncapi-QNFKXHEI.js} +10 -11
  35. package/chunks/{build.action-AZ5ECU4B.js → build.action-NM6CAE5F.js} +37 -33
  36. package/chunks/{chunk-FOKFF4EP.js → chunk-22HYZ7LE.js} +3 -3
  37. package/chunks/{chunk-KEOCJ3NJ.js → chunk-2OCWX42S.js} +38 -87
  38. package/chunks/{chunk-RPVHJMQT.js → chunk-5DEU2DVL.js} +2 -2
  39. package/chunks/{chunk-OQKDBLOZ.js → chunk-5JLVQVKO.js} +8 -0
  40. package/chunks/{chunk-VNYE4R7N.js → chunk-5UHLAJQD.js} +2 -1
  41. package/chunks/{chunk-CX7ZRMTC.js → chunk-6XWCMJDB.js} +1 -1
  42. package/chunks/{chunk-6ZMT63IV.js → chunk-6YPQGVF4.js} +1 -1
  43. package/chunks/{chunk-HXIDUCSZ.js → chunk-BPGFSSUH.js} +1 -1
  44. package/chunks/{chunk-M622VXRQ.js → chunk-C2KAWRIX.js} +1 -1
  45. package/chunks/chunk-EGOXR5FB.js +15 -0
  46. package/chunks/{chunk-UB3XGOUW.js → chunk-EXY3ZTV4.js} +262 -9
  47. package/chunks/{chunk-3BWGTPPT.js → chunk-FDC2IESH.js} +1776 -1113
  48. package/chunks/{chunk-TYLWJ2UL.js → chunk-GTV2BVXV.js} +2 -2
  49. package/chunks/{chunk-SWWWYWHC.js → chunk-HGOD6THU.js} +27 -18
  50. package/chunks/{chunk-3DJ2GKEG.js → chunk-IMG35UXX.js} +1 -1
  51. package/chunks/{chunk-MNLXYOVF.js → chunk-KCCFN4F7.js} +2 -2
  52. package/chunks/{chunk-FQVVKQPU.js → chunk-KKRGBXCE.js} +137 -1
  53. package/chunks/{chunk-UMPODUJO.js → chunk-L3UXDCBI.js} +105 -15
  54. package/chunks/{chunk-B2MHTD3R.js → chunk-MLSZVVTT.js} +1 -1
  55. package/chunks/{chunk-LCPFHE4Z.js → chunk-OJ2EWIJH.js} +21 -2
  56. package/chunks/{chunk-RAO7VUGM.js → chunk-PH3WFNXJ.js} +1 -1
  57. package/chunks/{chunk-NIXG4KDE.js → chunk-QVQ4PNVL.js} +170 -5
  58. package/chunks/{chunk-CIFOFSZ3.js → chunk-R5LK6VPY.js} +72 -7
  59. package/chunks/{chunk-T7B6WNZC.js → chunk-TSURUX4A.js} +12 -3
  60. package/chunks/{chunk-JV7TUEXQ.js → chunk-UXJ753NV.js} +14 -1
  61. package/chunks/{chunk-HUCR333E.js → chunk-W24BETFG.js} +2 -2
  62. package/chunks/{chunk-LQN4S62O.js → chunk-XEDGMZJD.js} +18 -4
  63. package/chunks/{chunk-NNMSZVAB.js → chunk-XXSQUBXS.js} +82 -6
  64. package/chunks/{chunk-M6Q3ARBV.js → chunk-YILQODZF.js} +2 -2
  65. package/chunks/{create.action-34OTO2SB.js → create.action-FUQ2BVJA.js} +29 -17
  66. package/chunks/{delete.action-ZYXFMIOW.js → delete.action-47E66R3I.js} +26 -17
  67. package/chunks/{delete.action-6LRT4M3S.js → delete.action-BTDFH7WY.js} +26 -17
  68. package/chunks/{get.action-XP36SA2J.js → get.action-XC7KC2JO.js} +10 -10
  69. package/chunks/{list.action-6LF6KSD5.js → list.action-LXKEUYKO.js} +13 -13
  70. package/chunks/{list.action-WVRVLX5E.js → list.action-OFGLMRE7.js} +17 -17
  71. package/chunks/{publish.action-AHFUBT5C.js → publish.action-OS27XOX4.js} +50 -24
  72. package/chunks/{update.action-YQTVUDYE.js → update.action-AEIBLCWD.js} +27 -18
  73. package/chunks/{update.action-ZREAFJVG.js → update.action-ZMS4CQ3T.js} +27 -18
  74. package/docs.html +679 -175
  75. package/index.js +492 -406
  76. package/package.json +14 -22
  77. package/skills/scalar-cli/SKILL.md +77 -0
  78. package/template.md +101 -3
  79. package/chunks/action-YRWHX2AE.js +0 -64
@@ -1,10 +1,10 @@
1
1
  import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
2
2
  import {
3
3
  config
4
- } from "./chunk-JV7TUEXQ.js";
4
+ } from "./chunk-UXJ753NV.js";
5
5
  import {
6
6
  RegistryAsset
7
- } from "./chunk-MNLXYOVF.js";
7
+ } from "./chunk-KCCFN4F7.js";
8
8
 
9
9
  // src/domains/registry/helpers/links.ts
10
10
  function registryUrl(path) {
@@ -1,7 +1,7 @@
1
1
  import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
2
2
  import {
3
3
  detectManagedDocType
4
- } from "./chunk-MNLXYOVF.js";
4
+ } from "./chunk-KCCFN4F7.js";
5
5
  import {
6
6
  isUrl
7
7
  } from "./chunk-4ORL4MST.js";
@@ -40,10 +40,13 @@ var safeNormalize = (value) => {
40
40
  var isAsyncApiDocument = (document) => detectManagedDocType(document) === "asyncapi";
41
41
  var isAsyncApiContent = (content) => content.includes("asyncapi") && isAsyncApiDocument(safeNormalize(content));
42
42
 
43
+ // src/domains/document/helpers/is-document.ts
44
+ var isDocument = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
45
+
43
46
  // src/domains/document/helpers/imports.ts
44
47
  import fs from "node:fs";
45
48
  import as2 from "ansis";
46
- import { load, validate } from "@scalar/openapi-parser";
49
+ import { validate } from "@scalar/openapi-validator";
47
50
  var getFileOrUrl = async (input) => {
48
51
  if (isUrl(input)) {
49
52
  const response = await fetch(input);
@@ -57,21 +60,31 @@ var getFileOrUrl = async (input) => {
57
60
  }
58
61
  return fs.readFileSync(input, "utf-8");
59
62
  };
60
- var loadOpenApiFile = async (input) => {
61
- return loadOpenApiDocument(await getFileOrUrl(input));
62
- };
63
- var loadOpenApiDocument = async (specification) => {
63
+ var loadOpenApiDocument = async (content) => {
64
64
  try {
65
- const { filesystem } = await load(specification);
66
- const result = await validate(filesystem);
65
+ const document = safeNormalize(content);
66
+ if (!isDocument(document)) {
67
+ throw new Error("Could not parse an OpenAPI document.");
68
+ }
69
+ if (isDocument(document.info) && typeof document.info.version !== "string") {
70
+ document.info.version = "0.1.0";
71
+ }
72
+ const result = validate(document);
67
73
  if (!result.valid) {
68
74
  output.warn().title("File does not match the OpenAPI specification.").print();
69
- result.errors?.forEach((error) => {
70
- output.warn().title(`${error.message} (${error.path})`).print();
75
+ result.errors.forEach((error) => {
76
+ output.warn().title(
77
+ error.path ? `${error.message} (${error.path})` : error.message
78
+ ).print();
71
79
  });
72
- return result;
80
+ return { ...result, specification: document };
73
81
  }
74
- return result;
82
+ return {
83
+ ...result,
84
+ valid: true,
85
+ specification: document,
86
+ schema: result.schema
87
+ };
75
88
  } catch (error) {
76
89
  output.error().title(error ? as2.red(error.toString()) : "Unknown error.").print();
77
90
  const message = typeof error === "object" && error !== null && "message" in error ? String(error.message) : "Unknown error";
@@ -90,16 +103,12 @@ var loadOpenApiDocument = async (specification) => {
90
103
  }
91
104
  };
92
105
 
93
- // src/domains/document/helpers/is-document.ts
94
- var isDocument = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
95
-
96
106
  export {
97
107
  printSpecificationBanner,
98
108
  safeNormalize,
99
109
  isAsyncApiDocument,
100
110
  isAsyncApiContent,
111
+ isDocument,
101
112
  getFileOrUrl,
102
- loadOpenApiFile,
103
- loadOpenApiDocument,
104
- isDocument
113
+ loadOpenApiDocument
105
114
  };
@@ -2,7 +2,7 @@ import { createRequire as $$cR } from "node:module"; const require = $$cR(import
2
2
  import {
3
3
  getPublishPreviewUrl,
4
4
  getPublishUrl
5
- } from "./chunk-M6Q3ARBV.js";
5
+ } from "./chunk-YILQODZF.js";
6
6
 
7
7
  // src/domains/project/publish/url.ts
8
8
  function getPublishDeploymentUrl(publish) {
@@ -2,10 +2,10 @@ import { createRequire as $$cR } from "node:module"; const require = $$cR(import
2
2
  import {
3
3
  baseRegistrySchema,
4
4
  docVersionToolSchema
5
- } from "./chunk-CX7ZRMTC.js";
5
+ } from "./chunk-6XWCMJDB.js";
6
6
  import {
7
7
  HTTP_METHODS
8
- } from "./chunk-LQN4S62O.js";
8
+ } from "./chunk-XEDGMZJD.js";
9
9
  import {
10
10
  brandedUid,
11
11
  compareVersionsDesc,
@@ -3,7 +3,7 @@ import {
3
3
  RegistryResourceTypes,
4
4
  baseRegistrySchema,
5
5
  contentShaSchema
6
- } from "./chunk-CX7ZRMTC.js";
6
+ } from "./chunk-6XWCMJDB.js";
7
7
  import {
8
8
  brandedUid,
9
9
  docVersionSchema,
@@ -210,6 +210,87 @@ var AuthDomains;
210
210
  AuthDomains2["Mcp"] = "mcp";
211
211
  })(AuthDomains || (AuthDomains = {}));
212
212
 
213
+ // ../../packages/entities/dist/publish/publish.js
214
+ var headingRecordSchema = external_exports.object({
215
+ slug: external_exports.string(),
216
+ name: external_exports.string(),
217
+ level: external_exports.coerce.number().int(),
218
+ uid: nanoidSchema,
219
+ parent: external_exports.string().optional(),
220
+ isPageTitle: external_exports.boolean().optional()
221
+ }).meta({ id: "heading-record" });
222
+ var publishAssetSchema = external_exports.object({
223
+ path: external_exports.string(),
224
+ data: external_exports.string()
225
+ }).meta({ id: "publish-asset" });
226
+ var typesenseConfigSchema = external_exports.object({
227
+ keyId: external_exports.number(),
228
+ keyValue: external_exports.string(),
229
+ collectionName: external_exports.string()
230
+ }).meta({ id: "typesense-config" });
231
+
232
+ // ../../packages/entities/dist/deploys/deploy.js
233
+ var subpathSchema = external_exports.object({
234
+ subpath: external_exports.string(),
235
+ projectUid: external_exports.string(),
236
+ /**
237
+ * The project's own title, for labelling it in cross-project search.
238
+ * Written on publish, so it is absent until the project next publishes.
239
+ */
240
+ name: external_exports.string().optional(),
241
+ /**
242
+ * The project's active publish, used to cache-bust its search index the
243
+ * way a project already busts its own. Absent until it next publishes.
244
+ */
245
+ publishUid: external_exports.string().optional(),
246
+ /**
247
+ * Present only for sites still served by Typesense. Builds on the jsonl
248
+ * search backend omit it; federated search fetches `${subpath}/search-entries.jsonl`.
249
+ */
250
+ typesenseConfig: typesenseConfigSchema.optional().nullable()
251
+ }).meta({ id: "subpath" });
252
+ var cloudflareHttpTokenSchema = external_exports.object({
253
+ /** URL path, e.g. `/.well-known/pki-validation/ca3-<id>.txt` */
254
+ path: external_exports.string(),
255
+ /** Plain-text response body the token path must answer with */
256
+ body: external_exports.string()
257
+ }).meta({ id: "cloudflare-http-token" });
258
+ var cloudflareHostnameStateSchema = external_exports.object({
259
+ /** Custom hostname id in the Cloudflare zone */
260
+ hostnameId: external_exports.string(),
261
+ /** Hostname ownership status reported by Cloudflare (pending, active, …) */
262
+ status: external_exports.string(),
263
+ /** Certificate status reported by Cloudflare (pending_validation, active, …) */
264
+ sslStatus: external_exports.string(),
265
+ httpTokens: cloudflareHttpTokenSchema.array().default([]),
266
+ /** Unix seconds of the reconciler run that last wrote this state */
267
+ syncedAt: external_exports.number()
268
+ }).meta({ id: "cloudflare-hostname-state" });
269
+ var siteDeploySchema = entitySchema.extend({
270
+ domain: external_exports.string(),
271
+ teamUid: nanoidSchema,
272
+ projectUid: nanoidSchema,
273
+ /**
274
+ * Title of the project mounted at the domain root.
275
+ *
276
+ * The root project is deliberately not one of `subpaths` — both request
277
+ * matchers resolve by longest path prefix, so a '/' entry would become a
278
+ * catch-all that every request matched. It is denormalized here instead so
279
+ * search can name and scope it without a second lookup.
280
+ */
281
+ rootName: external_exports.string().optional(),
282
+ subpaths: subpathSchema.array().default([]),
283
+ cloudflare: cloudflareHostnameStateSchema.optional().nullable()
284
+ }).meta({ id: "site-deploy" });
285
+ var searchConfigRootSchema = external_exports.object({
286
+ projectUid: external_exports.string(),
287
+ name: external_exports.string().optional()
288
+ }).meta({ id: "search-config-root" });
289
+ var searchConfigResponseSchema = external_exports.object({
290
+ subpaths: subpathSchema.array(),
291
+ root: searchConfigRootSchema.optional()
292
+ }).meta({ id: "search-config-response" });
293
+
213
294
  // ../../packages/entities/dist/login-portals/customization.js
214
295
  var loginPortalEmailSchema = external_exports.object({
215
296
  /** @deprecated No longer rendered in the email template */
@@ -291,6 +372,51 @@ var managedSchema = baseRegistrySchema.extend({
291
372
  format: managedSchemaFormat.default("json")
292
373
  }).meta({ id: "managed-schema" });
293
374
 
375
+ // ../../packages/entities/dist/mcp-server/schema.js
376
+ var mcpServerToolStates = ["enabled", "disabled"];
377
+ var mcpServerRecordSchema = baseRegistrySchema.extend({
378
+ /** Own uid, branded so it cannot be confused with another entity's uid */
379
+ uid: brandedUid().default(mintUid).meta({ default: "nanoid()" }),
380
+ /** The state a tool starts in when a linked document gains an operation. */
381
+ defaultToolState: external_exports.enum(mcpServerToolStates).default("enabled"),
382
+ /** A custom domain the server is served from, when one is configured. */
383
+ domain: external_exports.string().nullable().default(null),
384
+ /**
385
+ * The Cloudflare custom hostname behind `domain`, mirrored by the edge
386
+ * cache sync. Absent until the sync has provisioned it.
387
+ */
388
+ cloudflare: cloudflareHostnameStateSchema.optional().nullable(),
389
+ /**
390
+ * When core last asked the sync to re-read the hostname from Cloudflare,
391
+ * in Unix milliseconds. The sync's own refresh schedule ends ten minutes
392
+ * after a claim, and core holds no Cloudflare credentials, so a domain
393
+ * check that finds the CNAME in place but the certificate not yet active
394
+ * stamps this for the sync to pick up.
395
+ */
396
+ domainRefreshRequestedAt: external_exports.number().nullable().optional()
397
+ }).meta({ id: "mcp-server-record" });
398
+
399
+ // ../../packages/entities/dist/mcp-server/domain.js
400
+ var mcpDomainStatuses = [
401
+ "pending",
402
+ "misconfigured",
403
+ "issuing",
404
+ "active",
405
+ "failed"
406
+ ];
407
+ var mcpDomainCheckSchema = external_exports.object({
408
+ status: external_exports.enum(mcpDomainStatuses),
409
+ /** The record the customer adds at their DNS provider. */
410
+ expected: external_exports.object({ type: external_exports.literal("CNAME"), target: external_exports.string() }),
411
+ /** What the domain resolves to today. */
412
+ found: external_exports.array(external_exports.string()),
413
+ /** The Cloudflare hostname and certificate state, once the sync has provisioned it. */
414
+ hostname: cloudflareHostnameStateSchema.pick({ status: true, sslStatus: true }).nullable()
415
+ });
416
+ var mcpServerDomainSchema = external_exports.object({
417
+ domain: external_exports.string().nullable()
418
+ });
419
+
294
420
  // ../../packages/entities/dist/repository/repository.js
295
421
  var linkedRepositoryRemoteSchema = external_exports.discriminatedUnion("provider", [
296
422
  external_exports.object({
@@ -436,6 +562,10 @@ var webhookSecretSchema = entitySchema.extend({
436
562
  expiresAt: external_exports.number()
437
563
  }).nullable().optional()
438
564
  }).meta({ id: "webhook-secret" });
565
+ var userInfoHookSecretSchema = webhookSecretSchema.extend({
566
+ uid: nanoidSchema,
567
+ teamUid: nanoidSchema
568
+ }).meta({ id: "user-info-hook-secret" });
439
569
  var webhookDeliveryStatusSchema = external_exports.enum(["pending", "succeeded", "failed"]).meta({ id: "webhook-delivery-status" });
440
570
  var webhookDeliverySchema = entitySchema.extend({
441
571
  uid: brandedUid().default(mintUid).meta({ default: "nanoid()" }),
@@ -621,12 +751,18 @@ var workspaceSchema = baseRegistrySchema.extend({
621
751
  }).meta({ id: "workspace" });
622
752
 
623
753
  export {
754
+ emailDomainSchema,
755
+ accessGroupDomains,
756
+ accessGroupNameSchema,
624
757
  accessGroupSchema,
625
758
  identityProviders,
626
759
  identityProviderRecordSchema,
760
+ siteDeploySchema,
627
761
  loginPortalSchema,
628
762
  managedSchemaVersion,
629
763
  managedSchema,
764
+ mcpDomainCheckSchema,
765
+ mcpServerDomainSchema,
630
766
  linkedRepositorySchema,
631
767
  WaitlistProducts,
632
768
  WaitlistSources,
@@ -5,10 +5,10 @@ import {
5
5
  import {
6
6
  ISOLATE_DIR,
7
7
  ISOLATE_EXTRACTION_DIR
8
- } from "./chunk-HXIDUCSZ.js";
8
+ } from "./chunk-BPGFSSUH.js";
9
9
  import {
10
10
  config
11
- } from "./chunk-JV7TUEXQ.js";
11
+ } from "./chunk-UXJ753NV.js";
12
12
  import {
13
13
  output
14
14
  } from "./chunk-T5HJUAWB.js";
@@ -25,6 +25,7 @@ import { nanoid } from "nanoid";
25
25
  import tar from "tar-fs";
26
26
 
27
27
  // src/domains/project/download-isolate/helpers.ts
28
+ import semver from "semver";
28
29
  var PLATFORM_TARBALL_TARGETS = /* @__PURE__ */ new Set([
29
30
  "darwin-arm64",
30
31
  "darwin-x64",
@@ -40,14 +41,38 @@ function getIsolateDownloadUrls(options) {
40
41
  if (!PLATFORM_TARBALL_TARGETS.has(target)) return [universalUrl];
41
42
  return [`${baseUrl}-${target}.tar.gz`, universalUrl];
42
43
  }
44
+ var getLatestIsolateUrl = (cdnUrl) => `${cdnUrl}/isolates/latest.json`;
45
+ var getCompatibleFallbackVersion = (version, latestVersion) => {
46
+ if (!latestVersion || latestVersion === version) return void 0;
47
+ if (!semver.valid(version) || !semver.valid(latestVersion)) return void 0;
48
+ if (semver.prerelease(latestVersion)) return void 0;
49
+ if (semver.major(latestVersion) !== semver.major(version)) return void 0;
50
+ return latestVersion;
51
+ };
43
52
 
44
53
  // src/domains/project/download-isolate/action.ts
45
54
  var execFileAsync = promisify(execFile);
46
55
  var IsolateDownloadError = class extends Error {
56
+ /**
57
+ * True when every candidate URL answered 404: the version has no published
58
+ * archive, as opposed to a network problem. `installIsolate` uses this to
59
+ * try the newest published release instead of telling the user to check
60
+ * their connection.
61
+ */
62
+ notFound;
47
63
  constructor(message, options) {
48
64
  super(message, options);
49
65
  this.name = "IsolateDownloadError";
66
+ this.notFound = options?.notFound ?? false;
67
+ }
68
+ };
69
+ var HttpStatusError = class extends Error {
70
+ constructor(status, statusText) {
71
+ super(`HTTP ${status} ${statusText}`.trim());
72
+ this.status = status;
73
+ this.name = "HttpStatusError";
50
74
  }
75
+ status;
51
76
  };
52
77
  var DOWNLOAD_TIMEOUT_MS = 10 * 60 * 1e3;
53
78
  var EXTRACTION_ALLOWANCE_MS = 5 * 60 * 1e3;
@@ -121,7 +146,7 @@ async function downloadAndExtract(url, destinationDir, options) {
121
146
  signal: AbortSignal.timeout(options.timeoutMs)
122
147
  });
123
148
  if (!response.ok) {
124
- throw new Error(`HTTP ${response.status} ${response.statusText}`.trim());
149
+ throw new HttpStatusError(response.status, response.statusText);
125
150
  }
126
151
  if (!response.body) {
127
152
  throw new Error("Response had no body");
@@ -175,17 +200,24 @@ var DISK_WRITE_ERROR_MESSAGES = [
175
200
  "read-only file system"
176
201
  // EROFS
177
202
  ];
203
+ var getErrorDetails = (error) => `${error.message} ${error.stderr ?? ""}`;
178
204
  function isDiskWriteError(error) {
179
205
  if (!(error instanceof Error)) return false;
180
206
  const code = error.code;
181
207
  if (typeof code === "string" && DISK_WRITE_ERROR_CODES.has(code)) {
182
208
  return true;
183
209
  }
184
- const details = `${error.message} ${error.stderr ?? ""}`.toLowerCase();
210
+ const details = getErrorDetails(error).toLowerCase();
185
211
  return DISK_WRITE_ERROR_MESSAGES.some((phrase) => details.includes(phrase));
186
212
  }
213
+ var isNotFoundError = (error) => {
214
+ if (error instanceof HttpStatusError) return error.status === 404;
215
+ if (!(error instanceof Error)) return false;
216
+ return /\b404\b/.test(getErrorDetails(error));
217
+ };
187
218
  async function downloadFirstAvailable(urls, destinationDir, options) {
188
219
  const failures = [];
220
+ let notFound = true;
189
221
  for (const url of urls) {
190
222
  try {
191
223
  await fs.rm(destinationDir, { recursive: true, force: true });
@@ -194,6 +226,7 @@ async function downloadFirstAvailable(urls, destinationDir, options) {
194
226
  return url;
195
227
  } catch (error) {
196
228
  if (isDiskWriteError(error)) throw error;
229
+ notFound &&= isNotFoundError(error);
197
230
  failures.push(
198
231
  ` - ${url}: ${error instanceof Error ? error.message : String(error)}`
199
232
  );
@@ -202,7 +235,8 @@ async function downloadFirstAvailable(urls, destinationDir, options) {
202
235
  throw new IsolateDownloadError(
203
236
  `Failed to download the docs preview server. Attempted:
204
237
  ${failures.join("\n")}
205
- Your existing preview server (if any) was left untouched. Check your network connection and try again.`
238
+ Your existing preview server (if any) was left untouched.` + (notFound ? "" : " Check your network connection and try again."),
239
+ { notFound }
206
240
  );
207
241
  }
208
242
  async function removeQuarantineAttributes(isolateDir) {
@@ -310,18 +344,76 @@ async function updateIsolate(options) {
310
344
  });
311
345
  }
312
346
  }
347
+ var LATEST_LOOKUP_TIMEOUT_MS = 15 * 1e3;
348
+ var fetchLatestIsolateVersion = async (cdnUrl) => {
349
+ try {
350
+ const response = await fetch(getLatestIsolateUrl(cdnUrl), {
351
+ signal: AbortSignal.timeout(LATEST_LOOKUP_TIMEOUT_MS)
352
+ });
353
+ if (!response.ok) return void 0;
354
+ const pointer = await response.json();
355
+ const version = typeof pointer === "object" && pointer !== null && "version" in pointer ? pointer.version : void 0;
356
+ return typeof version === "string" ? version : void 0;
357
+ } catch {
358
+ return void 0;
359
+ }
360
+ };
361
+ var getMissingArchiveHint = (version, fallbackVersion) => {
362
+ const missing = `No docs preview server archive is published for version ${version}`;
363
+ const latestUrl = getLatestIsolateUrl(config.cdnUrl);
364
+ if (fallbackVersion) {
365
+ return `${missing}, and the newest release named by ${latestUrl}, ${fallbackVersion}, has none either. Set SSG_DOCS_ISOLATE_VERSION to the version of another released CLI and try again.`;
366
+ }
367
+ return `${missing}. Each CLI release publishes its own archive, so a local build has none until it ships. Set SSG_DOCS_ISOLATE_VERSION to the version of a released CLI (${latestUrl} names the newest one) and try again.`;
368
+ };
369
+ var isMissingArchiveError = (error) => error instanceof IsolateDownloadError && error.notFound;
370
+ var withMissingArchiveHint = (error, version, fallbackVersion) => new IsolateDownloadError(
371
+ `${error.message}
372
+
373
+ ${getMissingArchiveHint(version, fallbackVersion)}`,
374
+ { notFound: true }
375
+ );
376
+ var installIsolate = async (version, existingVersion) => {
377
+ const install = (isolateVersion) => updateIsolate({
378
+ urls: getIsolateDownloadUrls({
379
+ cdnUrl: config.cdnUrl,
380
+ version: isolateVersion,
381
+ platform: process.platform,
382
+ arch: process.arch
383
+ }),
384
+ extractionDir: ISOLATE_EXTRACTION_DIR
385
+ });
386
+ try {
387
+ await install(version);
388
+ return "Download complete.";
389
+ } catch (error) {
390
+ if (!isMissingArchiveError(error)) throw error;
391
+ const fallbackVersion = getCompatibleFallbackVersion(
392
+ version,
393
+ await fetchLatestIsolateVersion(config.cdnUrl)
394
+ );
395
+ if (!fallbackVersion) throw withMissingArchiveHint(error, version);
396
+ const notice = `no archive is published for ${version}, using the newest release, ${fallbackVersion}`;
397
+ if (fallbackVersion === existingVersion) {
398
+ return `Docs preview server ${fallbackVersion} is already installed (${notice}).`;
399
+ }
400
+ try {
401
+ await install(fallbackVersion);
402
+ } catch (fallbackError) {
403
+ throw isMissingArchiveError(fallbackError) ? withMissingArchiveHint(fallbackError, version, fallbackVersion) : fallbackError;
404
+ }
405
+ return `Download complete (${notice}).`;
406
+ }
407
+ };
313
408
  async function downloadIsolate() {
314
409
  const existingIsolateVersion = await getExistingIsolateVersion();
315
- if (config.ssgDocsIsolateVersion === existingIsolateVersion) return;
410
+ const version = config.ssgDocsIsolateVersion;
411
+ if (version === existingIsolateVersion) return;
316
412
  const logger = output.info({ animate: true }).loader("Downloading the docs preview server. This may take a minute...");
317
- const urls = getIsolateDownloadUrls({
318
- cdnUrl: config.cdnUrl,
319
- version: config.ssgDocsIsolateVersion,
320
- platform: process.platform,
321
- arch: process.arch
322
- });
323
413
  try {
324
- await updateIsolate({ urls, extractionDir: ISOLATE_EXTRACTION_DIR });
414
+ const completion = await installIsolate(version, existingIsolateVersion);
415
+ logger.update("loader", 0, { content: completion });
416
+ logger.finish();
325
417
  } catch (error) {
326
418
  const isDownloadFailure = error instanceof IsolateDownloadError;
327
419
  logger.update("loader", 0, {
@@ -338,8 +430,6 @@ async function downloadIsolate() {
338
430
  ].filter(Boolean).join("\n\n")
339
431
  ).exit("error");
340
432
  }
341
- logger.update("loader", 0, { content: "Download complete." });
342
- logger.finish();
343
433
  }
344
434
 
345
435
  export {
@@ -2,7 +2,7 @@ import { createRequire as $$cR } from "node:module"; const require = $$cR(import
2
2
  import {
3
3
  teamImageSchema,
4
4
  teamNameSchema
5
- } from "./chunk-VNYE4R7N.js";
5
+ } from "./chunk-5UHLAJQD.js";
6
6
  import {
7
7
  brandedUid,
8
8
  emailSchema,
@@ -2,6 +2,22 @@ import { createRequire as $$cR } from "node:module"; const require = $$cR(import
2
2
 
3
3
  // src/domains/document/bundle/index.ts
4
4
  import { Command } from "commander";
5
+
6
+ // src/helpers/parse-integer-option.ts
7
+ import { InvalidArgumentError } from "commander";
8
+ var parseIntegerOption = (value, minimum, maximum) => {
9
+ const parsed = Number(value);
10
+ if (!/^\d+$/.test(value) || !Number.isSafeInteger(parsed) || parsed < minimum || parsed > maximum) {
11
+ throw new InvalidArgumentError(
12
+ `Expected an integer between ${minimum} and ${maximum}.`
13
+ );
14
+ }
15
+ return parsed;
16
+ };
17
+ var parsePort = (value) => parseIntegerOption(value, 0, 65535);
18
+ var parseFetchLimit = (value) => parseIntegerOption(value, 1, Number.MAX_SAFE_INTEGER);
19
+
20
+ // src/domains/document/bundle/index.ts
5
21
  var DEFAULT_FETCH_CONCURRENCY = 5;
6
22
  function BundleCommand() {
7
23
  const cmd = new Command("bundle");
@@ -17,16 +33,19 @@ function BundleCommand() {
17
33
  );
18
34
  cmd.option(
19
35
  "--fetchLimit <limit>",
20
- "Maximum number of URLs to fetch during bundling at the same time"
36
+ "Maximum number of URLs to fetch during bundling at the same time",
37
+ parseFetchLimit
21
38
  );
22
39
  cmd.action(async (...args) => {
23
- const { bundleAction } = await import("./action-7H3XARJP.js");
40
+ const { bundleAction } = await import("./action-EOAVVL52.js");
24
41
  return bundleAction(...args);
25
42
  });
26
43
  return cmd;
27
44
  }
28
45
 
29
46
  export {
47
+ parsePort,
48
+ parseFetchLimit,
30
49
  DEFAULT_FETCH_CONCURRENCY,
31
50
  BundleCommand
32
51
  };
@@ -1,7 +1,7 @@
1
1
  import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
2
2
  import {
3
3
  registryUrl
4
- } from "./chunk-TYLWJ2UL.js";
4
+ } from "./chunk-GTV2BVXV.js";
5
5
 
6
6
  // src/domains/registry/helpers/fetch.ts
7
7
  async function fetchFromRegistry(path, accessToken) {