@stainless-api/docs-ui 0.1.0-beta.6 → 0.1.0-beta.61
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/breadcrumbs-BVskoBYz.d.ts +25 -0
- package/dist/breadcrumbs-C9LLJyuJ.d.ts +25 -0
- package/dist/breadcrumbs-CqA6kow2.js +63 -0
- package/dist/chunk-BN_g-Awi.js +18 -0
- package/dist/cli-0bJ66S1r.js +157 -0
- package/dist/component-CjJJYIxG.js +23 -0
- package/dist/component-generics-BC_P155r.d.ts +30 -0
- package/dist/component-generics-BkwbbxJF.d.ts +30 -0
- package/dist/component-generics-POFirVVb.js +45 -0
- package/dist/components/MaskedInput.d.ts +14 -0
- package/dist/components/MaskedInput.js +76 -0
- package/dist/components/breadcrumbs.d.ts +2 -0
- package/dist/components/breadcrumbs.js +9 -0
- package/dist/components/icons.d.ts +60 -0
- package/dist/components/icons.js +3 -0
- package/dist/components/index.d.ts +10 -0
- package/dist/components/index.js +18 -0
- package/dist/components/method.d.ts +2 -0
- package/dist/components/method.js +10 -0
- package/dist/components/overview.d.ts +2 -0
- package/dist/components/overview.js +11 -0
- package/dist/components/primitives.d.ts +2 -0
- package/dist/components/primitives.js +8 -0
- package/dist/components/properties.d.ts +2 -0
- package/dist/components/properties.js +9 -0
- package/dist/components/sdk.d.ts +2 -0
- package/dist/components/sdk.js +10 -0
- package/dist/components/sidebar.d.ts +2 -0
- package/dist/components/sidebar.js +9 -0
- package/dist/components/snippets.d.ts +3 -0
- package/dist/components/snippets.js +9 -0
- package/dist/components-FEHnQBJC.js +70 -0
- package/dist/contexts/component-generics.d.ts +2 -0
- package/dist/contexts/component-generics.js +3 -0
- package/dist/contexts/component-types.d.ts +16 -0
- package/dist/contexts/component-types.js +0 -0
- package/dist/contexts/component.d.ts +29 -0
- package/dist/contexts/component.js +28 -0
- package/dist/contexts/docs.d.ts +2 -0
- package/dist/contexts/docs.js +3 -0
- package/dist/contexts/index.d.ts +22 -0
- package/dist/contexts/index.js +7 -0
- package/dist/contexts/markdown.d.ts +2 -0
- package/dist/contexts/markdown.js +4 -0
- package/dist/contexts/navigation.d.ts +2 -0
- package/dist/contexts/navigation.js +3 -0
- package/dist/contexts/use-components.d.ts +14 -0
- package/dist/contexts/use-components.js +4 -0
- package/dist/contexts-CeV_L_Iy.js +39 -0
- package/dist/csharp-Dl2RIiYP.js +283 -0
- package/dist/docs--qWFuJCM.d.ts +46 -0
- package/dist/docs-DSFRsmbQ.d.ts +46 -0
- package/dist/docs-Di94viZV.js +54 -0
- package/dist/go-DuKdRGqU.js +303 -0
- package/dist/http-C7bu4oCl.js +331 -0
- package/dist/icons-BYKn5X8E.js +885 -0
- package/dist/index-C0qvL4yP.d.ts +15 -0
- package/dist/index-DE1vA8T2.d.ts +302 -0
- package/dist/index-DsFyACw9.d.ts +15 -0
- package/dist/index-FDM-j9s-.d.ts +302 -0
- package/dist/index-zNpvNvtN.d.ts +1691 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +30 -7542
- package/dist/java-DSyzO-6F.js +403 -0
- package/dist/languages/cli.d.ts +11 -0
- package/dist/languages/cli.js +20 -0
- package/dist/languages/csharp.d.ts +11 -0
- package/dist/languages/csharp.js +9 -0
- package/dist/languages/go.d.ts +11 -0
- package/dist/languages/go.js +9 -0
- package/dist/languages/http.d.ts +11 -0
- package/dist/languages/http.js +19 -0
- package/dist/languages/index.d.ts +11 -0
- package/dist/languages/index.js +27 -0
- package/dist/languages/java.d.ts +11 -0
- package/dist/languages/java.js +9 -0
- package/dist/languages/python.d.ts +11 -0
- package/dist/languages/python.js +9 -0
- package/dist/languages/ruby.d.ts +11 -0
- package/dist/languages/ruby.js +9 -0
- package/dist/languages/typescript.d.ts +11 -0
- package/dist/languages/typescript.js +9 -0
- package/dist/languages-BO5YJ6cy.js +28 -0
- package/dist/markdown/index.d.ts +12 -0
- package/dist/markdown/index.js +105 -0
- package/dist/markdown/md.d.ts +15 -0
- package/dist/markdown/md.js +41 -0
- package/dist/markdown/printer.d.ts +13 -0
- package/dist/markdown/printer.js +98 -0
- package/dist/markdown/utils.d.ts +21 -0
- package/dist/markdown/utils.js +31 -0
- package/dist/markdown-B517MrZh.d.ts +22 -0
- package/dist/markdown-C7Tb41LZ.d.ts +22 -0
- package/dist/markdown-D2JWyRws.js +49 -0
- package/dist/method-BaQEZVlw.d.ts +59 -0
- package/dist/method-Dln4ZTIB.d.ts +59 -0
- package/dist/method-jTnA0G8m.js +90 -0
- package/dist/navigation-XhIgqXwM.d.ts +29 -0
- package/dist/navigation-aoYZ_tl4.js +24 -0
- package/dist/navigation-rKdts-BR.d.ts +29 -0
- package/dist/overview-B3kgyac2.d.ts +39 -0
- package/dist/overview-BnagZfH1.js +139 -0
- package/dist/overview-Dp-gGl3v.d.ts +39 -0
- package/dist/primitives-B6zu2rrx.d.ts +105 -0
- package/dist/primitives-DQLc9kN7.js +250 -0
- package/dist/primitives-VtUGoYwX.d.ts +105 -0
- package/dist/properties-Bun4nfUE.d.ts +54 -0
- package/dist/properties-DGL2J11L.js +131 -0
- package/dist/properties-ZOIqpkET.d.ts +54 -0
- package/dist/python-D8ABqtn1.js +269 -0
- package/dist/routing-Ce0_tBW6.js +197 -0
- package/dist/routing-CtbZJru_.d.ts +54 -0
- package/dist/routing.d.ts +2 -0
- package/dist/routing.js +3 -180
- package/dist/ruby-261jvCjl.js +387 -0
- package/dist/sdk-BebFnWYL.d.ts +118 -0
- package/dist/sdk-CIxaNoAs.d.ts +118 -0
- package/dist/sdk-GGpyGTao.js +338 -0
- package/dist/sidebar-BWno0E4w.js +85 -0
- package/dist/sidebar-CLsIJZZf.d.ts +36 -0
- package/dist/sidebar-D4m_pVpS.d.ts +36 -0
- package/dist/snippets-CwVjwsAo.d.ts +53 -0
- package/dist/snippets-Ym3mnHO3.d.ts +53 -0
- package/dist/snippets-kI8eNs1F.js +164 -0
- package/dist/spec.d.ts +65 -0
- package/dist/spec.js +167 -0
- package/dist/style-LwfvXElj.js +170 -0
- package/dist/style.d.ts +169 -0
- package/dist/style.js +3 -0
- package/dist/styles/main.css +722 -755
- package/dist/styles/main.js +0 -0
- package/dist/styles/primitives.css +322 -459
- package/dist/styles/primitives.js +0 -0
- package/dist/styles/resets.css +32 -41
- package/dist/styles/resets.js +0 -0
- package/dist/styles/search.css +192 -270
- package/dist/styles/search.js +0 -0
- package/dist/styles/sidebar.css +56 -61
- package/dist/styles/sidebar.js +0 -0
- package/dist/styles/variables.css +26 -89
- package/dist/styles/variables.js +0 -0
- package/dist/styles.css +3145 -0
- package/dist/styles.mjs +1 -0
- package/dist/typescript-D924WidI.js +449 -0
- package/dist/use-components-BUz3GbO4.js +7 -0
- package/dist/utils-D01mAUfQ.js +32 -0
- package/dist/utils.d.ts +14 -0
- package/dist/utils.js +3 -0
- package/package.json +73 -21
- package/dist/mcp.js +0 -16003
- package/dist/styles/snippets.css +0 -132
- package/src/components/breadcrumbs.tsx +0 -94
- package/src/components/chat.tsx +0 -154
- package/src/components/dropdown.tsx +0 -91
- package/src/components/icons.tsx +0 -584
- package/src/components/index.ts +0 -9
- package/src/components/method.tsx +0 -144
- package/src/components/overview.tsx +0 -159
- package/src/components/primitives.tsx +0 -284
- package/src/components/properties.tsx +0 -130
- package/src/components/scripts/dropdown.ts +0 -78
- package/src/components/sdk.tsx +0 -402
- package/src/components/sidebar.tsx +0 -99
- package/src/components/snippets.tsx +0 -179
- package/src/contexts/component-generics.tsx +0 -48
- package/src/contexts/component-types.tsx +0 -5
- package/src/contexts/component.tsx +0 -32
- package/src/contexts/docs.tsx +0 -75
- package/src/contexts/index.tsx +0 -17
- package/src/contexts/markdown.tsx +0 -43
- package/src/contexts/navigation.tsx +0 -44
- package/src/contexts/search.tsx +0 -28
- package/src/contexts/use-components.tsx +0 -4
- package/src/index.ts +0 -6
- package/src/languages/go.tsx +0 -281
- package/src/languages/http.tsx +0 -321
- package/src/languages/index.ts +0 -26
- package/src/languages/java.tsx +0 -358
- package/src/languages/python.tsx +0 -255
- package/src/languages/ruby.tsx +0 -320
- package/src/languages/typescript.tsx +0 -393
- package/src/markdown/index.ts +0 -107
- package/src/markdown/md.ts +0 -45
- package/src/markdown/utils.ts +0 -49
- package/src/routing.ts +0 -238
- package/src/search/form.tsx +0 -127
- package/src/search/index.tsx +0 -1
- package/src/search/indexer.ts +0 -246
- package/src/search/mcp.ts +0 -61
- package/src/search/printer.tsx +0 -86
- package/src/search/providers/algolia.ts +0 -88
- package/src/search/providers/fuse.ts +0 -19
- package/src/search/providers/pagefind.ts +0 -17
- package/src/search/providers/walker.ts +0 -30
- package/src/search/results.tsx +0 -181
- package/src/search/state.ts +0 -64
- package/src/search/types.ts +0 -116
- package/src/style.ts +0 -197
- package/src/styles/main.css +0 -993
- package/src/styles/primitives.css +0 -573
- package/src/styles/resets.css +0 -47
- package/src/styles/search.css +0 -342
- package/src/styles/sidebar.css +0 -87
- package/src/styles/snippets.css +0 -132
- package/src/styles/variables.css +0 -90
- package/src/utils.ts +0 -41
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { t as __exportAll } from "./chunk-BN_g-Awi.js";
|
|
2
|
+
|
|
3
|
+
//#region src/routing.ts
|
|
4
|
+
var routing_exports = /* @__PURE__ */ __exportAll({
|
|
5
|
+
LanguageNames: () => LanguageNames,
|
|
6
|
+
Languages: () => Languages,
|
|
7
|
+
SupportedLanguageSyntaxes: () => SupportedLanguageSyntaxes,
|
|
8
|
+
expandToElement: () => expandToElement,
|
|
9
|
+
findNavigationPath: () => findNavigationPath,
|
|
10
|
+
generateRoute: () => generateRoute,
|
|
11
|
+
generateRouteList: () => generateRouteList,
|
|
12
|
+
getLanguageSnippet: () => getLanguageSnippet,
|
|
13
|
+
getResource: () => getResource,
|
|
14
|
+
isSupportedLanguage: () => isSupportedLanguage,
|
|
15
|
+
parseRoute: () => parseRoute,
|
|
16
|
+
parseStainlessPath: () => parseStainlessPath,
|
|
17
|
+
scrollToPath: () => scrollToPath,
|
|
18
|
+
trimStainlessPath: () => trimStainlessPath,
|
|
19
|
+
updateHistory: () => updateHistory,
|
|
20
|
+
walkTree: () => walkTree
|
|
21
|
+
});
|
|
22
|
+
const Languages = [
|
|
23
|
+
"http",
|
|
24
|
+
"node",
|
|
25
|
+
"python",
|
|
26
|
+
"go",
|
|
27
|
+
"typescript",
|
|
28
|
+
"terraform",
|
|
29
|
+
"ruby",
|
|
30
|
+
"java",
|
|
31
|
+
"kotlin",
|
|
32
|
+
"csharp",
|
|
33
|
+
"php",
|
|
34
|
+
"cli"
|
|
35
|
+
];
|
|
36
|
+
const SupportedLanguageSyntaxes = [
|
|
37
|
+
"http",
|
|
38
|
+
"javascript",
|
|
39
|
+
"python",
|
|
40
|
+
"go",
|
|
41
|
+
"typescript",
|
|
42
|
+
"terraform",
|
|
43
|
+
"ruby",
|
|
44
|
+
"java",
|
|
45
|
+
"kotlin",
|
|
46
|
+
"csharp",
|
|
47
|
+
"bash"
|
|
48
|
+
];
|
|
49
|
+
const LanguageNames = {
|
|
50
|
+
http: "HTTP",
|
|
51
|
+
node: "TypeScript",
|
|
52
|
+
typescript: "TypeScript",
|
|
53
|
+
python: "Python",
|
|
54
|
+
go: "Go",
|
|
55
|
+
ruby: "Ruby",
|
|
56
|
+
java: "Java",
|
|
57
|
+
kotlin: "Kotlin",
|
|
58
|
+
terraform: "Terraform",
|
|
59
|
+
csharp: "C#",
|
|
60
|
+
php: "PHP",
|
|
61
|
+
cli: "CLI Tool"
|
|
62
|
+
};
|
|
63
|
+
function getLanguageSnippet(language) {
|
|
64
|
+
return language === "http" ? "http.curl" : `${language}.default`;
|
|
65
|
+
}
|
|
66
|
+
function isSupportedLanguage(language) {
|
|
67
|
+
return Languages.includes(language);
|
|
68
|
+
}
|
|
69
|
+
const DefaultLanguage = "http";
|
|
70
|
+
const StainlessPathPattern = /(\(resource\) (?<resource>[^\s]+))( > (\(method\) (?<method>[^\s]+)|\(model\) (?<model>[^\s]+))?)?/;
|
|
71
|
+
function parseStainlessPath(stainlessPath) {
|
|
72
|
+
const match = stainlessPath.match(StainlessPathPattern);
|
|
73
|
+
if (!match?.groups) return null;
|
|
74
|
+
return {
|
|
75
|
+
resource: match.groups.resource?.split(".") ?? null,
|
|
76
|
+
method: match.groups.method ?? null,
|
|
77
|
+
model: match.groups.model ?? null,
|
|
78
|
+
routable: match.groups.model ? match[1] : match[0]
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
function trimStainlessPath(stainlessPath) {
|
|
82
|
+
return stainlessPath.replace(/ > \([^\s]+\)$/, "");
|
|
83
|
+
}
|
|
84
|
+
function getResource(stainlessPath) {
|
|
85
|
+
return parseStainlessPath(stainlessPath)?.resource?.[0];
|
|
86
|
+
}
|
|
87
|
+
function parseRoute(basePath, route) {
|
|
88
|
+
if (!route.startsWith(basePath)) return {
|
|
89
|
+
stainlessPath: "",
|
|
90
|
+
language: DefaultLanguage
|
|
91
|
+
};
|
|
92
|
+
if (basePath && route.startsWith(basePath)) route = route.slice(basePath.length);
|
|
93
|
+
let stainlessPath = "";
|
|
94
|
+
let elements = route.slice(1).split("/");
|
|
95
|
+
let language = DefaultLanguage;
|
|
96
|
+
if (elements[0] && Languages.includes(elements[0])) {
|
|
97
|
+
language = elements[0];
|
|
98
|
+
elements = elements.slice(1);
|
|
99
|
+
}
|
|
100
|
+
while (elements.length > 0) switch (elements.shift()) {
|
|
101
|
+
case "resources":
|
|
102
|
+
stainlessPath += `(resource) ${elements.shift()}`;
|
|
103
|
+
break;
|
|
104
|
+
case "subresources":
|
|
105
|
+
stainlessPath += `.${elements.shift()}`;
|
|
106
|
+
break;
|
|
107
|
+
case "methods":
|
|
108
|
+
stainlessPath += ` > (method) ${elements.shift()}`;
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
111
|
+
return {
|
|
112
|
+
stainlessPath,
|
|
113
|
+
language
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
function generateRoute(basePath, language, stainlessPath) {
|
|
117
|
+
const parsedPath = parseStainlessPath(stainlessPath);
|
|
118
|
+
if (!parsedPath) return null;
|
|
119
|
+
const path = [basePath.endsWith("/") ? basePath.slice(0, -1) : basePath];
|
|
120
|
+
if (language && language !== DefaultLanguage) path.push(language);
|
|
121
|
+
const resources = parsedPath.resource.flatMap((name, index) => [index > 0 ? "subresources" : "resources", name]);
|
|
122
|
+
const resourcePath = parsedPath.model ? resources.slice(0, 2) : resources;
|
|
123
|
+
path.push(...resourcePath);
|
|
124
|
+
if (parsedPath.method) path.push("methods", parsedPath.method);
|
|
125
|
+
return stainlessPath.length > parsedPath.routable.length ? `${path.join("/")}#${encodeURIComponent(stainlessPath)}` : path.join("/");
|
|
126
|
+
}
|
|
127
|
+
function* walkResource(resource, path, includeModels) {
|
|
128
|
+
yield {
|
|
129
|
+
data: resource,
|
|
130
|
+
path
|
|
131
|
+
};
|
|
132
|
+
for (const data of Object.values(resource.methods)) yield {
|
|
133
|
+
data,
|
|
134
|
+
path: [
|
|
135
|
+
...path,
|
|
136
|
+
"methods",
|
|
137
|
+
data.name
|
|
138
|
+
]
|
|
139
|
+
};
|
|
140
|
+
if (includeModels) for (const data of Object.values(resource.models)) yield {
|
|
141
|
+
data,
|
|
142
|
+
path: [
|
|
143
|
+
...path,
|
|
144
|
+
"models",
|
|
145
|
+
data.name
|
|
146
|
+
]
|
|
147
|
+
};
|
|
148
|
+
for (const data of Object.values(resource.subresources ?? {})) yield* walkResource(data, [
|
|
149
|
+
...path,
|
|
150
|
+
"subresources",
|
|
151
|
+
data.name
|
|
152
|
+
]);
|
|
153
|
+
}
|
|
154
|
+
function* walkTree(spec, includeModels) {
|
|
155
|
+
for (const data of Object.values(spec.resources)) yield* walkResource(data, ["resources", data.name], includeModels);
|
|
156
|
+
}
|
|
157
|
+
function generateRouteList({ spec, languages, excludeLanguages = [] }) {
|
|
158
|
+
const entries = Array.from(walkTree(spec));
|
|
159
|
+
return (languages ?? spec.docs?.languages ?? ["http"]).filter((lang) => Languages.includes(lang) && lang !== "terraform").filter((lang) => !excludeLanguages?.includes(lang)).flatMap((language) => entries.map(({ path, data: { title, kind, stainlessPath } }) => ({
|
|
160
|
+
title,
|
|
161
|
+
kind,
|
|
162
|
+
language,
|
|
163
|
+
stainlessPath,
|
|
164
|
+
slug: (language === "http" ? path : [language, ...path]).join("/")
|
|
165
|
+
})));
|
|
166
|
+
}
|
|
167
|
+
function findNavigationPath(items, target) {
|
|
168
|
+
for (const item of Object.values(items)) {
|
|
169
|
+
if (item.stainlessPath === target) return [item.stainlessPath];
|
|
170
|
+
if (item.kind === "http_method") continue;
|
|
171
|
+
const path = findNavigationPath([...Object.values(item.methods ?? {}), ...Object.values(item.subresources ?? {})], target);
|
|
172
|
+
if (path) return [item.stainlessPath, ...path];
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
function expandToElement(el) {
|
|
176
|
+
while (el) {
|
|
177
|
+
if (el instanceof HTMLDetailsElement) el.open = true;
|
|
178
|
+
el = el.parentElement;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
function scrollToPath(stainlessPath) {
|
|
182
|
+
const el = document.getElementById(stainlessPath);
|
|
183
|
+
if (el) {
|
|
184
|
+
expandToElement(el);
|
|
185
|
+
el.scrollIntoView({ behavior: "smooth" });
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
function updateHistory(basePath, language, stainlessPath) {
|
|
189
|
+
const path = generateRoute(basePath, language, stainlessPath);
|
|
190
|
+
window.history.pushState({
|
|
191
|
+
stainlessPath,
|
|
192
|
+
language
|
|
193
|
+
}, "", path);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
//#endregion
|
|
197
|
+
export { walkTree as _, findNavigationPath as a, getLanguageSnippet as c, parseRoute as d, parseStainlessPath as f, updateHistory as g, trimStainlessPath as h, expandToElement as i, getResource as l, scrollToPath as m, Languages as n, generateRoute as o, routing_exports as p, SupportedLanguageSyntaxes as r, generateRouteList as s, LanguageNames as t, isSupportedLanguage as u };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { f as Resource, h as Spec, l as Method, u as Model } from "./index-zNpvNvtN.js";
|
|
2
|
+
|
|
3
|
+
//#region src/routing.d.ts
|
|
4
|
+
declare namespace routing_d_exports {
|
|
5
|
+
export { DocsLanguage, LanguageNames, Languages, ParsedStainlessPath, RouteEntry, SpecTreeEntry, SupportedLanguageSyntaxes, expandToElement, findNavigationPath, generateRoute, generateRouteList, getLanguageSnippet, getResource, isSupportedLanguage, parseRoute, parseStainlessPath, scrollToPath, trimStainlessPath, updateHistory, walkTree };
|
|
6
|
+
}
|
|
7
|
+
declare const Languages: readonly ["http", "node", "python", "go", "typescript", "terraform", "ruby", "java", "kotlin", "csharp", "php", "cli"];
|
|
8
|
+
declare const SupportedLanguageSyntaxes: string[];
|
|
9
|
+
type DocsLanguage = (typeof Languages)[number];
|
|
10
|
+
declare const LanguageNames: Record<DocsLanguage, string>;
|
|
11
|
+
declare function getLanguageSnippet(language: DocsLanguage): "http.curl" | "node.default" | "python.default" | "go.default" | "typescript.default" | "terraform.default" | "ruby.default" | "java.default" | "kotlin.default" | "csharp.default" | "php.default" | "cli.default";
|
|
12
|
+
declare function isSupportedLanguage(language: string): language is DocsLanguage;
|
|
13
|
+
type ParsedStainlessPath = ReturnType<typeof parseStainlessPath>;
|
|
14
|
+
declare function parseStainlessPath(stainlessPath: string): {
|
|
15
|
+
resource: string[] | null;
|
|
16
|
+
method: string | null;
|
|
17
|
+
model: string | null;
|
|
18
|
+
routable: string | undefined;
|
|
19
|
+
} | null;
|
|
20
|
+
declare function trimStainlessPath(stainlessPath: string): string;
|
|
21
|
+
declare function getResource(stainlessPath: string): string | undefined;
|
|
22
|
+
declare function parseRoute(basePath: string, route: string): {
|
|
23
|
+
stainlessPath: string;
|
|
24
|
+
language: DocsLanguage;
|
|
25
|
+
};
|
|
26
|
+
declare function generateRoute(basePath: string, language: string, stainlessPath: string): string | null;
|
|
27
|
+
type SpecTreeEntry = {
|
|
28
|
+
data: Method | Resource | Model;
|
|
29
|
+
path: string[];
|
|
30
|
+
};
|
|
31
|
+
declare function walkTree(spec: Spec, includeModels?: boolean): Generator<SpecTreeEntry, void, any>;
|
|
32
|
+
type RouteEntry = {
|
|
33
|
+
title: string;
|
|
34
|
+
kind: SpecTreeEntry['data']['kind'];
|
|
35
|
+
language: DocsLanguage;
|
|
36
|
+
stainlessPath: string;
|
|
37
|
+
slug: string;
|
|
38
|
+
};
|
|
39
|
+
declare function generateRouteList({
|
|
40
|
+
spec,
|
|
41
|
+
languages,
|
|
42
|
+
excludeLanguages
|
|
43
|
+
}: {
|
|
44
|
+
spec: Spec;
|
|
45
|
+
languages?: DocsLanguage[];
|
|
46
|
+
excludeLanguages?: DocsLanguage[];
|
|
47
|
+
}): RouteEntry[];
|
|
48
|
+
type ResourceOrMethod = Resource | Method;
|
|
49
|
+
declare function findNavigationPath(items: ResourceOrMethod[], target: string): string[] | undefined;
|
|
50
|
+
declare function expandToElement(el: HTMLElement | null): void;
|
|
51
|
+
declare function scrollToPath(stainlessPath: string): void;
|
|
52
|
+
declare function updateHistory(basePath: string, language: DocsLanguage, stainlessPath: string): void;
|
|
53
|
+
//#endregion
|
|
54
|
+
export { routing_d_exports as _, RouteEntry as a, updateHistory as b, expandToElement as c, generateRouteList as d, getLanguageSnippet as f, parseStainlessPath as g, parseRoute as h, ParsedStainlessPath as i, findNavigationPath as l, isSupportedLanguage as m, LanguageNames as n, SpecTreeEntry as o, getResource as p, Languages as r, SupportedLanguageSyntaxes as s, DocsLanguage as t, generateRoute as u, scrollToPath as v, walkTree as x, trimStainlessPath as y };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as RouteEntry, b as updateHistory, c as expandToElement, d as generateRouteList, f as getLanguageSnippet, g as parseStainlessPath, h as parseRoute, i as ParsedStainlessPath, l as findNavigationPath, m as isSupportedLanguage, n as LanguageNames, o as SpecTreeEntry, p as getResource, r as Languages, s as SupportedLanguageSyntaxes, t as DocsLanguage, u as generateRoute, v as scrollToPath, x as walkTree, y as trimStainlessPath } from "./routing-CtbZJru_.js";
|
|
2
|
+
export { DocsLanguage, LanguageNames, Languages, ParsedStainlessPath, RouteEntry, SpecTreeEntry, SupportedLanguageSyntaxes, expandToElement, findNavigationPath, generateRoute, generateRouteList, getLanguageSnippet, getResource, isSupportedLanguage, parseRoute, parseStainlessPath, scrollToPath, trimStainlessPath, updateHistory, walkTree };
|
package/dist/routing.js
CHANGED
|
@@ -1,180 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
"node",
|
|
5
|
-
"python",
|
|
6
|
-
"go",
|
|
7
|
-
"typescript",
|
|
8
|
-
"terraform",
|
|
9
|
-
"ruby",
|
|
10
|
-
"java",
|
|
11
|
-
"kotlin"
|
|
12
|
-
];
|
|
13
|
-
var SupportedLanguageSyntaxes = [
|
|
14
|
-
"http",
|
|
15
|
-
"javascript",
|
|
16
|
-
"python",
|
|
17
|
-
"go",
|
|
18
|
-
"typescript",
|
|
19
|
-
"terraform",
|
|
20
|
-
"ruby",
|
|
21
|
-
"java",
|
|
22
|
-
"kotlin"
|
|
23
|
-
];
|
|
24
|
-
var LanguageNames = {
|
|
25
|
-
http: "HTTP",
|
|
26
|
-
node: "TypeScript",
|
|
27
|
-
typescript: "TypeScript",
|
|
28
|
-
python: "Python",
|
|
29
|
-
go: "Go",
|
|
30
|
-
ruby: "Ruby",
|
|
31
|
-
java: "Java",
|
|
32
|
-
kotlin: "Kotlin",
|
|
33
|
-
terraform: "Terraform"
|
|
34
|
-
};
|
|
35
|
-
function getLanguageSnippet(language) {
|
|
36
|
-
return language === "http" ? "http.curl" : `${language}.default`;
|
|
37
|
-
}
|
|
38
|
-
function isSupportedLanguage(language) {
|
|
39
|
-
return Languages.includes(language);
|
|
40
|
-
}
|
|
41
|
-
var DefaultLanguage = "http";
|
|
42
|
-
var StainlessPathPattern = /(\(resource\) (?<resource>[^\s]+))( > (\(method\) (?<method>[^\s]+)|\(model\) (?<model>[^\s]+))?)?/;
|
|
43
|
-
function parseStainlessPath(stainlessPath) {
|
|
44
|
-
const match = stainlessPath.match(StainlessPathPattern);
|
|
45
|
-
if (!match) return null;
|
|
46
|
-
return {
|
|
47
|
-
resource: match.groups.resource.split("."),
|
|
48
|
-
method: match.groups.method ?? null,
|
|
49
|
-
model: match.groups.model ?? null,
|
|
50
|
-
routable: match.groups.model ? match[1] : match[0]
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
function trimStainlessPath(stainlessPath) {
|
|
54
|
-
return stainlessPath.replace(/ > \([^\s]+\)$/, "");
|
|
55
|
-
}
|
|
56
|
-
function getResource(stainlessPath) {
|
|
57
|
-
const parsed = parseStainlessPath(stainlessPath);
|
|
58
|
-
return parsed?.resource[0];
|
|
59
|
-
}
|
|
60
|
-
function parseRoute(basePath, route) {
|
|
61
|
-
if (!route.startsWith(basePath)) return { stainlessPath: "", language: DefaultLanguage };
|
|
62
|
-
if (basePath && route.startsWith(basePath)) route = route.slice(basePath.length);
|
|
63
|
-
let stainlessPath = "";
|
|
64
|
-
let elements = route.slice(1).split("/");
|
|
65
|
-
let language = DefaultLanguage;
|
|
66
|
-
if (elements[0] && Languages.includes(elements[0])) {
|
|
67
|
-
language = elements[0];
|
|
68
|
-
elements = elements.slice(1);
|
|
69
|
-
}
|
|
70
|
-
while (elements.length > 0) {
|
|
71
|
-
const element = elements.shift();
|
|
72
|
-
switch (element) {
|
|
73
|
-
case "resources":
|
|
74
|
-
stainlessPath += `(resource) ${elements.shift()}`;
|
|
75
|
-
break;
|
|
76
|
-
case "subresources":
|
|
77
|
-
stainlessPath += `.${elements.shift()}`;
|
|
78
|
-
break;
|
|
79
|
-
case "methods":
|
|
80
|
-
stainlessPath += ` > (method) ${elements.shift()}`;
|
|
81
|
-
break;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
return { stainlessPath, language };
|
|
85
|
-
}
|
|
86
|
-
function generateRoute(basePath, language, stainlessPath) {
|
|
87
|
-
const parsedPath = parseStainlessPath(stainlessPath);
|
|
88
|
-
if (!parsedPath) return null;
|
|
89
|
-
const path = [basePath.endsWith("/") ? basePath.slice(0, -1) : basePath];
|
|
90
|
-
if (language && language !== DefaultLanguage) path.push(language);
|
|
91
|
-
const resources = parsedPath.resource.flatMap((name, index) => [
|
|
92
|
-
index > 0 ? "subresources" : "resources",
|
|
93
|
-
name
|
|
94
|
-
]);
|
|
95
|
-
const resourcePath = parsedPath.model ? resources.slice(0, 2) : resources;
|
|
96
|
-
path.push(...resourcePath);
|
|
97
|
-
if (parsedPath.method) path.push("methods", parsedPath.method);
|
|
98
|
-
return stainlessPath.length > parsedPath.routable.length ? `${path.join("/")}#${encodeURIComponent(stainlessPath)}` : path.join("/");
|
|
99
|
-
}
|
|
100
|
-
function* walkResource(resource, path, includeModels) {
|
|
101
|
-
yield { data: resource, path };
|
|
102
|
-
for (const data of Object.values(resource.methods)) {
|
|
103
|
-
yield { data, path: [...path, "methods", data.name] };
|
|
104
|
-
}
|
|
105
|
-
if (includeModels)
|
|
106
|
-
for (const data of Object.values(resource.models)) {
|
|
107
|
-
yield { data, path: [...path, "models", data.name] };
|
|
108
|
-
}
|
|
109
|
-
for (const data of Object.values(resource.subresources ?? {})) {
|
|
110
|
-
yield* walkResource(data, [...path, "subresources", data.name]);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
function* walkTree(spec, includeModels) {
|
|
114
|
-
for (const data of Object.values(spec.resources)) {
|
|
115
|
-
yield* walkResource(data, ["resources", data.name], includeModels);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
function generateRouteList({
|
|
119
|
-
spec,
|
|
120
|
-
languages,
|
|
121
|
-
excludeLanguages = []
|
|
122
|
-
}) {
|
|
123
|
-
const entries = Array.from(walkTree(spec));
|
|
124
|
-
const langs = languages ?? spec.docs?.languages ?? ["http"];
|
|
125
|
-
return langs.filter((lang) => Languages.includes(lang) && lang !== "terraform").filter((lang) => !excludeLanguages?.includes(lang)).flatMap(
|
|
126
|
-
(language) => entries.map(({ path, data: { title, kind, stainlessPath } }) => ({
|
|
127
|
-
title,
|
|
128
|
-
kind,
|
|
129
|
-
language,
|
|
130
|
-
stainlessPath,
|
|
131
|
-
slug: (language === "http" ? path : [language, ...path]).join("/")
|
|
132
|
-
}))
|
|
133
|
-
);
|
|
134
|
-
}
|
|
135
|
-
function findNavigationPath(items, target) {
|
|
136
|
-
for (const item of Object.values(items)) {
|
|
137
|
-
if (item.stainlessPath === target) return [item.stainlessPath];
|
|
138
|
-
if (item.kind === "http_method") continue;
|
|
139
|
-
const path = findNavigationPath(
|
|
140
|
-
[...Object.values(item.methods ?? {}), ...Object.values(item.subresources ?? {})],
|
|
141
|
-
target
|
|
142
|
-
);
|
|
143
|
-
if (path) return [item.stainlessPath, ...path];
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
function expandToElement(el) {
|
|
147
|
-
while (el) {
|
|
148
|
-
if (el.tagName === "DETAILS") el["open"] = true;
|
|
149
|
-
el = el.parentElement;
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
function scrollToPath(stainlessPath) {
|
|
153
|
-
const el = document.getElementById(stainlessPath);
|
|
154
|
-
if (el) {
|
|
155
|
-
expandToElement(el);
|
|
156
|
-
el.scrollIntoView({ behavior: "smooth" });
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
function updateHistory(basePath, language, stainlessPath) {
|
|
160
|
-
const path = generateRoute(basePath, language, stainlessPath);
|
|
161
|
-
window.history.pushState({ stainlessPath, language }, "", path);
|
|
162
|
-
}
|
|
163
|
-
export {
|
|
164
|
-
LanguageNames,
|
|
165
|
-
Languages,
|
|
166
|
-
SupportedLanguageSyntaxes,
|
|
167
|
-
expandToElement,
|
|
168
|
-
findNavigationPath,
|
|
169
|
-
generateRoute,
|
|
170
|
-
generateRouteList,
|
|
171
|
-
getLanguageSnippet,
|
|
172
|
-
getResource,
|
|
173
|
-
isSupportedLanguage,
|
|
174
|
-
parseRoute,
|
|
175
|
-
parseStainlessPath,
|
|
176
|
-
scrollToPath,
|
|
177
|
-
trimStainlessPath,
|
|
178
|
-
updateHistory,
|
|
179
|
-
walkTree
|
|
180
|
-
};
|
|
1
|
+
import { _ as walkTree, a as findNavigationPath, c as getLanguageSnippet, d as parseRoute, f as parseStainlessPath, g as updateHistory, h as trimStainlessPath, i as expandToElement, l as getResource, m as scrollToPath, n as Languages, o as generateRoute, r as SupportedLanguageSyntaxes, s as generateRouteList, t as LanguageNames, u as isSupportedLanguage } from "./routing-Ce0_tBW6.js";
|
|
2
|
+
|
|
3
|
+
export { LanguageNames, Languages, SupportedLanguageSyntaxes, expandToElement, findNavigationPath, generateRoute, generateRouteList, getLanguageSnippet, getResource, isSupportedLanguage, parseRoute, parseStainlessPath, scrollToPath, trimStainlessPath, updateHistory, walkTree };
|