@stainless-api/docs-ui 0.1.0-beta.9 → 0.1.0-beta.91

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 (162) hide show
  1. package/dist/breadcrumbs-BaNU4WsC.d.ts +25 -0
  2. package/dist/chunk-pbuEa-1d.js +13 -0
  3. package/dist/component-generics-D9XaPlr8.d.ts +30 -0
  4. package/dist/component-generics-DYxBWv1v.js +42 -0
  5. package/dist/components/MaskedInput.d.ts +14 -0
  6. package/dist/components/MaskedInput.js +74 -0
  7. package/dist/components/breadcrumbs.d.ts +2 -0
  8. package/dist/components/breadcrumbs.js +61 -0
  9. package/dist/components/icons.d.ts +72 -0
  10. package/dist/components/icons.js +953 -0
  11. package/dist/components/index.d.ts +10 -0
  12. package/dist/components/index.js +72 -0
  13. package/dist/components/method.d.ts +2 -0
  14. package/dist/components/method.js +94 -0
  15. package/dist/components/overview.d.ts +2 -0
  16. package/dist/components/overview.js +139 -0
  17. package/dist/components/primitives.d.ts +2 -0
  18. package/dist/components/primitives.js +250 -0
  19. package/dist/components/properties.d.ts +2 -0
  20. package/dist/components/properties.js +143 -0
  21. package/dist/components/sdk-sidebar.d.ts +2 -0
  22. package/dist/components/sdk-sidebar.js +49 -0
  23. package/dist/components/sdk.d.ts +2 -0
  24. package/dist/components/sdk.js +487 -0
  25. package/dist/components/snippets.d.ts +2 -0
  26. package/dist/components/snippets.js +183 -0
  27. package/dist/components/stl-sidebar.d.ts +2 -0
  28. package/dist/components/stl-sidebar.js +111 -0
  29. package/dist/contexts/component-generics.d.ts +2 -0
  30. package/dist/contexts/component-generics.js +2 -0
  31. package/dist/contexts/component-types.d.ts +7 -0
  32. package/dist/contexts/component-types.js +0 -0
  33. package/dist/contexts/component.d.ts +20 -0
  34. package/dist/contexts/component.js +21 -0
  35. package/dist/contexts/docs.d.ts +2 -0
  36. package/dist/contexts/docs.js +89 -0
  37. package/dist/contexts/index.d.ts +6 -0
  38. package/dist/contexts/index.js +43 -0
  39. package/dist/contexts/markdown.d.ts +2 -0
  40. package/dist/contexts/markdown.js +62 -0
  41. package/dist/contexts/navigation.d.ts +2 -0
  42. package/dist/contexts/navigation.js +21 -0
  43. package/dist/contexts/use-components.d.ts +6 -0
  44. package/dist/contexts/use-components.js +5 -0
  45. package/dist/docs-D0qzNoXq.d.ts +62 -0
  46. package/dist/index-DFr9Mesr.d.ts +1776 -0
  47. package/dist/index-Dt9uPKZP.d.ts +464 -0
  48. package/dist/index.d.ts +5 -0
  49. package/dist/index.js +7 -7542
  50. package/dist/languages/cli.d.ts +2 -0
  51. package/dist/languages/cli.js +164 -0
  52. package/dist/languages/csharp.d.ts +2 -0
  53. package/dist/languages/csharp.js +281 -0
  54. package/dist/languages/go.d.ts +2 -0
  55. package/dist/languages/go.js +301 -0
  56. package/dist/languages/http.d.ts +2 -0
  57. package/dist/languages/http.js +381 -0
  58. package/dist/languages/index.d.ts +2 -0
  59. package/dist/languages/index.js +30 -0
  60. package/dist/languages/java.d.ts +2 -0
  61. package/dist/languages/java.js +401 -0
  62. package/dist/languages/php.d.ts +2 -0
  63. package/dist/languages/php.js +310 -0
  64. package/dist/languages/python.d.ts +2 -0
  65. package/dist/languages/python.js +267 -0
  66. package/dist/languages/ruby.d.ts +2 -0
  67. package/dist/languages/ruby.js +385 -0
  68. package/dist/languages/terraform.d.ts +2 -0
  69. package/dist/languages/terraform.js +258 -0
  70. package/dist/languages/typescript.d.ts +2 -0
  71. package/dist/languages/typescript.js +447 -0
  72. package/dist/markdown/index.d.ts +11 -0
  73. package/dist/markdown/index.js +86 -0
  74. package/dist/markdown/md.d.ts +15 -0
  75. package/dist/markdown/md.js +39 -0
  76. package/dist/markdown/printer.d.ts +13 -0
  77. package/dist/markdown/printer.js +73 -0
  78. package/dist/markdown/utils.d.ts +28 -0
  79. package/dist/markdown/utils.js +31 -0
  80. package/dist/markdown-B30HO-Vy.d.ts +33 -0
  81. package/dist/method-BKJnP-rW.d.ts +59 -0
  82. package/dist/navigation-DGl8lR6w.d.ts +29 -0
  83. package/dist/overview-iH1evPEF.d.ts +39 -0
  84. package/dist/primitives-BHt-BuLf.d.ts +107 -0
  85. package/dist/properties-CCbMRhSX.d.ts +54 -0
  86. package/dist/routing-yTSG7nWM.d.ts +61 -0
  87. package/dist/routing.d.ts +2 -0
  88. package/dist/routing.js +174 -150
  89. package/dist/sdk-BengV7mg.d.ts +128 -0
  90. package/dist/sdk-sidebar-CRqLm3YO.d.ts +15 -0
  91. package/dist/spec.d.ts +65 -0
  92. package/dist/spec.js +165 -0
  93. package/dist/stl-sidebar-Pra9uCYo.d.ts +58 -0
  94. package/dist/style.d.ts +178 -0
  95. package/dist/style.js +178 -0
  96. package/dist/styles/main.css +765 -755
  97. package/dist/styles/primitives.css +359 -442
  98. package/dist/styles/resets.css +25 -41
  99. package/dist/styles/search.css +187 -270
  100. package/dist/styles/sidebar.css +155 -69
  101. package/dist/styles/variables.css +23 -89
  102. package/dist/styles.css +3171 -0
  103. package/dist/utils.d.ts +20 -0
  104. package/dist/utils.js +52 -0
  105. package/package.json +75 -22
  106. package/dist/mcp.js +0 -16003
  107. package/dist/styles/snippets.css +0 -132
  108. package/src/components/breadcrumbs.tsx +0 -94
  109. package/src/components/chat.tsx +0 -154
  110. package/src/components/dropdown.tsx +0 -91
  111. package/src/components/icons.tsx +0 -584
  112. package/src/components/index.ts +0 -9
  113. package/src/components/method.tsx +0 -146
  114. package/src/components/overview.tsx +0 -160
  115. package/src/components/primitives.tsx +0 -284
  116. package/src/components/properties.tsx +0 -130
  117. package/src/components/scripts/dropdown.ts +0 -78
  118. package/src/components/sdk.tsx +0 -403
  119. package/src/components/sidebar.tsx +0 -99
  120. package/src/components/snippets.tsx +0 -180
  121. package/src/contexts/component-generics.tsx +0 -48
  122. package/src/contexts/component-types.tsx +0 -5
  123. package/src/contexts/component.tsx +0 -32
  124. package/src/contexts/docs.tsx +0 -75
  125. package/src/contexts/index.tsx +0 -17
  126. package/src/contexts/markdown.tsx +0 -43
  127. package/src/contexts/navigation.tsx +0 -44
  128. package/src/contexts/search.tsx +0 -28
  129. package/src/contexts/use-components.tsx +0 -4
  130. package/src/index.ts +0 -6
  131. package/src/languages/go.tsx +0 -281
  132. package/src/languages/http.tsx +0 -321
  133. package/src/languages/index.ts +0 -26
  134. package/src/languages/java.tsx +0 -358
  135. package/src/languages/python.tsx +0 -255
  136. package/src/languages/ruby.tsx +0 -320
  137. package/src/languages/typescript.tsx +0 -393
  138. package/src/markdown/index.ts +0 -107
  139. package/src/markdown/md.ts +0 -45
  140. package/src/markdown/utils.ts +0 -49
  141. package/src/routing.ts +0 -238
  142. package/src/search/form.tsx +0 -127
  143. package/src/search/index.tsx +0 -1
  144. package/src/search/indexer.ts +0 -246
  145. package/src/search/mcp.ts +0 -61
  146. package/src/search/printer.tsx +0 -86
  147. package/src/search/providers/algolia.ts +0 -88
  148. package/src/search/providers/fuse.ts +0 -19
  149. package/src/search/providers/pagefind.ts +0 -17
  150. package/src/search/providers/walker.ts +0 -30
  151. package/src/search/results.tsx +0 -182
  152. package/src/search/state.ts +0 -64
  153. package/src/search/types.ts +0 -116
  154. package/src/style.ts +0 -196
  155. package/src/styles/main.css +0 -986
  156. package/src/styles/primitives.css +0 -580
  157. package/src/styles/resets.css +0 -39
  158. package/src/styles/search.css +0 -341
  159. package/src/styles/sidebar.css +0 -85
  160. package/src/styles/snippets.css +0 -130
  161. package/src/styles/variables.css +0 -86
  162. package/src/utils.ts +0 -41
