@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,164 @@
|
|
|
1
|
+
import { a as useLanguage, c as useSnippet, r as useDeclaration } from "./docs-Di94viZV.js";
|
|
2
|
+
import { r as useHighlight } from "./markdown-D2JWyRws.js";
|
|
3
|
+
import { t as useComponents } from "./use-components-BUz3GbO4.js";
|
|
4
|
+
import { t as style_default } from "./style-LwfvXElj.js";
|
|
5
|
+
import * as React$1 from "react";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import clsx from "clsx";
|
|
8
|
+
import { CheckIcon, CircleAlertIcon, CopyIcon } from "lucide-react";
|
|
9
|
+
import { Badge, Button, getHttpMethod } from "@stainless-api/ui-primitives";
|
|
10
|
+
|
|
11
|
+
//#region src/components/snippets.tsx
|
|
12
|
+
function SnippetCode({ content, language }) {
|
|
13
|
+
const lang = useLanguage();
|
|
14
|
+
const highlighted = useHighlight(content, language || lang);
|
|
15
|
+
return /* @__PURE__ */ jsx("div", {
|
|
16
|
+
className: style_default.SnippetCode,
|
|
17
|
+
"data-stldocs-copy-content": true,
|
|
18
|
+
dangerouslySetInnerHTML: { __html: highlighted }
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
function SnippetContainer({ children }) {
|
|
22
|
+
return /* @__PURE__ */ jsx("div", {
|
|
23
|
+
className: clsx(style_default.Snippet),
|
|
24
|
+
children
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
function SnippetRequestContainer({ children }) {
|
|
28
|
+
return /* @__PURE__ */ jsx("div", { children });
|
|
29
|
+
}
|
|
30
|
+
function Snippet({ requestTitle, method, transformRequestSnippet }) {
|
|
31
|
+
const Docs = useComponents();
|
|
32
|
+
const language = useLanguage();
|
|
33
|
+
const originalSnippet = useSnippet(method.stainlessPath, void 0, language === "http" ? "curl" : "default");
|
|
34
|
+
const decl = useDeclaration(method.stainlessPath, false);
|
|
35
|
+
if (!originalSnippet) {
|
|
36
|
+
console.warn(`Snippet not found for method '${method.stainlessPath}'`);
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
const signature = decl && "qualified" in decl ? decl.qualified : void 0;
|
|
40
|
+
const responses = method.exampleResponses;
|
|
41
|
+
const snippet = transformRequestSnippet ? transformRequestSnippet({
|
|
42
|
+
snippet: originalSnippet,
|
|
43
|
+
language
|
|
44
|
+
}) : originalSnippet;
|
|
45
|
+
const httpMethod = getHttpMethod(method.httpMethod);
|
|
46
|
+
return /* @__PURE__ */ jsxs(Docs.SnippetContainer, {
|
|
47
|
+
signature,
|
|
48
|
+
method,
|
|
49
|
+
children: [snippet && /* @__PURE__ */ jsx(Docs.SnippetRequestContainer, {
|
|
50
|
+
signature,
|
|
51
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
52
|
+
className: style_default.SnippetRequest,
|
|
53
|
+
"data-stldocs-copy-parent": true,
|
|
54
|
+
children: [
|
|
55
|
+
/* @__PURE__ */ jsxs("div", {
|
|
56
|
+
className: style_default.SnippetRequestTitle,
|
|
57
|
+
children: [
|
|
58
|
+
/* @__PURE__ */ jsxs("div", {
|
|
59
|
+
className: style_default.SnippetRequestTitleMethod,
|
|
60
|
+
children: [httpMethod && /* @__PURE__ */ jsx(Badge.HTTP, {
|
|
61
|
+
method: httpMethod,
|
|
62
|
+
iconOnly: true
|
|
63
|
+
}), /* @__PURE__ */ jsx("h3", { children: method.summary ?? method.title })]
|
|
64
|
+
}),
|
|
65
|
+
/* @__PURE__ */ jsx("div", {
|
|
66
|
+
className: style_default.SnippetRequestTitleContent,
|
|
67
|
+
children: requestTitle
|
|
68
|
+
}),
|
|
69
|
+
/* @__PURE__ */ jsx(Docs.SnippetButtons, { content: snippet })
|
|
70
|
+
]
|
|
71
|
+
}),
|
|
72
|
+
/* @__PURE__ */ jsx(Docs.SnippetCode, {
|
|
73
|
+
content: snippet,
|
|
74
|
+
signature
|
|
75
|
+
}),
|
|
76
|
+
/* @__PURE__ */ jsx(Docs.SnippetFooter, {})
|
|
77
|
+
]
|
|
78
|
+
})
|
|
79
|
+
}), responses && /* @__PURE__ */ jsx(Docs.SnippetResponse, { responses })]
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
function SnippetButtons({ content }) {
|
|
83
|
+
const [CopyButtonIcon, setCopyIcon] = React$1.useState(CopyIcon);
|
|
84
|
+
async function handleCopy() {
|
|
85
|
+
try {
|
|
86
|
+
await navigator.clipboard.writeText(content);
|
|
87
|
+
setCopyIcon(CheckIcon);
|
|
88
|
+
} catch {
|
|
89
|
+
setCopyIcon(CircleAlertIcon);
|
|
90
|
+
}
|
|
91
|
+
setTimeout(() => setCopyIcon(CopyIcon), 1e3);
|
|
92
|
+
}
|
|
93
|
+
return /* @__PURE__ */ jsx(Button, {
|
|
94
|
+
variant: "outline",
|
|
95
|
+
"data-stldocs-snippet-copy": true,
|
|
96
|
+
children: /* @__PURE__ */ jsx(CopyButtonIcon, {
|
|
97
|
+
size: 16,
|
|
98
|
+
className: style_default.Icon,
|
|
99
|
+
onClick: handleCopy
|
|
100
|
+
})
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
function SnippetFooter() {
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
function SnippetResponse({ responses }) {
|
|
107
|
+
const { SnippetCode } = useComponents();
|
|
108
|
+
if (!responses) return null;
|
|
109
|
+
const mappedResponses = Object.keys(responses).map((key) => {
|
|
110
|
+
const responseContent = responses[key];
|
|
111
|
+
if (!responseContent) return null;
|
|
112
|
+
const responseType = Object.keys(responseContent)[0];
|
|
113
|
+
if (!responseType) return null;
|
|
114
|
+
const response = responseContent[responseType];
|
|
115
|
+
if (!response) return null;
|
|
116
|
+
const examples = response?.examples;
|
|
117
|
+
if (!examples) return null;
|
|
118
|
+
const exampleType = Object.keys(examples)[0];
|
|
119
|
+
if (!exampleType) return null;
|
|
120
|
+
let value = examples[exampleType]?.value;
|
|
121
|
+
if (!value) return null;
|
|
122
|
+
let language = "none";
|
|
123
|
+
if (responseType === "application/json" || typeof value === "object") {
|
|
124
|
+
language = "json";
|
|
125
|
+
value = JSON.stringify(value, null, 2);
|
|
126
|
+
}
|
|
127
|
+
return {
|
|
128
|
+
language,
|
|
129
|
+
responseCode: key,
|
|
130
|
+
content: value
|
|
131
|
+
};
|
|
132
|
+
}).filter(Boolean);
|
|
133
|
+
if (mappedResponses.length === 0) return null;
|
|
134
|
+
return /* @__PURE__ */ jsx("div", {
|
|
135
|
+
className: style_default.SnippetMultiResponse,
|
|
136
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
137
|
+
className: clsx(style_default.Snippet),
|
|
138
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
139
|
+
className: clsx(style_default.SnippetResponseTab, mappedResponses.length === 1 && style_default.SnippetResponseTabSingleReturn),
|
|
140
|
+
children: mappedResponses.map(({ responseCode }, index) => /* @__PURE__ */ jsx("div", {
|
|
141
|
+
"data-snippet-response-tab-id": `snippet-response-tab-${responseCode}-${index}`,
|
|
142
|
+
className: clsx(style_default.SnippetResponseTabItem, index === 0 && style_default.SnippetResponseTabItemActive),
|
|
143
|
+
children: /* @__PURE__ */ jsxs(Button, {
|
|
144
|
+
disabled: mappedResponses.length === 1,
|
|
145
|
+
variant: "ghost",
|
|
146
|
+
children: [responseCode, " example"]
|
|
147
|
+
})
|
|
148
|
+
}, `snippet-response-tab-item-${responseCode}-${index}`))
|
|
149
|
+
}), mappedResponses.map(({ responseCode, content, language }, index) => {
|
|
150
|
+
return /* @__PURE__ */ jsx("div", {
|
|
151
|
+
className: clsx(style_default.SnippetResponsePane, index === 0 && style_default.SnippetResponsePaneActive),
|
|
152
|
+
"data-snippet-response-pane-id": `snippet-response-tab-${responseCode}-${index}`,
|
|
153
|
+
children: /* @__PURE__ */ jsx(SnippetCode, {
|
|
154
|
+
content,
|
|
155
|
+
language
|
|
156
|
+
})
|
|
157
|
+
}, `snippet-response-${responseCode}-${index}`);
|
|
158
|
+
})]
|
|
159
|
+
})
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
//#endregion
|
|
164
|
+
export { SnippetFooter as a, SnippetContainer as i, SnippetButtons as n, SnippetRequestContainer as o, SnippetCode as r, SnippetResponse as s, Snippet as t };
|
package/dist/spec.d.ts
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { f as Resource, g as SpecLanguage, h as Spec, l as Method, r as DeclarationNode, u as Model } from "./index-zNpvNvtN.js";
|
|
2
|
+
import { t as DocsLanguage } from "./routing-CtbZJru_.js";
|
|
3
|
+
|
|
4
|
+
//#region src/spec.d.ts
|
|
5
|
+
type SecurityScheme = Spec['security_schemes'][number];
|
|
6
|
+
interface SpecTransforms {
|
|
7
|
+
resource(resource: Resource): Resource;
|
|
8
|
+
method(method: Method): Method;
|
|
9
|
+
model(model: Model): Model;
|
|
10
|
+
declaration(decl: DeclarationNode, language: SpecLanguage): DeclarationNode;
|
|
11
|
+
securityScheme(scheme: SecurityScheme): SecurityScheme;
|
|
12
|
+
snippet(snippet: string, language: string): string;
|
|
13
|
+
markdown(content?: string): string | undefined;
|
|
14
|
+
}
|
|
15
|
+
declare function defineTransforms(transforms?: Partial<SpecTransforms>): {
|
|
16
|
+
resource: (resource: Resource) => Resource;
|
|
17
|
+
method: (method: Method) => Method;
|
|
18
|
+
model: (model: Model) => Model;
|
|
19
|
+
declaration: (decl: DeclarationNode, language: SpecLanguage) => DeclarationNode;
|
|
20
|
+
securityScheme: (scheme: SecurityScheme) => SecurityScheme;
|
|
21
|
+
snippet: (snippet: string, language: string) => string;
|
|
22
|
+
markdown: (content?: string) => string | undefined;
|
|
23
|
+
};
|
|
24
|
+
declare function generateNavigation(resource: Partial<Resource>): {
|
|
25
|
+
title: string | undefined;
|
|
26
|
+
name: string | undefined;
|
|
27
|
+
subresources: Record<string, Partial<Resource>> | undefined;
|
|
28
|
+
methods: Record<string, Partial<Method>> | undefined;
|
|
29
|
+
models: Record<string, Partial<Model>> | undefined;
|
|
30
|
+
stainlessPath: string | undefined;
|
|
31
|
+
terraform: {
|
|
32
|
+
Name: string;
|
|
33
|
+
QualifiedName: string;
|
|
34
|
+
} | undefined;
|
|
35
|
+
};
|
|
36
|
+
declare function generateSpecForResource(spec: Spec, name: string, lang: DocsLanguage, transforms: SpecTransforms): Partial<Spec>;
|
|
37
|
+
declare function transform(spec: Spec, transforms: SpecTransforms): {
|
|
38
|
+
name: string;
|
|
39
|
+
lang: "cli" | "csharp" | "go" | "http" | "java" | "kotlin" | "node" | "php" | "python" | "ruby" | "terraform" | "typescript";
|
|
40
|
+
spec: Partial<Spec>;
|
|
41
|
+
}[];
|
|
42
|
+
declare function split(spec: Spec, transforms?: SpecTransforms): {
|
|
43
|
+
resources: ReturnType<typeof transform>;
|
|
44
|
+
navigation: {
|
|
45
|
+
languages: ("go" | "http" | "java" | "kotlin" | "node" | "python" | "ruby" | "terraform" | "typescript")[] | undefined;
|
|
46
|
+
resources: {
|
|
47
|
+
[k: string]: {
|
|
48
|
+
title: string | undefined;
|
|
49
|
+
name: string | undefined;
|
|
50
|
+
subresources: Record<string, Partial<Resource>> | undefined;
|
|
51
|
+
methods: Record<string, Partial<Method>> | undefined;
|
|
52
|
+
models: Record<string, Partial<Model>> | undefined;
|
|
53
|
+
stainlessPath: string | undefined;
|
|
54
|
+
terraform: {
|
|
55
|
+
Name: string;
|
|
56
|
+
QualifiedName: string;
|
|
57
|
+
} | undefined;
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
declare function parseSpec(content: string): Spec | undefined;
|
|
63
|
+
declare function retrieve(apiKey: string, project: string, revision: string): Promise<Spec | undefined>;
|
|
64
|
+
//#endregion
|
|
65
|
+
export { SecurityScheme, SpecTransforms, defineTransforms, generateNavigation, generateSpecForResource, parseSpec, retrieve, split, transform };
|
package/dist/spec.js
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { n as Languages } from "./routing-Ce0_tBW6.js";
|
|
2
|
+
import { r as isResourceEmpty } from "./utils-D01mAUfQ.js";
|
|
3
|
+
|
|
4
|
+
//#region src/spec.ts
|
|
5
|
+
const defaultTransforms = {
|
|
6
|
+
resource: (resource) => resource,
|
|
7
|
+
method: (method) => method,
|
|
8
|
+
model: (model) => model,
|
|
9
|
+
declaration: (decl) => decl,
|
|
10
|
+
securityScheme: (scheme) => scheme,
|
|
11
|
+
snippet: (snippet) => snippet,
|
|
12
|
+
markdown: (content) => content
|
|
13
|
+
};
|
|
14
|
+
function defineTransforms(transforms = {}) {
|
|
15
|
+
return {
|
|
16
|
+
...defaultTransforms,
|
|
17
|
+
...transforms
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function removeStudioRefs(obj) {
|
|
21
|
+
if (typeof obj !== "object" || obj === null) return obj;
|
|
22
|
+
if (Array.isArray(obj)) return obj.map(removeStudioRefs);
|
|
23
|
+
const newObj = {};
|
|
24
|
+
for (const [key, value] of Object.entries(obj)) if (key !== "oasRef" && key !== "configRef") newObj[key] = removeStudioRefs(value);
|
|
25
|
+
return newObj;
|
|
26
|
+
}
|
|
27
|
+
function mapEntries({ input, fn, filter }) {
|
|
28
|
+
if (!input) return;
|
|
29
|
+
const output = {};
|
|
30
|
+
for (const [name, entry] of Object.entries(input)) {
|
|
31
|
+
if (filter && !filter(name, entry)) continue;
|
|
32
|
+
output[name] = fn ? fn(entry) : entry;
|
|
33
|
+
}
|
|
34
|
+
return output;
|
|
35
|
+
}
|
|
36
|
+
function transformRecursively(resource, transforms) {
|
|
37
|
+
return {
|
|
38
|
+
...transforms.resource(resource),
|
|
39
|
+
methods: mapEntries({
|
|
40
|
+
input: resource.methods,
|
|
41
|
+
fn: (method) => transforms.method(method)
|
|
42
|
+
}) ?? {},
|
|
43
|
+
models: mapEntries({
|
|
44
|
+
input: resource.models,
|
|
45
|
+
fn: (model) => transforms.model(model)
|
|
46
|
+
}) ?? {},
|
|
47
|
+
subresources: mapEntries({
|
|
48
|
+
input: resource.subresources,
|
|
49
|
+
fn: (sub) => transformRecursively(sub, transforms)
|
|
50
|
+
}) ?? {}
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function generateNavigation(resource) {
|
|
54
|
+
const { title, name, stainlessPath, terraform } = resource;
|
|
55
|
+
return {
|
|
56
|
+
title,
|
|
57
|
+
name,
|
|
58
|
+
subresources: mapEntries({
|
|
59
|
+
input: resource.subresources,
|
|
60
|
+
fn: generateNavigation
|
|
61
|
+
}),
|
|
62
|
+
methods: mapEntries({
|
|
63
|
+
input: resource.methods,
|
|
64
|
+
fn: (method) => ({
|
|
65
|
+
name: method.name,
|
|
66
|
+
stainlessPath: method.stainlessPath,
|
|
67
|
+
summary: method.summary,
|
|
68
|
+
httpMethod: method.httpMethod
|
|
69
|
+
})
|
|
70
|
+
}),
|
|
71
|
+
models: mapEntries({
|
|
72
|
+
input: resource.models,
|
|
73
|
+
fn: (model) => ({
|
|
74
|
+
name: model.name,
|
|
75
|
+
stainlessPath: model.stainlessPath
|
|
76
|
+
})
|
|
77
|
+
}),
|
|
78
|
+
stainlessPath,
|
|
79
|
+
terraform
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
function generateSpecForResource(spec, name, lang, transforms) {
|
|
83
|
+
const resource = spec.resources[name];
|
|
84
|
+
if (!resource) throw new Error(`Invalid resource: ${name}`);
|
|
85
|
+
return {
|
|
86
|
+
resources: {
|
|
87
|
+
[name]: transformRecursively(resource, transforms),
|
|
88
|
+
...spec.resources["$shared"] ? { $shared: transformRecursively(spec.resources["$shared"], transforms) } : {}
|
|
89
|
+
},
|
|
90
|
+
security_schemes: spec.security_schemes?.map((scheme) => transforms.securityScheme(scheme)),
|
|
91
|
+
decls: { [lang]: mapEntries({
|
|
92
|
+
input: spec.decls[lang] ?? {},
|
|
93
|
+
filter: (name) => name.startsWith(resource.stainlessPath) || name.startsWith("(resource) $shared"),
|
|
94
|
+
fn: (decl) => transforms.declaration(decl, lang)
|
|
95
|
+
}) },
|
|
96
|
+
snippets: mapEntries({
|
|
97
|
+
input: spec.snippets,
|
|
98
|
+
filter: (name) => name.startsWith(lang),
|
|
99
|
+
fn: (snippets) => mapEntries({
|
|
100
|
+
input: snippets,
|
|
101
|
+
filter: (name) => name.startsWith(resource.stainlessPath),
|
|
102
|
+
fn: (snippet) => transforms.snippet(snippet, lang)
|
|
103
|
+
}) ?? {}
|
|
104
|
+
})
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
function transform(spec, transforms) {
|
|
108
|
+
const t = {
|
|
109
|
+
...transforms,
|
|
110
|
+
declaration: (decl, lang) => transforms.declaration({
|
|
111
|
+
...decl,
|
|
112
|
+
..."docstring" in decl ? { docstring: transforms.markdown(decl.docstring) } : {}
|
|
113
|
+
}, lang),
|
|
114
|
+
method: (method) => transforms.method({
|
|
115
|
+
...method,
|
|
116
|
+
description: transforms.markdown(method.description),
|
|
117
|
+
deprecated: typeof method.deprecated === "string" ? transforms.markdown(method.deprecated) : method.deprecated
|
|
118
|
+
}),
|
|
119
|
+
securityScheme: (scheme) => transforms.securityScheme({
|
|
120
|
+
...scheme,
|
|
121
|
+
description: transforms.markdown(scheme.description)
|
|
122
|
+
})
|
|
123
|
+
};
|
|
124
|
+
const output = [];
|
|
125
|
+
for (const lang of Languages) for (const [name, resource] of Object.entries(spec.resources)) {
|
|
126
|
+
if (isResourceEmpty(resource)) continue;
|
|
127
|
+
output.push({
|
|
128
|
+
name,
|
|
129
|
+
lang,
|
|
130
|
+
spec: generateSpecForResource(spec, name, lang, t)
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
return output;
|
|
134
|
+
}
|
|
135
|
+
function split(spec, transforms) {
|
|
136
|
+
return {
|
|
137
|
+
resources: transform(spec, transforms ?? defineTransforms()).map(removeStudioRefs),
|
|
138
|
+
navigation: {
|
|
139
|
+
languages: spec.docs?.languages,
|
|
140
|
+
resources: Object.fromEntries(Object.entries(spec.resources).filter(([, res]) => !isResourceEmpty(res)).map(([name, res]) => [name, generateNavigation(res)]))
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
function parseSpec(content) {
|
|
145
|
+
const parsed = JSON.parse(content);
|
|
146
|
+
if (parsed && typeof parsed === "object" && "kind" in parsed && parsed.kind === "spec") return parsed;
|
|
147
|
+
}
|
|
148
|
+
async function retrieve(apiKey, project, revision) {
|
|
149
|
+
const data = await (await fetch("https://app.stainless.com/api/generate/spec", {
|
|
150
|
+
method: "POST",
|
|
151
|
+
headers: {
|
|
152
|
+
Authorization: `Bearer ${apiKey}`,
|
|
153
|
+
"Content-Type": "application/json"
|
|
154
|
+
},
|
|
155
|
+
body: JSON.stringify({
|
|
156
|
+
project,
|
|
157
|
+
source: {
|
|
158
|
+
type: "git",
|
|
159
|
+
revision
|
|
160
|
+
}
|
|
161
|
+
})
|
|
162
|
+
})).json();
|
|
163
|
+
if (typeof data.spec === "string") return parseSpec(data.spec);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
//#endregion
|
|
167
|
+
export { defineTransforms, generateNavigation, generateSpecForResource, parseSpec, retrieve, split, transform };
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
//#region src/style.ts
|
|
2
|
+
var style_default = {
|
|
3
|
+
TextIdentifier: "stldocs-text-identifier",
|
|
4
|
+
TextOperator: "stldocs-text-operator",
|
|
5
|
+
TextPunctuation: "stldocs-text-punctuation",
|
|
6
|
+
TextKeyword: "stldocs-text-keyword",
|
|
7
|
+
ContentArea: "stldocs-content-area",
|
|
8
|
+
Markdown: "stldocs-markdown",
|
|
9
|
+
Content: "stldocs-content",
|
|
10
|
+
Truncation: "stldocs-truncation",
|
|
11
|
+
Expander: "stldocs-expander",
|
|
12
|
+
ExpanderContent: "stldocs-expander-content",
|
|
13
|
+
ExpanderSummary: "stldocs-expander-summary",
|
|
14
|
+
ExpanderSummaryIcon: "stldocs-expander-summary-icon",
|
|
15
|
+
ExpanderSummaryContent: "stldocs-expander-summary-content",
|
|
16
|
+
ExpanderIndent: "stldocs-expander-indent",
|
|
17
|
+
Badge: "stldocs-badge",
|
|
18
|
+
Icon: "stldocs-icon",
|
|
19
|
+
Tooltip: "stldocs-tooltip",
|
|
20
|
+
TooltipHost: "stldocs-tooltip-host",
|
|
21
|
+
TooltipContent: "stldocs-tooltip-content",
|
|
22
|
+
Input: "stldocs-input",
|
|
23
|
+
InputDisabled: "stldocs-input-disabled",
|
|
24
|
+
InputTextField: "stldocs-input-textfield",
|
|
25
|
+
MaskedInputWrapper: "stldocs-masked-input-wrapper",
|
|
26
|
+
MaskedInputDisplay: "stldocs-masked-input-display",
|
|
27
|
+
MaskedInputObscured: "stldocs-masked-input-obscured",
|
|
28
|
+
ToggleButton: "stldocs-togglebutton",
|
|
29
|
+
ListView: "stldocs-listview",
|
|
30
|
+
ListViewItem: "stldocs-listview-item",
|
|
31
|
+
ExpandToggle: "stldocs-expand-toggle",
|
|
32
|
+
ExpandToggleContent: "stldocs-expand-toggle-content",
|
|
33
|
+
LoadingSpinner: "stldocs-loading-spinner",
|
|
34
|
+
Type: "stldocs-type",
|
|
35
|
+
TypeName: "stldocs-typename",
|
|
36
|
+
TypeKeyword: "stldocs-type-keyword",
|
|
37
|
+
TypeString: "stldocs-type-string",
|
|
38
|
+
TypeArray: "stldocs-type-array",
|
|
39
|
+
TypeReference: "stldocs-type-reference",
|
|
40
|
+
TypeBracket: "stldocs-type-bracket",
|
|
41
|
+
TypeBrace: "stldocs-type-brace",
|
|
42
|
+
TypePropertyName: "stldocs-type-propertyname",
|
|
43
|
+
TypePlain: "stldocs-type-plain",
|
|
44
|
+
TypePreview: "stldocs-type-preview",
|
|
45
|
+
TypePreviewContent: "stldocs-type-preview-content",
|
|
46
|
+
LiteralString: "stldocs-literal-string",
|
|
47
|
+
LiteralNumeric: "stldocs-literal-numeric",
|
|
48
|
+
LiteralBoolean: "stldocs-literal-boolean",
|
|
49
|
+
Snippet: "stldocs-snippet",
|
|
50
|
+
SnippetCode: "stldocs-snippet-code",
|
|
51
|
+
SnippetFooter: "stldocs-snippet-footer",
|
|
52
|
+
SnippetRequest: "stldocs-snippet-request",
|
|
53
|
+
SnippetRequestTitle: "stldocs-snippet-request-title",
|
|
54
|
+
SnippetRequestTitleContent: "stldocs-snippet-request-title-content",
|
|
55
|
+
SnippetRequestTitleLabel: "stldocs-snippet-request-title-label",
|
|
56
|
+
SnippetRequestTitleLanguage: "stldocs-snippet-request-title-language",
|
|
57
|
+
SnippetRequestTitleMethod: "stldocs-snippet-request-title-method",
|
|
58
|
+
SnippetResponse: "stldocs-snippet-response",
|
|
59
|
+
SnippetMultiResponse: "stldocs-snippet-multi-response",
|
|
60
|
+
SnippetResponseOpen: "stldocs-snippet-response-opened",
|
|
61
|
+
SnippetResponseTab: "stldocs-snippet-response-tab",
|
|
62
|
+
SnippetResponseTabItem: "stldocs-snippet-response-tab-item",
|
|
63
|
+
SnippetResponseTabItemActive: "stldocs-snippet-response-tab-item-active",
|
|
64
|
+
SnippetResponseTabSingleReturn: "stldocs-snippet-response-tab-single-return",
|
|
65
|
+
SnippetResponsePane: "stldocs-snippet-response-pane",
|
|
66
|
+
SnippetResponsePaneActive: "stldocs-snippet-response-pane-active",
|
|
67
|
+
Method: "stldocs-method",
|
|
68
|
+
MethodHeader: "stldocs-method-header",
|
|
69
|
+
MethodBody: "stldocs-method-body",
|
|
70
|
+
MethodInfo: "stldocs-method-info",
|
|
71
|
+
MethodInfoSection: "stldocs-method-info-section",
|
|
72
|
+
MethodExample: "stldocs-method-example",
|
|
73
|
+
MethodResponseColumn: "stldocs-method-response-column",
|
|
74
|
+
MethodTitle: "stldocs-method-title",
|
|
75
|
+
MethodBadges: "stldocs-method-badges",
|
|
76
|
+
MethodSignature: "stldocs-method-signature",
|
|
77
|
+
MethodDescription: "stldocs-method-description",
|
|
78
|
+
MethodParameters: "stldocs-method-parameters",
|
|
79
|
+
MethodReturns: "stldocs-method-returns",
|
|
80
|
+
MethodContent: "stldocs-method-content",
|
|
81
|
+
MethodContentColumn: "stldocs-method-content-column",
|
|
82
|
+
MethodRouteEndpoint: "stldocs-method-route-endpoint",
|
|
83
|
+
MethodRoute: "stldocs-method-route",
|
|
84
|
+
MethodSummary: "stldocs-method-summary",
|
|
85
|
+
MethodSinglePane: "stldocs-method-single-pane",
|
|
86
|
+
MethodDoublePane: "stldocs-method-double-pane",
|
|
87
|
+
SignatureTitle: "stldocs-signature-title",
|
|
88
|
+
SignatureName: "stldocs-signature-name",
|
|
89
|
+
SignatureQualified: "stldocs-signature-qualified",
|
|
90
|
+
SignatureParams: "stldoc-signature-params",
|
|
91
|
+
SignatureParen: "stldocs-signature-paren",
|
|
92
|
+
SignatureReturns: "stldocs-signature-returns",
|
|
93
|
+
Property: "stldocs-property",
|
|
94
|
+
Properties: "stldocs-properties",
|
|
95
|
+
PropertyHeader: "stldocs-property-header",
|
|
96
|
+
PropertyInfo: "stldocs-property-info",
|
|
97
|
+
PropertyDeclaration: "stldocs-property-declaration",
|
|
98
|
+
PropertyDeprecated: "stldocs-property-deprecated",
|
|
99
|
+
PropertyDeprecatedMessage: "stldocs-property-deprecated-message",
|
|
100
|
+
PropertyContent: "stldocs-property-content",
|
|
101
|
+
PropertyChildren: "stldocs-property-children",
|
|
102
|
+
PropertyConstraints: "stldocs-property-constraints",
|
|
103
|
+
PropertyConstraint: "stldocs-property-constraint",
|
|
104
|
+
PropertyConstraintName: "stldocs-property-constraint-name",
|
|
105
|
+
PropertyConstraintValue: "stldocs-property-constraint-value",
|
|
106
|
+
PropertyDefault: "stldocs-property-default",
|
|
107
|
+
PropertyDescription: "stldocs-property-description",
|
|
108
|
+
PropertyTitle: "stldocs-property-title",
|
|
109
|
+
PropertyAnnotation: "stldocs-property-annotation",
|
|
110
|
+
PropertyName: "stldocs-property-name",
|
|
111
|
+
PropertyBadges: "stldocs-property-badges",
|
|
112
|
+
PropertyTypeName: "stldocs-property-typename",
|
|
113
|
+
PropertyType: "stldocs-property-type",
|
|
114
|
+
Overview: "stldocs-overview",
|
|
115
|
+
OverviewHeader: "stldocs-overview-header",
|
|
116
|
+
OverviewHeaderInfo: "stldocs-overview-header-info",
|
|
117
|
+
OverviewHeaderInfoTimestamp: "stldocs-overview-header-info-timestamp",
|
|
118
|
+
Resource: "stldocs-resource",
|
|
119
|
+
ResourceContent: "stldocs-resource-content",
|
|
120
|
+
ResourceContentProperties: "stldocs-resource-content-properties",
|
|
121
|
+
ResourceContentGroup: "stldocs-resource-content-group",
|
|
122
|
+
ResourceContentGroupName: "stldocs-resource-content-group-name",
|
|
123
|
+
ResourceContentGroupModelTitle: "stldocs-resource-content-group-model-title",
|
|
124
|
+
ResourceHeader: "stldocs-resource-header",
|
|
125
|
+
ResourceTitle: "stldocs-resource-title",
|
|
126
|
+
ResourceTitleSegment: "stldocs-resource-title-segment",
|
|
127
|
+
ResourceDescription: "stldocs-resource-description",
|
|
128
|
+
ResourceName: "stldocs-resource-name",
|
|
129
|
+
Model: "stldocs-model",
|
|
130
|
+
Root: "stldocs-root",
|
|
131
|
+
Sidebar: "stldocs-sidebar",
|
|
132
|
+
SidebarResource: "stldocs-sidebar-resource",
|
|
133
|
+
SidebarResourceTitle: "stldocs-sidebar-resource-title",
|
|
134
|
+
SidebarMethod: "stldocs-sidebar-method",
|
|
135
|
+
SidebarItemTitle: "stldocs-sidebar-resource-title",
|
|
136
|
+
SidebarExpander: "stldocs-sidebar-expander",
|
|
137
|
+
SidebarExpanderSummary: "stldocs-sidebar-expander-summary",
|
|
138
|
+
SidebarExpanderContent: "stldocs-sidebar-expander-content",
|
|
139
|
+
SearchForm: "stldocs-search-form",
|
|
140
|
+
SearchModal: "stldocs-search-modal",
|
|
141
|
+
SearchFilter: "stldocs-search-filter",
|
|
142
|
+
SearchFilterLabel: "stldocs-search-filter-label",
|
|
143
|
+
SearchFilterCount: "stldocs-search-filter-count",
|
|
144
|
+
SearchBreadcrumb: "stldocs-search-breadcrumb",
|
|
145
|
+
SearchBreadcrumbItem: "stldocs-search-breadcrumb-item",
|
|
146
|
+
SearchBreadcrumbDivider: "stldocs-search-breadcrumb-divider",
|
|
147
|
+
SearchResult: "stldocs-search-result",
|
|
148
|
+
SearchResultResourceInfo: "stldocs-search-result-resource-info",
|
|
149
|
+
SearchResultResourceTitle: "stldocs-search-result-resource-title",
|
|
150
|
+
SearchResultResourcePath: "stldocs-search-result-resource-path",
|
|
151
|
+
SearchResultGuideTitle: "stldocs-search-result-guide-title",
|
|
152
|
+
SearchResultGuideExcerpt: "stldocs-search-result-guide-excerpt",
|
|
153
|
+
SearchDisabledStateContainer: "stldocs-search-disabled-state-container",
|
|
154
|
+
SearchModalCloseButton: "stldocs-search-modal-close-button",
|
|
155
|
+
LanguageBlock: "stldocs-language-block",
|
|
156
|
+
LanguageBlockContent: "stldocs-language-block-content",
|
|
157
|
+
LanguageBlockContentIcon: "stldocs-language-block-content-icon",
|
|
158
|
+
LanguageBlockContentInfo: "stldocs-language-block-content-info",
|
|
159
|
+
LanguageBlockContentInfoLanguage: "stldocs-language-block-content-info-language",
|
|
160
|
+
LanguageBlockContentInfoVersion: "stldocs-language-block-content-info-version",
|
|
161
|
+
LanguageBlockLinks: "stldocs-language-block-links",
|
|
162
|
+
LanguageBlockInstall: "stldocs-language-block-install",
|
|
163
|
+
Breadcrumbs: "stldocs-breadcrumbs",
|
|
164
|
+
BreadcrumbsItem: "stldocs-breadcrumbs-item",
|
|
165
|
+
BreadcrumbsLink: "stldocs-breadcrumbs-link",
|
|
166
|
+
BreadcrumbsNonLink: "stldocs-breadcrumbs-non-link"
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
//#endregion
|
|
170
|
+
export { style_default as t };
|