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
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
import {
|
|
2
|
+
SITES_CREATE_METADATA,
|
|
3
|
+
registerSitesCreate
|
|
4
|
+
} from "./chunk-IWIVHHZI.js";
|
|
1
5
|
import {
|
|
2
6
|
asCliError,
|
|
3
7
|
clientFor
|
|
4
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-FUZE54DG.js";
|
|
5
9
|
import {
|
|
6
10
|
applyCommandHelp
|
|
7
11
|
} from "./chunk-M2BZEDAS.js";
|
|
@@ -9,13 +13,13 @@ import {
|
|
|
9
13
|
commandMetadata,
|
|
10
14
|
createResultWriter,
|
|
11
15
|
failureResult,
|
|
12
|
-
invalidInput,
|
|
16
|
+
invalidInput2 as invalidInput,
|
|
13
17
|
listSites,
|
|
14
18
|
readSiteDetail,
|
|
15
19
|
resolveGlobalOptions,
|
|
16
20
|
resolveTarget,
|
|
17
21
|
successResult
|
|
18
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-3KCCCMQY.js";
|
|
19
23
|
|
|
20
24
|
// src/commands/sites.ts
|
|
21
25
|
var SITES_METADATA = Object.freeze([
|
|
@@ -45,7 +49,8 @@ var SITES_METADATA = Object.freeze([
|
|
|
45
49
|
{ command: "saturndocs sites get acme --connections", description: "One site with its documentation repository and watched repositories." },
|
|
46
50
|
{ command: "saturndocs sites get --json", description: "The site read as one result object, with the resolved site_id in the envelope." }
|
|
47
51
|
]
|
|
48
|
-
})
|
|
52
|
+
}),
|
|
53
|
+
SITES_CREATE_METADATA
|
|
49
54
|
]);
|
|
50
55
|
function requestedSite(positional, flag) {
|
|
51
56
|
const named = positional ?? flag ?? void 0;
|
|
@@ -79,7 +84,8 @@ function detailText(detail) {
|
|
|
79
84
|
return lines.join("\n");
|
|
80
85
|
}
|
|
81
86
|
function registerSites(program, _cliDir, environment = {}) {
|
|
82
|
-
const sites = program.command("sites").description("
|
|
87
|
+
const sites = program.command("sites").description("Create a site, or discover and inspect the sites this credential reaches");
|
|
88
|
+
registerSitesCreate(sites, environment);
|
|
83
89
|
const list = sites.command("list").action(async (_options, self) => {
|
|
84
90
|
const globals = resolveGlobalOptions(self);
|
|
85
91
|
const writer = createResultWriter({ json: globals.json });
|
|
@@ -98,8 +104,8 @@ function registerSites(program, _cliDir, environment = {}) {
|
|
|
98
104
|
const writer = createResultWriter({ json: globals.json });
|
|
99
105
|
const context = { command: "sites get", siteId: null };
|
|
100
106
|
try {
|
|
101
|
-
const client = clientFor(globals, environment);
|
|
102
107
|
const named = requestedSite(siteId, globals.site);
|
|
108
|
+
const client = clientFor(named === void 0 ? globals : { ...globals, site: named }, environment);
|
|
103
109
|
const target = await resolveTarget(client, named === void 0 ? {} : { site: named });
|
|
104
110
|
context.siteId = target.site_id;
|
|
105
111
|
const detail = await readSiteDetail(client, target.site_id, { connections: options.connections === true });
|
|
@@ -30,25 +30,158 @@ function reservedPageClash(docIds, hasVariants) {
|
|
|
30
30
|
}
|
|
31
31
|
return null;
|
|
32
32
|
}
|
|
33
|
+
var MAX_REDIRECTS = 5e3;
|
|
34
|
+
var REDIRECT_SPLAT = "/*";
|
|
35
|
+
var PLATFORM_ROUTES = [
|
|
36
|
+
"/api",
|
|
37
|
+
"/auth",
|
|
38
|
+
"/mcp",
|
|
39
|
+
"/a2a",
|
|
40
|
+
"/ask",
|
|
41
|
+
"/runtime",
|
|
42
|
+
"/_astro",
|
|
43
|
+
"/pagefind",
|
|
44
|
+
"/.well-known",
|
|
45
|
+
"/favicon.svg"
|
|
46
|
+
];
|
|
47
|
+
function isPlatformRoute(path) {
|
|
48
|
+
return PLATFORM_ROUTES.some((route) => path === route || path.startsWith(`${route}/`));
|
|
49
|
+
}
|
|
50
|
+
function canonicalRedirectPath(value) {
|
|
51
|
+
let decoded;
|
|
52
|
+
try {
|
|
53
|
+
decoded = decodeURIComponent(value.split(/[?#]/, 1)[0] ?? "");
|
|
54
|
+
} catch {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
if (!decoded.startsWith("/") || /[\u0000-\u001f\u007f\\%]/.test(decoded)) return null;
|
|
58
|
+
const collapsed = decoded.replace(/\/{2,}/g, "/");
|
|
59
|
+
if (collapsed.split("/").some((segment) => segment === "." || segment === "..")) return null;
|
|
60
|
+
return collapsed === "/" ? "/" : collapsed.replace(/\/$/, "");
|
|
61
|
+
}
|
|
33
62
|
function normalizedRedirectPath(value) {
|
|
34
63
|
if (!value.startsWith("/") || value.startsWith("//") || value.includes("\\")) return value;
|
|
64
|
+
const canonical = canonicalRedirectPath(value);
|
|
65
|
+
if (canonical !== null) return canonical;
|
|
35
66
|
const path = value.split(/[?#]/, 1)[0]?.replace(/\/+$/, "") ?? "";
|
|
36
67
|
return path || "/";
|
|
37
68
|
}
|
|
38
|
-
function
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
69
|
+
function isRedirectPattern(value) {
|
|
70
|
+
return value.endsWith(REDIRECT_SPLAT);
|
|
71
|
+
}
|
|
72
|
+
function redirectPatternPrefix(source) {
|
|
73
|
+
return normalizedRedirectPath(source.slice(0, -1));
|
|
74
|
+
}
|
|
75
|
+
function redirectSourceKey(source) {
|
|
76
|
+
if (!isRedirectPattern(source)) return normalizedRedirectPath(source);
|
|
77
|
+
const prefix = redirectPatternPrefix(source);
|
|
78
|
+
return prefix === "/" ? REDIRECT_SPLAT : `${prefix}${REDIRECT_SPLAT}`;
|
|
79
|
+
}
|
|
80
|
+
function redirectSourceProblem(source) {
|
|
81
|
+
if (!source.startsWith("/")) return "Must start with /";
|
|
82
|
+
if (source.startsWith("//")) return "Must not start with //";
|
|
83
|
+
const star = source.indexOf("*");
|
|
84
|
+
if (star !== -1 && (star !== source.length - 1 || !isRedirectPattern(source))) {
|
|
85
|
+
return 'A wildcard is allowed only as a trailing "/*"';
|
|
86
|
+
}
|
|
87
|
+
if (isRedirectPattern(source)) {
|
|
88
|
+
if (canonicalRedirectPath(source.slice(0, -1)) === null) {
|
|
89
|
+
return `${source} is not a path the site serves, so the pattern never matches`;
|
|
90
|
+
}
|
|
91
|
+
if (isPlatformRoute(redirectPatternPrefix(source))) {
|
|
92
|
+
return `${source} covers only platform routes, which patterns never redirect`;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
function redirectDestinationProblem(rule) {
|
|
98
|
+
if (isRedirectPattern(rule.destination) && !isRedirectPattern(rule.source)) {
|
|
99
|
+
return `The destination ends in "/*" but the source ${rule.source} does not, so there is no remainder to append`;
|
|
100
|
+
}
|
|
101
|
+
if (isRedirectPattern(rule.destination) && !splatHasFixedHost(rule.destination.slice(0, -REDIRECT_SPLAT.length))) {
|
|
102
|
+
return 'A "/*" destination must name a fixed host before the "/*", or the rest of the request path chooses where readers go';
|
|
103
|
+
}
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
function splatHasFixedHost(base) {
|
|
107
|
+
if (base.includes("*") || base.includes("\\")) return false;
|
|
108
|
+
if (base === "" || base.startsWith("/")) return !base.startsWith("//");
|
|
109
|
+
if (!/^https?:\/\/[^/?#]+(?:\/|$)/i.test(base)) return false;
|
|
110
|
+
try {
|
|
111
|
+
return new URL(base).hostname !== "";
|
|
112
|
+
} catch {
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
function compileRedirects(rules) {
|
|
117
|
+
const exact = /* @__PURE__ */ new Map();
|
|
118
|
+
const patterns = /* @__PURE__ */ new Map();
|
|
119
|
+
for (const rule of rules) {
|
|
120
|
+
const pattern = isRedirectPattern(rule.source);
|
|
121
|
+
const table = pattern ? patterns : exact;
|
|
122
|
+
const key = pattern ? redirectPatternPrefix(rule.source) : normalizedRedirectPath(rule.source);
|
|
123
|
+
if (!table.has(key)) table.set(key, rule);
|
|
124
|
+
}
|
|
125
|
+
return (pathname) => {
|
|
126
|
+
const canonical = canonicalRedirectPath(pathname);
|
|
127
|
+
const path = canonical ?? normalizedRedirectPath(pathname);
|
|
128
|
+
const hit = exact.get(path);
|
|
129
|
+
if (hit !== void 0) return { rule: hit, destination: hit.destination };
|
|
130
|
+
if (patterns.size === 0 || canonical === null || isPlatformRoute(path)) return null;
|
|
131
|
+
let prefix = path;
|
|
132
|
+
for (; ; ) {
|
|
133
|
+
const rule = patterns.get(prefix);
|
|
134
|
+
if (rule !== void 0) {
|
|
135
|
+
const remainder = path === prefix ? "" : prefix === "/" ? path : path.slice(prefix.length);
|
|
136
|
+
return { rule, destination: splatDestination(rule.destination, encodedRemainder(remainder)) };
|
|
48
137
|
}
|
|
49
|
-
|
|
50
|
-
|
|
138
|
+
if (prefix === "/") return null;
|
|
139
|
+
const cut = prefix.lastIndexOf("/");
|
|
140
|
+
prefix = cut <= 0 ? "/" : prefix.slice(0, cut);
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
function encodedRemainder(remainder) {
|
|
145
|
+
return remainder.split("/").map(encodeURIComponent).join("/");
|
|
146
|
+
}
|
|
147
|
+
function splatDestination(destination, remainder) {
|
|
148
|
+
if (!isRedirectPattern(destination)) return destination;
|
|
149
|
+
const joined = `${destination.slice(0, -REDIRECT_SPLAT.length)}${remainder.replace(/\/{2,}/g, "/")}`;
|
|
150
|
+
return joined === "" ? "/" : joined;
|
|
151
|
+
}
|
|
152
|
+
var MAX_REDIRECT_CHAIN = 20;
|
|
153
|
+
var PROBE_SEGMENT = "\u{10FFFF}";
|
|
154
|
+
function findRedirectLoop(rules) {
|
|
155
|
+
const match = compileRedirects(rules);
|
|
156
|
+
for (const [index, rule] of rules.entries()) {
|
|
157
|
+
let pathname = rule.source;
|
|
158
|
+
if (isRedirectPattern(rule.source)) {
|
|
159
|
+
const prefix = redirectPatternPrefix(rule.source);
|
|
160
|
+
pathname = `${prefix === "/" ? "" : prefix}/${PROBE_SEGMENT}`;
|
|
51
161
|
}
|
|
162
|
+
const visited = /* @__PURE__ */ new Set();
|
|
163
|
+
for (; ; ) {
|
|
164
|
+
const found = match(pathname);
|
|
165
|
+
if (found === null) break;
|
|
166
|
+
const key = canonicalRedirectPath(pathname) ?? normalizedRedirectPath(pathname);
|
|
167
|
+
if (visited.has(key) || visited.size >= MAX_REDIRECT_CHAIN) return { index, source: rule.source };
|
|
168
|
+
visited.add(key);
|
|
169
|
+
if (!found.destination.startsWith("/") || found.destination.startsWith("//")) break;
|
|
170
|
+
pathname = found.destination;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return null;
|
|
174
|
+
}
|
|
175
|
+
function resolveRootRedirectDestination(redirects, knownPagePaths) {
|
|
176
|
+
const loop = findRedirectLoop(redirects);
|
|
177
|
+
if (loop !== null) {
|
|
178
|
+
throw new BuildRuleError("redirect_cycle", `docs.json redirects contain a cycle involving ${loop.source}.`);
|
|
179
|
+
}
|
|
180
|
+
const bySource = /* @__PURE__ */ new Map();
|
|
181
|
+
for (const redirect of redirects) {
|
|
182
|
+
if (isRedirectPattern(redirect.source)) continue;
|
|
183
|
+
const source = normalizedRedirectPath(redirect.source);
|
|
184
|
+
if (!bySource.has(source)) bySource.set(source, redirect.destination);
|
|
52
185
|
}
|
|
53
186
|
if (!bySource.has("/")) return void 0;
|
|
54
187
|
let destination = normalizedRedirectPath(bySource.get("/") ?? "");
|
|
@@ -188,6 +321,10 @@ var CODE_THEMES = [
|
|
|
188
321
|
"vitesse-dark",
|
|
189
322
|
"vitesse-light"
|
|
190
323
|
];
|
|
324
|
+
var NAVIGATION_PAGE_METHODS = ["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS", "TRACE"];
|
|
325
|
+
var DEFAULT_HEADER_LOGO_HEIGHT = 26;
|
|
326
|
+
var MIN_HEADER_LOGO_HEIGHT = 20;
|
|
327
|
+
var MAX_HEADER_LOGO_HEIGHT = 40;
|
|
191
328
|
var MAX_ASSISTANT_GREETING_CHARS = 200;
|
|
192
329
|
var MAX_ASSISTANT_SUGGESTED_QUESTIONS = 6;
|
|
193
330
|
var MAX_ASSISTANT_SUGGESTED_QUESTION_CHARS = 160;
|
|
@@ -259,9 +396,14 @@ var navigationLinkSchema = z.object({
|
|
|
259
396
|
href: z.string(),
|
|
260
397
|
external: z.literal(true).optional()
|
|
261
398
|
}).strict();
|
|
399
|
+
var navigationIconSchema = z.string().min(1, "Icons must not be empty").refine((icon) => !icon.startsWith("/") || !icon.startsWith("//") && !icon.includes("\\") && !icon.split("/").includes(".."), {
|
|
400
|
+
message: "Icon asset paths must start with a single / and contain no backslashes or .. segments"
|
|
401
|
+
});
|
|
262
402
|
var navigationPageSchema = z.object({
|
|
263
403
|
page: z.string().min(1, "Page paths must not be empty"),
|
|
264
|
-
label: z.string().min(1, "Page labels must not be empty")
|
|
404
|
+
label: z.string().min(1, "Page labels must not be empty").optional(),
|
|
405
|
+
icon: navigationIconSchema.optional(),
|
|
406
|
+
method: z.enum(NAVIGATION_PAGE_METHODS).optional()
|
|
265
407
|
}).strict();
|
|
266
408
|
var navigationEntrySchema = z.lazy(
|
|
267
409
|
() => z.union([
|
|
@@ -275,14 +417,28 @@ var navigationEntrySchema = z.lazy(
|
|
|
275
417
|
var navigationGroupSchema = z.lazy(
|
|
276
418
|
() => z.object({
|
|
277
419
|
group: z.string(),
|
|
420
|
+
icon: navigationIconSchema.optional(),
|
|
421
|
+
root: z.string().min(1, "Group root pages must not be empty").optional(),
|
|
278
422
|
pages: z.array(navigationEntrySchema),
|
|
279
423
|
openapi: z.string().optional(),
|
|
280
424
|
collapsed: z.boolean().optional()
|
|
281
|
-
}).strict()
|
|
425
|
+
}).strict().superRefine((group, ctx) => {
|
|
426
|
+
const index = group.pages.findIndex(
|
|
427
|
+
(entry) => entry === group.root || isNavigationPage(entry) && entry.page === group.root
|
|
428
|
+
);
|
|
429
|
+
if (group.root !== void 0 && index !== -1) {
|
|
430
|
+
ctx.addIssue({
|
|
431
|
+
code: z.ZodIssueCode.custom,
|
|
432
|
+
path: ["pages", index],
|
|
433
|
+
message: `Group "${group.group}" links its heading to "${group.root}"; remove it from pages`
|
|
434
|
+
});
|
|
435
|
+
}
|
|
436
|
+
})
|
|
282
437
|
);
|
|
283
438
|
var navigationSectionSchema = z.lazy(
|
|
284
439
|
() => z.object({
|
|
285
440
|
section: z.string(),
|
|
441
|
+
icon: navigationIconSchema.optional(),
|
|
286
442
|
pages: z.array(navigationEntrySchema)
|
|
287
443
|
}).strict()
|
|
288
444
|
);
|
|
@@ -299,6 +455,7 @@ var navigationVersionSchema = z.object({
|
|
|
299
455
|
}).strict();
|
|
300
456
|
var navigationTabSchema = z.object({
|
|
301
457
|
tab: z.string().min(1, "Tab labels must not be empty"),
|
|
458
|
+
icon: navigationIconSchema.optional(),
|
|
302
459
|
groups: z.array(navigationContainerSchema)
|
|
303
460
|
}).strict();
|
|
304
461
|
var navigationSchema = z.union([
|
|
@@ -320,7 +477,7 @@ var navigationSchema = z.union([
|
|
|
320
477
|
}
|
|
321
478
|
seen.add(entry.tab);
|
|
322
479
|
if (entry.groups.every(
|
|
323
|
-
(group) => group.pages.length === 0 && (!isNavigationGroup(group) || !group.openapi)
|
|
480
|
+
(group) => group.pages.length === 0 && (!isNavigationGroup(group) || !group.openapi && !group.root)
|
|
324
481
|
)) {
|
|
325
482
|
ctx.addIssue({
|
|
326
483
|
code: z.ZodIssueCode.custom,
|
|
@@ -373,6 +530,8 @@ var logoSchema = z.union([
|
|
|
373
530
|
]);
|
|
374
531
|
var docsAiConfigSchema = z.object({
|
|
375
532
|
assistant: z.boolean().optional(),
|
|
533
|
+
triggerPlacement: z.enum(["header", "floating"]).optional(),
|
|
534
|
+
triggerIcon: z.string().regex(/^\/(?!\/)[^\s\\?#]+$/u, "Must be a root-relative image path").optional(),
|
|
376
535
|
graphEnrichment: z.boolean().optional(),
|
|
377
536
|
home: z.boolean().default(false),
|
|
378
537
|
greeting: z.string().trim().min(1).max(MAX_ASSISTANT_GREETING_CHARS).optional(),
|
|
@@ -434,13 +593,19 @@ var navigationHrefSchema = z.string().refine((value) => {
|
|
|
434
593
|
return false;
|
|
435
594
|
}
|
|
436
595
|
}, "Must start with / or be an absolute http(s) URL");
|
|
596
|
+
var labelledLinkSchema = z.object({
|
|
597
|
+
label: z.string().trim().min(1),
|
|
598
|
+
href: navigationHrefSchema
|
|
599
|
+
}).strict();
|
|
600
|
+
var HEADER_LOGO_HEIGHT_MESSAGE = `Must be a whole number of pixels from ${MIN_HEADER_LOGO_HEIGHT} to ${MAX_HEADER_LOGO_HEIGHT}; omit it for the default ${DEFAULT_HEADER_LOGO_HEIGHT}`;
|
|
437
601
|
var docsHeaderConfigSchema = z.object({
|
|
438
602
|
website: httpsUrlSchema.optional(),
|
|
439
603
|
showName: z.boolean().optional(),
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
604
|
+
logoHeight: z.number({ error: HEADER_LOGO_HEIGHT_MESSAGE }).int(HEADER_LOGO_HEIGHT_MESSAGE).min(MIN_HEADER_LOGO_HEIGHT, HEADER_LOGO_HEIGHT_MESSAGE).max(MAX_HEADER_LOGO_HEIGHT, HEADER_LOGO_HEIGHT_MESSAGE).optional(),
|
|
605
|
+
logoPlacement: z.enum(["header", "sidebar"]).optional(),
|
|
606
|
+
searchPlacement: z.enum(["header", "sidebar"]).optional(),
|
|
607
|
+
links: z.array(labelledLinkSchema).optional(),
|
|
608
|
+
cta: labelledLinkSchema.optional()
|
|
444
609
|
}).strict();
|
|
445
610
|
var editLinkSchema = z.object({
|
|
446
611
|
baseUrl: z.string()
|
|
@@ -453,7 +618,10 @@ var siteUrlSchema = z.string().url().refine((value) => {
|
|
|
453
618
|
}
|
|
454
619
|
}, "Must be an https URL");
|
|
455
620
|
var redirectSchema = z.object({
|
|
456
|
-
source: z.string().
|
|
621
|
+
source: z.string().superRefine((value, ctx) => {
|
|
622
|
+
const problem = redirectSourceProblem(value);
|
|
623
|
+
if (problem !== null) ctx.addIssue({ code: z.ZodIssueCode.custom, message: problem });
|
|
624
|
+
}),
|
|
457
625
|
destination: z.string().refine((value) => {
|
|
458
626
|
if (value.startsWith("/")) return !value.startsWith("//");
|
|
459
627
|
try {
|
|
@@ -464,6 +632,14 @@ var redirectSchema = z.object({
|
|
|
464
632
|
}
|
|
465
633
|
}, "Must start with / or be an absolute http(s) URL"),
|
|
466
634
|
permanent: z.boolean().optional()
|
|
635
|
+
}).strict().superRefine((redirect, ctx) => {
|
|
636
|
+
const problem = redirectDestinationProblem(redirect);
|
|
637
|
+
if (problem !== null) ctx.addIssue({ code: z.ZodIssueCode.custom, path: ["destination"], message: problem });
|
|
638
|
+
});
|
|
639
|
+
var docsApiConfigSchema = z.object({
|
|
640
|
+
playground: z.object({
|
|
641
|
+
layout: z.enum(["inline", "popup"]).default("inline")
|
|
642
|
+
}).strict().optional()
|
|
467
643
|
}).strict();
|
|
468
644
|
var docsConfigSchema = z.object({
|
|
469
645
|
name: z.string(),
|
|
@@ -491,27 +667,33 @@ var docsConfigSchema = z.object({
|
|
|
491
667
|
]).default(true),
|
|
492
668
|
navigation: navigationSchema,
|
|
493
669
|
footer: z.object({
|
|
494
|
-
text: z.string().optional()
|
|
670
|
+
text: z.string().optional(),
|
|
671
|
+
attribution: z.literal("text").optional(),
|
|
672
|
+
links: z.array(labelledLinkSchema).optional(),
|
|
673
|
+
social: z.array(socialLinkSchema.extend({ href: navigationHrefSchema })).optional()
|
|
495
674
|
}).strict().optional(),
|
|
496
675
|
instructions: z.string().optional(),
|
|
497
676
|
ai: docsAiConfigSchema.optional(),
|
|
498
677
|
analytics: docsAnalyticsConfigSchema.optional(),
|
|
499
678
|
auth: docsAuthConfigSchema.optional(),
|
|
500
679
|
agents: docsAgentsConfigSchema.optional(),
|
|
501
|
-
|
|
680
|
+
api: docsApiConfigSchema.optional(),
|
|
681
|
+
redirects: z.array(redirectSchema).max(MAX_REDIRECTS, `At most ${MAX_REDIRECTS} redirects`).optional()
|
|
502
682
|
}).strict().superRefine((config, ctx) => {
|
|
683
|
+
const redirects = config.redirects ?? [];
|
|
503
684
|
const seen = /* @__PURE__ */ new Set();
|
|
504
|
-
for (let index = 0; index <
|
|
505
|
-
const redirect =
|
|
685
|
+
for (let index = 0; index < redirects.length; index++) {
|
|
686
|
+
const redirect = redirects[index];
|
|
506
687
|
if (!redirect) continue;
|
|
507
|
-
|
|
688
|
+
const key = redirectSourceKey(redirect.source);
|
|
689
|
+
if (seen.has(key)) {
|
|
508
690
|
ctx.addIssue({
|
|
509
691
|
code: z.ZodIssueCode.custom,
|
|
510
692
|
path: ["redirects", index, "source"],
|
|
511
693
|
message: `Duplicate redirect source "${redirect.source}"`
|
|
512
694
|
});
|
|
513
695
|
}
|
|
514
|
-
seen.add(
|
|
696
|
+
seen.add(key);
|
|
515
697
|
}
|
|
516
698
|
});
|
|
517
699
|
var modelsConfigSchema = z.object({
|
|
@@ -595,18 +777,71 @@ function isNavigationPage(entry) {
|
|
|
595
777
|
return typeof entry === "object" && entry !== null && "page" in entry;
|
|
596
778
|
}
|
|
597
779
|
function authoredNavigationGroups(groups) {
|
|
598
|
-
return groups.flatMap((group) =>
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
),
|
|
780
|
+
return groups.flatMap((group) => {
|
|
781
|
+
const name = isNavigationGroup(group) ? group.group : group.section;
|
|
782
|
+
const first = {
|
|
783
|
+
group: name,
|
|
784
|
+
pages: isNavigationGroup(group) && group.root !== void 0 ? [group.root] : [],
|
|
604
785
|
...isNavigationGroup(group) && group.openapi ? { openapi: group.openapi } : {},
|
|
605
786
|
...isNavigationGroup(group) && group.collapsed !== void 0 ? { collapsed: group.collapsed } : {}
|
|
606
|
-
}
|
|
607
|
-
|
|
787
|
+
};
|
|
788
|
+
const result = [first];
|
|
789
|
+
let current = first;
|
|
790
|
+
for (const entry of group.pages) {
|
|
791
|
+
if (isNavigationContainer(entry)) {
|
|
792
|
+
result.push(...authoredNavigationGroups([entry]));
|
|
793
|
+
current = { group: name, pages: [], continued: true };
|
|
794
|
+
continue;
|
|
795
|
+
}
|
|
796
|
+
const page = typeof entry === "string" ? entry : isNavigationPage(entry) ? entry.page : void 0;
|
|
797
|
+
if (page === void 0) continue;
|
|
798
|
+
if (current.pages.length === 0 && current !== first) result.push(current);
|
|
799
|
+
current.pages.push(page);
|
|
800
|
+
}
|
|
801
|
+
return result;
|
|
802
|
+
});
|
|
803
|
+
}
|
|
804
|
+
function openApiSpecGroups(groups) {
|
|
805
|
+
return groups.flatMap((group) => [
|
|
806
|
+
...isNavigationGroup(group) && group.openapi ? [{
|
|
807
|
+
openapi: group.openapi,
|
|
808
|
+
pages: [
|
|
809
|
+
...group.root !== void 0 ? [group.root] : [],
|
|
810
|
+
...group.pages.flatMap(
|
|
811
|
+
(entry) => typeof entry === "string" ? [entry] : isNavigationPage(entry) ? [entry.page] : []
|
|
812
|
+
)
|
|
813
|
+
]
|
|
814
|
+
}] : [],
|
|
815
|
+
...openApiSpecGroups(group.pages.filter(isNavigationContainer))
|
|
608
816
|
]);
|
|
609
817
|
}
|
|
818
|
+
function navigationOpenApiSpecGroups(config) {
|
|
819
|
+
return openApiSpecGroups(topLevelNavigationGroups(config));
|
|
820
|
+
}
|
|
821
|
+
function navigationIconRefs(config) {
|
|
822
|
+
const refs = [];
|
|
823
|
+
const visit = (group, keys) => {
|
|
824
|
+
const owner = isNavigationGroup(group) ? `group "${group.group}"` : `section "${group.section}"`;
|
|
825
|
+
if (group.icon !== void 0) refs.push({ icon: group.icon, owner, keys: [...keys, "icon"] });
|
|
826
|
+
group.pages.forEach((entry, index) => {
|
|
827
|
+
const child = [...keys, "pages", index];
|
|
828
|
+
if (isNavigationContainer(entry)) visit(entry, child);
|
|
829
|
+
else if (isNavigationPage(entry) && entry.icon !== void 0) {
|
|
830
|
+
refs.push({ icon: entry.icon, owner: `page "${entry.page}"`, keys: [...child, "icon"] });
|
|
831
|
+
}
|
|
832
|
+
});
|
|
833
|
+
};
|
|
834
|
+
const groups = (entries, keys) => entries.forEach((group, index) => visit(group, [...keys, "groups", index]));
|
|
835
|
+
const nav = config.navigation;
|
|
836
|
+
if ("groups" in nav) groups(nav.groups, ["navigation"]);
|
|
837
|
+
else if ("tabs" in nav) nav.tabs.forEach((tab, index) => {
|
|
838
|
+
const keys = ["navigation", "tabs", index];
|
|
839
|
+
if (tab.icon !== void 0) refs.push({ icon: tab.icon, owner: `tab "${tab.tab}"`, keys: [...keys, "icon"] });
|
|
840
|
+
groups(tab.groups, keys);
|
|
841
|
+
});
|
|
842
|
+
else nav.versions.forEach((version, index) => groups(version.groups, ["navigation", "versions", index]));
|
|
843
|
+
return refs;
|
|
844
|
+
}
|
|
610
845
|
function navigationGroups(config) {
|
|
611
846
|
return authoredNavigationGroups(topLevelNavigationGroups(config));
|
|
612
847
|
}
|
|
@@ -678,6 +913,19 @@ function platformModelApiBase(platformApiBase) {
|
|
|
678
913
|
function errorMessage(cause) {
|
|
679
914
|
return cause instanceof Error ? cause.message : String(cause);
|
|
680
915
|
}
|
|
916
|
+
function configuredAssetHref(source, hasFile) {
|
|
917
|
+
if (!source) return void 0;
|
|
918
|
+
if (/^(?:https?:)?\/\//.test(source) || source.startsWith("data:")) return source;
|
|
919
|
+
const normalized = source.replace(/\\/g, "/");
|
|
920
|
+
const corpusAsset = normalized.match(/^(?:\/)?(?:src\/)?assets\/(.+)$/);
|
|
921
|
+
if (corpusAsset?.[1]) {
|
|
922
|
+
return hasFile(corpusAsset[1]) ? `/${corpusAsset[1]}` : void 0;
|
|
923
|
+
}
|
|
924
|
+
return normalized.startsWith("/") ? normalized : `/${normalized}`;
|
|
925
|
+
}
|
|
926
|
+
function assetPathname(href) {
|
|
927
|
+
return decodeURIComponent(href.split(/[?#]/, 1)[0]);
|
|
928
|
+
}
|
|
681
929
|
|
|
682
930
|
export {
|
|
683
931
|
BuildRuleError,
|
|
@@ -690,8 +938,12 @@ export {
|
|
|
690
938
|
ungatedOpenApiSpecPaths,
|
|
691
939
|
themeCssProblems,
|
|
692
940
|
parseDocsConfig,
|
|
941
|
+
navigationOpenApiSpecGroups,
|
|
942
|
+
navigationIconRefs,
|
|
693
943
|
navigationGroups,
|
|
694
944
|
loadDocsConfig,
|
|
695
945
|
loadModelsConfig,
|
|
696
|
-
parseModelsConfig
|
|
946
|
+
parseModelsConfig,
|
|
947
|
+
configuredAssetHref,
|
|
948
|
+
assetPathname
|
|
697
949
|
};
|