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