@@ -0,0 +1,143 @@
1
+ import { useIgnoredResources, useLanguage, useSettings } from "../contexts/docs.js";
2
+ import "../contexts/index.js";
3
+ import { useComponents } from "../contexts/use-components.js";
4
+ import style_default from "../style.js";
5
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
6
+ import { ArrowDownWideNarrowIcon, ArrowUpNarrowWideIcon, LinkIcon } from "lucide-react";
7
+ import { Button } from "@stainless-api/ui-primitives";
8
+ //#region src/components/properties.tsx
9
+ function PropertyToggle({ target }) {
10
+ return /* @__PURE__ */ jsxs("span", {
11
+ className: style_default.ExpandToggle,
12
+ "data-stldocs-property-toggle-expanded": "false",
13
+ "data-stldocs-property-toggle-target": target,
14
+ children: [/* @__PURE__ */ jsxs("span", {
15
+ className: style_default.ExpandToggleContent,
16
+ children: ["Expand ", /* @__PURE__ */ jsx(ArrowDownWideNarrowIcon, {
17
+ className: style_default.Icon,
18
+ size: 16
19
+ })]
20
+ }), /* @__PURE__ */ jsxs("span", {
21
+ className: style_default.ExpandToggleContent,
22
+ children: ["Collapse ", /* @__PURE__ */ jsx(ArrowUpNarrowWideIcon, {
23
+ className: style_default.Icon,
24
+ size: 16
25
+ })]
26
+ })]
27
+ });
28
+ }
29
+ function PropertyDescription({ description }) {
30
+ const { Markdown } = useComponents();
31
+ if (description) return /* @__PURE__ */ jsx("div", {
32
+ className: style_default.PropertyDescription,
33
+ children: /* @__PURE__ */ jsx(Markdown, { content: description })
34
+ });
35
+ }
36
+ function PropertyTitle({ title }) {
37
+ const { Markdown } = useComponents();
38
+ if (title) return /* @__PURE__ */ jsx("div", {
39
+ className: style_default.PropertyTitle,
40
+ children: /* @__PURE__ */ jsx(Markdown, { content: title })
41
+ });
42
+ }
43
+ function splitDescription(description) {
44
+ const pos = description?.indexOf("\n\n");
45
+ if (!description || !pos || pos < 0) return [description, null];
46
+ return [description.slice(0, pos), description.slice(pos)];
47
+ }
48
+ function Property({ id, name, typeName, badges, type, declaration, description, title, deprecated, expand, additional, constraints, children }) {
49
+ const Docs = useComponents();
50
+ const language = useLanguage();
51
+ const { collapseDescription, showTitle, types } = useSettings()?.properties ?? {};
52
+ if (useIgnoredResources().includes(id || "")) return null;
53
+ const [descFirstLine, descRest] = collapseDescription === "show-first-line" ? splitDescription(description) : [null, description];
54
+ const textContent = /* @__PURE__ */ jsxs(Fragment, { children: [
55
+ typeof deprecated === "string" && /* @__PURE__ */ jsx("div", {
56
+ className: style_default.PropertyDeprecatedMessage,
57
+ children: deprecated
58
+ }),
59
+ descRest && /* @__PURE__ */ jsx(Docs.PropertyDescription, { description: descRest }),
60
+ constraints ? /* @__PURE__ */ jsx("div", {
61
+ className: style_default.PropertyContent,
62
+ children: constraints
63
+ }) : null
64
+ ] });
65
+ const rich = /* @__PURE__ */ jsxs(Fragment, { children: [
66
+ /* @__PURE__ */ jsxs("div", {
67
+ className: style_default.PropertyDeclaration,
68
+ children: [
69
+ deprecated && /* @__PURE__ */ jsx("span", {
70
+ className: style_default.PropertyDeprecated,
71
+ children: "Deprecated"
72
+ }),
73
+ declaration,
74
+ badges ? /* @__PURE__ */ jsx("span", {
75
+ className: style_default.PropertyBadges,
76
+ children: badges
77
+ }) : null
78
+ ]
79
+ }),
80
+ title && showTitle && /* @__PURE__ */ jsx(Docs.PropertyTitle, { title }),
81
+ collapseDescription === false ? textContent : descFirstLine && /* @__PURE__ */ jsx(Docs.PropertyDescription, { description: descFirstLine })
82
+ ] });
83
+ const simple = /* @__PURE__ */ jsxs(Fragment, { children: [
84
+ name ? /* @__PURE__ */ jsxs("div", {
85
+ className: style_default.PropertyHeader,
86
+ children: [
87
+ deprecated && /* @__PURE__ */ jsx("span", {
88
+ className: style_default.PropertyDeprecated,
89
+ children: "Deprecated"
90
+ }),
91
+ /* @__PURE__ */ jsx("span", {
92
+ className: style_default.PropertyName,
93
+ children: name
94
+ }),
95
+ typeName ? /* @__PURE__ */ jsx("span", {
96
+ className: style_default.PropertyTypeName,
97
+ children: typeName
98
+ }) : null,
99
+ badges ? /* @__PURE__ */ jsx("span", {
100
+ className: style_default.PropertyBadges,
101
+ children: badges
102
+ }) : null
103
+ ]
104
+ }) : null,
105
+ type ? /* @__PURE__ */ jsx("div", {
106
+ className: style_default.PropertyType,
107
+ children: type
108
+ }) : null,
109
+ title && showTitle && /* @__PURE__ */ jsx(Docs.PropertyTitle, { title }),
110
+ collapseDescription === false ? textContent : null
111
+ ] });
112
+ const content = /* @__PURE__ */ jsx("div", {
113
+ id,
114
+ className: style_default.PropertyInfo,
115
+ children: types === "simple" ? simple : rich
116
+ });
117
+ return /* @__PURE__ */ jsxs("div", {
118
+ className: style_default.Property,
119
+ "data-stldocs-language": language,
120
+ children: [children || collapseDescription !== false && descRest ? /* @__PURE__ */ jsxs(Docs.Expander, {
121
+ summary: content,
122
+ muted: !children,
123
+ open: expand,
124
+ children: [
125
+ collapseDescription !== false ? textContent : null,
126
+ additional,
127
+ children ? /* @__PURE__ */ jsx("div", {
128
+ className: style_default.PropertyChildren,
129
+ children
130
+ }) : null
131
+ ]
132
+ }) : content, id && /* @__PURE__ */ jsx(Button, {
133
+ className: style_default.DeepLinkButton,
134
+ variant: "outline",
135
+ size: "sm",
136
+ href: `#${encodeURIComponent(id)}`,
137
+ "aria-label": "Link to this property",
138
+ children: /* @__PURE__ */ jsx(Button.Icon, { icon: LinkIcon })
139
+ })]
140
+ });
141
+ }
142
+ //#endregion
143
+ export { Property, PropertyDescription, PropertyTitle, PropertyToggle };
@@ -0,0 +1,2 @@
1
+ import { n as SDKSidebarProps, t as SDKSidebar } from "../sdk-sidebar-CRqLm3YO.js";
2
+ export { SDKSidebar, SDKSidebarProps };
@@ -0,0 +1,49 @@
1
+ import { useNavigation } from "../contexts/navigation.js";
2
+ import "../contexts/index.js";
3
+ import { isResourceEmpty } from "../utils.js";
4
+ import { StlSidebar } from "./stl-sidebar.js";
5
+ import * as React$1 from "react";
6
+ import { jsx } from "react/jsx-runtime";
7
+ import { Badge, getHttpMethod } from "@stainless-api/ui-primitives";
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
+ //#endregion
49
+ export { SDKSidebar };
@@ -0,0 +1,2 @@
1
+ import { A as useStreamingResponse, C as SDKRequestTitleProps, D as useDeclarationParents, E as TransformRequestSnippetFn, O as usePropertyModel, S as SDKRequestTitle, T as SDKSnippetLanguagesType, _ as SDKMethodNotImplemented, a as ReferenceNestingContextType, b as SDKModelProps, c as SDKConstraintsProps, d as SDKIcon, f as SDKLanguageBlock, g as SDKMethodInfoContent, h as SDKMethodInfo, i as ReferenceNestingContext, k as useReferenceNesting, l as SDKDeclaration, m as SDKMethodHeader, n as PropertyModelContext, o as SDKChildren, p as SDKMethod, r as PropertyModelContextType, s as SDKConstraints, t as DeclarationParentsContextType, u as SDKExample, v as SDKMethodProps, w as SDKSnippetLanguages, x as SDKReference, y as SDKModel } from "../sdk-BengV7mg.js";
2
+ export { DeclarationParentsContextType, PropertyModelContext, PropertyModelContextType, ReferenceNestingContext, ReferenceNestingContextType, SDKChildren, SDKConstraints, SDKConstraintsProps, SDKDeclaration, SDKExample, SDKIcon, SDKLanguageBlock, SDKMethod, SDKMethodHeader, SDKMethodInfo, SDKMethodInfoContent, SDKMethodNotImplemented, SDKMethodProps, SDKModel, SDKModelProps, SDKReference, SDKRequestTitle, SDKRequestTitleProps, SDKSnippetLanguages, SDKSnippetLanguagesType, TransformRequestSnippetFn, useDeclarationParents, usePropertyModel, useReferenceNesting, useStreamingResponse };
@@ -0,0 +1,487 @@
1
+ import { useAvailableLanguages, useContentPanelLayout, useDeclaration, useLanguage, useSettings, useSnippetIds, useSnippetResponse, useSpec } from "../contexts/docs.js";
2
+ import { useNavigation } from "../contexts/navigation.js";
3
+ import { useLanguageComponents } from "../contexts/index.js";
4
+ import { useComponents } from "../contexts/use-components.js";
5
+ import style_default from "../style.js";
6
+ import { LanguageNames, generateRoute, getLanguageSnippet, parseStainlessPath } from "../routing.js";
7
+ import { CLIIcon, CSharpIcon, CurlIcon, GithubIcon, GoIcon, JavaIcon, KotlinIcon, PHPIcon, PowershellIcon, PythonIcon, RubyIcon, TerraformIcon, TypescriptIcon } from "./icons.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 { BookOpenIcon, CopyIcon } from "lucide-react";
12
+ import { Button, Callout } from "@stainless-api/ui-primitives";
13
+ //#region src/components/sdk.tsx
14
+ const PropertyModelContext = React$1.createContext({});
15
+ function usePropertyModel() {
16
+ return React$1.use(PropertyModelContext);
17
+ }
18
+ const ReferenceNestingContext = React$1.createContext([]);
19
+ function useReferenceNesting() {
20
+ return React$1.use(ReferenceNestingContext);
21
+ }
22
+ const DeclarationParentsContext = React$1.createContext(/* @__PURE__ */ new Set());
23
+ const AddToDeclarationParents = ({ id, children }) => /* @__PURE__ */ jsx(DeclarationParentsContext, {
24
+ value: new Set([...useDeclarationParents(), id.replace(/(?<=> \(schema\))((?!> \(schema\) > ).)+$/, "")]),
25
+ children
26
+ });
27
+ function useDeclarationParents() {
28
+ return React$1.use(DeclarationParentsContext);
29
+ }
30
+ const SDKSnippetLanguages = {
31
+ "node.default": { name: "TypeScript" },
32
+ "typescript.default": { name: "TypeScript" },
33
+ "python.default": { name: "Python" },
34
+ "go.default": { name: "Go" },
35
+ "java.default": { name: "Java" },
36
+ "kotlin.default": { name: "Kotlin" },
37
+ "http.curl": { name: "cURL" },
38
+ "http.powershell": { name: "Powershell" },
39
+ "terraform.default": { name: "Terraform" },
40
+ "ruby.default": { name: "Ruby" },
41
+ "csharp.default": { name: "C#" },
42
+ "php.default": { name: "PHP" },
43
+ "cli.default": { name: "CLI tool" }
44
+ };
45
+ function SDKChildren({ paths, expand, depth }) {
46
+ const Docs = useComponents();
47
+ return /* @__PURE__ */ jsx("div", {
48
+ className: style_default.Properties,
49
+ children: paths.map((path, i) => /* @__PURE__ */ jsx(Docs.SDKDeclaration, {
50
+ path,
51
+ expand,
52
+ depth
53
+ }, i))
54
+ });
55
+ }
56
+ function normalizeDeclaration(raw, http) {
57
+ if (raw.kind === "JavaDeclProperty" && raw.type.kind === "JavaTypeString" && raw.constraints?.format === "binary") return {
58
+ ...raw,
59
+ type: {
60
+ kind: "JavaTypeReference",
61
+ typeName: "InputStream"
62
+ }
63
+ };
64
+ if (http?.kind === "HttpDeclProperty" && http.type.kind === "HttpTypeString" && http.constraints?.format === "binary") switch (raw.kind) {
65
+ case "CLISchemaProperty":
66
+ case "CLIFlag":
67
+ case "HttpDeclProperty": return {
68
+ ...raw,
69
+ type: {
70
+ kind: "HttpTypeBinary",
71
+ contentType: []
72
+ }
73
+ };
74
+ case "RubyDeclProperty": return {
75
+ ...raw,
76
+ type: {
77
+ kind: "RubyTypeBinary",
78
+ contentType: []
79
+ }
80
+ };
81
+ }
82
+ return raw;
83
+ }
84
+ function SDKDeclaration({ path, expand, depth = 0 }) {
85
+ const Lang = useLanguageComponents();
86
+ const Docs = useComponents();
87
+ let pendingDecl = normalizeDeclaration(useDeclaration(path, true), useDeclaration(path.replace(/ > \(schema\)$/, "") + " > (schema)", false, "http"));
88
+ const settings = useSettings();
89
+ const model = usePropertyModel();
90
+ const nesting = useReferenceNesting();
91
+ const { selectedPath, basePath } = useNavigation();
92
+ const parents = useDeclarationParents();
93
+ const language = useLanguage();
94
+ if (parents.has(path)) if (pendingDecl.kind === "GoDeclType") pendingDecl = {
95
+ ...pendingDecl,
96
+ kind: "GoDeclType",
97
+ type: {
98
+ kind: "GoTypeReference",
99
+ typeName: pendingDecl.ident,
100
+ $ref: pendingDecl.stainlessPath
101
+ },
102
+ children: []
103
+ };
104
+ else if (pendingDecl.kind === "HttpDeclTypeAlias") pendingDecl = {
105
+ ...pendingDecl,
106
+ kind: "HttpDeclTypeAlias",
107
+ children: []
108
+ };
109
+ else if (pendingDecl.kind === "PythonDeclClass") pendingDecl = {
110
+ kind: "PythonDeclType",
111
+ ident: pendingDecl.ident,
112
+ stainlessPath: pendingDecl.stainlessPath,
113
+ type: {
114
+ kind: "PythonTypeReference",
115
+ typeName: pendingDecl.ident,
116
+ $ref: pendingDecl.stainlessPath
117
+ }
118
+ };
119
+ else if (pendingDecl.kind === "TSDeclInterface") pendingDecl = {
120
+ kind: "TSDeclTypeAlias",
121
+ ident: pendingDecl.ident,
122
+ stainlessPath: pendingDecl.stainlessPath,
123
+ type: {
124
+ kind: "TSTypeReference",
125
+ ident: pendingDecl.ident,
126
+ $ref: pendingDecl.stainlessPath
127
+ }
128
+ };
129
+ else if ("ident" in pendingDecl) {
130
+ const ident = pendingDecl.ident;
131
+ const url = generateRoute(basePath ?? "/", language, pendingDecl.stainlessPath);
132
+ return /* @__PURE__ */ jsx("span", {
133
+ className: style_default.Type,
134
+ children: /* @__PURE__ */ jsx("span", {
135
+ className: style_default.TypeReference,
136
+ children: url ? /* @__PURE__ */ jsx("a", {
137
+ href: url,
138
+ children: ident
139
+ }) : ident
140
+ })
141
+ });
142
+ } else throw new Error("Infinite recursion in SDKDeclaration: " + JSON.stringify({
143
+ parents: [...parents],
144
+ path,
145
+ pendingDecl
146
+ }));
147
+ const decl = pendingDecl;
148
+ if (decl.kind.endsWith("Reference")) {
149
+ const refId = "type" in decl && decl.type !== void 0 && typeof decl.type !== "string" && "$ref" in decl.type ? decl.type["$ref"] : void 0;
150
+ if (refId && refId !== path && !nesting.includes(refId)) return /* @__PURE__ */ jsx(AddToDeclarationParents, {
151
+ id: path,
152
+ children: /* @__PURE__ */ jsx(ReferenceNestingContext, {
153
+ value: [...nesting, refId],
154
+ children: /* @__PURE__ */ jsx(SDKDeclaration, {
155
+ path: refId,
156
+ expand,
157
+ depth
158
+ })
159
+ })
160
+ });
161
+ }
162
+ const parsedPath = selectedPath ? parseStainlessPath(selectedPath) : null;
163
+ const modelPropSetting = settings?.properties?.includeModelProperties;
164
+ const inlineModelProps = modelPropSetting === "method-page" ? Boolean(parsedPath?.method) : modelPropSetting !== false;
165
+ const isUnion = "childrenParentSchema" in decl && !!decl.childrenParentSchema && decl.kind !== "CLIFlag" && decl.kind !== "CLISchemaProperty" && ["enum", "union"].includes(decl.childrenParentSchema);
166
+ const id = model?.propertyPath ? `${model.propertyPath} + ${path}` : path;
167
+ const shouldExpand = selectedPath?.startsWith(path) && nesting.length < 1 || settings?.properties?.expandDepth && depth <= settings?.properties?.expandDepth && !isUnion || expand;
168
+ 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));
169
+ const content = /* @__PURE__ */ jsx(Lang.Property, {
170
+ decl,
171
+ children: ({ ...props }) => /* @__PURE__ */ jsx(Docs.Property, {
172
+ id,
173
+ expand: shouldExpand,
174
+ constraints: "constraints" in decl && decl.kind !== "CLIFlag" && decl.kind !== "CLISchemaProperty" && /* @__PURE__ */ jsx(Docs.SDKConstraints, { constraints: decl["constraints"] }),
175
+ declaration: /* @__PURE__ */ jsx(Lang.Declaration, { decl }),
176
+ title: "title" in decl ? decl.title : void 0,
177
+ description: "docstring" in decl ? decl["docstring"] : void 0,
178
+ deprecated: decl.deprecated,
179
+ ...props,
180
+ children: hasChildren && /* @__PURE__ */ jsxs(Fragment$1, { children: [isUnion && /* @__PURE__ */ jsx("div", {
181
+ className: style_default.PropertyAnnotation,
182
+ children: "One of the following:"
183
+ }), /* @__PURE__ */ jsx(Docs.SDKChildren, {
184
+ paths: decl.children ?? [],
185
+ depth: depth + 1
186
+ })] })
187
+ })
188
+ });
189
+ if ("modelPath" in decl) return /* @__PURE__ */ jsx(AddToDeclarationParents, {
190
+ id: path,
191
+ children: /* @__PURE__ */ jsx(PropertyModelContext, {
192
+ value: {
193
+ modelPath: decl.modelPath,
194
+ propertyPath: decl.stainlessPath
195
+ },
196
+ children: content
197
+ })
198
+ });
199
+ return /* @__PURE__ */ jsx(AddToDeclarationParents, {
200
+ id: path,
201
+ children: content
202
+ });
203
+ }
204
+ function SDKConstraints({ constraints }) {
205
+ if (constraints) return /* @__PURE__ */ jsx("div", {
206
+ className: style_default.PropertyConstraints,
207
+ children: Object.entries(constraints).map(([name, value]) => name === "format" && value === "binary" ? null : /* @__PURE__ */ jsxs("div", {
208
+ className: style_default.PropertyConstraint,
209
+ children: [/* @__PURE__ */ jsx("span", {
210
+ className: style_default.PropertyConstraintName,
211
+ children: name
212
+ }), /* @__PURE__ */ jsx("span", {
213
+ className: style_default.PropertyConstraintValue,
214
+ children: value
215
+ })]
216
+ }, name))
217
+ });
218
+ }
219
+ const snippetIcons = {
220
+ "node.default": TypescriptIcon,
221
+ "typescript.default": TypescriptIcon,
222
+ "go.default": GoIcon,
223
+ "python.default": PythonIcon,
224
+ "terraform.default": TerraformIcon,
225
+ "http.curl": CurlIcon,
226
+ "http.powershell": PowershellIcon,
227
+ "ruby.default": RubyIcon,
228
+ "java.default": JavaIcon,
229
+ "kotlin.default": KotlinIcon,
230
+ "csharp.default": CSharpIcon,
231
+ "cli.default": CLIIcon,
232
+ "php.default": PHPIcon
233
+ };
234
+ function SDKIcon({ language }) {
235
+ const LangIcon = snippetIcons[language];
236
+ if (!LangIcon) return null;
237
+ return /* @__PURE__ */ jsx(LangIcon, { className: clsx(style_default.Icon, language.split(".").shift()) });
238
+ }
239
+ function SDKRequestTitle({ snippetLanguage }) {
240
+ const languageName = SDKSnippetLanguages[snippetLanguage]?.name;
241
+ return /* @__PURE__ */ jsxs("span", {
242
+ className: style_default.SnippetRequestTitleLanguage,
243
+ children: [
244
+ /* @__PURE__ */ jsx(SDKIcon, { language: snippetLanguage }),
245
+ " ",
246
+ languageName
247
+ ]
248
+ });
249
+ }
250
+ function SDKExample({ method, transformRequestSnippet }) {
251
+ const Docs = useComponents();
252
+ const language = useLanguage();
253
+ const snippetLanguage = getLanguageSnippet(language);
254
+ if ((useSnippetIds(method.stainlessPath, language)?.filter((id) => id !== "default")?.length ?? 0) >= 2) return /* @__PURE__ */ jsx(Docs.MultiSnippets, {
255
+ requestTitle: /* @__PURE__ */ jsx(Docs.SDKRequestTitle, { snippetLanguage }),
256
+ method
257
+ });
258
+ return /* @__PURE__ */ jsx(Docs.Snippet, {
259
+ requestTitle: /* @__PURE__ */ jsx(Docs.SDKRequestTitle, { snippetLanguage }),
260
+ method,
261
+ transformRequestSnippet
262
+ });
263
+ }
264
+ function SDKMethodHeader({ method }) {
265
+ const Docs = useComponents();
266
+ const Lang = useLanguageComponents();
267
+ const decl = useDeclaration(method.stainlessPath, true);
268
+ return /* @__PURE__ */ jsx(Docs.MethodHeader, {
269
+ level: "h1",
270
+ title: method.summary || method.title,
271
+ signature: /* @__PURE__ */ jsx(Lang.MethodSignature, { decl }),
272
+ badges: method.deprecated && /* @__PURE__ */ jsx(Docs.Badge, {
273
+ id: "deprecated",
274
+ children: "Deprecated"
275
+ }),
276
+ children: /* @__PURE__ */ jsx(Docs.MethodRoute, {
277
+ httpMethod: method.httpMethod,
278
+ endpoint: method.endpoint.split(" ", 2).at(-1)
279
+ })
280
+ });
281
+ }
282
+ function useStreamingResponse(method) {
283
+ const tsDecl = useDeclaration(method.stainlessPath, false, "typescript");
284
+ if (tsDecl?.kind === "TSDeclFunction" && tsDecl.overloads) {
285
+ 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") {
286
+ const id = e.returns.typeParameters?.[0].$ref;
287
+ if (id) return id;
288
+ }
289
+ }
290
+ }
291
+ function SDKMethodInfo({ method, children }) {
292
+ const Docs = useComponents();
293
+ const Lang = useLanguageComponents();
294
+ const decl = useDeclaration(method.stainlessPath, true);
295
+ const streamingResponseID = useStreamingResponse(method);
296
+ const streamingResponseDecl = useDeclaration(streamingResponseID ?? "", false);
297
+ const spec = useSpec();
298
+ const language = useLanguage();
299
+ if (Lang.MethodInfo) return /* @__PURE__ */ jsx(Lang.MethodInfo, {
300
+ decl,
301
+ children
302
+ });
303
+ function shouldExpand(items) {
304
+ if (items.length > 1) return false;
305
+ const item = items[0];
306
+ if (!item) return false;
307
+ const decl = spec?.decls?.[language]?.[item];
308
+ return decl && "children" in decl && decl.children && decl.children.length > 0;
309
+ }
310
+ const responseChildren = "responseChildren" in decl && decl.responseChildren && decl.responseChildren.length > 0 ? [...decl.responseChildren] : [];
311
+ if (streamingResponseDecl && streamingResponseID && !responseChildren.includes(streamingResponseID)) responseChildren.push(streamingResponseID);
312
+ return /* @__PURE__ */ jsx(Docs.MethodInfo, {
313
+ parameters: "paramsChildren" in decl && Array.isArray(decl.paramsChildren) && decl.paramsChildren.length > 0 && /* @__PURE__ */ jsx(Docs.SDKChildren, {
314
+ expand: shouldExpand(decl.paramsChildren),
315
+ paths: decl.paramsChildren
316
+ }),
317
+ returns: responseChildren.length > 0 && /* @__PURE__ */ jsx(Docs.SDKChildren, {
318
+ expand: shouldExpand(responseChildren),
319
+ paths: responseChildren
320
+ }),
321
+ children
322
+ });
323
+ }
324
+ function SDKMethodNotImplemented({ method }) {
325
+ const Docs = useComponents();
326
+ const languages = useAvailableLanguages(method?.stainlessPath);
327
+ const language = useLanguage();
328
+ const { basePath } = useNavigation();
329
+ const availableLanguageLinks = languages.flatMap((lang) => {
330
+ const url = generateRoute(basePath ?? "/", lang, method.stainlessPath);
331
+ return url ? [{
332
+ url,
333
+ label: LanguageNames[lang] ?? lang
334
+ }] : [];
335
+ });
336
+ return /* @__PURE__ */ jsxs("div", {
337
+ className: style_default.Method,
338
+ children: [/* @__PURE__ */ jsx(Docs.MethodHeader, {
339
+ level: "h1",
340
+ title: method.summary || method.title,
341
+ children: /* @__PURE__ */ jsx(Docs.MethodRoute, {
342
+ httpMethod: method.httpMethod,
343
+ endpoint: method.endpoint.split(" ", 2).at(-1)
344
+ })
345
+ }), /* @__PURE__ */ jsxs(Callout, {
346
+ variant: "warning",
347
+ children: [
348
+ "The method ",
349
+ /* @__PURE__ */ jsx("code", { children: method.name }),
350
+ " is not implemented in ",
351
+ LanguageNames[language] ?? language,
352
+ 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 }) => {
353
+ return /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx("a", {
354
+ href: url,
355
+ children: label
356
+ }) }, url);
357
+ }) })] }) : "."
358
+ ]
359
+ })]
360
+ });
361
+ }
362
+ function SDKMethodInfoContent(_props) {
363
+ return null;
364
+ }
365
+ function SDKMethod({ method, transformRequestSnippet }) {
366
+ const Docs = useComponents();
367
+ const decl = useDeclaration(method?.stainlessPath, false);
368
+ const layout = useContentPanelLayout();
369
+ const defaultResponses = useSnippetResponse(method.stainlessPath);
370
+ if (!decl) return /* @__PURE__ */ jsx(SDKMethodNotImplemented, { method });
371
+ return /* @__PURE__ */ jsxs(Docs.Method, {
372
+ id: method.stainlessPath,
373
+ header: /* @__PURE__ */ jsx(Docs.SDKMethodHeader, { method }),
374
+ className: clsx({
375
+ [style_default.MethodSinglePane]: layout === "single-pane",
376
+ [style_default.MethodDoublePane]: layout === "double-pane"
377
+ }),
378
+ children: [
379
+ /* @__PURE__ */ jsxs("div", {
380
+ className: style_default.MethodContentColumn,
381
+ children: [/* @__PURE__ */ jsx(Docs.MethodDescription, { description: method.description }), /* @__PURE__ */ jsx(Docs.SDKMethodInfo, {
382
+ method,
383
+ children: /* @__PURE__ */ jsx(Docs.SDKMethodInfoContent, { method })
384
+ })]
385
+ }),
386
+ /* @__PURE__ */ jsx("div", {
387
+ className: clsx(style_default.MethodExample, "not-content", "stl-ui-not-prose"),
388
+ children: /* @__PURE__ */ jsx(Docs.SDKExample, {
389
+ method,
390
+ transformRequestSnippet
391
+ })
392
+ }),
393
+ /* @__PURE__ */ jsxs("div", {
394
+ className: style_default.MethodResponseColumn,
395
+ children: [/* @__PURE__ */ jsx("h5", { children: "Returns Examples" }), /* @__PURE__ */ jsx(Docs.SnippetResponse, { responses: defaultResponses })]
396
+ })
397
+ ]
398
+ });
399
+ }
400
+ function SDKModel({ model }) {
401
+ const Docs = useComponents();
402
+ if (!useDeclaration(`${model.stainlessPath} > (schema)`, true)) return null;
403
+ return /* @__PURE__ */ jsx("div", {
404
+ className: style_default.Model,
405
+ tabIndex: 0,
406
+ children: /* @__PURE__ */ jsx("div", {
407
+ className: style_default.ResourceContentProperties,
408
+ children: /* @__PURE__ */ jsx(Docs.SDKDeclaration, { path: `${model.stainlessPath} > (schema)` })
409
+ })
410
+ });
411
+ }
412
+ function SDKReference({ stainlessPath, children }) {
413
+ const Docs = useComponents();
414
+ if (!stainlessPath || !stainlessPath.endsWith("(schema)")) return children;
415
+ return /* @__PURE__ */ jsx("span", {
416
+ className: style_default.TypeReference,
417
+ children: /* @__PURE__ */ jsx(Docs.Link, {
418
+ stainlessPath,
419
+ children
420
+ })
421
+ });
422
+ }
423
+ function SDKLanguageBlock({ language, version, install, links }) {
424
+ const Docs = useComponents();
425
+ const lang = `${language}.default`;
426
+ return /* @__PURE__ */ jsxs("div", {
427
+ className: style_default.LanguageBlock,
428
+ children: [
429
+ /* @__PURE__ */ jsxs("div", {
430
+ className: style_default.LanguageBlockContent,
431
+ children: [/* @__PURE__ */ jsx("div", {
432
+ className: style_default.LanguageBlockContentIcon,
433
+ children: /* @__PURE__ */ jsx(Docs.SDKIcon, {
434
+ language: lang,
435
+ size: 24
436
+ })
437
+ }), /* @__PURE__ */ jsxs("div", {
438
+ className: style_default.LanguageBlockContentInfo,
439
+ children: [/* @__PURE__ */ jsx("div", {
440
+ className: style_default.LanguageBlockContentInfoLanguage,
441
+ children: Docs.SDKSnippetLanguages[lang].name
442
+ }), /* @__PURE__ */ jsx("div", {
443
+ className: style_default.LanguageBlockContentInfoVersion,
444
+ children: version
445
+ })]
446
+ })]
447
+ }),
448
+ /* @__PURE__ */ jsxs("div", {
449
+ className: style_default.LanguageBlockInstall,
450
+ "data-stldocs-copy-parent": true,
451
+ children: [
452
+ /* @__PURE__ */ jsx("pre", {
453
+ "data-stldocs-copy-content": true,
454
+ children: install
455
+ }),
456
+ " ",
457
+ /* @__PURE__ */ jsx(Button, {
458
+ variant: "ghost",
459
+ size: "sm",
460
+ "data-stldocs-snippet-copy": true,
461
+ children: /* @__PURE__ */ jsx(CopyIcon, {
462
+ size: 16,
463
+ className: style_default.Icon
464
+ })
465
+ })
466
+ ]
467
+ }),
468
+ /* @__PURE__ */ jsxs("div", {
469
+ className: style_default.LanguageBlockLinks,
470
+ children: [/* @__PURE__ */ jsx(Button, {
471
+ href: links.repo,
472
+ variant: "outline",
473
+ children: /* @__PURE__ */ jsx(Button.Icon, {
474
+ icon: GithubIcon,
475
+ style: { color: "var(--stl-color-foreground-reduced)" }
476
+ })
477
+ }), /* @__PURE__ */ jsxs(Button, {
478
+ href: links.docs,
479
+ variant: "outline",
480
+ children: [/* @__PURE__ */ jsx(Button.Icon, { icon: BookOpenIcon }), /* @__PURE__ */ jsx(Button.Label, { children: "Read Docs" })]
481
+ })]
482
+ })
483
+ ]
484
+ });
485
+ }
486
+ //#endregion
487
+ export { PropertyModelContext, ReferenceNestingContext, SDKChildren, SDKConstraints, SDKDeclaration, SDKExample, SDKIcon, SDKLanguageBlock, SDKMethod, SDKMethodHeader, SDKMethodInfo, SDKMethodInfoContent, SDKMethodNotImplemented, SDKModel, SDKReference, SDKRequestTitle, SDKSnippetLanguages, useDeclarationParents, usePropertyModel, useReferenceNesting, useStreamingResponse };