@stainless-api/docs-ui 0.1.0-beta.11 → 0.1.0-beta.13
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/index.js +6933 -16
- package/dist/mcp.js +15389 -0
- package/dist/routing.js +180 -3
- package/dist/styles/main.css +10 -9
- package/dist/styles/primitives.css +0 -1
- package/dist/styles/resets.css +0 -1
- package/dist/styles/search.css +0 -1
- package/dist/styles/sidebar.css +0 -1
- package/dist/styles/snippets.css +0 -1
- package/dist/styles/variables.css +0 -1
- package/package.json +2 -2
- package/src/components/overview.tsx +5 -7
- package/src/styles/main.css +10 -8
- package/src/utils.ts +7 -9
- package/dist/styles/main.js +0 -1
- package/dist/styles/primitives.js +0 -1
- package/dist/styles/resets.js +0 -1
- package/dist/styles/search.js +0 -1
- package/dist/styles/sidebar.js +0 -1
- package/dist/styles/snippets.js +0 -1
- package/dist/styles/variables.js +0 -1
package/dist/routing.js
CHANGED
|
@@ -1,3 +1,180 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
// src/routing.ts
|
|
2
|
+
var Languages = [
|
|
3
|
+
"http",
|
|
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
|
+
};
|
package/dist/styles/main.css
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* Overview page content */
|
|
2
2
|
.stldocs-root .stldocs-overview {
|
|
3
3
|
.stldocs-overview-header {
|
|
4
|
-
padding: var(--stldocs-title-padding-y)
|
|
4
|
+
padding: var(--stldocs-title-padding-y) 0;
|
|
5
5
|
|
|
6
6
|
& > * {
|
|
7
7
|
max-width: var(--stldocs-content-width);
|
|
@@ -27,7 +27,6 @@
|
|
|
27
27
|
|
|
28
28
|
.stldocs-resource-content {
|
|
29
29
|
max-width: var(--stldocs-content-width);
|
|
30
|
-
padding: 0 calc(var(--stldocs-content-padding));
|
|
31
30
|
margin: auto 0;
|
|
32
31
|
}
|
|
33
32
|
|
|
@@ -534,7 +533,7 @@
|
|
|
534
533
|
gap: 2rem;
|
|
535
534
|
grid-template-columns: minmax(0, 1fr);
|
|
536
535
|
grid-template-rows: repeat(4, auto);
|
|
537
|
-
padding: var(--stldocs-content-padding) 0
|
|
536
|
+
padding: var(--stldocs-content-padding) 0;
|
|
538
537
|
|
|
539
538
|
.stldocs-method-description p {
|
|
540
539
|
color: var(--stldocs-color-text-secondary);
|
|
@@ -874,11 +873,6 @@ starlight-theme-select select {
|
|
|
874
873
|
@media (max-width: 50rem) {
|
|
875
874
|
.stldocs-root .stldocs-method-body {
|
|
876
875
|
padding: 1rem var(--stldocs-content-padding) !important;
|
|
877
|
-
|
|
878
|
-
.stldocs-method-parameters,
|
|
879
|
-
.stldocs-method-returns {
|
|
880
|
-
margin-left: 0 !important;
|
|
881
|
-
}
|
|
882
876
|
}
|
|
883
877
|
|
|
884
878
|
.stldocs-root .stldocs-resource .stldocs-resource-content {
|
|
@@ -899,6 +893,14 @@ starlight-theme-select select {
|
|
|
899
893
|
}
|
|
900
894
|
}
|
|
901
895
|
|
|
896
|
+
@media (min-width: 50rem) {
|
|
897
|
+
.stldocs-root .stldocs-method {
|
|
898
|
+
.stldocs-method-header {
|
|
899
|
+
padding: var(--stldocs-title-padding-y) 0;
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
|
|
902
904
|
@media (min-width: 1280px) {
|
|
903
905
|
.stldocs-root {
|
|
904
906
|
.stldocs-method.stldocs-method-double-pane .stldocs-method-content-column {
|
|
@@ -984,4 +986,3 @@ starlight-theme-select select {
|
|
|
984
986
|
}
|
|
985
987
|
}
|
|
986
988
|
}
|
|
987
|
-
|
package/dist/styles/resets.css
CHANGED
package/dist/styles/search.css
CHANGED
package/dist/styles/sidebar.css
CHANGED
package/dist/styles/snippets.css
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stainless-api/docs-ui",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.1.0-beta.
|
|
4
|
+
"version": "0.1.0-beta.13",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"lucide-react": "^0.544.0",
|
|
21
21
|
"react": "^19.2.0",
|
|
22
22
|
"react-dom": "^19.2.0",
|
|
23
|
-
"@stainless-api/ui-primitives": "0.1.0-beta.
|
|
23
|
+
"@stainless-api/ui-primitives": "0.1.0-beta.14"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@types/node": "^24.4.0",
|
|
@@ -89,13 +89,11 @@ export function SDKResource({ resource, parents, showModels }: SDKResourceProps
|
|
|
89
89
|
<Docs.SDKResourceHeader resource={resource} parents={parents} />
|
|
90
90
|
{methods.length > 0 && (
|
|
91
91
|
<div className={style.ResourceContentGroup}>
|
|
92
|
-
{methods
|
|
93
|
-
.
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
</div>
|
|
98
|
-
))}
|
|
92
|
+
{methods.map((method) => (
|
|
93
|
+
<div className={style.MethodSummary} key={method.stainlessPath}>
|
|
94
|
+
<Docs.SDKMethodSummary method={method} />
|
|
95
|
+
</div>
|
|
96
|
+
))}
|
|
99
97
|
</div>
|
|
100
98
|
)}
|
|
101
99
|
|
package/src/styles/main.css
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* Overview page content */
|
|
2
2
|
.stldocs-root .stldocs-overview {
|
|
3
3
|
.stldocs-overview-header {
|
|
4
|
-
padding: var(--stldocs-title-padding-y)
|
|
4
|
+
padding: var(--stldocs-title-padding-y) 0;
|
|
5
5
|
|
|
6
6
|
& > * {
|
|
7
7
|
max-width: var(--stldocs-content-width);
|
|
@@ -27,7 +27,6 @@
|
|
|
27
27
|
|
|
28
28
|
.stldocs-resource-content {
|
|
29
29
|
max-width: var(--stldocs-content-width);
|
|
30
|
-
padding: 0 calc(var(--stldocs-content-padding));
|
|
31
30
|
margin: auto 0;
|
|
32
31
|
}
|
|
33
32
|
|
|
@@ -534,7 +533,7 @@
|
|
|
534
533
|
gap: 2rem;
|
|
535
534
|
grid-template-columns: minmax(0, 1fr);
|
|
536
535
|
grid-template-rows: repeat(4, auto);
|
|
537
|
-
padding: var(--stldocs-content-padding) 0
|
|
536
|
+
padding: var(--stldocs-content-padding) 0;
|
|
538
537
|
|
|
539
538
|
.stldocs-method-description p {
|
|
540
539
|
color: var(--stldocs-color-text-secondary);
|
|
@@ -874,11 +873,6 @@ starlight-theme-select select {
|
|
|
874
873
|
@media (max-width: 50rem) {
|
|
875
874
|
.stldocs-root .stldocs-method-body {
|
|
876
875
|
padding: 1rem var(--stldocs-content-padding) !important;
|
|
877
|
-
|
|
878
|
-
.stldocs-method-parameters,
|
|
879
|
-
.stldocs-method-returns {
|
|
880
|
-
margin-left: 0 !important;
|
|
881
|
-
}
|
|
882
876
|
}
|
|
883
877
|
|
|
884
878
|
.stldocs-root .stldocs-resource .stldocs-resource-content {
|
|
@@ -899,6 +893,14 @@ starlight-theme-select select {
|
|
|
899
893
|
}
|
|
900
894
|
}
|
|
901
895
|
|
|
896
|
+
@media (min-width: 50rem) {
|
|
897
|
+
.stldocs-root .stldocs-method {
|
|
898
|
+
.stldocs-method-header {
|
|
899
|
+
padding: var(--stldocs-title-padding-y) 0;
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
|
|
902
904
|
@media (min-width: 1280px) {
|
|
903
905
|
.stldocs-root {
|
|
904
906
|
.stldocs-method.stldocs-method-double-pane .stldocs-method-content-column {
|
package/src/utils.ts
CHANGED
|
@@ -5,15 +5,13 @@ export function flatResources(
|
|
|
5
5
|
resources: Record<string, SDKJSON.Resource>,
|
|
6
6
|
parents: SDKJSON.Resource[],
|
|
7
7
|
): { resource: SDKJSON.Resource; parents: SDKJSON.Resource[] }[] {
|
|
8
|
-
return Object.keys(resources)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
];
|
|
16
|
-
});
|
|
8
|
+
return Object.keys(resources).flatMap((key: string | number) => {
|
|
9
|
+
const resource = resources[key]!;
|
|
10
|
+
return [
|
|
11
|
+
{ resource, parents },
|
|
12
|
+
...(resource.subresources ? flatResources(resource.subresources, [...parents, resource]) : []),
|
|
13
|
+
];
|
|
14
|
+
});
|
|
17
15
|
}
|
|
18
16
|
|
|
19
17
|
export function getResourceFromSpec(
|
package/dist/styles/main.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { };
|
package/dist/styles/resets.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { };
|
package/dist/styles/search.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { };
|
package/dist/styles/sidebar.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { };
|
package/dist/styles/snippets.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { };
|
package/dist/styles/variables.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { };
|