saturndocs 0.2.0 → 0.3.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.
- package/dist/auth-OIEL34E4.js +16 -0
- package/dist/{chunk-GGGL4O7Z.js → chunk-32ATWMIS.js} +3 -3
- package/dist/{chunk-QF2ADHQZ.js → chunk-3EW6ZPL6.js} +5 -5
- package/dist/{chunk-ADZOBRZE.js → chunk-3KCCCMQY.js} +325 -35
- package/dist/{chunk-2RZEC3VH.js → chunk-3X2NBWZN.js} +123 -35
- package/dist/{chunk-EB7RWFQA.js → chunk-5ZYUBLEH.js} +1463 -130
- package/dist/{chunk-WBI4EI3D.js → chunk-6EKGBIUR.js} +2 -2
- package/dist/{chunk-W3GKH5DY.js → chunk-BOWRQKXR.js} +12 -6
- package/dist/{chunk-FGKHDJOC.js → chunk-E3G56DR2.js} +287 -35
- package/dist/chunk-FUZE54DG.js +905 -0
- package/dist/chunk-HBSJ4Z4S.js +53 -0
- package/dist/{chunk-DBMFJXKP.js → chunk-IJOYWJVM.js} +5 -5
- package/dist/chunk-IWIVHHZI.js +426 -0
- package/dist/{chunk-Z5CBPJ2L.js → chunk-PU37LVIF.js} +3 -3
- package/dist/{chunk-4ORVQCHY.js → chunk-RKM7YWPD.js} +25 -6
- package/dist/{chunk-2YTD2XNI.js → chunk-T3MCJYSF.js} +1 -1
- package/dist/{chunk-YSFP37B7.js → chunk-TEYHAN2L.js} +20 -6
- package/dist/{chunk-WUPP3THV.js → chunk-VDGVERLX.js} +5 -5
- package/dist/{chunk-SVDVBZPA.js → chunk-W3FZTCKV.js} +6 -4
- package/dist/chunk-WMS6FUKK.js +414 -0
- package/dist/chunk-WXLJZ7RD.js +115 -0
- package/dist/{chunk-56U46JVN.js → chunk-YGVC4N4V.js} +2 -1
- package/dist/{chunk-6JGAA5TF.js → chunk-YPWPLIEZ.js} +4 -4
- package/dist/cli.js +6 -6
- package/dist/{coverage-EBWULNQQ.js → coverage-SRIA65FT.js} +5 -5
- package/dist/{dist-XISZDQTR.js → dist-LJSALT4X.js} +33 -3
- package/dist/index.d.ts +69 -37
- package/dist/index.js +112 -47
- package/dist/{init-PI4VTG7V.js → init-Y3GDNDWW.js} +5 -3
- package/dist/{lint-SXBP37G3.js → lint-XM26WIGE.js} +3 -3
- package/dist/login-HIXLPRUI.js +22 -0
- package/dist/{manage-OB6DQK3Q.js → manage-3HEBB3EQ.js} +6 -2
- package/dist/{nav-R4OORY2G.js → nav-K43WZJ4J.js} +4 -4
- package/dist/openapiCheck-CL2AH3YC.js +105 -0
- package/dist/pages-4VWB7Z4S.js +16 -0
- package/dist/{read-VECMKHBW.js → read-DYGYUOFK.js} +5 -4
- package/dist/{read-WWOMA67R.js → read-RKT6HUZ7.js} +41 -7
- package/dist/requests-CZYE6GI3.js +13 -0
- package/dist/{schema-NKOXZHQH.js → schema-QMJMGD5P.js} +3 -3
- package/dist/{sites-XMMGWPY2.js → sites-JKS25SEM.js} +5 -4
- package/dist/{status-SYIUUSSU.js → status-FM2ALQUJ.js} +4 -4
- package/dist/{suggestions-GX5CQK26.js → suggestions-Z6XIHMFN.js} +13 -7
- package/dist/unavailable-DVPNUO3J.js +40 -0
- package/dist/validate-X42T4TJ6.js +12 -0
- package/package.json +15 -9
- package/dist/auth-DUYYFNEZ.js +0 -14
- package/dist/brokenLinks-E364XYH3.js +0 -48
- package/dist/build-F5PWGP57.js +0 -39
- package/dist/chunk-4J33CCAC.js +0 -49
- package/dist/chunk-D3CLXV7D.js +0 -131
- package/dist/chunk-GLI3OUYL.js +0 -637
- package/dist/chunk-K5YY6NSF.js +0 -71
- package/dist/chunk-KOJJUISB.js +0 -39
- package/dist/chunk-O72DR5FK.js +0 -152
- package/dist/chunk-VNYDYHXM.js +0 -22
- package/dist/chunk-VXEUNRVA.js +0 -26
- package/dist/chunk-WHNL6UYJ.js +0 -57
- package/dist/deploy-QUVLOGII.js +0 -13
- package/dist/dev-VDSDCBO2.js +0 -43
- package/dist/openapiCheck-X2QQGETY.js +0 -66
- package/dist/pages-MKFZAVGI.js +0 -15
- package/dist/requests-A7WC3B4M.js +0 -13
- package/dist/validate-D4I3DY2W.js +0 -32
|
@@ -30,10 +30,11 @@ var DEFAULT_SKIP_LABELS = Object.freeze(["no-docs", "skip-docs"]);
|
|
|
30
30
|
var DEFAULT_IGNORE_GLOBS = Object.freeze(["**/*.test.*", "**/__tests__/**", "**/*.lock", "**/node_modules/**", ".github/**"]);
|
|
31
31
|
var DEFAULT_SKIP_AUTHORS = Object.freeze(["*[bot]"]);
|
|
32
32
|
var ENFORCEMENT = Object.freeze({ ownership: "d1_transaction", heads: "d1_transaction", hostname: "d1_transaction", gitConnections: "d1_transaction", webhookDeliveries: "d1_transaction", tombstone: "d1_transaction", jobRelations: "d1_transaction", records: "d1_transaction", sourceBlobs: "r2_ordering", releaseObjects: "r2_ordering" });
|
|
33
|
+
var PR_PREVIEW_IDLE_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
33
34
|
|
|
34
35
|
// ../owner-contract/dist/index.js
|
|
35
36
|
import { z } from "zod";
|
|
36
|
-
var MANAGEMENT_SCOPES = ["manage:read", "manage:write", "manage:approve", "manage:access"];
|
|
37
|
+
var MANAGEMENT_SCOPES = ["manage:read", "manage:write", "manage:approve", "manage:access", "rollback"];
|
|
37
38
|
var ManagementCredential = z.object({
|
|
38
39
|
token_id: z.string(),
|
|
39
40
|
site_id: z.string(),
|
|
@@ -49,7 +50,7 @@ var ManagementCredential = z.object({
|
|
|
49
50
|
var ManagementCredentials = z.object({ site_id: z.string(), credentials: z.array(ManagementCredential) });
|
|
50
51
|
var CreateManagementCredential = z.object({
|
|
51
52
|
label: z.string().trim().min(1).max(80),
|
|
52
|
-
scopes: z.array(z.enum(MANAGEMENT_SCOPES)).min(1).max(
|
|
53
|
+
scopes: z.array(z.enum(MANAGEMENT_SCOPES)).min(1).max(MANAGEMENT_SCOPES.length).refine((scopes) => new Set(scopes).size === scopes.length, "Permissions must be unique"),
|
|
53
54
|
expires_at: z.iso.datetime()
|
|
54
55
|
}).strict();
|
|
55
56
|
var IssuedManagementCredential = z.object({ credential: ManagementCredential, token: z.string() });
|
|
@@ -57,9 +58,21 @@ var OWNER_PREFIX = "/__gs-portal";
|
|
|
57
58
|
var MAX_SESSION_EVIDENCE = 20;
|
|
58
59
|
var OWNER_PATHS = {
|
|
59
60
|
login: `${OWNER_PREFIX}/login`,
|
|
60
|
-
|
|
61
|
-
magicVerify: `${OWNER_PREFIX}/magic/verify`,
|
|
61
|
+
start: `${OWNER_PREFIX}/start`,
|
|
62
62
|
logout: `${OWNER_PREFIX}/logout`,
|
|
63
|
+
account: `${OWNER_PREFIX}/account`,
|
|
64
|
+
accountRequirePasskey: `${OWNER_PREFIX}/account/require-passkey`,
|
|
65
|
+
accountSignOutEverywhere: `${OWNER_PREFIX}/account/sign-out-everywhere`,
|
|
66
|
+
accountSession: (id) => OWNER_PREFIX + "/account/sessions/" + encodeURIComponent(id),
|
|
67
|
+
accountPasskey: (id) => `${OWNER_PREFIX}/account/passkeys/${encodeURIComponent(id)}`,
|
|
68
|
+
passkeyRegisterOptions: `${OWNER_PREFIX}/auth/passkey/generate-register-options`,
|
|
69
|
+
passkeyRegister: `${OWNER_PREFIX}/auth/passkey/verify-registration`,
|
|
70
|
+
organization: `${OWNER_PREFIX}/organization`,
|
|
71
|
+
organizationLeave: `${OWNER_PREFIX}/organization/leave`,
|
|
72
|
+
audit: `${OWNER_PREFIX}/audit`,
|
|
73
|
+
billing: `${OWNER_PREFIX}/billing`,
|
|
74
|
+
billingCheckout: `${OWNER_PREFIX}/billing/checkout`,
|
|
75
|
+
billingPortal: `${OWNER_PREFIX}/billing/portal`,
|
|
63
76
|
switch: `${OWNER_PREFIX}/switch`,
|
|
64
77
|
site: `${OWNER_PREFIX}/site`,
|
|
65
78
|
sites: `${OWNER_PREFIX}/sites`,
|
|
@@ -78,6 +91,7 @@ var OWNER_PATHS = {
|
|
|
78
91
|
gaps: `${OWNER_PREFIX}/gaps`,
|
|
79
92
|
gapWork: `${OWNER_PREFIX}/gaps/work`,
|
|
80
93
|
pages: `${OWNER_PREFIX}/pages`,
|
|
94
|
+
releaseRollback: `${OWNER_PREFIX}/releases/rollback`,
|
|
81
95
|
releases: `${OWNER_PREFIX}/releases`,
|
|
82
96
|
metrics: `${OWNER_PREFIX}/metrics`,
|
|
83
97
|
domains: `${OWNER_PREFIX}/domains`,
|
|
@@ -88,6 +102,7 @@ var OWNER_PATHS = {
|
|
|
88
102
|
buildRetry: `${OWNER_PREFIX}/builds/retry`,
|
|
89
103
|
build: `${OWNER_PREFIX}/builds`,
|
|
90
104
|
notifications: `${OWNER_PREFIX}/notifications`,
|
|
105
|
+
previews: `${OWNER_PREFIX}/previews`,
|
|
91
106
|
owners: `${OWNER_PREFIX}/owners`,
|
|
92
107
|
owner: (email) => `${OWNER_PREFIX}/owners/${encodeURIComponent(email)}`,
|
|
93
108
|
settingsProposal: `${OWNER_PREFIX}/settings/proposal`,
|
|
@@ -171,8 +186,8 @@ var TRIGGER_MODES = ["off", "manual", "daily", "weekly", "push"];
|
|
|
171
186
|
var CONNECTION_STATES = ["active", "paused", "broken"];
|
|
172
187
|
var CONNECTION_BROKEN_REASONS = ["uninstalled", "repository_transferred", "branch_deleted"];
|
|
173
188
|
var INSTALLATION_HEALTH = ["healthy", "stale", "broken"];
|
|
174
|
-
var
|
|
175
|
-
var ACTIVITY_OPERATIONS = ["product_push", "manual_request", "git_push", "rebuild", "bundle_upload"];
|
|
189
|
+
var ROLLBACK_ACTIVITY_ACCEPT = "application/json; activity=rollback";
|
|
190
|
+
var ACTIVITY_OPERATIONS = ["product_push", "manual_request", "git_push", "rebuild", "bundle_upload", "rollback"];
|
|
176
191
|
var CONFIDENCES = ["high", "medium", "low"];
|
|
177
192
|
var TRIAGES = ["user_facing", "internal", "unclear"];
|
|
178
193
|
var PAGE_CHANGE_OPS = ["create", "update", "delete"];
|
|
@@ -278,13 +293,19 @@ var PortalSite = z2.object({
|
|
|
278
293
|
latest_job: LatestJob.nullable(),
|
|
279
294
|
latest_authoring_job: LatestAuthoringJob.nullable().optional(),
|
|
280
295
|
reader_status: z2.enum(["published", "unpublished", "unknown"]).optional(),
|
|
296
|
+
repo_watcher: z2.boolean().optional(),
|
|
281
297
|
connections: z2.array(ProductConnection),
|
|
282
298
|
docs_repo: DocsRepo.nullable(),
|
|
283
299
|
installations: z2.array(Installation).optional(),
|
|
284
300
|
slack: SlackConnection.nullable().optional(),
|
|
285
301
|
usage: PortalUsage.optional()
|
|
286
302
|
});
|
|
287
|
-
var SiteSummary = z2.object({
|
|
303
|
+
var SiteSummary = z2.object({
|
|
304
|
+
site_id: z2.string(),
|
|
305
|
+
primary_host: z2.string().nullable(),
|
|
306
|
+
organization_id: z2.string().nullable().optional(),
|
|
307
|
+
organization_name: z2.string().nullable().optional()
|
|
308
|
+
});
|
|
288
309
|
var SitesResponse = z2.object({ current: z2.string(), sites: z2.array(SiteSummary) });
|
|
289
310
|
var RationaleEntry = z2.object({ change: z2.string(), affects: z2.array(z2.string()) });
|
|
290
311
|
var PreviewBlock = z2.object({
|
|
@@ -445,7 +466,9 @@ var RequestChangesBody = z2.object({ note: z2.string().min(1).max(MAX_REQUEST_CH
|
|
|
445
466
|
var RetryBody = z2.object({});
|
|
446
467
|
var SessionMessageBody = z2.object({
|
|
447
468
|
message: z2.string().min(1).max(MAX_SESSION_MESSAGE_CHARS),
|
|
448
|
-
question_id: z2.string().min(1).max(MAX_QUESTION_ID_CHARS).optional()
|
|
469
|
+
question_id: z2.string().min(1).max(MAX_QUESTION_ID_CHARS).optional(),
|
|
470
|
+
/** The session object's dedup key: a replay with the same id and message gets the first turn's result, not a second turn. */
|
|
471
|
+
turn_id: z2.string().uuid().optional()
|
|
449
472
|
});
|
|
450
473
|
var SessionResponse = z2.object({
|
|
451
474
|
answer: z2.string().min(1).max(2e3),
|
|
@@ -478,7 +501,7 @@ var ActivityEvent = z2.object({
|
|
|
478
501
|
pr_number: z2.number().int().nullable(),
|
|
479
502
|
triage: z2.enum(TRIAGES).nullable().optional(),
|
|
480
503
|
pages_considered: nullableString.optional(),
|
|
481
|
-
skip_reason: z2.
|
|
504
|
+
skip_reason: z2.string().nullable().optional(),
|
|
482
505
|
reason: nullableString.optional(),
|
|
483
506
|
release: ActivityRelease.nullable().optional(),
|
|
484
507
|
pusher: nullableString.optional(),
|
|
@@ -596,7 +619,48 @@ var ReleaseRecord = z2.object({
|
|
|
596
619
|
generation: z2.number().int().nullable(),
|
|
597
620
|
job: z2.object({ job_id: z2.string(), operation: nullableString, commit_sha: nullableString, requested_by: nullableString })
|
|
598
621
|
});
|
|
622
|
+
var rollbackReleaseId = z2.string().min(1).max(200).regex(/^[^/\\\s\u0000]+$/u).refine((id) => id !== "." && id !== "..");
|
|
623
|
+
var ReleaseRollbackBody = z2.strictObject({
|
|
624
|
+
release_id: rollbackReleaseId,
|
|
625
|
+
expected_active_release_id: rollbackReleaseId,
|
|
626
|
+
expected_generation: z2.number().int().nonnegative()
|
|
627
|
+
});
|
|
628
|
+
var ReleaseRollbackResponse = z2.object({
|
|
629
|
+
site_id: z2.string(),
|
|
630
|
+
active_release_id: z2.string(),
|
|
631
|
+
previous_release_id: z2.string(),
|
|
632
|
+
generation: z2.number().int().positive(),
|
|
633
|
+
security_epoch: z2.number().int().nonnegative(),
|
|
634
|
+
message: z2.string()
|
|
635
|
+
});
|
|
636
|
+
function rollbackProofMatches(site, body, proof) {
|
|
637
|
+
return proof.site_id === site && proof.active_release_id === body.release_id && proof.previous_release_id === body.expected_active_release_id && proof.generation === body.expected_generation + 1;
|
|
638
|
+
}
|
|
639
|
+
var SUPERSEDED_ROLLBACK = "rollback_applied_then_superseded";
|
|
640
|
+
var SupersededRollbackReceipt = z2.object({
|
|
641
|
+
error: z2.literal(SUPERSEDED_ROLLBACK),
|
|
642
|
+
site_id: z2.string().min(1),
|
|
643
|
+
release_id: rollbackReleaseId,
|
|
644
|
+
previous_release_id: rollbackReleaseId,
|
|
645
|
+
applied_generation: z2.number().int().positive(),
|
|
646
|
+
active_release_id: rollbackReleaseId,
|
|
647
|
+
generation: z2.number().int().positive()
|
|
648
|
+
});
|
|
649
|
+
function matchSupersededRollback(site, body, value) {
|
|
650
|
+
const parsed = SupersededRollbackReceipt.safeParse(value);
|
|
651
|
+
if (!parsed.success) return null;
|
|
652
|
+
const receipt = parsed.data;
|
|
653
|
+
return receipt.site_id === site && receipt.release_id === body.release_id && receipt.previous_release_id === body.expected_active_release_id && receipt.applied_generation === body.expected_generation + 1 && receipt.generation > receipt.applied_generation ? receipt : null;
|
|
654
|
+
}
|
|
655
|
+
function describeSupersededRollback(receipt) {
|
|
656
|
+
return `Rollback to ${receipt.release_id} was applied at generation ${receipt.applied_generation} and later superseded by ${receipt.active_release_id} at generation ${receipt.generation}.`;
|
|
657
|
+
}
|
|
658
|
+
var ROLLBACK_RECOVERY = "The rollback may already have been applied. Check the active release and generation. To reconcile, repeat the original rollback with the same site, target, expected active release, and generation.";
|
|
659
|
+
function uncertainRollbackRefusal(status, code) {
|
|
660
|
+
return code === "rollback_superseded" || (status ?? 0) >= 500 && code !== "limit_unavailable";
|
|
661
|
+
}
|
|
599
662
|
var ReleasesPage = z2.object({
|
|
663
|
+
active_generation: z2.number().int().nullable().optional(),
|
|
600
664
|
site_id: z2.string(),
|
|
601
665
|
active_release_id: nullableString,
|
|
602
666
|
active_release_status: z2.enum(["known", "unknown"]).optional(),
|
|
@@ -727,16 +791,101 @@ var NotificationPut = z2.object({
|
|
|
727
791
|
event: z2.enum(OWNER_NOTIFICATION_EVENTS),
|
|
728
792
|
mode: z2.enum(OWNER_NOTIFICATION_MODES)
|
|
729
793
|
});
|
|
730
|
-
var
|
|
731
|
-
var
|
|
732
|
-
var
|
|
733
|
-
var
|
|
734
|
-
var
|
|
794
|
+
var PreviewSettings = z2.object({ pr_previews: z2.boolean() });
|
|
795
|
+
var ORGANIZATION_ROLES = ["owner", "admin", "editor", "viewer"];
|
|
796
|
+
var OrganizationRole = z2.enum(ORGANIZATION_ROLES);
|
|
797
|
+
var OrganizationSummary = z2.object({ id: z2.string(), name: z2.string() });
|
|
798
|
+
var OwnerRow = z2.object({ member_id: z2.string().optional(), email: z2.string(), role: OrganizationRole.optional(), added_at: isoString, you: z2.boolean() });
|
|
799
|
+
var OwnersResponse = z2.object({ site_id: z2.string(), organization: OrganizationSummary.optional(), owners: z2.array(OwnerRow) });
|
|
800
|
+
var OwnerResponse = z2.object({ owner: OwnerRow, organization: OrganizationSummary.optional() });
|
|
801
|
+
var AddOwnerBody = z2.object({ email: z2.string().min(3).max(320), role: OrganizationRole.optional() });
|
|
802
|
+
var OwnerRoleBody = z2.object({ role: OrganizationRole, member_id: z2.string().min(1) });
|
|
803
|
+
var OrganizationResponse = z2.object({
|
|
804
|
+
id: z2.string(),
|
|
805
|
+
name: z2.string(),
|
|
806
|
+
role: OrganizationRole.nullable(),
|
|
807
|
+
sites: z2.array(z2.object({ site_id: z2.string(), primary_host: z2.string().nullable() })),
|
|
808
|
+
can_leave: z2.boolean().optional(),
|
|
809
|
+
member_count: z2.number().int().nonnegative()
|
|
810
|
+
});
|
|
811
|
+
var OrganizationLeaveResponse = z2.object({ left: z2.string() });
|
|
812
|
+
var AuditResponse = z2.object({
|
|
813
|
+
entries: z2.array(z2.object({
|
|
814
|
+
id: z2.number().int(),
|
|
815
|
+
organization_id: z2.string(),
|
|
816
|
+
site_id: z2.string(),
|
|
817
|
+
actor: z2.string().nullable(),
|
|
818
|
+
op: z2.string(),
|
|
819
|
+
outcome: z2.string(),
|
|
820
|
+
subject: z2.string().nullable(),
|
|
821
|
+
created_at: z2.string(),
|
|
822
|
+
detail: z2.record(z2.string(), z2.union([z2.string(), z2.number(), z2.boolean(), z2.null()]))
|
|
823
|
+
})),
|
|
824
|
+
next_cursor: z2.string().nullable()
|
|
825
|
+
});
|
|
826
|
+
var OrganizationRenameBody = z2.object({ name: z2.string().min(1).max(80) });
|
|
827
|
+
var AccountPasskey = z2.object({
|
|
828
|
+
id: z2.string(),
|
|
829
|
+
name: z2.string().nullable(),
|
|
830
|
+
device_type: z2.string(),
|
|
831
|
+
backed_up: z2.boolean(),
|
|
832
|
+
created_at: z2.string().nullable()
|
|
833
|
+
});
|
|
834
|
+
var AccountResponse = z2.object({
|
|
835
|
+
id: z2.string(),
|
|
836
|
+
email: z2.string(),
|
|
837
|
+
signed_in_with: z2.enum(["email-otp", "passkey"]),
|
|
838
|
+
sessions: z2.array(z2.object({
|
|
839
|
+
id: z2.string(),
|
|
840
|
+
device: z2.string(),
|
|
841
|
+
host: z2.string().nullable(),
|
|
842
|
+
signed_in: z2.string(),
|
|
843
|
+
last_active: z2.string(),
|
|
844
|
+
method: z2.string().nullable(),
|
|
845
|
+
current: z2.boolean()
|
|
846
|
+
})),
|
|
847
|
+
require_passkey: z2.boolean(),
|
|
848
|
+
passkeys: z2.array(AccountPasskey),
|
|
849
|
+
organizations: z2.array(OrganizationSummary.extend({ role: OrganizationRole }))
|
|
850
|
+
});
|
|
851
|
+
var AccountActionResponse = z2.object({ ok: z2.literal(true) });
|
|
852
|
+
var AccountLastOwnerResponse = z2.object({ error: z2.literal("last_owner"), organizations: z2.array(OrganizationSummary) });
|
|
853
|
+
var RequirePasskeyBody = z2.object({ enabled: z2.boolean() });
|
|
854
|
+
var SignOutEverywhereResponse = z2.object({ signed_out: z2.number().int().nonnegative() });
|
|
855
|
+
var BILLING_PLANS = ["none", "standard", "enterprise", "complimentary"];
|
|
856
|
+
var BillingPlan = z2.enum(BILLING_PLANS);
|
|
857
|
+
var BILLING_STATUSES = ["none", "trialing", "active", "past_due", "unpaid", "canceled", "incomplete", "incomplete_expired", "paused"];
|
|
858
|
+
var BillingStatus = z2.enum(BILLING_STATUSES);
|
|
859
|
+
var BillingResponse = z2.object({
|
|
860
|
+
organization: OrganizationSummary,
|
|
861
|
+
plan: BillingPlan,
|
|
862
|
+
offer: z2.literal("early_adopter").nullable().default(null),
|
|
863
|
+
offer_price_cents: z2.number().int().nonnegative().nullable().default(null),
|
|
864
|
+
offer_started_at: z2.string().nullable().default(null),
|
|
865
|
+
offer_locked_until: z2.string().nullable().default(null),
|
|
866
|
+
status: BillingStatus,
|
|
867
|
+
paid: z2.boolean(),
|
|
868
|
+
previewing: z2.boolean(),
|
|
869
|
+
in_grace: z2.boolean(),
|
|
870
|
+
current_period_end: z2.string().nullable(),
|
|
871
|
+
cancel_at_period_end: z2.boolean(),
|
|
872
|
+
site_limit: z2.number().int().nonnegative().nullable(),
|
|
873
|
+
sites_used: z2.number().int().nonnegative(),
|
|
874
|
+
entitlements: z2.object({ custom_domain: z2.boolean(), agent_updates: z2.boolean() }),
|
|
875
|
+
enforced: z2.boolean(),
|
|
876
|
+
checkout_available: z2.boolean(),
|
|
877
|
+
has_customer: z2.boolean(),
|
|
878
|
+
can_subscribe: z2.boolean(),
|
|
879
|
+
portal_available: z2.boolean(),
|
|
880
|
+
reconcile_pending: z2.boolean(),
|
|
881
|
+
can_manage: z2.boolean()
|
|
882
|
+
});
|
|
883
|
+
var BillingRedirect = z2.object({ url: z2.url() });
|
|
735
884
|
var RemoveOwnerResponse = z2.object({ removed: z2.string(), signed_out: z2.boolean() });
|
|
736
885
|
var PendingSettingsPr = z2.object({ pr_number: z2.number().int(), html_url: z2.string() });
|
|
737
886
|
var LogoValue = z2.union([z2.string(), z2.object({ light: z2.string().optional(), dark: z2.string().optional() })]);
|
|
738
887
|
var RedirectEntry = z2.object({ source: z2.string(), destination: z2.string(), permanent: z2.boolean().optional() });
|
|
739
|
-
var MAX_REDIRECTS =
|
|
888
|
+
var MAX_REDIRECTS = 5e3;
|
|
740
889
|
var SettingsValues = z2.object({
|
|
741
890
|
name: nullableString.optional(),
|
|
742
891
|
colors: z2.object({ primary: nullableString }).optional(),
|
|
@@ -818,14 +967,15 @@ var DocsRepoConnectBody = z2.object({
|
|
|
818
967
|
});
|
|
819
968
|
var DocsRepoInspectBody = DocsRepoConnectBody.omit({ first_build: true });
|
|
820
969
|
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() });
|
|
970
|
+
var DocsRepoScaffoldBody = DocsRepoConnectBody.omit({ first_build: true }).extend({ mode: z2.enum(["starter", "convert"]), source_mode: z2.enum(["folder", "root_copy"]).optional() });
|
|
971
|
+
var DocsRepoScaffoldSummary = z2.object({ pages: z2.number().int(), starter_added: z2.boolean(), unconverted: z2.number().int(), copied: z2.boolean().optional() });
|
|
823
972
|
var DocsRepoScaffoldResponse = z2.object({ docs_repo: DocsRepo, pending: BootstrapPr, summary: DocsRepoScaffoldSummary.nullable().optional() });
|
|
824
973
|
var DocsRepoBootstrapStatus = z2.object({
|
|
825
974
|
pending: BootstrapPr.nullable(),
|
|
826
975
|
state: z2.enum(["none", "open", "merged", "closed"]),
|
|
827
976
|
pull: BootstrapPr.nullable(),
|
|
828
|
-
docs_json: z2.boolean().nullable()
|
|
977
|
+
docs_json: z2.boolean().nullable(),
|
|
978
|
+
source_mode: z2.enum(["root_copy", "folder"]).optional()
|
|
829
979
|
});
|
|
830
980
|
var DocsRepoSourceBlocked = z2.object({
|
|
831
981
|
error: z2.literal("source_blocked"),
|
|
@@ -838,7 +988,7 @@ var DocsRepoSourceBlocked = z2.object({
|
|
|
838
988
|
var DocsCounts = z2.object({ pages: z2.number().int(), assets: z2.number().int(), unconverted: z2.number().int(), total: z2.number().int() });
|
|
839
989
|
var DocsPlatform = z2.enum(["mintlify", "docusaurus", "mkdocs", "docsify", "mdbook", "sphinx", "gitbook", "jekyll", "antora"]).nullable();
|
|
840
990
|
var DocsInspection = z2.discriminatedUnion("verdict", [
|
|
841
|
-
z2.object({ verdict: z2.enum(["saturndocs", "incompatible", "empty"]), platform: DocsPlatform, counts: DocsCounts, structure_violations: z2.number().int() }),
|
|
991
|
+
z2.object({ verdict: z2.enum(["saturndocs", "incompatible", "empty"]), platform: DocsPlatform, counts: DocsCounts, structure_violations: z2.number().int(), site_folder: z2.string().optional() }),
|
|
842
992
|
z2.object({ verdict: z2.literal("unknown"), reason: z2.enum(["token_refused", "branch_missing", "tree_truncated", "github_error"]) })
|
|
843
993
|
]);
|
|
844
994
|
var ProductConnectionsResponse = z2.object({ site_id: z2.string().optional(), product_connections: z2.array(ProductConnectionRules) });
|
|
@@ -1101,6 +1251,8 @@ var RequestChangesOutcome2 = RequestChangesOutcome.loose();
|
|
|
1101
1251
|
var ErrorEnvelope2 = ErrorEnvelope.loose();
|
|
1102
1252
|
var DocsRepoSettings2 = DocsRepoSettings.loose();
|
|
1103
1253
|
var ProductConnectionsResponse2 = ProductConnectionsResponse.loose();
|
|
1254
|
+
var ReleaseRollbackResponse2 = ReleaseRollbackResponse;
|
|
1255
|
+
var ReleaseRollbackBody2 = ReleaseRollbackBody;
|
|
1104
1256
|
var MANAGEMENT_SCOPES2 = MANAGEMENT_SCOPES;
|
|
1105
1257
|
var SHA = /^[0-9a-f]{40}$/u;
|
|
1106
1258
|
var ExactReviewInput = z32.object({
|
|
@@ -1173,6 +1325,7 @@ var P0_OPERATIONS = {
|
|
|
1173
1325
|
response: ActivityPage2,
|
|
1174
1326
|
note: "An exact job read comes from the jobs alone, so a queued job is found however many events came after it."
|
|
1175
1327
|
},
|
|
1328
|
+
"releases.rollback": { path: "/releases/rollback", method: "POST", permission: "rollback", mutation: true, query: [], response: ReleaseRollbackResponse2, note: "Activate the named pin at the expected active release and generation." },
|
|
1176
1329
|
"releases.list": {
|
|
1177
1330
|
path: "/releases",
|
|
1178
1331
|
method: "GET",
|
|
@@ -1350,6 +1503,9 @@ var cursor = { name: "--cursor", value: "string", required: false, description:
|
|
|
1350
1503
|
var limit = { name: "--limit", value: "integer", required: false, description: "Page size, within the operation's server ceiling." };
|
|
1351
1504
|
var P0_COMMANDS = [
|
|
1352
1505
|
{ name: "auth status", operation: "sites.list", operations: ["sites.list"], permission: "manage:read", mutation: false, requires_site: false, text_input: "none", text_limit: null, flags: [], exits: READ_EXITS, summary: "Verify read access and report the credential's own site. Says nothing about scopes the server did not return." },
|
|
1506
|
+
{ name: "login", operation: null, operations: [], permission: null, mutation: false, requires_site: false, text_input: "none", text_limit: null, flags: [{ name: "--new-site", value: "string", required: false, description: "Propose a new site address; the person creates the site while approving." }, { name: "--scope", value: "string", required: false, description: "Comma-separated permissions to request: read, draft, build, publish. Omit to let the person choose from the defaults." }, { name: "--no-wait", value: "boolean", required: false, description: "Print the approval link and exit; finish later with --resume." }, { name: "--resume", value: "boolean", required: false, description: "Wait for the approval started by an earlier --no-wait." }, { name: "--open", value: "boolean", required: false, description: "Open the approval link in the default browser." }], exits: WAIT_EXITS, summary: "Ask a person to approve this agent for one site in the browser, then save the resulting login." },
|
|
1507
|
+
{ name: "logout", operation: null, operations: [], permission: null, mutation: false, requires_site: false, text_input: "none", text_limit: null, flags: [{ name: "--all", value: "boolean", required: false, description: "Revoke and forget every saved login for this API origin." }], exits: WRITE_EXITS, summary: "Revoke a saved login on the server and delete it from this computer." },
|
|
1508
|
+
{ name: "sites create", operation: null, operations: [], permission: null, mutation: false, requires_site: false, text_input: "none", text_limit: null, flags: [{ name: "--scope", value: "string", required: false, description: "Comma-separated permissions to request: read, draft, build, publish. Omit to let the person choose from the defaults." }, { name: "--no-wait", value: "boolean", required: false, description: "Print the approval link and exit; finish later with saturndocs login --resume." }, { name: "--open", value: "boolean", required: false, description: "Open the approval link in the default browser." }], exits: WAIT_EXITS, summary: "Propose a new site; a person creates it while approving this agent, and the login is saved." },
|
|
1353
1509
|
{ name: "sites list", operation: "sites.list", operations: ["sites.list"], permission: "manage:read", mutation: false, requires_site: false, text_input: "none", text_limit: null, flags: [], exits: READ_EXITS, summary: "The sites the presented credential resolves to." },
|
|
1354
1510
|
{ name: "sites get", operation: "site.get", operations: ["site.get", "docs-repo.get", "product-connections.list"], permission: "manage:read", mutation: false, requires_site: false, text_input: "none", text_limit: null, flags: [{ name: "--connections", value: "boolean", required: false, description: "Also read the documentation repository and watched repositories." }], exits: READ_EXITS, summary: "One site's status, hostnames, publication, and usage." },
|
|
1355
1511
|
{ 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." },
|
|
@@ -1379,6 +1535,23 @@ var P0_COMMANDS = [
|
|
|
1379
1535
|
{ name: "activity list", operation: "activity.list", operations: ["activity.list"], permission: "manage:read", mutation: false, requires_site: false, text_input: "none", text_limit: null, flags: [cursor, limit, { name: "--outcome", value: "string", required: false, description: "suggestion, nochange, skipped, failed, or published." }, { name: "--repo", value: "string", required: false, description: "Full repository name." }, { name: "--from", value: "string", required: false, description: "Inclusive UTC date." }, { name: "--to", value: "string", required: false, description: "Inclusive UTC date." }], exits: READ_EXITS, summary: "Operational activity, newest first." },
|
|
1380
1536
|
{ name: "activity get", operation: "activity.list", operations: ["activity.list"], permission: "manage:read", mutation: false, requires_site: false, text_input: "none", text_limit: null, flags: [], exits: READ_EXITS, summary: "One job by id, through the list operation's job_id filter. No page-one scan." },
|
|
1381
1537
|
{ name: "releases list", operation: "releases.list", operations: ["releases.list"], permission: "manage:read", mutation: false, requires_site: false, text_input: "none", text_limit: null, flags: [cursor, limit], exits: READ_EXITS, summary: "Releases, newest first, with activation and current-active status." },
|
|
1538
|
+
{
|
|
1539
|
+
name: "releases rollback",
|
|
1540
|
+
operation: "releases.rollback",
|
|
1541
|
+
operations: ["releases.rollback"],
|
|
1542
|
+
permission: "rollback",
|
|
1543
|
+
mutation: true,
|
|
1544
|
+
requires_site: true,
|
|
1545
|
+
text_input: "none",
|
|
1546
|
+
text_limit: null,
|
|
1547
|
+
flags: [
|
|
1548
|
+
{ name: "--expected-active", value: "string", required: true, description: "Currently active release id." },
|
|
1549
|
+
{ name: "--expected-generation", value: "integer", required: true, description: "Currently active generation." },
|
|
1550
|
+
{ name: "--yes", value: "boolean", required: true, description: "Confirm the rollback." }
|
|
1551
|
+
],
|
|
1552
|
+
exits: WRITE_EXITS,
|
|
1553
|
+
summary: "Make the pinned release live until the next successful docs push."
|
|
1554
|
+
},
|
|
1382
1555
|
{ name: "releases get", operation: "releases.list", operations: ["releases.list"], permission: "manage:read", mutation: false, requires_site: false, text_input: "none", text_limit: null, flags: [], exits: READ_EXITS, summary: "One release by id, including one older than the first page." }
|
|
1383
1556
|
];
|
|
1384
1557
|
var P0_COMMAND_NAMES = Object.freeze(P0_COMMANDS.map((command) => command.name));
|
|
@@ -1571,7 +1744,9 @@ function defaultSleep(ms, signal) {
|
|
|
1571
1744
|
}
|
|
1572
1745
|
function createClient(config = {}) {
|
|
1573
1746
|
const origin = parseOrigin(config.origin);
|
|
1574
|
-
|
|
1747
|
+
let token = config.token;
|
|
1748
|
+
let pendingToken = null;
|
|
1749
|
+
const provider = config.token === void 0 ? config.tokenProvider : void 0;
|
|
1575
1750
|
const fetchImpl = config.fetchImpl ?? fetch;
|
|
1576
1751
|
const callerSignal = config.signal;
|
|
1577
1752
|
const defaultDeadline = config.deadlineMs ?? DEFAULT_DEADLINE_MS;
|
|
@@ -1589,9 +1764,14 @@ function createClient(config = {}) {
|
|
|
1589
1764
|
if (input.method === "GET" && (input.body !== void 0 || input.rawBody !== void 0)) throw invalidInput("A GET request does not carry a body.");
|
|
1590
1765
|
if (input.body !== void 0 && input.rawBody !== void 0) throw invalidInput("A request carries either a JSON body or an encoded one, never both.");
|
|
1591
1766
|
const anonymous = input.anonymous === true;
|
|
1592
|
-
if (!anonymous &&
|
|
1767
|
+
if (!anonymous && token === void 0 && provider !== void 0) {
|
|
1768
|
+
pendingToken ??= provider();
|
|
1769
|
+
token = await pendingToken;
|
|
1770
|
+
secrets.push(token);
|
|
1771
|
+
}
|
|
1772
|
+
if (!anonymous && (token === void 0 || token === "")) throw invalidInput("Run saturndocs login, or set SATURNDOCS_MANAGEMENT_TOKEN to a management credential for this site.");
|
|
1593
1773
|
const mutation = input.mutation === true || !IDEMPOTENT.has(input.method);
|
|
1594
|
-
const headers = new Headers({ accept: "application/json" });
|
|
1774
|
+
const headers = new Headers({ accept: input.accept ?? "application/json" });
|
|
1595
1775
|
if (!anonymous) headers.set("authorization", `Bearer ${token}`);
|
|
1596
1776
|
if (input.revision !== void 0) headers.set("if-match", ifMatchHeader(input.revision));
|
|
1597
1777
|
const body = input.rawBody ?? (input.body === void 0 ? void 0 : JSON.stringify(input.body));
|
|
@@ -1655,6 +1835,7 @@ function createClient(config = {}) {
|
|
|
1655
1835
|
correlationId,
|
|
1656
1836
|
mutation: "not_submitted"
|
|
1657
1837
|
});
|
|
1838
|
+
if (response.status === 409 && input.classifyConflict) throw input.classifyConflict(refusal, data);
|
|
1658
1839
|
const retryable = !mutation && RETRYABLE_STATUS.has(response.status) && attempts < MAX_READ_ATTEMPTS;
|
|
1659
1840
|
if (!retryable) throw refusal;
|
|
1660
1841
|
const waitMs = retryAfter === null ? null : retryAfter * 1e3;
|
|
@@ -1753,7 +1934,7 @@ async function resolveTarget(client, request = {}) {
|
|
|
1753
1934
|
if (request.mutation === true && request.site === void 0) {
|
|
1754
1935
|
throw invalidInput("This command writes, so it needs an explicit --site naming the site to act on.");
|
|
1755
1936
|
}
|
|
1756
|
-
const response = await client.get("/v1/sites", { signal: request.signal, deadlineMs: request.deadlineMs });
|
|
1937
|
+
const response = await client.get("/v1/sites", { signal: request.signal, deadlineMs: request.deadlineMs, query: { for: request.forOperation } });
|
|
1757
1938
|
const parsed = SitesResponse2.safeParse(response.data);
|
|
1758
1939
|
if (!parsed.success) {
|
|
1759
1940
|
throw managementError(
|
|
@@ -1869,7 +2050,7 @@ function commandMetadata(name, details) {
|
|
|
1869
2050
|
}),
|
|
1870
2051
|
permissions: Object.freeze({
|
|
1871
2052
|
server: spec.permission,
|
|
1872
|
-
preflight: spec.mutation ? "manage:read" : null
|
|
2053
|
+
preflight: spec.permission === "rollback" ? "rollback" : spec.mutation ? "manage:read" : null
|
|
1873
2054
|
}),
|
|
1874
2055
|
side_effects: Object.freeze({
|
|
1875
2056
|
mutation: spec.mutation,
|
|
@@ -1989,6 +2170,7 @@ async function listActivity(client, siteId, options = {}) {
|
|
|
1989
2170
|
const query = activityQuery({ cursor: cursor2, limit: limit2, outcome, repo, from, to });
|
|
1990
2171
|
const response = await client.get(operationPath("activity.list", siteId), {
|
|
1991
2172
|
...read,
|
|
2173
|
+
accept: ROLLBACK_ACTIVITY_ACCEPT,
|
|
1992
2174
|
...Object.keys(query).length === 0 ? {} : { query }
|
|
1993
2175
|
});
|
|
1994
2176
|
return parseResponse(ActivityPageRead, response.data, `The activity listing for ${siteId}`);
|
|
@@ -2834,6 +3016,39 @@ async function readRequestThread(client, input) {
|
|
|
2834
3016
|
});
|
|
2835
3017
|
return parseResponse(RequestThread2, response.data, "The request thread");
|
|
2836
3018
|
}
|
|
3019
|
+
async function rollbackRelease(client, siteId, input, signal) {
|
|
3020
|
+
const parsed = ReleaseRollbackBody2.safeParse(input);
|
|
3021
|
+
if (!parsed.success || parsed.data.release_id === parsed.data.expected_active_release_id) {
|
|
3022
|
+
throw invalidInput("Name the pinned release, a different active release, and the current generation.");
|
|
3023
|
+
}
|
|
3024
|
+
const body = parsed.data;
|
|
3025
|
+
const response = await client.request({
|
|
3026
|
+
method: "POST",
|
|
3027
|
+
path: operationPath("releases.rollback", siteId),
|
|
3028
|
+
body,
|
|
3029
|
+
signal,
|
|
3030
|
+
classifyConflict(error, payload) {
|
|
3031
|
+
const { server } = error.detail;
|
|
3032
|
+
if (server?.code !== SUPERSEDED_ROLLBACK) return error;
|
|
3033
|
+
const receipt = matchSupersededRollback(siteId, body, payload);
|
|
3034
|
+
if (!receipt) return unknownOutcome(ROLLBACK_RECOVERY);
|
|
3035
|
+
const message = describeSupersededRollback(receipt);
|
|
3036
|
+
return managementError("conflict", message, { server: { ...server, message }, mutation: "known" });
|
|
3037
|
+
}
|
|
3038
|
+
}).catch((error) => {
|
|
3039
|
+
if (!isManagementError(error)) throw error;
|
|
3040
|
+
const { server } = error.detail;
|
|
3041
|
+
if (server && uncertainRollbackRefusal(server.status, server.code)) {
|
|
3042
|
+
throw managementError("unknown_outcome", ROLLBACK_RECOVERY, { server });
|
|
3043
|
+
}
|
|
3044
|
+
throw error;
|
|
3045
|
+
});
|
|
3046
|
+
const proof = ReleaseRollbackResponse2.safeParse(response.data);
|
|
3047
|
+
if (!proof.success || !rollbackProofMatches(siteId, body, proof.data)) {
|
|
3048
|
+
throw unknownOutcome(ROLLBACK_RECOVERY);
|
|
3049
|
+
}
|
|
3050
|
+
return proof.data;
|
|
3051
|
+
}
|
|
2837
3052
|
var REQUEST_PAGE_LIMIT = 400;
|
|
2838
3053
|
var UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/iu;
|
|
2839
3054
|
function checkedSubmissionId(value) {
|
|
@@ -3199,6 +3414,12 @@ function previewIds(result) {
|
|
|
3199
3414
|
return { suggestion_id: result.suggestion_id };
|
|
3200
3415
|
}
|
|
3201
3416
|
var SESSION_MESSAGE_LIMIT2 = MAX_SESSION_MESSAGE_CHARS;
|
|
3417
|
+
var SESSION_MESSAGE_DEADLINE_MS = 5 * 6e4;
|
|
3418
|
+
var SESSION_ATTEMPT_MS = DEFAULT_DEADLINE_MS;
|
|
3419
|
+
var MAX_UNREACHABLE_SENDS = 3;
|
|
3420
|
+
var UNREACHABLE_BACKOFF_MS = 250;
|
|
3421
|
+
var RUNNING_BACKOFF_MS = 1e3;
|
|
3422
|
+
var MAX_REPLAY_BACKOFF_MS = 5e3;
|
|
3202
3423
|
function requireSuggestionId3(value, usage) {
|
|
3203
3424
|
if (value.trim() === "") throw invalidInput(`Name the suggestion to act on, as ${usage}.`);
|
|
3204
3425
|
return value;
|
|
@@ -3214,6 +3435,13 @@ function unreadableTurn(suggestionId) {
|
|
|
3214
3435
|
`The message was accepted and its answer was not in the shape this client understands, so whether it queued a revision is not reported here. Read the transcript with saturndocs suggestions conversation ${suggestionId} before sending anything again; sending this message again would ask the suggestion twice.`
|
|
3215
3436
|
);
|
|
3216
3437
|
}
|
|
3438
|
+
function unansweredTurn(suggestionId, why) {
|
|
3439
|
+
throw managementError(
|
|
3440
|
+
"transport_failure",
|
|
3441
|
+
`${why} The turn may still complete and may queue a revision. Read the transcript with saturndocs suggestions conversation ${suggestionId} before sending anything again; sending this message again would ask the suggestion twice.`,
|
|
3442
|
+
{ mutation: "unknown", retryable: false }
|
|
3443
|
+
);
|
|
3444
|
+
}
|
|
3217
3445
|
async function readConversation(client, input) {
|
|
3218
3446
|
const suggestionId = requireSuggestionId3(input.suggestionId, "saturndocs suggestions conversation <suggestion-id>");
|
|
3219
3447
|
const response = await client.get(resourcePath(input.site, ["suggestions", suggestionId, "session"]), {
|
|
@@ -3232,20 +3460,79 @@ async function readConversation(client, input) {
|
|
|
3232
3460
|
async function sendSessionMessage(client, input) {
|
|
3233
3461
|
const suggestionId = requireSuggestionId3(input.suggestionId, "saturndocs suggestions message <suggestion-id>");
|
|
3234
3462
|
const questionId = input.questionId === void 0 || input.questionId === null || input.questionId === "" ? void 0 : input.questionId;
|
|
3235
|
-
const body = SessionMessageBody.safeParse({
|
|
3463
|
+
const body = SessionMessageBody.safeParse({
|
|
3464
|
+
message: input.message,
|
|
3465
|
+
turn_id: input.turnId ?? crypto.randomUUID(),
|
|
3466
|
+
...questionId === void 0 ? {} : { question_id: questionId }
|
|
3467
|
+
});
|
|
3236
3468
|
if (!body.success) {
|
|
3237
|
-
const
|
|
3469
|
+
const fields = new Set(body.error.issues.map((issue) => issue.path[0]));
|
|
3238
3470
|
throw invalidInput(
|
|
3239
|
-
|
|
3471
|
+
fields.has("message") ? `saturndocs suggestions message accepts at most ${SESSION_MESSAGE_LIMIT2} characters and no empty message. Nothing was sent.` : fields.has("question_id") ? `--question-id takes a question id this suggestion carries, and this one is not a length the server mints. Read the suggestion's questions first; a request thread id is not a suggestion question.` : "A turn id is a UUID, so a replay can be matched to the turn it repeats. Nothing was sent."
|
|
3240
3472
|
);
|
|
3241
3473
|
}
|
|
3242
|
-
const
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3474
|
+
const deadlineMs = input.deadlineMs ?? SESSION_MESSAGE_DEADLINE_MS;
|
|
3475
|
+
const attemptMs = input.attemptMs ?? SESSION_ATTEMPT_MS;
|
|
3476
|
+
if (!Number.isFinite(deadlineMs) || deadlineMs <= 0 || !Number.isFinite(attemptMs) || attemptMs <= 0) {
|
|
3477
|
+
throw invalidInput("The timeout must be a positive number of seconds. Nothing was sent.");
|
|
3478
|
+
}
|
|
3479
|
+
const sleep = input.sleep ?? defaultSleep2;
|
|
3480
|
+
const cancelled = () => input.signal?.aborted === true;
|
|
3481
|
+
const startedAt = Date.now();
|
|
3482
|
+
const remaining = () => deadlineMs - (Date.now() - startedAt);
|
|
3483
|
+
const seconds = Math.round(deadlineMs / 1e3);
|
|
3484
|
+
let sends = 0;
|
|
3485
|
+
let unreachable = 0;
|
|
3486
|
+
let running = 0;
|
|
3487
|
+
let response;
|
|
3488
|
+
for (; ; ) {
|
|
3489
|
+
if (cancelled()) throw interrupted(sends === 0 ? "not_submitted" : "unknown");
|
|
3490
|
+
const left = remaining();
|
|
3491
|
+
if (left <= 0) {
|
|
3492
|
+
unansweredTurn(
|
|
3493
|
+
suggestionId,
|
|
3494
|
+
running > 0 ? `The suggestion did not answer within ${seconds}s, and the server last reported the turn as still running.` : `The suggestion did not answer within ${seconds}s.`
|
|
3495
|
+
);
|
|
3496
|
+
}
|
|
3497
|
+
const attempt = AbortSignal.timeout(Math.min(attemptMs, left));
|
|
3498
|
+
sends += 1;
|
|
3499
|
+
let backoff = 0;
|
|
3500
|
+
try {
|
|
3501
|
+
const answered = await client.request({
|
|
3502
|
+
method: "POST",
|
|
3503
|
+
path: resourcePath(input.site, ["suggestions", suggestionId, "session"]),
|
|
3504
|
+
body: body.data,
|
|
3505
|
+
signal: input.signal === void 0 ? attempt : AbortSignal.any([attempt, input.signal]),
|
|
3506
|
+
deadlineMs: left
|
|
3507
|
+
});
|
|
3508
|
+
unreachable = 0;
|
|
3509
|
+
if (answered.status !== 202) {
|
|
3510
|
+
response = answered;
|
|
3511
|
+
break;
|
|
3512
|
+
}
|
|
3513
|
+
running += 1;
|
|
3514
|
+
backoff = Math.min(MAX_REPLAY_BACKOFF_MS, RUNNING_BACKOFF_MS * 2 ** (running - 1));
|
|
3515
|
+
} catch (cause) {
|
|
3516
|
+
if (cancelled() || !isManagementError(cause)) throw cause;
|
|
3517
|
+
if (cause.detail.code !== "transport_failure" && !(attempt.aborted && cause.detail.code === "interrupted")) throw cause;
|
|
3518
|
+
if (!attempt.aborted && remaining() > 0) {
|
|
3519
|
+
unreachable += 1;
|
|
3520
|
+
if (unreachable >= MAX_UNREACHABLE_SENDS) {
|
|
3521
|
+
unansweredTurn(suggestionId, `The session route could not be reached after ${unreachable} tries in a row: ${cause.detail.message}`);
|
|
3522
|
+
}
|
|
3523
|
+
backoff = UNREACHABLE_BACKOFF_MS * 2 ** (unreachable - 1);
|
|
3524
|
+
}
|
|
3525
|
+
}
|
|
3526
|
+
const wait = Math.min(backoff, remaining());
|
|
3527
|
+
if (wait > 0) {
|
|
3528
|
+
try {
|
|
3529
|
+
await sleep(wait, input.signal ?? new AbortController().signal);
|
|
3530
|
+
} catch (cause) {
|
|
3531
|
+
if (cancelled()) throw interrupted("unknown");
|
|
3532
|
+
throw cause;
|
|
3533
|
+
}
|
|
3534
|
+
}
|
|
3535
|
+
}
|
|
3249
3536
|
const parsed = SessionResponse2.safeParse(response.data);
|
|
3250
3537
|
if (!parsed.success) unreadableTurn(suggestionId);
|
|
3251
3538
|
const outcome = parsed.data;
|
|
@@ -3504,8 +3791,10 @@ export {
|
|
|
3504
3791
|
CLIENT_SCHEMA_VERSION,
|
|
3505
3792
|
GLOBAL_FLAGS,
|
|
3506
3793
|
REQUEST_TEXT_LIMIT,
|
|
3794
|
+
invalidInput,
|
|
3507
3795
|
isManagementError,
|
|
3508
3796
|
requireCommitSha,
|
|
3797
|
+
parseOrigin,
|
|
3509
3798
|
createClient,
|
|
3510
3799
|
resolveTarget,
|
|
3511
3800
|
COMMAND_SCHEMA_VERSION,
|
|
@@ -3544,6 +3833,7 @@ export {
|
|
|
3544
3833
|
waitForSuggestion,
|
|
3545
3834
|
listRequestThreads,
|
|
3546
3835
|
readRequestThread,
|
|
3836
|
+
rollbackRelease,
|
|
3547
3837
|
checkedSubmissionId,
|
|
3548
3838
|
checkedRequestText,
|
|
3549
3839
|
createRequest,
|
|
@@ -3570,7 +3860,7 @@ export {
|
|
|
3570
3860
|
applyGlobalFlagsDeep,
|
|
3571
3861
|
resolveGlobalOptions,
|
|
3572
3862
|
CliError,
|
|
3573
|
-
invalidInput2
|
|
3863
|
+
invalidInput2,
|
|
3574
3864
|
interrupted2 as interrupted,
|
|
3575
3865
|
clientError2 as clientError,
|
|
3576
3866
|
successResult,
|