saturndocs 0.3.0 → 0.4.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 → auth-NKYU6ZSC.js} +4 -4
- package/dist/{chunk-3EW6ZPL6.js → chunk-22WNRYB7.js} +16 -18
- package/dist/{chunk-3X2NBWZN.js → chunk-2GBM6W4I.js} +5 -25
- package/dist/{chunk-RKM7YWPD.js → chunk-3JUP4HIA.js} +11 -5
- package/dist/{chunk-FUZE54DG.js → chunk-4B6PUKF5.js} +26 -16
- package/dist/{chunk-32ATWMIS.js → chunk-6JJEMNSP.js} +7 -6
- package/dist/{chunk-PU37LVIF.js → chunk-BB32XQJB.js} +9 -5
- package/dist/{chunk-IWIVHHZI.js → chunk-BRC7CU3J.js} +8 -7
- package/dist/{chunk-3KCCCMQY.js → chunk-EH6E45H4.js} +481 -112
- package/dist/{chunk-IJOYWJVM.js → chunk-GLB47CSE.js} +3 -3
- package/dist/{chunk-5ZYUBLEH.js → chunk-HHRZ3Y55.js} +1954 -1833
- package/dist/{chunk-T3MCJYSF.js → chunk-HJ7HRIAT.js} +1 -1
- package/dist/{chunk-6EKGBIUR.js → chunk-KEZAO7P5.js} +1 -1
- package/dist/{chunk-HBSJ4Z4S.js → chunk-KWEWL4MJ.js} +21 -21
- package/dist/{chunk-BOWRQKXR.js → chunk-N66SXAI5.js} +10 -8
- package/dist/{chunk-WMS6FUKK.js → chunk-QF5ELRAU.js} +20 -13
- package/dist/{chunk-VDGVERLX.js → chunk-QMA7433F.js} +3 -3
- package/dist/{chunk-TEYHAN2L.js → chunk-TRQCW5CZ.js} +2 -2
- package/dist/{chunk-YPWPLIEZ.js → chunk-UXCORL5H.js} +3 -3
- package/dist/{chunk-E3G56DR2.js → chunk-ZHYL7FYA.js} +589 -1
- package/dist/{chunk-WXLJZ7RD.js → chunk-ZXJ3Z3PR.js} +3 -3
- package/dist/cli.js +3 -3
- package/dist/{coverage-SRIA65FT.js → coverage-IUQLC2H6.js} +4 -4
- package/dist/{dist-LJSALT4X.js → dist-LZ5BC7HG.js} +8 -3
- package/dist/index.js +20 -21
- package/dist/{init-Y3GDNDWW.js → init-EFZZRZZM.js} +4 -5
- package/dist/{lint-XM26WIGE.js → lint-N7ENEJVU.js} +2 -2
- package/dist/{login-HIXLPRUI.js → login-34OM3PJ2.js} +4 -4
- package/dist/{manage-3HEBB3EQ.js → manage-2AOOCZE2.js} +4 -4
- package/dist/{nav-K43WZJ4J.js → nav-DKCGLENP.js} +4 -4
- package/dist/{openapiCheck-CL2AH3YC.js → openapiCheck-KEHPUZOD.js} +4 -6
- package/dist/pages-E73CUM6I.js +16 -0
- package/dist/{read-RKT6HUZ7.js → read-TQSSS7EJ.js} +25 -11
- package/dist/{read-DYGYUOFK.js → read-UGXFNEGJ.js} +11 -10
- package/dist/requests-OLCBRUAW.js +13 -0
- package/dist/{schema-QMJMGD5P.js → schema-3I6XJSCY.js} +3 -3
- package/dist/{sites-JKS25SEM.js → sites-6HKU6JP7.js} +5 -5
- package/dist/{status-FM2ALQUJ.js → status-DFAYOCC4.js} +4 -4
- package/dist/{suggestions-Z6XIHMFN.js → suggestions-JSTWOWRY.js} +26 -17
- package/dist/{unavailable-DVPNUO3J.js → unavailable-HVN65Q7D.js} +2 -2
- package/dist/validate-6RIKQWMI.js +11 -0
- package/package.json +2 -2
- package/dist/chunk-W3FZTCKV.js +0 -590
- package/dist/pages-4VWB7Z4S.js +0 -16
- package/dist/requests-CZYE6GI3.js +0 -13
- package/dist/validate-X42T4TJ6.js +0 -12
|
@@ -4,6 +4,7 @@ import { z as z22 } from "zod";
|
|
|
4
4
|
import { z as z32 } from "zod";
|
|
5
5
|
|
|
6
6
|
// ../owner-contract/dist/index.js
|
|
7
|
+
import { z } from "zod";
|
|
7
8
|
import { z as z2 } from "zod";
|
|
8
9
|
|
|
9
10
|
// ../control-abi/dist/index.js
|
|
@@ -33,7 +34,6 @@ var ENFORCEMENT = Object.freeze({ ownership: "d1_transaction", heads: "d1_transa
|
|
|
33
34
|
var PR_PREVIEW_IDLE_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
34
35
|
|
|
35
36
|
// ../owner-contract/dist/index.js
|
|
36
|
-
import { z } from "zod";
|
|
37
37
|
var MANAGEMENT_SCOPES = ["manage:read", "manage:write", "manage:approve", "manage:access", "rollback"];
|
|
38
38
|
var ManagementCredential = z.object({
|
|
39
39
|
token_id: z.string(),
|
|
@@ -434,6 +434,38 @@ var SuggestionRecord = z2.object({
|
|
|
434
434
|
provenance: Provenance.nullable().optional(),
|
|
435
435
|
merge_mode: z2.enum(MERGE_MODES).nullable().optional()
|
|
436
436
|
});
|
|
437
|
+
var SuggestionInboxRecord = SuggestionRecord.pick({
|
|
438
|
+
suggestion_id: true,
|
|
439
|
+
pr_number: true,
|
|
440
|
+
head_branch: true,
|
|
441
|
+
base_sha: true,
|
|
442
|
+
state: true,
|
|
443
|
+
title: true,
|
|
444
|
+
repository_id: true,
|
|
445
|
+
commit_sha: true,
|
|
446
|
+
source_pr_number: true,
|
|
447
|
+
request: true,
|
|
448
|
+
requested_by: true,
|
|
449
|
+
pages_count: true,
|
|
450
|
+
first_path: true,
|
|
451
|
+
confidence: true,
|
|
452
|
+
revision: true,
|
|
453
|
+
job_id: true,
|
|
454
|
+
error_code: true,
|
|
455
|
+
error_message: true,
|
|
456
|
+
dismiss_reason: true,
|
|
457
|
+
created_at: true,
|
|
458
|
+
updated_at: true
|
|
459
|
+
});
|
|
460
|
+
var SuggestionDetailRecord = SuggestionRecord.omit({
|
|
461
|
+
pages_count: true,
|
|
462
|
+
first_path: true,
|
|
463
|
+
repository: true,
|
|
464
|
+
error_code: true,
|
|
465
|
+
error_message: true,
|
|
466
|
+
references: true,
|
|
467
|
+
revisions: true
|
|
468
|
+
}).extend({ session_budget: z2.object({ spent: z2.number(), ceiling: z2.number() }) });
|
|
437
469
|
var SuggestionCounts = z2.object({
|
|
438
470
|
pending: z2.number().int(),
|
|
439
471
|
revising: z2.number().int(),
|
|
@@ -1081,10 +1113,147 @@ var ApproveOutcome = OperationFailure.extend({
|
|
|
1081
1113
|
});
|
|
1082
1114
|
var DismissOutcome = OperationFailure.extend({ state: z2.literal("dismissed").optional(), pr_number: z2.number().int().nullable().optional(), pull_request_closed: z2.boolean().optional() });
|
|
1083
1115
|
var RequestChangesOutcome = OperationFailure.extend({ state: z2.literal("revising").optional(), pr_number: z2.number().int().nullable().optional(), revision: z2.number().int().optional(), already_requested: z2.boolean().optional() });
|
|
1116
|
+
var RetryOutcome = ApproveOutcome;
|
|
1117
|
+
function isGitHubRepository(value) {
|
|
1118
|
+
const [owner, repo, ...extra] = value.split("/");
|
|
1119
|
+
return extra.length === 0 && !!owner && owner.length <= 39 && /^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*(?:_[A-Za-z0-9]{3,8})?$/u.test(owner) && !!repo && repo !== "." && repo !== ".." && /^[A-Za-z0-9._-]{1,100}$/u.test(repo);
|
|
1120
|
+
}
|
|
1121
|
+
var Grant = (() => {
|
|
1122
|
+
const suggestion = SuggestionRecord.pick({
|
|
1123
|
+
suggestion_id: true,
|
|
1124
|
+
title: true,
|
|
1125
|
+
state: true,
|
|
1126
|
+
revision: true,
|
|
1127
|
+
base_sha: true,
|
|
1128
|
+
head_sha: true,
|
|
1129
|
+
commit_sha: true,
|
|
1130
|
+
created_at: true,
|
|
1131
|
+
updated_at: true,
|
|
1132
|
+
merge_mode: true,
|
|
1133
|
+
requested_by: true,
|
|
1134
|
+
reviewer: true,
|
|
1135
|
+
head_edited_by: true
|
|
1136
|
+
});
|
|
1137
|
+
const suggestions = SuggestionsPage.pick({ site_id: true, state: true, next_cursor: true }).extend({ suggestions: z2.array(suggestion) });
|
|
1138
|
+
const detail = z2.object({ site_id: z2.string(), suggestion });
|
|
1139
|
+
const request = RequestRecord.pick({
|
|
1140
|
+
job_id: true,
|
|
1141
|
+
request: true,
|
|
1142
|
+
requested_by: true,
|
|
1143
|
+
state: true,
|
|
1144
|
+
attempt: true,
|
|
1145
|
+
thread_id: true,
|
|
1146
|
+
suggestion_id: true,
|
|
1147
|
+
created_at: true,
|
|
1148
|
+
updated_at: true
|
|
1149
|
+
});
|
|
1150
|
+
const entries = z2.array(RequestThreadEntry.pick({ job_id: true, seq: true, author: true, kind: true, body: true, created_at: true }));
|
|
1151
|
+
const thread = RequestThread.pick({ site_id: true, thread_id: true, open: true }).extend({ root: request, latest_job: request, entries });
|
|
1152
|
+
const flat = z2.object({ site_id: z2.string(), requests: z2.array(request), next_cursor: z2.string().nullable() });
|
|
1153
|
+
const grouped = RequestsPage.pick({ site_id: true, page_cursor: true, next_cursor: true, has_newer: true }).extend({
|
|
1154
|
+
threads: z2.array(RequestThreadSummary.pick({ thread_id: true, open: true, turns: true }).extend({ root: request, latest: request, entries }))
|
|
1155
|
+
});
|
|
1156
|
+
const site = PortalSite.pick({ site_id: true, reader_status: true }).extend({
|
|
1157
|
+
docs_repo: DocsRepo.pick({ repository: true, branch: true, docs_root: true, state: true }).nullable(),
|
|
1158
|
+
active_release: ActiveRelease.pick({ release_id: true, state: true, generation: true, activated_at: true }).nullable(),
|
|
1159
|
+
latest_job: LatestJob.pick({ state: true, updated_at: true }).nullable()
|
|
1160
|
+
});
|
|
1161
|
+
const pages = z2.object({
|
|
1162
|
+
site_id: z2.string(),
|
|
1163
|
+
unavailable: z2.literal("no_release").optional(),
|
|
1164
|
+
release_id: z2.string().optional(),
|
|
1165
|
+
pages: z2.array(z2.object({ path: z2.string(), url: z2.string() })).optional()
|
|
1166
|
+
});
|
|
1167
|
+
const releases = ReleasesPage.pick({ site_id: true, next_cursor: true, active_release_id: true, active_release_status: true }).extend({
|
|
1168
|
+
releases: z2.array(ReleaseRecord.pick({ release_id: true, state: true, built_at: true, activated_at: true, source_revision_id: true, git_commit: true }).extend({
|
|
1169
|
+
job: ReleaseRecord.shape.job.pick({ job_id: true, operation: true, requested_by: true })
|
|
1170
|
+
}))
|
|
1171
|
+
});
|
|
1172
|
+
const activityEvent = ActivityEvent.pick({
|
|
1173
|
+
id: true,
|
|
1174
|
+
operation: true,
|
|
1175
|
+
state: true,
|
|
1176
|
+
outcome_code: true,
|
|
1177
|
+
error_code: true,
|
|
1178
|
+
repository: true,
|
|
1179
|
+
commit_sha: true,
|
|
1180
|
+
actor: true,
|
|
1181
|
+
suggestion_id: true,
|
|
1182
|
+
pr_number: true,
|
|
1183
|
+
skip_reason: true,
|
|
1184
|
+
created_at: true,
|
|
1185
|
+
updated_at: true
|
|
1186
|
+
}).transform((event) => ({
|
|
1187
|
+
...event,
|
|
1188
|
+
repository: event.repository && isGitHubRepository(event.repository) ? event.repository : null,
|
|
1189
|
+
error_message: null,
|
|
1190
|
+
commit_message: null
|
|
1191
|
+
}));
|
|
1192
|
+
const activity = ActivityPage.pick({ site_id: true, next_cursor: true }).extend({ events: z2.array(activityEvent) });
|
|
1193
|
+
const count = z2.number().int().nonnegative().optional();
|
|
1194
|
+
const activitySummary = ActivitySummary.pick({ site_id: true, since: true, until: true, total: true }).extend({
|
|
1195
|
+
counts: z2.object({ suggestion: count, nochange: count, skipped: count, failed: count, published: count, working: count, cancelled: count })
|
|
1196
|
+
});
|
|
1197
|
+
const preview = SuggestionPreviewResponse.pick({ state: true, revision: true, current: true });
|
|
1198
|
+
const buildRetry = z2.object({ retried: z2.boolean(), job_id: z2.string().optional(), attempt: z2.number().int().optional(), operation: z2.string().optional() });
|
|
1199
|
+
const requests = z2.union([flat, grouped]);
|
|
1200
|
+
const update = UpdateRequestResponse.pick({ job_id: true, state: true });
|
|
1201
|
+
const retry = RequestRetryResponse.pick({ job_id: true, state: true, attempt: true });
|
|
1202
|
+
const build = BuildOutcome.pick({ job_id: true, commit_sha: true, state: true });
|
|
1203
|
+
return { suggestion, suggestions, detail, request, entries, grouped, flat, requests, thread, site, pages, releases, activity, activitySummary, preview, buildRetry, update, retry, build };
|
|
1204
|
+
})();
|
|
1205
|
+
var managementWriteReceipts = {
|
|
1206
|
+
"POST /settings/proposal/approve": SettingsApprovalResponse,
|
|
1207
|
+
"POST /settings/proposal/update": SettingsUpdateResponse,
|
|
1208
|
+
"POST /releases/rollback": ReleaseRollbackResponse,
|
|
1209
|
+
"POST /requests": UpdateRequestResponse,
|
|
1210
|
+
"POST /gaps/work": GapWorkResponse,
|
|
1211
|
+
"POST /requests/{job}/retry": RequestRetryResponse,
|
|
1212
|
+
"POST /domains": AddDomainResponse,
|
|
1213
|
+
"DELETE /domains/{hostname}": RemoveDomainResponse,
|
|
1214
|
+
"POST /readers": WriteReaderResponse,
|
|
1215
|
+
"DELETE /readers": ClearReadersResponse,
|
|
1216
|
+
"DELETE /readers/{entry}": RemoveReaderResponse,
|
|
1217
|
+
"POST /readers/rotate": RotateReadersResponse,
|
|
1218
|
+
"POST /owners": OwnerResponse,
|
|
1219
|
+
"PATCH /owners/{owner}": OwnerResponse,
|
|
1220
|
+
"DELETE /owners/{owner}": RemoveOwnerResponse,
|
|
1221
|
+
"PATCH /organization": OrganizationResponse,
|
|
1222
|
+
"POST /organization/leave": OrganizationLeaveResponse,
|
|
1223
|
+
"POST /billing/checkout": BillingRedirect,
|
|
1224
|
+
"POST /billing/portal": BillingRedirect,
|
|
1225
|
+
"POST /credentials": IssuedManagementCredential,
|
|
1226
|
+
"DELETE /grants/{grant}": z2.object({ revoked: z2.boolean(), grant_id: z2.string() }),
|
|
1227
|
+
"DELETE /credentials/{token}": z2.object({ revoked: z2.boolean(), token_id: z2.string() }),
|
|
1228
|
+
"POST /builds": BuildOutcome,
|
|
1229
|
+
"POST /builds/retry": z2.object({ retried: z2.boolean(), job_id: z2.string().optional(), operation: z2.string().optional(), attempt: z2.number().int().optional() }),
|
|
1230
|
+
"POST /suggestions/{suggestion}/approve": ApproveOutcome,
|
|
1231
|
+
"POST /suggestions/{suggestion}/retry": RetryOutcome,
|
|
1232
|
+
"POST /suggestions/{suggestion}/dismiss": DismissOutcome,
|
|
1233
|
+
"POST /suggestions/{suggestion}/request-changes": RequestChangesOutcome,
|
|
1234
|
+
"POST /docs-repo": z2.object({ docs_repo: DocsRepoSettings.shape.docs_repo, job_id: z2.string().nullable() }),
|
|
1235
|
+
"POST /docs-repo/inspect": DocsInspection,
|
|
1236
|
+
"POST /docs-repo/scaffold": DocsRepoScaffoldResponse,
|
|
1237
|
+
"POST /docs-repo/reconnect": z2.object({ state: z2.literal("active"), job_id: z2.string().nullable() }),
|
|
1238
|
+
"POST /product-connections": ProductConnectionWriteResponse,
|
|
1239
|
+
"PATCH /product-connections/{connection}": ProductConnectionWriteResponse,
|
|
1240
|
+
"POST /product-connections/{connection}/analyse": AnalyseOutcome,
|
|
1241
|
+
"POST /analysis-limit": AnalysisLimit,
|
|
1242
|
+
...Object.fromEntries(["pause", "resume", "reconnect"].map((action) => [`POST /product-connections/{connection}/${action}`, z2.object({ product_connection: ProductConnectionRules.nullable(), state: z2.string() })])),
|
|
1243
|
+
"POST /github/install": z2.object({ authorization_url: z2.string() }),
|
|
1244
|
+
"POST /github/connect": z2.object({ authorization_url: z2.string() }),
|
|
1245
|
+
"POST /github/link": GitHubLinkOutcome,
|
|
1246
|
+
"POST /slack/install": z2.object({ authorization_url: z2.string() }),
|
|
1247
|
+
"POST /suggestions/{suggestion}/session": SessionResponse,
|
|
1248
|
+
"POST /suggestions/{suggestion}/preview": SuggestionPreviewResponse,
|
|
1249
|
+
"PUT /notifications": NotificationsResponse,
|
|
1250
|
+
"PUT /previews": PreviewSettings
|
|
1251
|
+
};
|
|
1084
1252
|
|
|
1085
1253
|
// ../management-client/dist/index.js
|
|
1086
1254
|
import { z as z4 } from "zod";
|
|
1087
1255
|
import { z as z5 } from "zod";
|
|
1256
|
+
import { z as z6 } from "zod";
|
|
1088
1257
|
var EXIT = {
|
|
1089
1258
|
success: 0,
|
|
1090
1259
|
invalid_input: 2,
|
|
@@ -1190,7 +1359,11 @@ var LIMITATION_CODES = [
|
|
|
1190
1359
|
"hand_edited",
|
|
1191
1360
|
"cleanup_incomplete",
|
|
1192
1361
|
"activation_unknown",
|
|
1193
|
-
"section_unavailable"
|
|
1362
|
+
"section_unavailable",
|
|
1363
|
+
"field_omitted",
|
|
1364
|
+
"value_redacted",
|
|
1365
|
+
"actor_relabeled",
|
|
1366
|
+
"row_visibility"
|
|
1194
1367
|
];
|
|
1195
1368
|
var ClientLimitation = z22.object({
|
|
1196
1369
|
code: z22.enum(LIMITATION_CODES),
|
|
@@ -1231,20 +1404,64 @@ var ClientResult = z22.discriminatedUnion("ok", [ClientSuccess, ClientFailure]);
|
|
|
1231
1404
|
function exitForResult(result) {
|
|
1232
1405
|
return result.ok ? EXIT.success : result.error.exit;
|
|
1233
1406
|
}
|
|
1407
|
+
function projection(full, grant) {
|
|
1408
|
+
const omitted2 = Object.keys(full.shape).filter((key) => !(key in grant.shape));
|
|
1409
|
+
const absent = Object.fromEntries(omitted2.map((key) => [key, z32.never().optional()]));
|
|
1410
|
+
return grant.extend(absent);
|
|
1411
|
+
}
|
|
1412
|
+
function credentialSchema(schema, grantAuthenticated) {
|
|
1413
|
+
return grantAuthenticated ? schema : schema.options[0];
|
|
1414
|
+
}
|
|
1415
|
+
var G = Grant;
|
|
1416
|
+
var grantSite = projection(PortalSite, G.site).extend({
|
|
1417
|
+
docs_repo: projection(DocsRepo, G.site.shape.docs_repo.unwrap()).nullable(),
|
|
1418
|
+
latest_job: projection(LatestJob, G.site.shape.latest_job.unwrap()).nullable()
|
|
1419
|
+
});
|
|
1420
|
+
var fullDetail = SuggestionRecord.extend({ session_budget: SuggestionDetailRecord.shape.session_budget.optional() });
|
|
1421
|
+
var grantSuggestion = projection(SuggestionRecord, G.suggestion);
|
|
1422
|
+
var grantRequest = z32.union([RequestRecord, projection(RequestRecord, G.request)]);
|
|
1423
|
+
var grantEntries = z32.array(z32.union([RequestThreadEntry, projection(RequestThreadEntry, G.entries.element)]));
|
|
1424
|
+
var grantThread = G.thread.extend({ root: grantRequest, latest_job: grantRequest, entries: grantEntries });
|
|
1425
|
+
var grantGrouped = projection(RequestsPage, G.grouped).extend({
|
|
1426
|
+
threads: z32.array(G.grouped.shape.threads.element.extend({ root: grantRequest, latest: grantRequest, entries: grantEntries }))
|
|
1427
|
+
});
|
|
1428
|
+
var grantRelease = G.releases.shape.releases.element;
|
|
1429
|
+
var grantReleaseRow = projection(ReleaseRecord, grantRelease).extend({
|
|
1430
|
+
job: projection(ReleaseRecord.shape.job, grantRelease.shape.job)
|
|
1431
|
+
});
|
|
1432
|
+
var grantReleases = ReleasesPage.extend({
|
|
1433
|
+
releases: z32.array(z32.union([ReleaseRecord, grantReleaseRow]))
|
|
1434
|
+
});
|
|
1435
|
+
var [noRelease, published] = PagesResponse.options;
|
|
1436
|
+
var grantPublished = G.pages.pick({ site_id: true, release_id: true, pages: true }).required();
|
|
1437
|
+
var grantPages = z32.union([
|
|
1438
|
+
projection(noRelease, G.pages.pick({ site_id: true, unavailable: true }).required()),
|
|
1439
|
+
projection(published, grantPublished).extend({
|
|
1440
|
+
pages: z32.array(projection(published.shape.pages.element, G.pages.shape.pages.unwrap().element))
|
|
1441
|
+
})
|
|
1442
|
+
]);
|
|
1234
1443
|
var SitesResponse2 = SitesResponse.loose();
|
|
1235
|
-
var PortalSite2 = PortalSite.loose();
|
|
1236
|
-
var PagesResponse2 = PagesResponse;
|
|
1444
|
+
var PortalSite2 = z32.union([PortalSite.loose(), grantSite]);
|
|
1445
|
+
var PagesResponse2 = z32.union([PagesResponse, grantPages]);
|
|
1237
1446
|
var ActivityPage2 = ActivityPage.loose();
|
|
1238
|
-
var ReleasesPage2 = ReleasesPage.loose();
|
|
1239
|
-
var
|
|
1240
|
-
var
|
|
1447
|
+
var ReleasesPage2 = z32.union([ReleasesPage.loose(), grantReleases]);
|
|
1448
|
+
var BuildRetry = G.buildRetry;
|
|
1449
|
+
var FlatRequestsPage = z32.union([
|
|
1450
|
+
G.flat.extend({ requests: z32.array(RequestRecord), failed: z32.number().int().nonnegative().optional() }).loose(),
|
|
1451
|
+
G.flat.extend({ requests: z32.array(grantRequest) })
|
|
1452
|
+
]);
|
|
1453
|
+
var RequestsPage2 = z32.union([RequestsPage.loose(), grantGrouped]);
|
|
1454
|
+
var RequestThread2 = z32.union([RequestThread.loose(), grantThread]);
|
|
1241
1455
|
var UpdateRequestResponse2 = UpdateRequestResponse.loose();
|
|
1242
1456
|
var RequestRetryResponse2 = RequestRetryResponse.loose();
|
|
1243
|
-
var SuggestionsPage2 = SuggestionsPage.loose();
|
|
1244
|
-
var SuggestionDetailResponse2 =
|
|
1457
|
+
var SuggestionsPage2 = z32.union([SuggestionsPage.loose(), projection(SuggestionsPage, G.suggestions).extend({ suggestions: z32.array(z32.union([SuggestionRecord, grantSuggestion])) })]);
|
|
1458
|
+
var SuggestionDetailResponse2 = z32.union([
|
|
1459
|
+
SuggestionDetailResponse.extend({ suggestion: fullDetail }).loose(),
|
|
1460
|
+
G.detail.extend({ suggestion: projection(fullDetail, G.detail.shape.suggestion) })
|
|
1461
|
+
]);
|
|
1245
1462
|
var SuggestionThread2 = SuggestionThread.loose();
|
|
1246
1463
|
var SessionResponse2 = SessionResponse.loose();
|
|
1247
|
-
var SuggestionPreviewResponse2 = SuggestionPreviewResponse.loose();
|
|
1464
|
+
var SuggestionPreviewResponse2 = z32.union([SuggestionPreviewResponse.loose(), projection(SuggestionPreviewResponse, G.preview)]);
|
|
1248
1465
|
var ApproveOutcome2 = ApproveOutcome.loose();
|
|
1249
1466
|
var DismissOutcome2 = DismissOutcome.loose();
|
|
1250
1467
|
var RequestChangesOutcome2 = RequestChangesOutcome.loose();
|
|
@@ -1405,6 +1622,138 @@ function operationPath(key, siteId, params = {}) {
|
|
|
1405
1622
|
});
|
|
1406
1623
|
return `/v1/sites/${encodeURIComponent(siteId)}${rest}`;
|
|
1407
1624
|
}
|
|
1625
|
+
var receiptRoutes = Object.keys(managementWriteReceipts).map((key) => new RegExp("^" + key.replace(/\{[^}]+\}/gu, "[^/]+") + "$", "u"));
|
|
1626
|
+
function requiresManagementReceipt(method, route) {
|
|
1627
|
+
if (method === "GET") return route === "credentials";
|
|
1628
|
+
return route.startsWith("settings/") || receiptRoutes.some((pattern) => pattern.test(method + " /" + route));
|
|
1629
|
+
}
|
|
1630
|
+
var ManagementError = class extends Error {
|
|
1631
|
+
recovery;
|
|
1632
|
+
detail;
|
|
1633
|
+
constructor(detail, options) {
|
|
1634
|
+
super(detail.message, options);
|
|
1635
|
+
this.name = "ManagementError";
|
|
1636
|
+
this.detail = detail;
|
|
1637
|
+
this.recovery = options?.recovery;
|
|
1638
|
+
}
|
|
1639
|
+
};
|
|
1640
|
+
function clientError(code, message, overrides = {}) {
|
|
1641
|
+
const category = CLIENT_ERROR_CATEGORIES[code];
|
|
1642
|
+
return {
|
|
1643
|
+
code,
|
|
1644
|
+
message,
|
|
1645
|
+
retryable: overrides.retryable ?? category.retryable,
|
|
1646
|
+
mutation: overrides.mutation ?? category.mutation,
|
|
1647
|
+
exit: category.exit,
|
|
1648
|
+
server: overrides.server ?? null
|
|
1649
|
+
};
|
|
1650
|
+
}
|
|
1651
|
+
function managementError(code, message, overrides = {}) {
|
|
1652
|
+
return new ManagementError(clientError(code, message, overrides));
|
|
1653
|
+
}
|
|
1654
|
+
function invalidInput(message) {
|
|
1655
|
+
return managementError("invalid_input", message);
|
|
1656
|
+
}
|
|
1657
|
+
function refusalError(refusal, details = {}) {
|
|
1658
|
+
const code = classifyRefusal(refusal, { exactReview: details.exactReview });
|
|
1659
|
+
const fault = serverFault(refusal, details.retryAfter ?? null, details.correlationId ?? null);
|
|
1660
|
+
const message = code === "unauthorized" ? OPAQUE_UNAUTHORIZED_MESSAGE : fault.message ?? `The management API answered ${refusal.status}${fault.code === null ? "" : ` ${fault.code}`}.`;
|
|
1661
|
+
return new ManagementError(clientError(code, message, { mutation: details.mutation, server: fault }));
|
|
1662
|
+
}
|
|
1663
|
+
function transportFailure(message, mutation = "not_submitted") {
|
|
1664
|
+
return managementError("transport_failure", message, { mutation });
|
|
1665
|
+
}
|
|
1666
|
+
function interrupted(mutation = "not_submitted") {
|
|
1667
|
+
return managementError("interrupted", "The command was interrupted before it finished. Nothing remote was cancelled.", { mutation });
|
|
1668
|
+
}
|
|
1669
|
+
function unknownOutcome(message) {
|
|
1670
|
+
return managementError("unknown_outcome", message);
|
|
1671
|
+
}
|
|
1672
|
+
function isManagementError(value) {
|
|
1673
|
+
return value instanceof ManagementError;
|
|
1674
|
+
}
|
|
1675
|
+
function toClientError(cause, mutation = "not_submitted") {
|
|
1676
|
+
if (isManagementError(cause)) return cause.detail;
|
|
1677
|
+
const message = cause instanceof Error ? cause.message : String(cause);
|
|
1678
|
+
return clientError("transport_failure", message === "" ? "The request failed without a reason." : message, { mutation });
|
|
1679
|
+
}
|
|
1680
|
+
var REDACTION = "[redacted]";
|
|
1681
|
+
function redactSecrets(text, secrets) {
|
|
1682
|
+
let out = text.replace(/[Bb]earer\s+[\w.~+/=-]+/gu, `Bearer ${REDACTION}`);
|
|
1683
|
+
for (const secret of secrets) {
|
|
1684
|
+
if (secret === void 0 || secret === "") continue;
|
|
1685
|
+
out = out.split(secret).join(REDACTION);
|
|
1686
|
+
}
|
|
1687
|
+
return out;
|
|
1688
|
+
}
|
|
1689
|
+
var G2 = Grant;
|
|
1690
|
+
function omitted(full, grant, prefix = "") {
|
|
1691
|
+
return Object.keys(full.shape).filter((key) => !(key in grant.shape)).map((key) => prefix + key);
|
|
1692
|
+
}
|
|
1693
|
+
var grantFields = {
|
|
1694
|
+
site: [
|
|
1695
|
+
...omitted(PortalSite, G2.site),
|
|
1696
|
+
...omitted(DocsRepo, G2.site.shape.docs_repo.unwrap(), "docs_repo."),
|
|
1697
|
+
...omitted(LatestJob, G2.site.shape.latest_job.unwrap(), "latest_job.")
|
|
1698
|
+
],
|
|
1699
|
+
pages: [
|
|
1700
|
+
...omitted(PagesResponse.options[1], G2.pages),
|
|
1701
|
+
...omitted(PagesResponse.options[1].shape.pages.element, G2.pages.shape.pages.unwrap().element, "pages[].")
|
|
1702
|
+
],
|
|
1703
|
+
pagesUnavailable: omitted(PagesResponse.options[0], G2.pages),
|
|
1704
|
+
releases: omitted(ReleasesPage, G2.releases),
|
|
1705
|
+
release: omitted(ReleaseRecord, G2.releases.shape.releases.element),
|
|
1706
|
+
releaseJob: omitted(ReleaseRecord.shape.job, G2.releases.shape.releases.element.shape.job),
|
|
1707
|
+
suggestion: omitted(SuggestionDetailRecord, G2.detail.shape.suggestion),
|
|
1708
|
+
suggestions: omitted(SuggestionsPage, G2.suggestions),
|
|
1709
|
+
inboxRow: omitted(SuggestionInboxRecord, G2.suggestions.shape.suggestions.element),
|
|
1710
|
+
activity: omitted(ActivityEvent, G2.activity.shape.events.element.in).filter((key) => key !== "error_message" && key !== "commit_message"),
|
|
1711
|
+
requestCounts: omitted(RequestsPage, G2.grouped),
|
|
1712
|
+
request: omitted(RequestRecord, G2.request),
|
|
1713
|
+
entry: omitted(RequestThreadEntry, G2.entries.element, "entries[]."),
|
|
1714
|
+
preview: omitted(SuggestionPreviewResponse, G2.preview)
|
|
1715
|
+
};
|
|
1716
|
+
function grantLimitation(at, fields) {
|
|
1717
|
+
return { code: "field_omitted", at, message: `Saved login omits these fields from ${at}: ${fields.join(", ")}.` };
|
|
1718
|
+
}
|
|
1719
|
+
function actorLimitation(at, fields) {
|
|
1720
|
+
return { code: "actor_relabeled", at, message: `Saved login labels ${fields.join(", ")} as self, agent, or person.` };
|
|
1721
|
+
}
|
|
1722
|
+
function omittedLimitations(at, row, candidates) {
|
|
1723
|
+
const fields = candidates.filter((field) => !Object.hasOwn(row, field));
|
|
1724
|
+
return fields.length ? [grantLimitation(at, fields)] : [];
|
|
1725
|
+
}
|
|
1726
|
+
function labeledActors(at, row, candidates) {
|
|
1727
|
+
const fields = candidates.filter((field) => ["self", "agent", "person"].includes(Reflect.get(row, field)));
|
|
1728
|
+
return fields.length ? [actorLimitation(at, fields)] : [];
|
|
1729
|
+
}
|
|
1730
|
+
function activityGrantLimitations(at, event) {
|
|
1731
|
+
const omitted2 = omittedLimitations(at, event, grantFields.activity);
|
|
1732
|
+
const labels = labeledActors(at, event, ["actor"]);
|
|
1733
|
+
if (!omitted2.length && !labels.length) return [];
|
|
1734
|
+
const redactions = ["commit_message", "error_message", "repository"].filter((field) => event[field] === null);
|
|
1735
|
+
return [...omitted2, ...labels, ...redactions.length ? [{
|
|
1736
|
+
code: "value_redacted",
|
|
1737
|
+
at,
|
|
1738
|
+
message: `Saved login may redact ${redactions.join(", ")}. These values are null.`
|
|
1739
|
+
}] : []];
|
|
1740
|
+
}
|
|
1741
|
+
function suggestionListLimitations(page) {
|
|
1742
|
+
const limitations = omittedLimitations("suggestions", page, grantFields.suggestions);
|
|
1743
|
+
page.suggestions.forEach((row, index) => {
|
|
1744
|
+
const at = `suggestions[${index}]`;
|
|
1745
|
+
if (row.pr_number === void 0) limitations.push(...omittedLimitations(at, row, grantFields.inboxRow));
|
|
1746
|
+
limitations.push(...labeledActors(at, row, ["requested_by"]));
|
|
1747
|
+
});
|
|
1748
|
+
if (page.state === "failed" && page.counts === void 0) limitations.push({ code: "row_visibility", at: "suggestions", message: "For this saved login, the failed tab excludes product push failures that never created a suggestion row." });
|
|
1749
|
+
return limitations;
|
|
1750
|
+
}
|
|
1751
|
+
function requireManagementRead(purpose) {
|
|
1752
|
+
const message = "Set SATURNDOCS_MANAGEMENT_TOKEN to a management credential with manage:read scope.";
|
|
1753
|
+
throw new ManagementError(clientError("unauthorized", `Saved login does not include ${purpose}. ${message}`), {
|
|
1754
|
+
recovery: { message, command: null, replay: null }
|
|
1755
|
+
});
|
|
1756
|
+
}
|
|
1408
1757
|
var REQUEST_WAIT_TABLE = Object.freeze([
|
|
1409
1758
|
{ state: "queued", entry: null, decision: "continue", outcome: "working", exit: EXIT.success, note: "Still admitted; nothing to report yet." },
|
|
1410
1759
|
{ state: "running", entry: null, decision: "continue", outcome: "working", exit: EXIT.success, note: "Drafting." },
|
|
@@ -1424,14 +1773,20 @@ var REQUEST_WAIT_TABLE = Object.freeze([
|
|
|
1424
1773
|
{ state: "cancelled", entry: "failed", decision: "stop", outcome: "cancelled", exit: EXIT.service_failure, note: "Cancelled or superseded." }
|
|
1425
1774
|
]);
|
|
1426
1775
|
var ENTRY_KINDS = /* @__PURE__ */ new Set(["draft", "question", "no_change", "failed"]);
|
|
1776
|
+
function newestRequestWaitEntry(thread) {
|
|
1777
|
+
const latest = thread.latest_job;
|
|
1778
|
+
const firstGrantAttempt = latest.page === void 0 && latest.attempt === 1;
|
|
1779
|
+
return thread.entries.filter((entry) => entry.job_id === latest.job_id && (firstGrantAttempt || latest.attempt === null || entry.attempt === latest.attempt)).at(-1);
|
|
1780
|
+
}
|
|
1427
1781
|
function classifyRequestWait(thread) {
|
|
1428
1782
|
const latest = thread.latest_job;
|
|
1429
|
-
const
|
|
1430
|
-
|
|
1783
|
+
const projected = latest.page === void 0;
|
|
1784
|
+
if (projected && latest.state === "succeeded" && latest.attempt !== 1) requireManagementRead("the entry attempts needed to verify this request outcome");
|
|
1785
|
+
const newest = newestRequestWaitEntry(thread);
|
|
1431
1786
|
const entry = newest === void 0 ? null : ENTRY_KINDS.has(newest.kind) ? newest.kind : "other";
|
|
1432
1787
|
const rule = REQUEST_WAIT_TABLE.find((row) => row.state === latest.state && row.entry === entry) ?? REQUEST_WAIT_TABLE.find((row) => row.state === latest.state && row.entry === null);
|
|
1433
1788
|
if (rule === void 0) throw new Error(`No request wait rule for state ${latest.state}`);
|
|
1434
|
-
return { job_id: latest.job_id, attempt: latest.attempt, entry, rule, suggestion_id: newest?.suggestion_id ?? null };
|
|
1789
|
+
return { job_id: latest.job_id, attempt: latest.attempt, entry, rule, suggestion_id: newest?.suggestion_id ?? (projected && entry === "draft" ? latest.suggestion_id : null) };
|
|
1435
1790
|
}
|
|
1436
1791
|
var SUGGESTION_WAIT_TARGETS = ["reviewable", "published"];
|
|
1437
1792
|
var SUGGESTION_WAIT_TABLE = Object.freeze([
|
|
@@ -1509,7 +1864,7 @@ var P0_COMMANDS = [
|
|
|
1509
1864
|
{ 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." },
|
|
1510
1865
|
{ 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." },
|
|
1511
1866
|
{ 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." },
|
|
1512
|
-
{ 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
|
|
1867
|
+
{ 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, unavailable, or not_granted on its own." },
|
|
1513
1868
|
{ 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." },
|
|
1514
1869
|
{ 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." },
|
|
1515
1870
|
{ 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." },
|
|
@@ -1558,63 +1913,6 @@ var P0_COMMAND_NAMES = Object.freeze(P0_COMMANDS.map((command) => command.name))
|
|
|
1558
1913
|
function commandSpec(name) {
|
|
1559
1914
|
return P0_COMMANDS.find((command) => command.name === name);
|
|
1560
1915
|
}
|
|
1561
|
-
var ManagementError = class extends Error {
|
|
1562
|
-
detail;
|
|
1563
|
-
constructor(detail, options) {
|
|
1564
|
-
super(detail.message, options);
|
|
1565
|
-
this.name = "ManagementError";
|
|
1566
|
-
this.detail = detail;
|
|
1567
|
-
}
|
|
1568
|
-
};
|
|
1569
|
-
function clientError(code, message, overrides = {}) {
|
|
1570
|
-
const category = CLIENT_ERROR_CATEGORIES[code];
|
|
1571
|
-
return {
|
|
1572
|
-
code,
|
|
1573
|
-
message,
|
|
1574
|
-
retryable: overrides.retryable ?? category.retryable,
|
|
1575
|
-
mutation: overrides.mutation ?? category.mutation,
|
|
1576
|
-
exit: category.exit,
|
|
1577
|
-
server: overrides.server ?? null
|
|
1578
|
-
};
|
|
1579
|
-
}
|
|
1580
|
-
function managementError(code, message, overrides = {}) {
|
|
1581
|
-
return new ManagementError(clientError(code, message, overrides));
|
|
1582
|
-
}
|
|
1583
|
-
function invalidInput(message) {
|
|
1584
|
-
return managementError("invalid_input", message);
|
|
1585
|
-
}
|
|
1586
|
-
function refusalError(refusal, details = {}) {
|
|
1587
|
-
const code = classifyRefusal(refusal, { exactReview: details.exactReview });
|
|
1588
|
-
const fault = serverFault(refusal, details.retryAfter ?? null, details.correlationId ?? null);
|
|
1589
|
-
const message = code === "unauthorized" ? OPAQUE_UNAUTHORIZED_MESSAGE : fault.message ?? `The management API answered ${refusal.status}${fault.code === null ? "" : ` ${fault.code}`}.`;
|
|
1590
|
-
return new ManagementError(clientError(code, message, { mutation: details.mutation, server: fault }));
|
|
1591
|
-
}
|
|
1592
|
-
function transportFailure(message, mutation = "not_submitted") {
|
|
1593
|
-
return managementError("transport_failure", message, { mutation });
|
|
1594
|
-
}
|
|
1595
|
-
function interrupted(mutation = "not_submitted") {
|
|
1596
|
-
return managementError("interrupted", "The command was interrupted before it finished. Nothing remote was cancelled.", { mutation });
|
|
1597
|
-
}
|
|
1598
|
-
function unknownOutcome(message) {
|
|
1599
|
-
return managementError("unknown_outcome", message);
|
|
1600
|
-
}
|
|
1601
|
-
function isManagementError(value) {
|
|
1602
|
-
return value instanceof ManagementError;
|
|
1603
|
-
}
|
|
1604
|
-
function toClientError(cause, mutation = "not_submitted") {
|
|
1605
|
-
if (isManagementError(cause)) return cause.detail;
|
|
1606
|
-
const message = cause instanceof Error ? cause.message : String(cause);
|
|
1607
|
-
return clientError("transport_failure", message === "" ? "The request failed without a reason." : message, { mutation });
|
|
1608
|
-
}
|
|
1609
|
-
var REDACTION = "[redacted]";
|
|
1610
|
-
function redactSecrets(text, secrets) {
|
|
1611
|
-
let out = text.replace(/[Bb]earer\s+[\w.~+/=-]+/gu, `Bearer ${REDACTION}`);
|
|
1612
|
-
for (const secret of secrets) {
|
|
1613
|
-
if (secret === void 0 || secret === "") continue;
|
|
1614
|
-
out = out.split(secret).join(REDACTION);
|
|
1615
|
-
}
|
|
1616
|
-
return out;
|
|
1617
|
-
}
|
|
1618
1916
|
var COMMIT_SHA = /^[0-9a-f]{40}$/u;
|
|
1619
1917
|
var SETTINGS_REVISION = /^[0-9a-f]{64}$/u;
|
|
1620
1918
|
function parseReviewedRevision(base, head) {
|
|
@@ -1819,7 +2117,7 @@ function createClient(config = {}) {
|
|
|
1819
2117
|
throw transportFailure(`The management answer could not be read: ${message}`, mutation ? "unknown" : "not_submitted");
|
|
1820
2118
|
}
|
|
1821
2119
|
let data = null;
|
|
1822
|
-
if (text.
|
|
2120
|
+
if (text.length !== 0) {
|
|
1823
2121
|
try {
|
|
1824
2122
|
data = JSON.parse(text);
|
|
1825
2123
|
} catch {
|
|
@@ -1828,7 +2126,7 @@ function createClient(config = {}) {
|
|
|
1828
2126
|
data = null;
|
|
1829
2127
|
}
|
|
1830
2128
|
}
|
|
1831
|
-
if (response.ok) return { status: response.status, headers: response.headers, data, attempts };
|
|
2129
|
+
if (response.ok) return { status: response.status, headers: response.headers, data, attempts, ...text.length === 0 ? { emptyBody: true } : {} };
|
|
1832
2130
|
const refusal = refusalError({ status: response.status, body: data }, {
|
|
1833
2131
|
exactReview: input.exactReview,
|
|
1834
2132
|
retryAfter,
|
|
@@ -1863,6 +2161,9 @@ function createClient(config = {}) {
|
|
|
1863
2161
|
}
|
|
1864
2162
|
return {
|
|
1865
2163
|
origin: origin.origin,
|
|
2164
|
+
get grantAuthenticated() {
|
|
2165
|
+
return token !== void 0 && /^sdga1\.[a-f0-9]{64}$/u.test(token);
|
|
2166
|
+
},
|
|
1866
2167
|
request,
|
|
1867
2168
|
get(path, options = {}) {
|
|
1868
2169
|
return request({ ...options, method: "GET", path });
|
|
@@ -2083,7 +2384,7 @@ async function listSites(client, options = {}) {
|
|
|
2083
2384
|
}
|
|
2084
2385
|
async function getSite(client, siteId, options = {}) {
|
|
2085
2386
|
const response = await client.get(operationPath("site.get", siteId), options);
|
|
2086
|
-
return parseResponse(PortalSite2, response.data, `The site read for ${siteId}`);
|
|
2387
|
+
return parseResponse(credentialSchema(PortalSite2, client.grantAuthenticated), response.data, `The site read for ${siteId}`);
|
|
2087
2388
|
}
|
|
2088
2389
|
async function getDocsRepo(client, siteId, options = {}) {
|
|
2089
2390
|
const response = await client.get(operationPath("docs-repo.get", siteId), options);
|
|
@@ -2116,7 +2417,7 @@ async function listPages(client, siteId, options = {}) {
|
|
|
2116
2417
|
...read,
|
|
2117
2418
|
...days === void 0 ? {} : { query: { days } }
|
|
2118
2419
|
});
|
|
2119
|
-
return parseResponse(PagesResponse2, response.data, `The published page listing for ${siteId}`);
|
|
2420
|
+
return parseResponse(credentialSchema(PagesResponse2, client.grantAuthenticated), response.data, `The published page listing for ${siteId}`);
|
|
2120
2421
|
}
|
|
2121
2422
|
var ActivityPageRead = ActivityPage2.extend({ events: z5.array(ActivityEvent.loose()) });
|
|
2122
2423
|
var ACTIVITY_OUTCOMES = ACTIVITY_OUTCOME_FILTERS;
|
|
@@ -2220,7 +2521,7 @@ async function listSuggestions(client, input) {
|
|
|
2220
2521
|
signal: input.signal,
|
|
2221
2522
|
deadlineMs: input.deadlineMs
|
|
2222
2523
|
});
|
|
2223
|
-
const parsed = SuggestionsPage2.safeParse(response.data);
|
|
2524
|
+
const parsed = credentialSchema(SuggestionsPage2, client.grantAuthenticated).safeParse(response.data);
|
|
2224
2525
|
if (!parsed.success) unreadable("suggestion listing");
|
|
2225
2526
|
return parsed.data;
|
|
2226
2527
|
}
|
|
@@ -2230,7 +2531,7 @@ async function getSuggestion(client, input) {
|
|
|
2230
2531
|
signal: input.signal,
|
|
2231
2532
|
deadlineMs: input.deadlineMs
|
|
2232
2533
|
});
|
|
2233
|
-
const parsed = SuggestionDetailResponse2.safeParse(response.data);
|
|
2534
|
+
const parsed = credentialSchema(SuggestionDetailResponse2, client.grantAuthenticated).safeParse(response.data);
|
|
2234
2535
|
if (!parsed.success) unreadable("suggestion detail");
|
|
2235
2536
|
return parsed.data;
|
|
2236
2537
|
}
|
|
@@ -2258,6 +2559,7 @@ function suggestionLimitations(suggestion) {
|
|
|
2258
2559
|
at: "suggestion.head_sha"
|
|
2259
2560
|
});
|
|
2260
2561
|
}
|
|
2562
|
+
if (suggestion.pr_number === void 0) return [...limitations, ...omittedLimitations("suggestion", suggestion, grantFields.suggestion), ...labeledActors("suggestion", suggestion, ["reviewer", "requested_by", "head_edited_by"])];
|
|
2261
2563
|
if (suggestion.snapshots_available === false || suggestion.pages !== void 0 && !pageContentAvailable(suggestion)) {
|
|
2262
2564
|
limitations.push({
|
|
2263
2565
|
code: "content_unavailable",
|
|
@@ -2425,7 +2727,7 @@ function rowBytes(row) {
|
|
|
2425
2727
|
function bound(pages, maxBytes) {
|
|
2426
2728
|
const out = [];
|
|
2427
2729
|
let used = 0;
|
|
2428
|
-
let
|
|
2730
|
+
let omitted2 = 0;
|
|
2429
2731
|
for (const page of pages) {
|
|
2430
2732
|
used += new TextEncoder().encode(page.path).length + 16;
|
|
2431
2733
|
const kept = [];
|
|
@@ -2439,13 +2741,13 @@ function bound(pages, maxBytes) {
|
|
|
2439
2741
|
kept.push(row);
|
|
2440
2742
|
}
|
|
2441
2743
|
if (dropped > 0) kept.push({ op: "omitted", before_line: null, after_line: null, text: null, count: dropped });
|
|
2442
|
-
|
|
2744
|
+
omitted2 += dropped;
|
|
2443
2745
|
out.push({ ...page, rows: kept, omitted_rows: dropped });
|
|
2444
2746
|
}
|
|
2445
|
-
return { pages: out, used, omitted };
|
|
2747
|
+
return { pages: out, used, omitted: omitted2 };
|
|
2446
2748
|
}
|
|
2447
2749
|
var HANDOFF = "This is the content the server supplied, formatted here. Nothing in it was checked against the product, so it is a starting point for an owner's review, not a completed one.";
|
|
2448
|
-
function limitationsFor(suggestion, pages,
|
|
2750
|
+
function limitationsFor(suggestion, pages, omitted2, limit2) {
|
|
2449
2751
|
const limitations = [
|
|
2450
2752
|
{ code: "review_incomplete", message: HANDOFF, at: null }
|
|
2451
2753
|
];
|
|
@@ -2462,8 +2764,8 @@ function limitationsFor(suggestion, pages, omitted, limit2) {
|
|
|
2462
2764
|
limitations.push({ code: "page_bounded", message: `The comparison of ${page.path} hit a size bound, so this diff is part of the change and not all of it.`, at });
|
|
2463
2765
|
}
|
|
2464
2766
|
});
|
|
2465
|
-
if (
|
|
2466
|
-
limitations.push({ code: "output_truncated", message: `${
|
|
2767
|
+
if (omitted2 > 0) {
|
|
2768
|
+
limitations.push({ code: "output_truncated", message: `${omitted2} diff lines were left out to stay inside the ${limit2}-byte output bound. Read one page at a time with --path, or read the pull request.`, at: null });
|
|
2467
2769
|
}
|
|
2468
2770
|
if (typeof suggestion.head_edited_by === "string" && suggestion.head_edited_by !== "") {
|
|
2469
2771
|
limitations.push({ code: "hand_edited", message: `The head was edited on GitHub by ${suggestion.head_edited_by} after the draft, so this diff of the supplied content may not be what would publish.`, at: "head_sha" });
|
|
@@ -2474,6 +2776,7 @@ function limitationsFor(suggestion, pages, omitted, limit2) {
|
|
|
2474
2776
|
return limitations;
|
|
2475
2777
|
}
|
|
2476
2778
|
function suggestionDiff(suggestion, options = {}) {
|
|
2779
|
+
if (suggestion.pr_number === void 0) requireManagementRead("suggestion page changes");
|
|
2477
2780
|
const limit2 = options.maxBytes ?? DEFAULT_DIFF_MAX_BYTES;
|
|
2478
2781
|
const all = suggestion.pages ?? [];
|
|
2479
2782
|
const selected = options.path === void 0 ? all : all.filter((page) => page.path === options.path);
|
|
@@ -2792,8 +3095,8 @@ function summaryOf(release, state, active) {
|
|
|
2792
3095
|
if (state === "live") return `${release.release_id} is the release readers are seeing, activated ${release.activated_at ?? "at an unrecorded time"}.`;
|
|
2793
3096
|
if (state === "built") return `${release.release_id} was built and has no activation record, so it was never published.`;
|
|
2794
3097
|
if (state === "historical") {
|
|
2795
|
-
const generation = release.generation ===
|
|
2796
|
-
return `${release.release_id} went live at ${String(release.activated_at)}
|
|
3098
|
+
const generation = release.generation === void 0 ? "" : ` (generation ${release.generation ?? "unrecorded"})`;
|
|
3099
|
+
return `${release.release_id} went live at ${String(release.activated_at)}${generation} and is not what readers are seeing now${active === null ? "" : `; that is ${active}`}.`;
|
|
2797
3100
|
}
|
|
2798
3101
|
return `${release.release_id} went live at ${String(release.activated_at)}. The activation record could not be read, so whether it is live now is unknown.`;
|
|
2799
3102
|
}
|
|
@@ -2810,7 +3113,7 @@ function classifyReleaseActivation(release, page) {
|
|
|
2810
3113
|
return {
|
|
2811
3114
|
state,
|
|
2812
3115
|
activated_at: release.activated_at,
|
|
2813
|
-
generation: release.generation,
|
|
3116
|
+
...release.generation === void 0 ? {} : { generation: release.generation },
|
|
2814
3117
|
active_release_id: active,
|
|
2815
3118
|
active_release_status: status,
|
|
2816
3119
|
rule,
|
|
@@ -2830,14 +3133,14 @@ async function listReleases(client, siteId, options = {}) {
|
|
|
2830
3133
|
...read,
|
|
2831
3134
|
query: { ...cursor2 === void 0 ? {} : { cursor: cursor2 }, ...limit2 === void 0 ? {} : { limit: limit2 } }
|
|
2832
3135
|
});
|
|
2833
|
-
return parseResponse(ReleasesPage2, response.data, `The release listing for ${siteId}`);
|
|
3136
|
+
return parseResponse(credentialSchema(ReleasesPage2, client.grantAuthenticated), response.data, `The release listing for ${siteId}`);
|
|
2834
3137
|
}
|
|
2835
3138
|
async function getRelease(client, siteId, releaseId, options = {}) {
|
|
2836
3139
|
const id = releaseId.trim();
|
|
2837
3140
|
if (id === "") throw invalidInput("Name the release to read.");
|
|
2838
3141
|
if (id.length > RELEASE_ID_MAX_CHARS) throw invalidInput(`A release id is at most ${RELEASE_ID_MAX_CHARS} characters; the route refuses a longer one as invalid_release_id.`);
|
|
2839
3142
|
const response = await client.get(operationPath("releases.list", siteId), { ...options, query: { release_id: id } });
|
|
2840
|
-
const page = parseResponse(ReleasesPage2, response.data, `The release read for ${id} on ${siteId}`);
|
|
3143
|
+
const page = parseResponse(credentialSchema(ReleasesPage2, client.grantAuthenticated), response.data, `The release read for ${id} on ${siteId}`);
|
|
2841
3144
|
const release = page.releases[0];
|
|
2842
3145
|
if (release === void 0) {
|
|
2843
3146
|
throw managementError(
|
|
@@ -2923,7 +3226,9 @@ async function waitForSuggestion(client, input) {
|
|
|
2923
3226
|
});
|
|
2924
3227
|
const suggestion2 = detail.suggestion;
|
|
2925
3228
|
const reached = classifySuggestionWait(target, suggestion2);
|
|
2926
|
-
|
|
3229
|
+
const projected = suggestion2.pr_number === void 0;
|
|
3230
|
+
if (target === "published" && suggestion2.state === "published" && projected) requireManagementRead("publication proof");
|
|
3231
|
+
if (target !== "published" || reached.decision === "stop" || projected) {
|
|
2927
3232
|
return {
|
|
2928
3233
|
done: reached.decision === "stop",
|
|
2929
3234
|
value: { suggestion: suggestion2, outcome: reached.outcome, exit: reached.exit, note: reached.rule.note, release: null, release_unreadable: false }
|
|
@@ -2952,7 +3257,7 @@ async function waitForSuggestion(client, input) {
|
|
|
2952
3257
|
const missingContent = reviewLimitations.some((limitation) => limitation.code === "content_unavailable");
|
|
2953
3258
|
const reviewable = !outcome.timed_out && last?.outcome === "reviewable";
|
|
2954
3259
|
const limitations = Object.freeze([
|
|
2955
|
-
...target === "reviewable" ? reviewLimitations : [],
|
|
3260
|
+
...target === "reviewable" || suggestion?.pr_number === void 0 ? reviewLimitations : [],
|
|
2956
3261
|
...activationLimitation(release)
|
|
2957
3262
|
]);
|
|
2958
3263
|
const base = {
|
|
@@ -2963,10 +3268,12 @@ async function waitForSuggestion(client, input) {
|
|
|
2963
3268
|
revision: suggestion?.revision ?? null,
|
|
2964
3269
|
base_sha: suggestion?.base_sha ?? null,
|
|
2965
3270
|
head_sha: suggestion?.head_sha ?? null,
|
|
2966
|
-
|
|
2967
|
-
|
|
3271
|
+
...suggestion && suggestion.pr_number === void 0 ? {} : {
|
|
3272
|
+
pr_number: suggestion?.pr_number ?? null,
|
|
3273
|
+
publication_job_id: suggestion?.publication?.job_id ?? null
|
|
3274
|
+
},
|
|
2968
3275
|
release,
|
|
2969
|
-
owner_handoff: reviewable && missingContent,
|
|
3276
|
+
owner_handoff: reviewable && (missingContent || suggestion?.pr_number === void 0),
|
|
2970
3277
|
limitations,
|
|
2971
3278
|
polls: outcome.attempts,
|
|
2972
3279
|
elapsed_ms: outcome.elapsed_ms
|
|
@@ -2982,7 +3289,7 @@ async function waitForSuggestion(client, input) {
|
|
|
2982
3289
|
};
|
|
2983
3290
|
}
|
|
2984
3291
|
var REQUEST_THREAD_LIMIT_MAX = MAX_REQUEST_THREADS;
|
|
2985
|
-
function
|
|
3292
|
+
function checkedRequestThreadLimit(limit2) {
|
|
2986
3293
|
if (limit2 === null || limit2 === void 0) return void 0;
|
|
2987
3294
|
if (!Number.isInteger(limit2) || limit2 < 1 || limit2 > REQUEST_THREAD_LIMIT_MAX) {
|
|
2988
3295
|
throw invalidInput(`--limit takes a whole number from 1 to ${REQUEST_THREAD_LIMIT_MAX}. Nothing was sent.`);
|
|
@@ -2998,7 +3305,7 @@ async function listRequestThreads(client, input) {
|
|
|
2998
3305
|
const query = {
|
|
2999
3306
|
view: "threads",
|
|
3000
3307
|
cursor: checkedCursor(input.cursor),
|
|
3001
|
-
limit:
|
|
3308
|
+
limit: checkedRequestThreadLimit(input.limit),
|
|
3002
3309
|
attention: input.attention === true ? "1" : void 0
|
|
3003
3310
|
};
|
|
3004
3311
|
const response = await client.get(operationPath("requests.list", input.siteId), {
|
|
@@ -3006,7 +3313,7 @@ async function listRequestThreads(client, input) {
|
|
|
3006
3313
|
signal: input.signal,
|
|
3007
3314
|
deadlineMs: input.deadlineMs
|
|
3008
3315
|
});
|
|
3009
|
-
return parseResponse(RequestsPage2, response.data, "The request thread listing");
|
|
3316
|
+
return parseResponse(credentialSchema(RequestsPage2, client.grantAuthenticated), response.data, "The request thread listing");
|
|
3010
3317
|
}
|
|
3011
3318
|
async function readRequestThread(client, input) {
|
|
3012
3319
|
if (input.jobId.trim() === "") throw invalidInput("Name the job whose conversation to read.");
|
|
@@ -3014,7 +3321,29 @@ async function readRequestThread(client, input) {
|
|
|
3014
3321
|
signal: input.signal,
|
|
3015
3322
|
deadlineMs: input.deadlineMs
|
|
3016
3323
|
});
|
|
3017
|
-
return parseResponse(RequestThread2, response.data, "The request thread");
|
|
3324
|
+
return parseResponse(credentialSchema(RequestThread2, client.grantAuthenticated), response.data, "The request thread");
|
|
3325
|
+
}
|
|
3326
|
+
function isGrouped(page) {
|
|
3327
|
+
return "threads" in page && Array.isArray(page.threads);
|
|
3328
|
+
}
|
|
3329
|
+
function requestGrantLimitations(page, attention = false) {
|
|
3330
|
+
const grouped = isGrouped(page);
|
|
3331
|
+
const at = grouped ? "threads" : "thread";
|
|
3332
|
+
const limitations = [];
|
|
3333
|
+
if (grouped) limitations.push({ code: "row_visibility", at, message: "This list covers only request threads started by this saved login." });
|
|
3334
|
+
const threads = grouped ? page.threads : [{ root: page.root, latest: page.latest_job, entries: page.entries }];
|
|
3335
|
+
threads.forEach((thread, index) => {
|
|
3336
|
+
const path = grouped ? `threads[${index}]` : at;
|
|
3337
|
+
for (const [name, row] of [["root", thread.root], [grouped ? "latest" : "latest_job", thread.latest]]) {
|
|
3338
|
+
limitations.push(
|
|
3339
|
+
...omittedLimitations(path + "." + name, row, grantFields.request),
|
|
3340
|
+
...labeledActors(path + "." + name, row, ["requested_by"])
|
|
3341
|
+
);
|
|
3342
|
+
}
|
|
3343
|
+
if (thread.entries.some((entry) => entry.entry_id === void 0)) limitations.push(grantLimitation(path, grantFields.entry));
|
|
3344
|
+
});
|
|
3345
|
+
if (grouped && attention) limitations.push(...omittedLimitations(at, page, grantFields.requestCounts));
|
|
3346
|
+
return limitations;
|
|
3018
3347
|
}
|
|
3019
3348
|
async function rollbackRelease(client, siteId, input, signal) {
|
|
3020
3349
|
const parsed = ReleaseRollbackBody2.safeParse(input);
|
|
@@ -3152,7 +3481,6 @@ async function retryRequest(client, input) {
|
|
|
3152
3481
|
}
|
|
3153
3482
|
return parsed.data;
|
|
3154
3483
|
}
|
|
3155
|
-
var STATUS_SECTIONS = ["site", "requests", "suggestions", "activity"];
|
|
3156
3484
|
var STATUS_PAGE_LIMIT = 10;
|
|
3157
3485
|
function available(section2, data, empty, recovery) {
|
|
3158
3486
|
return { section: section2, state: empty ? "empty" : "available", data, error: null, recovery };
|
|
@@ -3173,7 +3501,10 @@ function retryRecovery(section2, siteId) {
|
|
|
3173
3501
|
message: `The ${section2} section of this briefing was not read. Run its own command to see whether the service answers, and read nothing into its absence here.`
|
|
3174
3502
|
};
|
|
3175
3503
|
}
|
|
3176
|
-
async function section(name, siteId, read, isEmpty, recovery) {
|
|
3504
|
+
async function section(scope, name, siteId, read, isEmpty, recovery) {
|
|
3505
|
+
if (name === "requests" && scope && !scope.includes("draft")) {
|
|
3506
|
+
return { section: name, state: "not_granted", reason: "This saved login lacks the draft capability.", data: null, error: null, recovery: null };
|
|
3507
|
+
}
|
|
3177
3508
|
try {
|
|
3178
3509
|
const data = await read();
|
|
3179
3510
|
return available(name, data, isEmpty(data), recovery(data));
|
|
@@ -3218,9 +3549,11 @@ function countsOf(requests, suggestions) {
|
|
|
3218
3549
|
}
|
|
3219
3550
|
async function readSiteStatus(client, siteId, options = {}) {
|
|
3220
3551
|
const { limit: limit2 = STATUS_PAGE_LIMIT, ...read } = options;
|
|
3552
|
+
const scope = await client.savedLoginScope?.();
|
|
3221
3553
|
const [site, requests, suggestions, activity] = await Promise.all([
|
|
3222
|
-
section("site", siteId, () => getSite(client, siteId, read), () => false, () => null),
|
|
3554
|
+
section(scope, "site", siteId, () => getSite(client, siteId, read), () => false, () => null),
|
|
3223
3555
|
section(
|
|
3556
|
+
scope,
|
|
3224
3557
|
"requests",
|
|
3225
3558
|
siteId,
|
|
3226
3559
|
() => listRequestThreads(client, { siteId, limit: limit2, attention: true, ...read }),
|
|
@@ -3228,6 +3561,7 @@ async function readSiteStatus(client, siteId, options = {}) {
|
|
|
3228
3561
|
(page) => requestsRecovery(page, siteId)
|
|
3229
3562
|
),
|
|
3230
3563
|
section(
|
|
3564
|
+
scope,
|
|
3231
3565
|
"suggestions",
|
|
3232
3566
|
siteId,
|
|
3233
3567
|
() => listSuggestions(client, { site: siteId, state: "pending", limit: limit2, ...read }),
|
|
@@ -3235,6 +3569,7 @@ async function readSiteStatus(client, siteId, options = {}) {
|
|
|
3235
3569
|
() => null
|
|
3236
3570
|
),
|
|
3237
3571
|
section(
|
|
3572
|
+
scope,
|
|
3238
3573
|
"activity",
|
|
3239
3574
|
siteId,
|
|
3240
3575
|
() => listActivity(client, siteId, { limit: limit2, ...read }),
|
|
@@ -3255,8 +3590,12 @@ async function readSiteStatus(client, siteId, options = {}) {
|
|
|
3255
3590
|
function statusSections(status) {
|
|
3256
3591
|
return [status.site, status.requests, status.suggestions, status.activity];
|
|
3257
3592
|
}
|
|
3258
|
-
function statusLimitations(status) {
|
|
3593
|
+
function statusLimitations(status, savedLogin = false) {
|
|
3259
3594
|
const limitations = [];
|
|
3595
|
+
if (status.site.data && status.site.data.hostnames === void 0) limitations.push(grantLimitation("site", grantFields.site));
|
|
3596
|
+
if (savedLogin && status.requests.data) limitations.push(...requestGrantLimitations(status.requests.data, true));
|
|
3597
|
+
if (savedLogin && status.suggestions.data) limitations.push(...suggestionListLimitations(status.suggestions.data));
|
|
3598
|
+
if (savedLogin && status.activity.data) limitations.push(...status.activity.data.events.flatMap((event, index) => activityGrantLimitations(`activity.data.events[${index}]`, event)));
|
|
3260
3599
|
for (const part of statusSections(status)) {
|
|
3261
3600
|
if (part.state !== "unavailable") continue;
|
|
3262
3601
|
limitations.push({
|
|
@@ -3280,7 +3619,7 @@ function statusBlocker(status) {
|
|
|
3280
3619
|
const failures = statusSections(status).filter((part) => part.state === "unavailable");
|
|
3281
3620
|
const refused = failures.find((part) => part.error?.code === "unauthorized" || part.error?.code === "forbidden");
|
|
3282
3621
|
if (refused?.error != null) return refused.error;
|
|
3283
|
-
if (failures.length ===
|
|
3622
|
+
if (failures.length === statusSections(status).filter((part) => part.state !== "not_granted").length) return failures[0]?.error ?? null;
|
|
3284
3623
|
return null;
|
|
3285
3624
|
}
|
|
3286
3625
|
function statusIds(status) {
|
|
@@ -3301,7 +3640,7 @@ function requestWaitErrorCode(outcome) {
|
|
|
3301
3640
|
return WAIT_ERROR_CODES2[outcome] ?? null;
|
|
3302
3641
|
}
|
|
3303
3642
|
function summaryOf2(state, thread) {
|
|
3304
|
-
const entry = thread
|
|
3643
|
+
const entry = newestRequestWaitEntry(thread);
|
|
3305
3644
|
const words = entry === void 0 ? null : entry.body.trim();
|
|
3306
3645
|
return words === null || words === "" ? state.rule.note : words;
|
|
3307
3646
|
}
|
|
@@ -3350,6 +3689,9 @@ function requireSuggestionId2(value) {
|
|
|
3350
3689
|
if (value.trim() === "") throw invalidInput("Name the suggestion to preview, as saturndocs suggestions preview <suggestion-id>.");
|
|
3351
3690
|
return value;
|
|
3352
3691
|
}
|
|
3692
|
+
function unreadableReceipt() {
|
|
3693
|
+
return unknownOutcome("The preview request was accepted but its receipt could not be read. Read the preview status before requesting another build.");
|
|
3694
|
+
}
|
|
3353
3695
|
function unreadable4() {
|
|
3354
3696
|
throw managementError(
|
|
3355
3697
|
"transport_failure",
|
|
@@ -3358,6 +3700,10 @@ function unreadable4() {
|
|
|
3358
3700
|
}
|
|
3359
3701
|
function limitationsFor2(body) {
|
|
3360
3702
|
const limitations = [];
|
|
3703
|
+
if (body.url === void 0) {
|
|
3704
|
+
const missing = grantLimitation("preview", grantFields.preview);
|
|
3705
|
+
limitations.push({ ...missing, message: missing.message + " Read the preview with SATURNDOCS_MANAGEMENT_TOKEN and manage:read scope to get its URL." });
|
|
3706
|
+
}
|
|
3361
3707
|
if (body.state === "building") {
|
|
3362
3708
|
limitations.push({
|
|
3363
3709
|
code: "activation_unknown",
|
|
@@ -3387,10 +3733,10 @@ function toResult(suggestionId, body, requestedBuild) {
|
|
|
3387
3733
|
state: body.state,
|
|
3388
3734
|
revision: body.revision,
|
|
3389
3735
|
current: body.current,
|
|
3390
|
-
url: body.url,
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
3736
|
+
...body.url === void 0 ? {} : { url: body.url, leave_url: body.leave_url, error: body.error },
|
|
3737
|
+
...body.state === "ready" && body.current && body.url === void 0 ? {} : {
|
|
3738
|
+
current_preview_available: body.state === "ready" && body.current && typeof body.url === "string"
|
|
3739
|
+
},
|
|
3394
3740
|
requested_build: requestedBuild,
|
|
3395
3741
|
response: body,
|
|
3396
3742
|
limitations: limitationsFor2(body)
|
|
@@ -3399,9 +3745,15 @@ function toResult(suggestionId, body, requestedBuild) {
|
|
|
3399
3745
|
async function readPreview(client, input, method) {
|
|
3400
3746
|
const suggestionId = requireSuggestionId2(input.suggestionId);
|
|
3401
3747
|
const path = resourcePath(input.site, ["suggestions", suggestionId, "preview"]);
|
|
3402
|
-
const response = method === "GET" ? await client.get(path, { signal: input.signal, deadlineMs: input.deadlineMs }) : await client.request({ method: "POST", path, signal: input.signal, deadlineMs: input.deadlineMs })
|
|
3403
|
-
|
|
3404
|
-
|
|
3748
|
+
const response = method === "GET" ? await client.get(path, { signal: input.signal, deadlineMs: input.deadlineMs }) : await client.request({ method: "POST", path, signal: input.signal, deadlineMs: input.deadlineMs }).catch((error) => {
|
|
3749
|
+
if (isManagementError(error) && error.detail.code === "unknown_outcome") throw unreadableReceipt();
|
|
3750
|
+
throw error;
|
|
3751
|
+
});
|
|
3752
|
+
const parsed = credentialSchema(SuggestionPreviewResponse2, client.grantAuthenticated).safeParse(response.data);
|
|
3753
|
+
if (!parsed.success) {
|
|
3754
|
+
if (method === "POST") throw unreadableReceipt();
|
|
3755
|
+
unreadable4();
|
|
3756
|
+
}
|
|
3405
3757
|
return toResult(suggestionId, parsed.data, method === "POST");
|
|
3406
3758
|
}
|
|
3407
3759
|
async function getSuggestionPreview(client, input) {
|
|
@@ -3418,6 +3770,11 @@ var SESSION_MESSAGE_DEADLINE_MS = 5 * 6e4;
|
|
|
3418
3770
|
var SESSION_ATTEMPT_MS = DEFAULT_DEADLINE_MS;
|
|
3419
3771
|
var MAX_UNREACHABLE_SENDS = 3;
|
|
3420
3772
|
var UNREACHABLE_BACKOFF_MS = 250;
|
|
3773
|
+
var PendingTurn = z6.object({
|
|
3774
|
+
turnId: z6.string(),
|
|
3775
|
+
sequence: z6.number().int().positive(),
|
|
3776
|
+
state: z6.enum(["queued", "running", "model_complete", "committing"])
|
|
3777
|
+
});
|
|
3421
3778
|
var RUNNING_BACKOFF_MS = 1e3;
|
|
3422
3779
|
var MAX_REPLAY_BACKOFF_MS = 5e3;
|
|
3423
3780
|
function requireSuggestionId3(value, usage) {
|
|
@@ -3510,10 +3867,13 @@ async function sendSessionMessage(client, input) {
|
|
|
3510
3867
|
response = answered;
|
|
3511
3868
|
break;
|
|
3512
3869
|
}
|
|
3870
|
+
const receipt = PendingTurn.safeParse(answered.data);
|
|
3871
|
+
if (!receipt.success || receipt.data.turnId !== `portal:${body.data.turn_id}`) unreadableTurn(suggestionId);
|
|
3513
3872
|
running += 1;
|
|
3514
3873
|
backoff = Math.min(MAX_REPLAY_BACKOFF_MS, RUNNING_BACKOFF_MS * 2 ** (running - 1));
|
|
3515
3874
|
} catch (cause) {
|
|
3516
3875
|
if (cancelled() || !isManagementError(cause)) throw cause;
|
|
3876
|
+
if (cause.detail.code === "unknown_outcome") unreadableTurn(suggestionId);
|
|
3517
3877
|
if (cause.detail.code !== "transport_failure" && !(attempt.aborted && cause.detail.code === "interrupted")) throw cause;
|
|
3518
3878
|
if (!attempt.aborted && remaining() > 0) {
|
|
3519
3879
|
unreachable += 1;
|
|
@@ -3789,10 +4149,17 @@ export {
|
|
|
3789
4149
|
CLIENT_ERROR_CODES,
|
|
3790
4150
|
CLIENT_ERROR_CATEGORIES,
|
|
3791
4151
|
CLIENT_SCHEMA_VERSION,
|
|
3792
|
-
|
|
3793
|
-
REQUEST_TEXT_LIMIT,
|
|
4152
|
+
requiresManagementReceipt,
|
|
3794
4153
|
invalidInput,
|
|
3795
4154
|
isManagementError,
|
|
4155
|
+
grantFields,
|
|
4156
|
+
grantLimitation,
|
|
4157
|
+
omittedLimitations,
|
|
4158
|
+
labeledActors,
|
|
4159
|
+
activityGrantLimitations,
|
|
4160
|
+
suggestionListLimitations,
|
|
4161
|
+
GLOBAL_FLAGS,
|
|
4162
|
+
REQUEST_TEXT_LIMIT,
|
|
3796
4163
|
requireCommitSha,
|
|
3797
4164
|
parseOrigin,
|
|
3798
4165
|
createClient,
|
|
@@ -3831,8 +4198,10 @@ export {
|
|
|
3831
4198
|
suggestionWaitErrorCode,
|
|
3832
4199
|
parseSuggestionWaitTarget,
|
|
3833
4200
|
waitForSuggestion,
|
|
4201
|
+
checkedRequestThreadLimit,
|
|
3834
4202
|
listRequestThreads,
|
|
3835
4203
|
readRequestThread,
|
|
4204
|
+
requestGrantLimitations,
|
|
3836
4205
|
rollbackRelease,
|
|
3837
4206
|
checkedSubmissionId,
|
|
3838
4207
|
checkedRequestText,
|