@stainless-api/docs-ui 0.1.0-beta.73 → 0.1.0-beta.75
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/{chunk-BN_g-Awi.js → chunk-BYypO7fO.js} +3 -3
- package/dist/components/MaskedInput.d.ts +3 -3
- package/dist/components/MaskedInput.js +1 -1
- package/dist/components/breadcrumbs.d.ts +24 -1
- package/dist/components/breadcrumbs.js +62 -7
- package/dist/components/icons.d.ts +18 -13
- package/dist/components/icons.js +940 -2
- package/dist/components/index.d.ts +16 -14
- package/dist/components/index.js +72 -18
- package/dist/components/method.d.ts +58 -1
- package/dist/components/method.js +95 -8
- package/dist/components/overview.d.ts +38 -1
- package/dist/components/overview.js +137 -9
- package/dist/components/primitives.d.ts +104 -1
- package/dist/components/primitives.js +250 -6
- package/dist/components/properties.d.ts +53 -1
- package/dist/components/properties.js +138 -7
- package/dist/components/sdk-sidebar.d.ts +14 -1
- package/dist/components/sdk-sidebar.js +50 -8
- package/dist/components/sdk.d.ts +121 -1
- package/dist/components/sdk.js +405 -8
- package/dist/components/snippets.d.ts +70 -13
- package/dist/components/snippets.js +182 -7
- package/dist/components/stl-sidebar.d.ts +57 -1
- package/dist/components/stl-sidebar.js +105 -3
- package/dist/contexts/component-generics.d.ts +29 -1
- package/dist/contexts/component-generics.js +31 -1
- package/dist/contexts/component-types.d.ts +4 -15
- package/dist/contexts/component.d.ts +7 -17
- package/dist/contexts/component.js +22 -28
- package/dist/contexts/docs.d.ts +61 -1
- package/dist/contexts/docs.js +89 -1
- package/dist/contexts/index.d.ts +13 -14
- package/dist/contexts/index.js +44 -6
- package/dist/contexts/markdown.d.ts +21 -1
- package/dist/contexts/markdown.js +47 -2
- package/dist/contexts/navigation.d.ts +28 -1
- package/dist/contexts/navigation.js +22 -1
- package/dist/contexts/use-components.d.ts +1 -13
- package/dist/contexts/use-components.js +6 -2
- package/dist/{index-HDt5wRiR.d.ts → index-Cl6Gny0o.d.ts} +37 -2
- package/dist/index.d.ts +4 -14
- package/dist/index.js +7 -30
- package/dist/languages/cli.d.ts +38 -14
- package/dist/languages/cli.js +166 -20
- package/dist/languages/csharp.d.ts +42 -14
- package/dist/languages/csharp.js +283 -8
- package/dist/languages/go.d.ts +40 -14
- package/dist/languages/go.js +303 -8
- package/dist/languages/http.d.ts +46 -14
- package/dist/languages/http.js +390 -19
- package/dist/languages/index.d.ts +51 -14
- package/dist/languages/index.js +32 -28
- package/dist/languages/java.d.ts +43 -14
- package/dist/languages/java.js +403 -8
- package/dist/languages/php.d.ts +40 -0
- package/dist/languages/php.js +313 -0
- package/dist/languages/python.d.ts +40 -14
- package/dist/languages/python.js +269 -8
- package/dist/languages/ruby.d.ts +40 -14
- package/dist/languages/ruby.js +387 -8
- package/dist/languages/terraform.d.ts +48 -14
- package/dist/languages/terraform.js +243 -8
- package/dist/languages/typescript.d.ts +40 -14
- package/dist/languages/typescript.js +449 -8
- package/dist/markdown/index.d.ts +1 -2
- package/dist/markdown/index.js +1 -28
- package/dist/markdown/printer.d.ts +2 -2
- package/dist/markdown/printer.js +6 -30
- package/dist/markdown/utils.d.ts +3 -3
- package/dist/routing.d.ts +61 -2
- package/dist/routing.js +205 -2
- package/dist/spec.d.ts +2 -2
- package/dist/spec.js +2 -2
- package/dist/style.js +176 -1
- package/dist/use-strict-context-L0c8JKg4.js +16 -0
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +53 -2
- package/package.json +3 -3
- package/dist/breadcrumbs-Dei_5sHd.d.ts +0 -25
- package/dist/breadcrumbs-oUp-6oJK.js +0 -63
- package/dist/cli-BX9ofVCR.js +0 -166
- package/dist/component-Dl5ZEHxB.js +0 -23
- package/dist/component-generics-C9ALAcZI.d.ts +0 -30
- package/dist/component-generics-POFirVVb.js +0 -45
- package/dist/components-DQPlXEwE.js +0 -72
- package/dist/contexts-_NNW5yqC.js +0 -44
- package/dist/csharp-sn5CJu9t.js +0 -283
- package/dist/docs-YgoQ3bzY.js +0 -81
- package/dist/docs-x-kfjRMc.d.ts +0 -66
- package/dist/go-BoaAVmP0.js +0 -303
- package/dist/http-Ccj1dOvE.js +0 -389
- package/dist/icons-BYKn5X8E.js +0 -885
- package/dist/index-OCM-LZIo.d.ts +0 -428
- package/dist/java-BiLRuLuD.js +0 -403
- package/dist/languages-COjc0Nwx.js +0 -30
- package/dist/markdown-BszOPZhh.d.ts +0 -22
- package/dist/markdown-Cq3XEhrR.js +0 -49
- package/dist/method-DjzVBzZe.js +0 -96
- package/dist/method-KkWyhvKa.d.ts +0 -59
- package/dist/navigation-BZjwfN2P.d.ts +0 -29
- package/dist/navigation-aoYZ_tl4.js +0 -24
- package/dist/overview-BNmMeDUE.d.ts +0 -39
- package/dist/overview-Clq5psZe.js +0 -138
- package/dist/primitives-B8OnSXRP.d.ts +0 -105
- package/dist/primitives-BBUs_flm.js +0 -250
- package/dist/properties-BhlRtWo4.d.ts +0 -54
- package/dist/properties-DQU0NBzb.js +0 -138
- package/dist/python-nqOBH7GS.js +0 -269
- package/dist/routing-GvhEMw6E.js +0 -205
- package/dist/routing-qJMPICGo.d.ts +0 -61
- package/dist/ruby-BBc8HdIt.js +0 -387
- package/dist/sdk-C8C6IRQp.d.ts +0 -122
- package/dist/sdk-DzCHhEoX.js +0 -405
- package/dist/sdk-sidebar-CkjSLggl.js +0 -50
- package/dist/sdk-sidebar-lgNmf-ns.d.ts +0 -15
- package/dist/snippets-CLpNVNlA.js +0 -181
- package/dist/stl-sidebar-8jF9cdnn.d.ts +0 -58
- package/dist/stl-sidebar-DC5UOJiT.js +0 -106
- package/dist/style-DJIYkFhO.js +0 -178
- package/dist/terraform-DVx2ea2h.js +0 -243
- package/dist/typescript-Cmk-jBBw.js +0 -449
- package/dist/use-components-BUz3GbO4.js +0 -7
- package/dist/utils-D6zJxUZ9.js +0 -54
package/dist/components/sdk.js
CHANGED
|
@@ -1,10 +1,407 @@
|
|
|
1
|
-
import "../docs
|
|
2
|
-
import "../
|
|
3
|
-
import "../navigation
|
|
4
|
-
import "../
|
|
5
|
-
import "../contexts-
|
|
6
|
-
import "../
|
|
7
|
-
import "../
|
|
8
|
-
import {
|
|
1
|
+
import { useAvailableLanguages, useContentPanelLayout, useDeclaration, useLanguage, useSettings, useSnippetIds, useSnippetResponse, useSpec } from "../contexts/docs.js";
|
|
2
|
+
import "../use-strict-context-L0c8JKg4.js";
|
|
3
|
+
import { useNavigation } from "../contexts/navigation.js";
|
|
4
|
+
import { useLanguageComponents } from "../contexts/index.js";
|
|
5
|
+
import { useComponents } from "../contexts/use-components.js";
|
|
6
|
+
import style_default from "../style.js";
|
|
7
|
+
import { LanguageNames, generateRoute, getLanguageSnippet, parseStainlessPath } from "../routing.js";
|
|
8
|
+
import { CLIIcon, CSharpIcon, CurlIcon, GoIcon, JavaIcon, KotlinIcon, PHPIcon, PowershellIcon, PythonIcon, RubyIcon, TerraformIcon, TypescriptIcon } from "./icons.js";
|
|
9
|
+
import * as React$1 from "react";
|
|
10
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
+
import clsx from "clsx";
|
|
12
|
+
import { BookOpen, Copy, Github } from "lucide-react";
|
|
13
|
+
import { Button, Callout } from "@stainless-api/ui-primitives";
|
|
9
14
|
|
|
15
|
+
//#region src/components/sdk.tsx
|
|
16
|
+
const PropertyModelContext = React$1.createContext({});
|
|
17
|
+
function usePropertyModel() {
|
|
18
|
+
return React$1.useContext(PropertyModelContext);
|
|
19
|
+
}
|
|
20
|
+
const ReferenceNestingContext = React$1.createContext([]);
|
|
21
|
+
function useReferenceNesting() {
|
|
22
|
+
return React$1.useContext(ReferenceNestingContext);
|
|
23
|
+
}
|
|
24
|
+
const SDKSnippetLanguages = {
|
|
25
|
+
"node.default": { name: "TypeScript" },
|
|
26
|
+
"typescript.default": { name: "TypeScript" },
|
|
27
|
+
"python.default": { name: "Python" },
|
|
28
|
+
"go.default": { name: "Go" },
|
|
29
|
+
"java.default": { name: "Java" },
|
|
30
|
+
"kotlin.default": { name: "Kotlin" },
|
|
31
|
+
"http.curl": { name: "cURL" },
|
|
32
|
+
"http.powershell": { name: "Powershell" },
|
|
33
|
+
"terraform.default": { name: "Terraform" },
|
|
34
|
+
"ruby.default": { name: "Ruby" },
|
|
35
|
+
"csharp.default": { name: "C#" },
|
|
36
|
+
"php.default": { name: "PHP" },
|
|
37
|
+
"cli.default": { name: "CLI tool" }
|
|
38
|
+
};
|
|
39
|
+
function SDKChildren({ paths, expand, depth }) {
|
|
40
|
+
const Docs = useComponents();
|
|
41
|
+
return /* @__PURE__ */ jsx("div", {
|
|
42
|
+
className: style_default.Properties,
|
|
43
|
+
children: paths.map((path, i) => /* @__PURE__ */ jsx(Docs.SDKDeclaration, {
|
|
44
|
+
path,
|
|
45
|
+
expand,
|
|
46
|
+
depth
|
|
47
|
+
}, i))
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
function normalizeDeclaration(raw, http) {
|
|
51
|
+
if (raw.kind === "JavaDeclProperty" && raw.type.kind === "JavaTypeString" && raw.constraints?.format === "binary") return {
|
|
52
|
+
...raw,
|
|
53
|
+
type: {
|
|
54
|
+
kind: "JavaTypeReference",
|
|
55
|
+
typeName: "InputStream"
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
if (http?.kind === "HttpDeclProperty" && http.type.kind === "HttpTypeString" && http.constraints?.format === "binary") switch (raw.kind) {
|
|
59
|
+
case "CLISchemaProperty":
|
|
60
|
+
case "CLIFlag":
|
|
61
|
+
case "HttpDeclProperty": return {
|
|
62
|
+
...raw,
|
|
63
|
+
type: {
|
|
64
|
+
kind: "HttpTypeBinary",
|
|
65
|
+
contentType: []
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
case "RubyDeclProperty": return {
|
|
69
|
+
...raw,
|
|
70
|
+
type: {
|
|
71
|
+
kind: "RubyTypeBinary",
|
|
72
|
+
contentType: []
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
return raw;
|
|
77
|
+
}
|
|
78
|
+
function SDKDeclaration({ path, expand, depth = 0 }) {
|
|
79
|
+
const Lang = useLanguageComponents();
|
|
80
|
+
const Docs = useComponents();
|
|
81
|
+
const decl = normalizeDeclaration(useDeclaration(path, true), useDeclaration(path.replace(/ > \(schema\)$/, "") + " > (schema)", false, "http"));
|
|
82
|
+
const settings = useSettings();
|
|
83
|
+
const model = usePropertyModel();
|
|
84
|
+
const nesting = useReferenceNesting();
|
|
85
|
+
const { selectedPath } = useNavigation();
|
|
86
|
+
if (decl.kind.endsWith("Reference")) {
|
|
87
|
+
const refId = "type" in decl && decl.type !== void 0 && typeof decl.type !== "string" && "$ref" in decl.type ? decl.type["$ref"] : void 0;
|
|
88
|
+
if (refId && refId !== path && !nesting.includes(refId)) return /* @__PURE__ */ jsx(ReferenceNestingContext.Provider, {
|
|
89
|
+
value: [...nesting, refId],
|
|
90
|
+
children: /* @__PURE__ */ jsx(SDKDeclaration, {
|
|
91
|
+
path: refId,
|
|
92
|
+
expand,
|
|
93
|
+
depth
|
|
94
|
+
})
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
const parsedPath = selectedPath ? parseStainlessPath(selectedPath) : null;
|
|
98
|
+
const modelPropSetting = settings?.properties?.includeModelProperties;
|
|
99
|
+
const inlineModelProps = modelPropSetting === "method-page" ? Boolean(parsedPath?.method) : modelPropSetting !== false;
|
|
100
|
+
const isUnion = "childrenParentSchema" in decl && decl.childrenParentSchema && decl.kind !== "CLIFlag" && decl.kind !== "CLISchemaProperty" && ["enum", "union"].includes(decl.childrenParentSchema);
|
|
101
|
+
const id = model?.propertyPath ? `${model.propertyPath} + ${path}` : path;
|
|
102
|
+
const shouldExpand = selectedPath?.startsWith(path) && nesting.length < 1 || settings?.properties?.expandDepth && depth <= settings?.properties?.expandDepth && !isUnion || expand;
|
|
103
|
+
const hasChildren = "children" in decl && (decl.children?.length ?? 0) > 0 && !decl.children?.includes(path) && !(isUnion && decl.childrenParentSchema === "enum" && decl.children?.length === 1) && (inlineModelProps || !("modelPath" in decl));
|
|
104
|
+
const content = /* @__PURE__ */ jsx(Lang.Property, {
|
|
105
|
+
decl,
|
|
106
|
+
children: ({ ...props }) => /* @__PURE__ */ jsx(Docs.Property, {
|
|
107
|
+
id,
|
|
108
|
+
expand: shouldExpand,
|
|
109
|
+
constraints: "constraints" in decl && decl.kind !== "CLIFlag" && decl.kind !== "CLISchemaProperty" && /* @__PURE__ */ jsx(Docs.SDKConstraints, { constraints: decl["constraints"] }),
|
|
110
|
+
declaration: /* @__PURE__ */ jsx(Lang.Declaration, { decl }),
|
|
111
|
+
title: "title" in decl ? decl.title : void 0,
|
|
112
|
+
description: "docstring" in decl ? decl["docstring"] : void 0,
|
|
113
|
+
deprecated: decl.deprecated,
|
|
114
|
+
...props,
|
|
115
|
+
children: hasChildren && /* @__PURE__ */ jsxs(Fragment$1, { children: [isUnion && /* @__PURE__ */ jsx("div", {
|
|
116
|
+
className: style_default.PropertyAnnotation,
|
|
117
|
+
children: "Accepts one of the following:"
|
|
118
|
+
}), /* @__PURE__ */ jsx(Docs.SDKChildren, {
|
|
119
|
+
paths: decl.children ?? [],
|
|
120
|
+
depth: depth + 1
|
|
121
|
+
})] })
|
|
122
|
+
})
|
|
123
|
+
});
|
|
124
|
+
if ("modelPath" in decl) {
|
|
125
|
+
const value = {
|
|
126
|
+
modelPath: decl.modelPath,
|
|
127
|
+
propertyPath: decl.stainlessPath
|
|
128
|
+
};
|
|
129
|
+
return /* @__PURE__ */ jsx(PropertyModelContext.Provider, {
|
|
130
|
+
value,
|
|
131
|
+
children: content
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
return content;
|
|
135
|
+
}
|
|
136
|
+
function SDKConstraints({ constraints }) {
|
|
137
|
+
if (constraints) return /* @__PURE__ */ jsx("div", {
|
|
138
|
+
className: style_default.PropertyConstraints,
|
|
139
|
+
children: Object.entries(constraints).map(([name, value]) => name === "format" && value === "binary" ? null : /* @__PURE__ */ jsxs("div", {
|
|
140
|
+
className: style_default.PropertyConstraint,
|
|
141
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
142
|
+
className: style_default.PropertyConstraintName,
|
|
143
|
+
children: name
|
|
144
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
145
|
+
className: style_default.PropertyConstraintValue,
|
|
146
|
+
children: value
|
|
147
|
+
})]
|
|
148
|
+
}, name))
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
const snippetIcons = {
|
|
152
|
+
"node.default": TypescriptIcon,
|
|
153
|
+
"typescript.default": TypescriptIcon,
|
|
154
|
+
"go.default": GoIcon,
|
|
155
|
+
"python.default": PythonIcon,
|
|
156
|
+
"terraform.default": TerraformIcon,
|
|
157
|
+
"http.curl": CurlIcon,
|
|
158
|
+
"http.powershell": PowershellIcon,
|
|
159
|
+
"ruby.default": RubyIcon,
|
|
160
|
+
"java.default": JavaIcon,
|
|
161
|
+
"kotlin.default": KotlinIcon,
|
|
162
|
+
"csharp.default": CSharpIcon,
|
|
163
|
+
"cli.default": CLIIcon,
|
|
164
|
+
"php.default": PHPIcon
|
|
165
|
+
};
|
|
166
|
+
function SDKIcon({ language }) {
|
|
167
|
+
const LangIcon = snippetIcons[language];
|
|
168
|
+
if (!LangIcon) return null;
|
|
169
|
+
return /* @__PURE__ */ jsx(LangIcon, { className: clsx(style_default.Icon, language.split(".").shift()) });
|
|
170
|
+
}
|
|
171
|
+
function SDKRequestTitle({ snippetLanguage }) {
|
|
172
|
+
const languageName = SDKSnippetLanguages[snippetLanguage]?.name;
|
|
173
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
174
|
+
className: style_default.SnippetRequestTitleLanguage,
|
|
175
|
+
children: [
|
|
176
|
+
/* @__PURE__ */ jsx(SDKIcon, { language: snippetLanguage }),
|
|
177
|
+
" ",
|
|
178
|
+
languageName
|
|
179
|
+
]
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
function SDKExample({ method, transformRequestSnippet }) {
|
|
183
|
+
const Docs = useComponents();
|
|
184
|
+
const language = useLanguage();
|
|
185
|
+
const snippetLanguage = getLanguageSnippet(language);
|
|
186
|
+
if ((useSnippetIds(method.stainlessPath, language)?.filter((id) => id !== "default")?.length ?? 0) >= 2) return /* @__PURE__ */ jsx(Docs.MultiSnippets, {
|
|
187
|
+
requestTitle: /* @__PURE__ */ jsx(Docs.SDKRequestTitle, { snippetLanguage }),
|
|
188
|
+
method
|
|
189
|
+
});
|
|
190
|
+
return /* @__PURE__ */ jsx(Docs.Snippet, {
|
|
191
|
+
requestTitle: /* @__PURE__ */ jsx(Docs.SDKRequestTitle, { snippetLanguage }),
|
|
192
|
+
method,
|
|
193
|
+
transformRequestSnippet
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
function SDKMethodHeader({ method }) {
|
|
197
|
+
const Docs = useComponents();
|
|
198
|
+
const Lang = useLanguageComponents();
|
|
199
|
+
const decl = useDeclaration(method.stainlessPath, true);
|
|
200
|
+
return /* @__PURE__ */ jsx(Docs.MethodHeader, {
|
|
201
|
+
level: "h1",
|
|
202
|
+
title: method.summary || method.title,
|
|
203
|
+
signature: /* @__PURE__ */ jsx(Lang.MethodSignature, { decl }),
|
|
204
|
+
badges: method.deprecated && /* @__PURE__ */ jsx(Docs.Badge, {
|
|
205
|
+
id: "deprecated",
|
|
206
|
+
children: "Deprecated"
|
|
207
|
+
}),
|
|
208
|
+
children: /* @__PURE__ */ jsx(Docs.MethodRoute, {
|
|
209
|
+
httpMethod: method.httpMethod,
|
|
210
|
+
endpoint: method.endpoint.split(" ", 2).at(-1)
|
|
211
|
+
})
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
function useStreamingResponse(method) {
|
|
215
|
+
const tsDecl = useDeclaration(method.stainlessPath, false, "typescript");
|
|
216
|
+
if (tsDecl?.kind === "TSDeclFunction" && tsDecl.overloads) {
|
|
217
|
+
for (const e of tsDecl.overloads) if (e.returns.kind === "TSTypeReference" && (e.returns.$ref === "$.typescript.Stream" || e.returns.$ref === "$.node.Stream") && e.returns.typeParameters?.[0]?.kind === "TSTypeReference") {
|
|
218
|
+
const id = e.returns.typeParameters?.[0].$ref;
|
|
219
|
+
if (id) return id;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
function SDKMethodInfo({ method }) {
|
|
224
|
+
const Docs = useComponents();
|
|
225
|
+
const Lang = useLanguageComponents();
|
|
226
|
+
const decl = useDeclaration(method.stainlessPath, true);
|
|
227
|
+
const streamingResponseID = useStreamingResponse(method);
|
|
228
|
+
const streamingResponseDecl = useDeclaration(streamingResponseID ?? "", false);
|
|
229
|
+
const spec = useSpec();
|
|
230
|
+
const language = useLanguage();
|
|
231
|
+
if (Lang.MethodInfo) return /* @__PURE__ */ jsx(Lang.MethodInfo, { decl });
|
|
232
|
+
function shouldExpand(items) {
|
|
233
|
+
if (items.length > 1) return false;
|
|
234
|
+
const item = items[0];
|
|
235
|
+
if (!item) return false;
|
|
236
|
+
const decl = spec?.decls?.[language]?.[item];
|
|
237
|
+
return decl && "children" in decl && decl.children && decl.children.length > 0;
|
|
238
|
+
}
|
|
239
|
+
const responseChildren = "responseChildren" in decl && decl.responseChildren && decl.responseChildren.length > 0 ? [...decl.responseChildren] : [];
|
|
240
|
+
if (streamingResponseDecl && streamingResponseID && !responseChildren.includes(streamingResponseID)) responseChildren.push(streamingResponseID);
|
|
241
|
+
return /* @__PURE__ */ jsx(Docs.MethodInfo, {
|
|
242
|
+
parameters: "paramsChildren" in decl && Array.isArray(decl.paramsChildren) && decl.paramsChildren.length > 0 && /* @__PURE__ */ jsx(Docs.SDKChildren, {
|
|
243
|
+
expand: shouldExpand(decl.paramsChildren),
|
|
244
|
+
paths: decl.paramsChildren
|
|
245
|
+
}),
|
|
246
|
+
returns: responseChildren.length > 0 && /* @__PURE__ */ jsx(Docs.SDKChildren, {
|
|
247
|
+
expand: shouldExpand(responseChildren),
|
|
248
|
+
paths: responseChildren
|
|
249
|
+
})
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
function SDKMethodNotImplemented({ method }) {
|
|
253
|
+
const Docs = useComponents();
|
|
254
|
+
const languages = useAvailableLanguages(method?.stainlessPath);
|
|
255
|
+
const language = useLanguage();
|
|
256
|
+
const { basePath } = useNavigation();
|
|
257
|
+
const availableLanguageLinks = languages.flatMap((lang) => {
|
|
258
|
+
const url = generateRoute(basePath ?? "/", lang, method.stainlessPath);
|
|
259
|
+
return url ? [{
|
|
260
|
+
url,
|
|
261
|
+
label: LanguageNames[lang] ?? lang
|
|
262
|
+
}] : [];
|
|
263
|
+
});
|
|
264
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
265
|
+
className: style_default.Method,
|
|
266
|
+
children: [/* @__PURE__ */ jsx(Docs.MethodHeader, {
|
|
267
|
+
level: "h1",
|
|
268
|
+
title: method.summary || method.title,
|
|
269
|
+
children: /* @__PURE__ */ jsx(Docs.MethodRoute, {
|
|
270
|
+
httpMethod: method.httpMethod,
|
|
271
|
+
endpoint: method.endpoint.split(" ", 2).at(-1)
|
|
272
|
+
})
|
|
273
|
+
}), /* @__PURE__ */ jsxs(Callout, {
|
|
274
|
+
variant: "warning",
|
|
275
|
+
children: [
|
|
276
|
+
"The method ",
|
|
277
|
+
/* @__PURE__ */ jsx("code", { children: method.name }),
|
|
278
|
+
" is not implemented in ",
|
|
279
|
+
LanguageNames[language] ?? language,
|
|
280
|
+
basePath && availableLanguageLinks.length > 0 ? /* @__PURE__ */ jsxs(Fragment$1, { children: [", but it is available in the following languages:", /* @__PURE__ */ jsx("ul", { children: availableLanguageLinks.map(({ url, label }) => {
|
|
281
|
+
return /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx("a", {
|
|
282
|
+
href: url,
|
|
283
|
+
children: label
|
|
284
|
+
}) }, url);
|
|
285
|
+
}) })] }) : "."
|
|
286
|
+
]
|
|
287
|
+
})]
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
function SDKMethod({ method, transformRequestSnippet }) {
|
|
291
|
+
const Docs = useComponents();
|
|
292
|
+
const decl = useDeclaration(method?.stainlessPath, false);
|
|
293
|
+
const layout = useContentPanelLayout();
|
|
294
|
+
const defaultResponses = useSnippetResponse(method.stainlessPath);
|
|
295
|
+
if (!decl) return /* @__PURE__ */ jsx(SDKMethodNotImplemented, { method });
|
|
296
|
+
return /* @__PURE__ */ jsxs(Docs.Method, {
|
|
297
|
+
id: method.stainlessPath,
|
|
298
|
+
header: /* @__PURE__ */ jsx(Docs.SDKMethodHeader, { method }),
|
|
299
|
+
className: clsx({
|
|
300
|
+
[style_default.MethodSinglePane]: layout === "single-pane",
|
|
301
|
+
[style_default.MethodDoublePane]: layout === "double-pane"
|
|
302
|
+
}),
|
|
303
|
+
children: [
|
|
304
|
+
/* @__PURE__ */ jsxs("div", {
|
|
305
|
+
className: style_default.MethodContentColumn,
|
|
306
|
+
children: [/* @__PURE__ */ jsx(Docs.MethodDescription, { description: method.description }), /* @__PURE__ */ jsx(Docs.SDKMethodInfo, { method })]
|
|
307
|
+
}),
|
|
308
|
+
/* @__PURE__ */ jsx("div", {
|
|
309
|
+
className: clsx(style_default.MethodExample, "not-content", "stl-ui-not-prose"),
|
|
310
|
+
children: /* @__PURE__ */ jsx(Docs.SDKExample, {
|
|
311
|
+
method,
|
|
312
|
+
transformRequestSnippet
|
|
313
|
+
})
|
|
314
|
+
}),
|
|
315
|
+
/* @__PURE__ */ jsxs("div", {
|
|
316
|
+
className: style_default.MethodResponseColumn,
|
|
317
|
+
children: [/* @__PURE__ */ jsx("h5", { children: "Returns Examples" }), /* @__PURE__ */ jsx(Docs.SnippetResponse, { responses: defaultResponses })]
|
|
318
|
+
})
|
|
319
|
+
]
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
function SDKModel({ model }) {
|
|
323
|
+
const Docs = useComponents();
|
|
324
|
+
if (!useDeclaration(`${model.stainlessPath} > (schema)`, true)) return null;
|
|
325
|
+
return /* @__PURE__ */ jsx("div", {
|
|
326
|
+
className: style_default.Model,
|
|
327
|
+
tabIndex: 0,
|
|
328
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
329
|
+
className: style_default.ResourceContentProperties,
|
|
330
|
+
children: /* @__PURE__ */ jsx(Docs.SDKDeclaration, { path: `${model.stainlessPath} > (schema)` })
|
|
331
|
+
})
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
function SDKReference({ stainlessPath, children }) {
|
|
335
|
+
const Docs = useComponents();
|
|
336
|
+
if (!stainlessPath || !stainlessPath.endsWith("(schema)")) return children;
|
|
337
|
+
return /* @__PURE__ */ jsx("span", {
|
|
338
|
+
className: style_default.TypeReference,
|
|
339
|
+
children: /* @__PURE__ */ jsx(Docs.Link, {
|
|
340
|
+
stainlessPath,
|
|
341
|
+
children
|
|
342
|
+
})
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
function SDKLanguageBlock({ language, version, install, links }) {
|
|
346
|
+
const Docs = useComponents();
|
|
347
|
+
const lang = `${language}.default`;
|
|
348
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
349
|
+
className: style_default.LanguageBlock,
|
|
350
|
+
children: [
|
|
351
|
+
/* @__PURE__ */ jsxs("div", {
|
|
352
|
+
className: style_default.LanguageBlockContent,
|
|
353
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
354
|
+
className: style_default.LanguageBlockContentIcon,
|
|
355
|
+
children: /* @__PURE__ */ jsx(Docs.SDKIcon, {
|
|
356
|
+
language: lang,
|
|
357
|
+
size: 24
|
|
358
|
+
})
|
|
359
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
360
|
+
className: style_default.LanguageBlockContentInfo,
|
|
361
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
362
|
+
className: style_default.LanguageBlockContentInfoLanguage,
|
|
363
|
+
children: Docs.SDKSnippetLanguages[lang].name
|
|
364
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
365
|
+
className: style_default.LanguageBlockContentInfoVersion,
|
|
366
|
+
children: version
|
|
367
|
+
})]
|
|
368
|
+
})]
|
|
369
|
+
}),
|
|
370
|
+
/* @__PURE__ */ jsxs("div", {
|
|
371
|
+
className: style_default.LanguageBlockInstall,
|
|
372
|
+
"data-stldocs-copy-parent": true,
|
|
373
|
+
children: [
|
|
374
|
+
/* @__PURE__ */ jsx("pre", {
|
|
375
|
+
"data-stldocs-copy-content": true,
|
|
376
|
+
children: install
|
|
377
|
+
}),
|
|
378
|
+
" ",
|
|
379
|
+
/* @__PURE__ */ jsx(Button, {
|
|
380
|
+
variant: "ghost",
|
|
381
|
+
size: "sm",
|
|
382
|
+
"data-stldocs-snippet-copy": true,
|
|
383
|
+
children: /* @__PURE__ */ jsx(Copy, {
|
|
384
|
+
size: 16,
|
|
385
|
+
className: style_default.Icon
|
|
386
|
+
})
|
|
387
|
+
})
|
|
388
|
+
]
|
|
389
|
+
}),
|
|
390
|
+
/* @__PURE__ */ jsxs("div", {
|
|
391
|
+
className: style_default.LanguageBlockLinks,
|
|
392
|
+
children: [/* @__PURE__ */ jsx(Button, {
|
|
393
|
+
href: links.repo,
|
|
394
|
+
variant: "outline",
|
|
395
|
+
children: /* @__PURE__ */ jsx(Button.Icon, { icon: Github })
|
|
396
|
+
}), /* @__PURE__ */ jsxs(Button, {
|
|
397
|
+
href: links.docs,
|
|
398
|
+
variant: "outline",
|
|
399
|
+
children: [/* @__PURE__ */ jsx(Button.Icon, { icon: BookOpen }), /* @__PURE__ */ jsx(Button.Label, { children: "Read Docs" })]
|
|
400
|
+
})]
|
|
401
|
+
})
|
|
402
|
+
]
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
//#endregion
|
|
10
407
|
export { PropertyModelContext, ReferenceNestingContext, SDKChildren, SDKConstraints, SDKDeclaration, SDKExample, SDKIcon, SDKLanguageBlock, SDKMethod, SDKMethodHeader, SDKMethodInfo, SDKMethodNotImplemented, SDKModel, SDKReference, SDKRequestTitle, SDKSnippetLanguages, usePropertyModel, useReferenceNesting, useStreamingResponse };
|
|
@@ -1,14 +1,71 @@
|
|
|
1
|
-
import "../
|
|
2
|
-
import "
|
|
3
|
-
import "../
|
|
4
|
-
import "../
|
|
5
|
-
import "
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import { d as Method, o as HasStainlessPath } from "../index-Cl6Gny0o.js";
|
|
2
|
+
import { TransformRequestSnippetFn } from "./sdk.js";
|
|
3
|
+
import { useSnippet } from "../contexts/docs.js";
|
|
4
|
+
import "../contexts/index.js";
|
|
5
|
+
import * as React$1 from "react";
|
|
6
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
7
|
+
|
|
8
|
+
//#region src/components/snippets.d.ts
|
|
9
|
+
type SnippetCodeProps = {
|
|
10
|
+
content: string;
|
|
11
|
+
signature?: string;
|
|
12
|
+
language?: string;
|
|
13
|
+
};
|
|
14
|
+
declare function SnippetCode({
|
|
15
|
+
content,
|
|
16
|
+
language
|
|
17
|
+
}: SnippetCodeProps): react_jsx_runtime0.JSX.Element;
|
|
18
|
+
type SnippetContainerProps = {
|
|
19
|
+
method: Partial<Method> & HasStainlessPath;
|
|
20
|
+
children: React$1.ReactNode;
|
|
21
|
+
signature?: string;
|
|
22
|
+
} & React$1.ComponentProps<'div'>;
|
|
23
|
+
declare function SnippetContainer({
|
|
24
|
+
children,
|
|
25
|
+
className,
|
|
26
|
+
...props
|
|
27
|
+
}: SnippetContainerProps): react_jsx_runtime0.JSX.Element;
|
|
28
|
+
type SnippetRequestContainerProps = {
|
|
29
|
+
children?: React$1.ReactNode;
|
|
30
|
+
signature?: string;
|
|
31
|
+
};
|
|
32
|
+
declare function SnippetRequestContainer({
|
|
33
|
+
children
|
|
34
|
+
}: SnippetRequestContainerProps): react_jsx_runtime0.JSX.Element;
|
|
35
|
+
type SnippetProps = {
|
|
36
|
+
requestTitle?: React$1.ReactNode;
|
|
37
|
+
method: Partial<Method> & HasStainlessPath;
|
|
38
|
+
snippet?: Parameters<typeof useSnippet>[2];
|
|
39
|
+
transformRequestSnippet?: TransformRequestSnippetFn;
|
|
40
|
+
};
|
|
41
|
+
declare function Snippet({
|
|
42
|
+
requestTitle,
|
|
43
|
+
method,
|
|
44
|
+
snippet,
|
|
45
|
+
transformRequestSnippet
|
|
46
|
+
}: SnippetProps): react_jsx_runtime0.JSX.Element | null;
|
|
47
|
+
type MultiSnippetsProps = {
|
|
48
|
+
method: Partial<Method> & HasStainlessPath;
|
|
49
|
+
requestTitle?: React$1.ReactNode;
|
|
50
|
+
};
|
|
51
|
+
declare function MultiSnippets({
|
|
52
|
+
requestTitle,
|
|
53
|
+
method
|
|
54
|
+
}: MultiSnippetsProps): react_jsx_runtime0.JSX.Element | null;
|
|
55
|
+
declare function SnippetButtons({
|
|
56
|
+
content
|
|
57
|
+
}: {
|
|
58
|
+
content: string;
|
|
59
|
+
}): react_jsx_runtime0.JSX.Element;
|
|
60
|
+
declare function SnippetFooter(): React$1.ReactNode;
|
|
61
|
+
declare function SnippetResponse({
|
|
62
|
+
responses
|
|
63
|
+
}: {
|
|
64
|
+
responses?: {
|
|
65
|
+
status?: string;
|
|
66
|
+
content: string;
|
|
67
|
+
contentType?: string;
|
|
68
|
+
}[];
|
|
69
|
+
}): react_jsx_runtime0.JSX.Element | null;
|
|
70
|
+
//#endregion
|
|
14
71
|
export { MultiSnippets, MultiSnippetsProps, Snippet, SnippetButtons, SnippetCode, SnippetCodeProps, SnippetContainer, SnippetContainerProps, SnippetFooter, SnippetProps, SnippetRequestContainer, SnippetRequestContainerProps, SnippetResponse };
|