saturndocs 0.1.2 → 0.2.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 (50) hide show
  1. package/dist/{auth-FRCFGNYT.js → auth-DUYYFNEZ.js} +4 -4
  2. package/dist/{brokenLinks-TTOBP4P7.js → brokenLinks-E364XYH3.js} +1 -1
  3. package/dist/{chunk-SABK3R2P.js → chunk-2RZEC3VH.js} +132 -136
  4. package/dist/{chunk-KGJESHJC.js → chunk-2YTD2XNI.js} +1 -1
  5. package/dist/{chunk-QLFODLVN.js → chunk-4J33CCAC.js} +18 -15
  6. package/dist/{chunk-STCCGFKC.js → chunk-4ORVQCHY.js} +1 -1
  7. package/dist/chunk-56U46JVN.js +28 -0
  8. package/dist/chunk-6JGAA5TF.js +86 -0
  9. package/dist/{chunk-GYRVGWDM.js → chunk-ADZOBRZE.js} +88 -6
  10. package/dist/chunk-D3CLXV7D.js +131 -0
  11. package/dist/{chunk-5KX4ZK5E.js → chunk-DBMFJXKP.js} +11 -5
  12. package/dist/chunk-EB7RWFQA.js +3821 -0
  13. package/dist/{chunk-R3X2DPFF.js → chunk-FGKHDJOC.js} +133 -4
  14. package/dist/{chunk-3V753MRI.js → chunk-GGGL4O7Z.js} +2 -2
  15. package/dist/{chunk-OZWTXMO3.js → chunk-GLI3OUYL.js} +57 -4
  16. package/dist/{chunk-3P2OFTXR.js → chunk-K5YY6NSF.js} +2 -2
  17. package/dist/{chunk-TKISMN3P.js → chunk-KOJJUISB.js} +2 -2
  18. package/dist/chunk-O72DR5FK.js +152 -0
  19. package/dist/{chunk-U7PKMSB3.js → chunk-QF2ADHQZ.js} +4 -4
  20. package/dist/{chunk-S45UWCML.js → chunk-SVDVBZPA.js} +9 -9
  21. package/dist/{chunk-CMNX5DLQ.js → chunk-W3GKH5DY.js} +2 -2
  22. package/dist/{chunk-N7QPZMLP.js → chunk-WBI4EI3D.js} +1 -1
  23. package/dist/{chunk-OEAEX5YW.js → chunk-WHNL6UYJ.js} +8 -2
  24. package/dist/chunk-WUPP3THV.js +87 -0
  25. package/dist/chunk-YSFP37B7.js +76 -0
  26. package/dist/{chunk-XO4CUC7V.js → chunk-Z5CBPJ2L.js} +3 -3
  27. package/dist/cli.js +3 -3
  28. package/dist/coverage-EBWULNQQ.js +15 -0
  29. package/dist/deploy-QUVLOGII.js +13 -0
  30. package/dist/dist-XISZDQTR.js +120 -0
  31. package/dist/index.d.ts +35 -2
  32. package/dist/index.js +66 -38
  33. package/dist/{init-7T5TEPBH.js → init-PI4VTG7V.js} +2 -2
  34. package/dist/lint-SXBP37G3.js +13 -0
  35. package/dist/{manage-MKH27U3B.js → manage-OB6DQK3Q.js} +2 -2
  36. package/dist/nav-R4OORY2G.js +14 -0
  37. package/dist/{openapiCheck-KGBQJTIQ.js → openapiCheck-X2QQGETY.js} +6 -6
  38. package/dist/{pages-HIPXRLSY.js → pages-MKFZAVGI.js} +5 -5
  39. package/dist/{read-DMSJUEDA.js → read-VECMKHBW.js} +4 -4
  40. package/dist/{read-ZEVUZNNB.js → read-WWOMA67R.js} +4 -4
  41. package/dist/requests-A7WC3B4M.js +13 -0
  42. package/dist/{schema-XJUEZSIW.js → schema-NKOXZHQH.js} +3 -3
  43. package/dist/{sites-I4WI2MPG.js → sites-XMMGWPY2.js} +4 -4
  44. package/dist/{status-7R3NOI5H.js → status-SYIUUSSU.js} +4 -4
  45. package/dist/{suggestions-4WFQ3APX.js → suggestions-GX5CQK26.js} +4 -4
  46. package/dist/{validate-VXL4PL42.js → validate-D4I3DY2W.js} +5 -3
  47. package/package.json +6 -5
  48. package/dist/chunk-I6U4V7B4.js +0 -1552
  49. package/dist/deploy-QU7DCKWU.js +0 -11
  50. package/dist/requests-H5MIGBIS.js +0 -13
@@ -25,6 +25,7 @@ var REQUEST_THREAD_AUTHORS = ["owner", "agent", "platform"];
25
25
  var REQUEST_THREAD_KINDS = ["request", "understood", "question", "answer", "draft", "no_change", "failed"];
26
26
  var GIT_CONNECTION_TRANSITIONS = Object.freeze({ active: Object.freeze(["broken"]), broken: Object.freeze(["active"]) });
27
27
  var GIT_CONNECTION_UNIQUENESS = Object.freeze({ activeSite: ["siteId"], activeSource: ["provider", "installationId", "repositoryId", "branch", "docsRoot"] });
28
+ var SCHEDULE_INTERVAL_MS = Object.freeze({ daily: 24 * 60 * 60 * 1e3, weekly: 7 * 24 * 60 * 60 * 1e3 });
28
29
  var DEFAULT_SKIP_LABELS = Object.freeze(["no-docs", "skip-docs"]);
29
30
  var DEFAULT_IGNORE_GLOBS = Object.freeze(["**/*.test.*", "**/__tests__/**", "**/*.lock", "**/node_modules/**", ".github/**"]);
30
31
  var DEFAULT_SKIP_AUTHORS = Object.freeze(["*[bot]"]);
@@ -97,12 +98,17 @@ var OWNER_PATHS = {
97
98
  settingsAssistant: `${OWNER_PREFIX}/settings/assistant`,
98
99
  docsRepo: `${OWNER_PREFIX}/docs-repo`,
99
100
  docsRepoReconnect: `${OWNER_PREFIX}/docs-repo/reconnect`,
101
+ docsRepoInspect: `${OWNER_PREFIX}/docs-repo/inspect`,
102
+ docsRepoScaffold: `${OWNER_PREFIX}/docs-repo/scaffold`,
100
103
  productConnections: `${OWNER_PREFIX}/product-connections`,
101
104
  productConnection: (id) => `${OWNER_PREFIX}/product-connections/${encodeURIComponent(id)}`,
102
105
  productConnectionAction: (id, action) => `${OWNER_PREFIX}/product-connections/${encodeURIComponent(id)}/${action}`,
103
106
  productConnectionAnalyse: (id) => `${OWNER_PREFIX}/product-connections/${encodeURIComponent(id)}/analyse`,
107
+ analysisLimit: `${OWNER_PREFIX}/analysis-limit`,
104
108
  githubInstall: `${OWNER_PREFIX}/github/install`,
109
+ githubConnect: `${OWNER_PREFIX}/github/connect`,
105
110
  githubSetup: `${OWNER_PREFIX}/github/setup`,
111
+ githubLink: `${OWNER_PREFIX}/github/link`,
106
112
  githubRepositories: `${OWNER_PREFIX}/github/repositories`,
107
113
  slackInstall: `${OWNER_PREFIX}/slack/install`
108
114
  };
@@ -161,10 +167,11 @@ var SessionSocketServerFrame = z2.discriminatedUnion("type", [SessionSocketDelta
161
167
  var SUGGESTION_TABS = ["pending", "revising", "published", "dismissed", "failed"];
162
168
  var SUGGESTION_ROW_STATES = ["pending_review", "changes_requested", "revising", "publishing", "published", "dismissed", "failed", "superseded"];
163
169
  var MERGE_MODES = ["review", "slack_approval", "autonomous"];
170
+ var TRIGGER_MODES = ["off", "manual", "daily", "weekly", "push"];
164
171
  var CONNECTION_STATES = ["active", "paused", "broken"];
165
172
  var CONNECTION_BROKEN_REASONS = ["uninstalled", "repository_transferred", "branch_deleted"];
166
173
  var INSTALLATION_HEALTH = ["healthy", "stale", "broken"];
167
- var SKIP_REASONS = ["no_matching_connection", "branch_mismatch", "connection_paused", "connection_broken", "no_watched_paths", "deleted_ref", "bot_author", "skip_label", "invalid_sha"];
174
+ var SKIP_REASONS = ["no_matching_connection", "branch_mismatch", "connection_paused", "connection_broken", "no_watched_paths", "deleted_ref", "bot_author", "skip_label", "invalid_sha", "suggestions_off", "manual_only", "scheduled"];
168
175
  var ACTIVITY_OPERATIONS = ["product_push", "manual_request", "git_push", "rebuild", "bundle_upload"];
169
176
  var CONFIDENCES = ["high", "medium", "low"];
170
177
  var TRIAGES = ["user_facing", "internal", "unclear"];
@@ -185,11 +192,28 @@ var ActiveRelease = z2.object({
185
192
  generation: z2.number().int(),
186
193
  activated_at: nullableString
187
194
  });
195
+ var JobDiagnostic = z2.object({
196
+ path: nullableString,
197
+ code: z2.string(),
198
+ severity: z2.enum(["error", "warning"]),
199
+ message: z2.string(),
200
+ requirement: z2.string().optional(),
201
+ example: z2.string().optional()
202
+ });
203
+ var JobDiagnostics = z2.object({
204
+ total: z2.number().int().nonnegative(),
205
+ items: z2.array(JobDiagnostic)
206
+ });
188
207
  var LatestJob = z2.object({
189
208
  state: z2.string(),
190
209
  error_code: nullableString,
191
210
  error_message: nullableString,
192
- updated_at: isoString
211
+ updated_at: isoString,
212
+ diagnostics: JobDiagnostics.nullable().optional()
213
+ });
214
+ var LatestAuthoringJob = LatestJob.extend({
215
+ /** False when the job failed before it wrote a suggestion, so nothing waits for review (#625). */
216
+ suggestion_created: z2.boolean().optional()
193
217
  });
194
218
  var UsageMeter = z2.object({ used: z2.number(), limit: z2.number() });
195
219
  var PortalUsage = z2.object({
@@ -231,6 +255,7 @@ var ProductConnection = z2.object({
231
255
  state: z2.enum(CONNECTION_STATES),
232
256
  broken_reason: z2.enum(CONNECTION_BROKEN_REASONS).nullable(),
233
257
  merge_mode: z2.enum(MERGE_MODES),
258
+ trigger_mode: z2.enum(TRIGGER_MODES).optional(),
234
259
  last_event_at: nullableString
235
260
  });
236
261
  var ProductConnectionRules = ProductConnection.omit({ last_event_at: true }).extend({
@@ -239,6 +264,8 @@ var ProductConnectionRules = ProductConnection.omit({ last_event_at: true }).ext
239
264
  ignore_globs: z2.array(z2.string()),
240
265
  skip_authors: z2.array(z2.string()),
241
266
  skip_labels: z2.array(z2.string()),
267
+ trigger_mode: z2.enum(TRIGGER_MODES),
268
+ last_scheduled_at: nullableString.optional(),
242
269
  connection_generation: z2.number().int()
243
270
  });
244
271
  var OWNER_ROLES = ["owner", "viewer"];
@@ -249,7 +276,7 @@ var PortalSite = z2.object({
249
276
  hostnames: z2.array(z2.string()),
250
277
  active_release: ActiveRelease.nullable(),
251
278
  latest_job: LatestJob.nullable(),
252
- latest_authoring_job: LatestJob.nullable().optional(),
279
+ latest_authoring_job: LatestAuthoringJob.nullable().optional(),
253
280
  reader_status: z2.enum(["published", "unpublished", "unknown"]).optional(),
254
281
  connections: z2.array(ProductConnection),
255
282
  docs_repo: DocsRepo.nullable(),
@@ -786,8 +813,34 @@ var DocsRepoConnectBody = z2.object({
786
813
  installation_id: z2.number().int(),
787
814
  repository_id: z2.number().int(),
788
815
  branch: z2.string().min(1),
789
- docs_root: z2.string()
816
+ docs_root: z2.string(),
817
+ first_build: z2.enum(["now", "deferred"]).optional()
818
+ });
819
+ var DocsRepoInspectBody = DocsRepoConnectBody.omit({ first_build: true });
820
+ var BootstrapPr = z2.object({ pr_number: z2.number().int(), html_url: z2.string() });
821
+ var DocsRepoScaffoldBody = DocsRepoConnectBody.omit({ first_build: true }).extend({ mode: z2.enum(["starter", "convert"]) });
822
+ var DocsRepoScaffoldSummary = z2.object({ pages: z2.number().int(), starter_added: z2.boolean(), unconverted: z2.number().int() });
823
+ var DocsRepoScaffoldResponse = z2.object({ docs_repo: DocsRepo, pending: BootstrapPr, summary: DocsRepoScaffoldSummary.nullable().optional() });
824
+ var DocsRepoBootstrapStatus = z2.object({
825
+ pending: BootstrapPr.nullable(),
826
+ state: z2.enum(["none", "open", "merged", "closed"]),
827
+ pull: BootstrapPr.nullable(),
828
+ docs_json: z2.boolean().nullable()
829
+ });
830
+ var DocsRepoSourceBlocked = z2.object({
831
+ error: z2.literal("source_blocked"),
832
+ reason: z2.string(),
833
+ path: z2.string().nullable(),
834
+ scope: z2.enum(["repository", "docs_root"]),
835
+ export_ignore: z2.string().nullable(),
836
+ message: z2.string()
790
837
  });
838
+ var DocsCounts = z2.object({ pages: z2.number().int(), assets: z2.number().int(), unconverted: z2.number().int(), total: z2.number().int() });
839
+ var DocsPlatform = z2.enum(["mintlify", "docusaurus", "mkdocs", "docsify", "mdbook", "sphinx", "gitbook", "jekyll", "antora"]).nullable();
840
+ var DocsInspection = z2.discriminatedUnion("verdict", [
841
+ z2.object({ verdict: z2.enum(["saturndocs", "incompatible", "empty"]), platform: DocsPlatform, counts: DocsCounts, structure_violations: z2.number().int() }),
842
+ z2.object({ verdict: z2.literal("unknown"), reason: z2.enum(["token_refused", "branch_missing", "tree_truncated", "github_error"]) })
843
+ ]);
791
844
  var ProductConnectionsResponse = z2.object({ site_id: z2.string().optional(), product_connections: z2.array(ProductConnectionRules) });
792
845
  var ProductConnectionCreateBody = z2.object({
793
846
  installation_id: z2.number().int(),
@@ -797,15 +850,24 @@ var ProductConnectionCreateBody = z2.object({
797
850
  ignore_globs: z2.array(z2.string()).optional(),
798
851
  skip_authors: z2.array(z2.string()).optional(),
799
852
  skip_labels: z2.array(z2.string()).optional(),
800
- merge_mode: z2.enum(MERGE_MODES).optional()
853
+ merge_mode: z2.enum(MERGE_MODES).optional(),
854
+ trigger_mode: z2.enum(TRIGGER_MODES).optional()
801
855
  });
802
856
  var ProductConnectionPatchBody = z2.object({
803
857
  watch_globs: z2.array(z2.string()).optional(),
804
858
  ignore_globs: z2.array(z2.string()).optional(),
805
859
  skip_authors: z2.array(z2.string()).optional(),
806
860
  skip_labels: z2.array(z2.string()).optional(),
807
- merge_mode: z2.enum(MERGE_MODES).optional()
861
+ merge_mode: z2.enum(MERGE_MODES).optional(),
862
+ trigger_mode: z2.enum(TRIGGER_MODES).optional()
863
+ });
864
+ var AnalysisLimit = z2.object({
865
+ used: z2.number().int(),
866
+ limit: z2.number().int(),
867
+ platform_limit: z2.number().int(),
868
+ owner_limit: z2.number().int().nullable()
808
869
  });
870
+ var AnalysisLimitBody = z2.object({ owner_limit: z2.number().int().min(1).nullable() });
809
871
  var ProductConnectionWriteResponse = z2.object({
810
872
  product_connection: ProductConnectionRules.optional(),
811
873
  dry_run: z2.boolean().optional(),
@@ -814,6 +876,20 @@ var ProductConnectionWriteResponse = z2.object({
814
876
  var GrantedRepository = z2.object({ id: z2.number().int(), full_name: z2.string(), default_branch: z2.string().optional() });
815
877
  var RepositoriesQuery = z2.object({ installation_id: z2.coerce.number().int() });
816
878
  var RepositoriesResponse = z2.object({ installation_id: z2.number().int(), repositories: z2.array(GrantedRepository) });
879
+ var GitHubLinkQuery = z2.object({ pick: z2.string().min(1).max(16384) });
880
+ var GitHubLinkCandidate = z2.object({
881
+ installation_id: z2.number().int(),
882
+ account_login: nullableString,
883
+ suspended: z2.boolean(),
884
+ linked: z2.boolean()
885
+ });
886
+ var GitHubLinkCandidates = z2.object({
887
+ site_id: z2.string(),
888
+ expires_at: z2.string(),
889
+ installations: z2.array(GitHubLinkCandidate)
890
+ });
891
+ var GitHubLinkBody = z2.object({ pick: z2.string().min(1).max(16384), installation_id: z2.number().int().positive() }).strict();
892
+ var GitHubLinkOutcome = z2.object({ installation_id: z2.number().int(), linked: z2.literal(true), already_linked: z2.boolean() });
817
893
  var SettingsApproval = z2.object({
818
894
  revision: z2.string(),
819
895
  pr_number: z2.number().int(),
@@ -1279,6 +1355,9 @@ var P0_COMMANDS = [
1279
1355
  { name: "pages list", operation: "pages.list", operations: ["pages.list"], permission: "manage:read", mutation: false, requires_site: false, text_input: "none", text_limit: null, flags: [{ name: "--days", value: "integer", required: false, description: "Traffic window: 7, 30, or 90." }], exits: READ_EXITS, summary: "Published pages of the live release. An unpublished site is not an empty list." },
1280
1356
  { name: "status", operation: null, operations: ["site.get", "requests.list", "suggestions.list", "activity.list"], permission: "manage:read", mutation: false, requires_site: true, text_input: "none", text_limit: null, flags: [], exits: READ_EXITS, summary: "Bounded briefing. Each section reports available, empty, or unavailable on its own." },
1281
1357
  { name: "schema", operation: null, operations: [], permission: null, mutation: false, requires_site: false, text_input: "none", text_limit: null, flags: [], exits: [EXIT.success, EXIT.invalid_input, EXIT.interrupted], summary: "Versioned command metadata, locally. No credential and no network." },
1358
+ { name: "nav", operation: null, operations: [], permission: null, mutation: false, requires_site: false, text_input: "none", text_limit: null, flags: [{ name: "--outline", value: "string", required: true, description: "Path to the approved outline JSON." }], exits: [EXIT.success, EXIT.invalid_input, EXIT.interrupted], summary: "Rewrite docs.json navigation from an approved outline. Local; no credential and no network." },
1359
+ { name: "lint", operation: null, operations: [], permission: null, mutation: false, requires_site: false, text_input: "none", text_limit: null, flags: [], exits: [EXIT.success, EXIT.invalid_input, EXIT.interrupted], summary: "Content lint and the known-pitfalls catalog over every page; exits 2 when any finding is an error. Local." },
1360
+ { name: "coverage", operation: null, operations: [], permission: null, mutation: false, requires_site: false, text_input: "none", text_limit: null, flags: [{ name: "--outline", value: "string", required: true, description: "Path to the approved outline JSON." }], exits: [EXIT.success, EXIT.invalid_input, EXIT.interrupted], summary: "Compare the pages on disk with an approved outline. Local." },
1282
1361
  { name: "manage", operation: null, operations: [], permission: null, mutation: false, requires_site: true, text_input: "optional", text_limit: null, flags: [{ name: "--data", value: "string", required: false, description: "JSON body, or @path to read one." }, { name: "--file", value: "string", required: false, description: "A multipart file part, repeatable." }, { name: "--revision", value: "string", required: false, description: "The quoted settings revision for If-Match." }], exits: WRITE_EXITS, summary: "One existing management operation chosen by the caller, under the same target and precondition rules as every other command." },
1283
1362
  { name: "requests create", operation: "requests.create", operations: ["requests.create"], permission: "manage:write", mutation: true, requires_site: true, text_input: "required", text_limit: REQUEST_TEXT_LIMIT, flags: [...TEXT, { name: "--submission-id", value: "string", required: true, description: "A UUID the caller keeps. Replaying it with the same payload recovers the same job." }, { name: "--page", value: "string", required: false, description: "The page the request is about." }], exits: WRITE_EXITS, summary: "Submit a documentation request and return its queued job and root thread." },
1284
1363
  { name: "requests reply", operation: "requests.create", operations: ["requests.create"], permission: "manage:write", mutation: true, requires_site: true, text_input: "required", text_limit: REQUEST_TEXT_LIMIT, flags: [...TEXT, { name: "--thread", value: "string", required: true, description: "The root job of the conversation being answered." }, { name: "--submission-id", value: "string", required: true, description: "A UUID the caller keeps, so a lost answer replays instead of duplicating." }], exits: WRITE_EXITS, summary: "Answer a clarification. The root thread is kept; a new job comes back." },
@@ -1441,6 +1520,7 @@ function parseRetryAfter(header, now) {
1441
1520
  async function readBounded(response, maxBytes) {
1442
1521
  const declared = response.headers.get("content-length");
1443
1522
  if (declared !== null && /^\d+$/u.test(declared) && Number(declared) > maxBytes) {
1523
+ await response.body?.cancel().catch(() => void 0);
1444
1524
  throw new Error(`The response is ${declared} bytes, over the ${maxBytes}-byte read limit.`);
1445
1525
  }
1446
1526
  const body = response.body;
@@ -1553,6 +1633,7 @@ function createClient(config = {}) {
1553
1633
  try {
1554
1634
  text = await readBounded(response, maxBytes);
1555
1635
  } catch (cause) {
1636
+ if (cancelled(input.signal)) throw interrupted(mutation ? "unknown" : "not_submitted");
1556
1637
  const message = clean(cause instanceof Error ? cause.message : String(cause));
1557
1638
  if (mutation && response.ok) throw unknownOutcome(`The write was accepted but its answer could not be read: ${message} Read the site's state before sending anything again.`);
1558
1639
  throw transportFailure(`The management answer could not be read: ${message}`, mutation ? "unknown" : "not_submitted");
@@ -3493,6 +3574,7 @@ export {
3493
3574
  interrupted2 as interrupted,
3494
3575
  clientError2 as clientError,
3495
3576
  successResult,
3577
+ messageOf,
3496
3578
  failureResult,
3497
3579
  createResultWriter,
3498
3580
  wantsJson
@@ -0,0 +1,131 @@
1
+ import {
2
+ createBundleArchive
3
+ } from "./chunk-O72DR5FK.js";
4
+ import {
5
+ messageOf
6
+ } from "./chunk-VNYDYHXM.js";
7
+
8
+ // src/commands/deploy.ts
9
+ import { randomUUID } from "crypto";
10
+ import { createReadStream } from "fs";
11
+ import { finished } from "stream/promises";
12
+ import pc from "picocolors";
13
+ var DEFAULT_API_URL = "https://saturndocs-ops.saturndocs.workers.dev";
14
+ var TERMINAL_STATES = /* @__PURE__ */ new Set(["succeeded", "failed", "cancelled", "superseded", "timed_out"]);
15
+ function trimSlash(value) {
16
+ return value.endsWith("/") ? value.slice(0, -1) : value;
17
+ }
18
+ async function responseValue(response) {
19
+ const value = await response.json().catch(() => null);
20
+ return value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
21
+ }
22
+ function apiError(response, value) {
23
+ const code = typeof value.code === "string" ? value.code : `http_${response.status}`;
24
+ const message = typeof value.error === "string" ? value.error : "request failed";
25
+ return new Error(`${code}: ${message}`);
26
+ }
27
+ async function deployBundle(input) {
28
+ const archive = await createBundleArchive(input.docsDir);
29
+ for (const warning of archive.warnings) input.onWarning?.(warning);
30
+ const fetchImpl = input.fetchImpl ?? fetch;
31
+ const apiUrl = trimSlash(input.apiUrl);
32
+ const idempotencyKey = input.idempotencyKey ?? randomUUID();
33
+ try {
34
+ let accepted = {};
35
+ for (let attempt = 0; attempt < 3; attempt += 1) {
36
+ let response;
37
+ const body = createReadStream(archive.path);
38
+ try {
39
+ response = await fetchImpl(`${apiUrl}/v1/deployments`, {
40
+ method: "POST",
41
+ headers: {
42
+ authorization: `Bearer ${input.token}`,
43
+ "content-type": "application/gzip",
44
+ "content-length": String(archive.byteLength),
45
+ "x-saturndocs-content-sha256": archive.sha256,
46
+ "x-saturndocs-idempotency-key": idempotencyKey,
47
+ "x-saturndocs-promote": String(input.promote)
48
+ },
49
+ body,
50
+ duplex: "half",
51
+ redirect: "error"
52
+ });
53
+ } catch (error) {
54
+ if (attempt === 2) throw error;
55
+ await new Promise((resolve) => setTimeout(resolve, 500));
56
+ continue;
57
+ } finally {
58
+ body.destroy();
59
+ await finished(body).catch(() => {
60
+ });
61
+ }
62
+ accepted = await responseValue(response);
63
+ if (response.ok) break;
64
+ if (response.status === 503 && accepted.code === "queue_unavailable" && attempt < 2) {
65
+ await new Promise((resolve) => setTimeout(resolve, 500));
66
+ continue;
67
+ }
68
+ throw apiError(response, accepted);
69
+ }
70
+ if (typeof accepted.job_id !== "string" || typeof accepted.status_url !== "string") throw new Error("deployment response is invalid");
71
+ const statusUrl = new URL(accepted.status_url, `${apiUrl}/`);
72
+ if (statusUrl.origin !== new URL(apiUrl).origin) throw new Error("deployment status URL has an unexpected origin");
73
+ const startedAt = Date.now();
74
+ const timeoutMs = input.timeoutMs ?? 9e5;
75
+ let previousState = "";
76
+ for (; ; ) {
77
+ if (Date.now() - startedAt > timeoutMs) throw new Error(`deployment timed out after ${Math.ceil(timeoutMs / 1e3)} seconds`);
78
+ const statusResponse = await fetchImpl(statusUrl, { headers: { authorization: `Bearer ${input.token}` }, redirect: "error" });
79
+ const value = await responseValue(statusResponse);
80
+ if (!statusResponse.ok) throw apiError(statusResponse, value);
81
+ if (typeof value.job_id !== "string" || typeof value.state !== "string") throw new Error("job status response is invalid");
82
+ const status = value;
83
+ if (status.state !== previousState) {
84
+ previousState = status.state;
85
+ input.onState?.(status);
86
+ }
87
+ if (TERMINAL_STATES.has(status.state)) {
88
+ if (status.state !== "succeeded") throw new Error(`${status.error_code ?? status.state}: deployment ${status.state}`);
89
+ if (input.promote && (!Number.isSafeInteger(status.generation) || status.generation < 1)) {
90
+ throw new Error("promotion_not_applied: deployment succeeded without activating the release");
91
+ }
92
+ return status;
93
+ }
94
+ await new Promise((resolve) => setTimeout(resolve, input.pollIntervalMs ?? 2e3));
95
+ }
96
+ } finally {
97
+ await archive.cleanup();
98
+ }
99
+ }
100
+ function registerDeploy(program) {
101
+ program.command("deploy").description("Publish a docs directory through the SaturnDocs operations pipeline").argument("[dir]", "docs directory (contains docs.json)", ".").option("--api-url <url>", "operations API URL", process.env.SATURNDOCS_API_URL ?? DEFAULT_API_URL).option("--token <token>", "site-bound API token", process.env.SATURNDOCS_TOKEN).option("--candidate", "build a verified candidate without activating it").option("--timeout <seconds>", "maximum wait in seconds", "900").action(async (dir, options) => {
102
+ if (!options.token) throw new Error("SATURNDOCS_TOKEN or --token is required");
103
+ const timeoutSeconds = Number(options.timeout);
104
+ if (!Number.isFinite(timeoutSeconds) || timeoutSeconds <= 0) throw new Error("--timeout must be a positive number of seconds");
105
+ try {
106
+ const result = await deployBundle({
107
+ docsDir: dir,
108
+ apiUrl: options.apiUrl,
109
+ token: options.token,
110
+ promote: options.candidate !== true,
111
+ timeoutMs: timeoutSeconds * 1e3,
112
+ onState(status) {
113
+ console.log(pc.dim(`deployment ${status.state}`));
114
+ },
115
+ onWarning(warning) {
116
+ console.log(pc.yellow(`warning: ${warning.path ?? "bundle"}: ${warning.message}`));
117
+ }
118
+ });
119
+ const outcome = result.generation === void 0 ? "verified candidate" : `served generation ${result.generation}`;
120
+ console.log(pc.green(`\u2713 ${outcome}: ${result.release_id ?? result.job_id}`));
121
+ } catch (error) {
122
+ console.error(pc.red(`error: ${messageOf(error)}`));
123
+ process.exitCode = 1;
124
+ }
125
+ });
126
+ }
127
+
128
+ export {
129
+ deployBundle,
130
+ registerDeploy
131
+ };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  COMMAND_GROUPS
3
- } from "./chunk-QLFODLVN.js";
3
+ } from "./chunk-4J33CCAC.js";
4
4
  import {
5
5
  applyCommandHelp
6
6
  } from "./chunk-M2BZEDAS.js";
@@ -19,16 +19,16 @@ import {
19
19
  resolveGlobalOptions,
20
20
  selectorFor,
21
21
  successResult
22
- } from "./chunk-GYRVGWDM.js";
22
+ } from "./chunk-ADZOBRZE.js";
23
23
 
24
24
  // src/commands/schema.ts
25
25
  var SCHEMA_METADATA = Object.freeze([
26
26
  commandMetadata("schema", {
27
- description: "Print this CLI's own command metadata. With no selector it lists the registered groups and the versions, exit codes, and error codes every command shares; with a selector it prints that one command's target rules, permissions, text sources, flags, output, and examples.",
27
+ description: "Print this CLI's own command metadata. With no selector it lists the registered groups and the versions, exit codes, and error codes every command shares; with a selector it prints that one command's target rules, permissions, text sources, flags, output, and examples. The reserved selector contract prints part of the content contract: the ABI version, allowed roots, extensions, size limits, admissible frontmatter keys and page layouts, the component table, and the outline JSON schema. Ingest enforces more rules than these.",
28
28
  target: { arguments: [{ name: "selector", required: false, description: "A group or a command, spoken with dots: requests, or requests.create." }] },
29
29
  effect: "Nothing. The document is built in this process from the command registry.",
30
30
  output: {
31
- fields: ["schema_version", "result_schema_version", "groups", "global_flags", "exits", "errors", "group", "commands", "command"],
31
+ fields: ["schema_version", "result_schema_version", "groups", "global_flags", "exits", "errors", "group", "commands", "command", "contract"],
32
32
  ids: [],
33
33
  limitations: []
34
34
  },
@@ -36,6 +36,7 @@ var SCHEMA_METADATA = Object.freeze([
36
36
  examples: [
37
37
  { command: "saturndocs schema", description: "Every registered group and the shared contract." },
38
38
  { command: "saturndocs schema requests.create", description: "One command's full metadata." },
39
+ { command: "saturndocs schema contract", description: "Roots, extensions, limits, frontmatter keys, components, and the outline schema." },
39
40
  { command: "saturndocs schema --json", description: "The same document inside the result envelope every command writes." }
40
41
  ]
41
42
  })
@@ -62,14 +63,19 @@ async function rootDocument(groups) {
62
63
  );
63
64
  return { ...sharedContract(), groups: listed };
64
65
  }
66
+ var CONTRACT_SELECTOR = "contract";
65
67
  function unknownSelector(selector, known) {
66
68
  throw invalidInput(
67
- `saturndocs schema does not know ${selector}. Run saturndocs schema for the list. Known here: ${known.join(", ")}.`
69
+ `saturndocs schema does not know ${selector}. Run saturndocs schema for the list. Known here: ${[...known, CONTRACT_SELECTOR].join(", ")}.`
68
70
  );
69
71
  }
70
72
  async function schemaDocument(selector, groups = COMMAND_GROUPS) {
71
73
  if (selector === null || selector === "") return rootDocument(groups);
72
74
  const normalized = selectorFor(selector.trim());
75
+ if (normalized === CONTRACT_SELECTOR) {
76
+ const { contentContract } = await import("./dist-XISZDQTR.js");
77
+ return { ...sharedContract(), contract: contentContract() };
78
+ }
73
79
  const groupName = normalized.split(".")[0];
74
80
  const group = groups.find((candidate) => candidate.name === groupName);
75
81
  if (group === void 0) unknownSelector(normalized, groups.map((candidate) => candidate.name));