@stainless-api/docs-ui 0.1.0-beta.48 → 0.1.0-beta.49

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 (160) hide show
  1. package/dist/{breadcrumbs-TNRag6Vy.d.ts → breadcrumbs-DEyC9k79.d.ts} +2 -2
  2. package/dist/breadcrumbs-nSFZO5Gf.js +63 -0
  3. package/dist/component-DRO8kQSp.js +23 -0
  4. package/dist/{component-generics-F0_Dx7UT.js → component-generics-B6Fn47Mz.js} +1 -1
  5. package/dist/{component-generics-Cs7jFHLq.d.ts → component-generics-COP53CRn.d.ts} +2 -2
  6. package/dist/component-generics-fyFHB6qA.d.ts +30 -0
  7. package/dist/components/MaskedInput.d.ts +1 -1
  8. package/dist/components/MaskedInput.js +1 -1
  9. package/dist/components/breadcrumbs.d.ts +1 -1
  10. package/dist/components/breadcrumbs.js +7 -9
  11. package/dist/components/icons.d.ts +11 -11
  12. package/dist/components/icons.js +1 -1
  13. package/dist/components/index.d.ts +9 -9
  14. package/dist/components/index.js +16 -9
  15. package/dist/components/method.d.ts +1 -1
  16. package/dist/components/method.js +8 -9
  17. package/dist/components/overview.d.ts +1 -1
  18. package/dist/components/overview.js +9 -9
  19. package/dist/components/primitives.d.ts +1 -1
  20. package/dist/components/primitives.js +6 -9
  21. package/dist/components/properties.d.ts +1 -1
  22. package/dist/components/properties.js +7 -9
  23. package/dist/components/sdk.d.ts +1 -1
  24. package/dist/components/sdk.js +8 -9
  25. package/dist/components/sidebar.d.ts +1 -1
  26. package/dist/components/sidebar.js +9 -9
  27. package/dist/components/snippets.d.ts +2 -2
  28. package/dist/components/snippets.js +7 -9
  29. package/dist/components-D7M-BwNI.js +71 -0
  30. package/dist/contexts/component-generics.d.ts +1 -1
  31. package/dist/contexts/component-generics.js +1 -1
  32. package/dist/contexts/component-types.d.ts +10 -10
  33. package/dist/contexts/component.d.ts +13 -13
  34. package/dist/contexts/component.js +25 -9
  35. package/dist/contexts/docs.d.ts +1 -1
  36. package/dist/contexts/docs.js +1 -1
  37. package/dist/contexts/index.d.ts +16 -17
  38. package/dist/contexts/index.js +6 -10
  39. package/dist/contexts/markdown.d.ts +1 -1
  40. package/dist/contexts/markdown.js +2 -2
  41. package/dist/contexts/navigation.d.ts +1 -1
  42. package/dist/contexts/navigation.js +1 -1
  43. package/dist/contexts/use-components.d.ts +9 -9
  44. package/dist/contexts/use-components.js +2 -2
  45. package/dist/contexts-p3rRZDlM.js +39 -0
  46. package/dist/csharp-CDSxfCZE.js +283 -0
  47. package/dist/docs-yYrp-uzs.d.ts +47 -0
  48. package/dist/go-1c3S5ETL.js +303 -0
  49. package/dist/http-2QNWXH9t.js +330 -0
  50. package/dist/{index-Dt1TxDPe.d.ts → index-BQpRynot.d.ts} +8 -8
  51. package/dist/{index-BPQVqZ6-.d.ts → index-CnilsjrJ.d.ts} +30 -30
  52. package/dist/index-Ct0NcQUK.d.ts +274 -0
  53. package/dist/{index-D_zoydBM.d.ts → index-D6NhcxHd.d.ts} +6 -7
  54. package/dist/index-LboM0f0c.d.ts +15 -0
  55. package/dist/index-avtZIGmX.d.ts +13 -0
  56. package/dist/index.d.ts +18 -19
  57. package/dist/index.js +27 -12
  58. package/dist/java-BbjF_oUI.js +403 -0
  59. package/dist/languages/csharp.d.ts +10 -10
  60. package/dist/languages/csharp.js +7 -9
  61. package/dist/languages/go.d.ts +10 -10
  62. package/dist/languages/go.js +7 -9
  63. package/dist/languages/http.d.ts +10 -10
  64. package/dist/languages/http.js +17 -9
  65. package/dist/languages/index.d.ts +10 -10
  66. package/dist/languages/index.js +24 -9
  67. package/dist/languages/java.d.ts +10 -10
  68. package/dist/languages/java.js +7 -9
  69. package/dist/languages/python.d.ts +10 -10
  70. package/dist/languages/python.js +7 -9
  71. package/dist/languages/ruby.d.ts +10 -10
  72. package/dist/languages/ruby.js +7 -9
  73. package/dist/languages/typescript.d.ts +10 -10
  74. package/dist/languages/typescript.js +7 -9
  75. package/dist/languages-BCYZjzuS.js +26 -0
  76. package/dist/markdown/index.d.ts +4 -3
  77. package/dist/markdown/index.js +103 -10
  78. package/dist/markdown/md.js +1 -1
  79. package/dist/markdown/printer.d.ts +2 -0
  80. package/dist/markdown/printer.js +28 -0
  81. package/dist/markdown/utils.d.ts +2 -2
  82. package/dist/markdown/utils.js +1 -1
  83. package/dist/{markdown-J4fsbXbi.d.ts → markdown-C8o8WrwG.d.ts} +2 -2
  84. package/dist/{markdown-Bx-mQFEj.js → markdown-CxdeWgjV.js} +1 -1
  85. package/dist/markdown-DA2cRtlr.d.ts +22 -0
  86. package/dist/{method-uqti5jIi.d.ts → method-B6eAtYl2.d.ts} +7 -7
  87. package/dist/method-CE08mUME.js +115 -0
  88. package/dist/{navigation-DztmhdsO.d.ts → navigation-BfAVGPgw.d.ts} +3 -3
  89. package/dist/navigation-CjBnMcop.d.ts +29 -0
  90. package/dist/{overview-CXiAiRu3.d.ts → overview-CswoJHww.d.ts} +6 -6
  91. package/dist/overview-DeZSiqFa.d.ts +39 -0
  92. package/dist/overview-S2hUqPXA.js +139 -0
  93. package/dist/primitives-BIWfwN5L.js +258 -0
  94. package/dist/{primitives-CS8fdjfv.d.ts → primitives-Caj5rKBc.d.ts} +9 -9
  95. package/dist/primitives-CbqXZ-5f.d.ts +97 -0
  96. package/dist/printer-DBw4S_Jn.d.ts +13 -0
  97. package/dist/printer-DVZVkqAr.d.ts +13 -0
  98. package/dist/printer-bNxiG6UB.js +74 -0
  99. package/dist/{properties-Bf600pp5.d.ts → properties-BkUlpvU4.d.ts} +5 -5
  100. package/dist/properties-jlGW3USi.js +131 -0
  101. package/dist/python-USOwFDv_.js +279 -0
  102. package/dist/{routing-BcGPNh2R.d.ts → routing-CMqh1cTZ.d.ts} +1 -1
  103. package/dist/routing-Dhmv52Fd.d.ts +54 -0
  104. package/dist/{routing-BGBmkDBL.js → routing-Wbb7YECB.js} +1 -1
  105. package/dist/routing.d.ts +1 -1
  106. package/dist/routing.js +1 -1
  107. package/dist/ruby-CSvGbSLe.js +387 -0
  108. package/dist/{sdk-CuOpWo9I.d.ts → sdk-BOwYR0k6.d.ts} +14 -14
  109. package/dist/sdk-CSCbbn3O.js +336 -0
  110. package/dist/sdk-CdhDsvo3.d.ts +118 -0
  111. package/dist/{sidebar-CqfIoVcr.d.ts → sidebar-BXz93vSy.d.ts} +5 -5
  112. package/dist/sidebar-CWyvCrJ0.js +81 -0
  113. package/dist/snippets-BQLXEIf6.js +161 -0
  114. package/dist/{snippets-BwifQYD4.d.ts → snippets-CbVFNmfq.d.ts} +8 -8
  115. package/dist/snippets-Wjo2dJNw.d.ts +51 -0
  116. package/dist/spec.d.ts +3 -3
  117. package/dist/spec.js +2 -2
  118. package/dist/style.d.ts +1 -1
  119. package/dist/style.js +1 -1
  120. package/dist/styles/resets.css +2 -1
  121. package/dist/styles.css +7 -3
  122. package/dist/typescript-DXG9psK3.js +449 -0
  123. package/dist/{use-components-BAHidYIO.js → use-components-RWQbviGq.js} +1 -1
  124. package/dist/{utils-DAOeBdRL.d.ts → utils-CTGH5e8c.d.ts} +2 -2
  125. package/dist/utils-DNKOwa7D.d.ts +21 -0
  126. package/dist/{utils-0z34vxY4.js → utils-D_1AWSRX.js} +2 -2
  127. package/dist/utils.d.ts +1 -1
  128. package/dist/utils.js +1 -1
  129. package/package.json +6 -20
  130. package/dist/contexts/search.d.ts +0 -2
  131. package/dist/contexts/search.js +0 -11
  132. package/dist/contexts-D3ClFTt3.js +0 -4117
  133. package/dist/pagefind-BHm6c3fb.js +0 -15
  134. package/dist/search/index.d.ts +0 -25
  135. package/dist/search/index.js +0 -332
  136. package/dist/search/mcp.d.ts +0 -13
  137. package/dist/search/mcp.js +0 -43
  138. package/dist/search/providers/algolia.d.ts +0 -24
  139. package/dist/search/providers/algolia.js +0 -11
  140. package/dist/search/providers/fuse.d.ts +0 -18
  141. package/dist/search/providers/fuse.js +0 -27
  142. package/dist/search/providers/pagefind.d.ts +0 -6
  143. package/dist/search/providers/pagefind.js +0 -3
  144. package/dist/search/providers/walker.d.ts +0 -9
  145. package/dist/search/providers/walker.js +0 -31
  146. package/dist/search/types.d.ts +0 -2
  147. package/dist/search/types.js +0 -3
  148. package/dist/search-DvzBAFUW.d.ts +0 -21
  149. package/dist/types-9YHj_ZeX.d.ts +0 -91
  150. package/dist/types-mRzd9aqe.js +0 -35
  151. /package/dist/{chunk-BWfJHHBp.js → chunk-DRcLgZ1e.js} +0 -0
  152. /package/dist/{docs-DGpIHBGY.d.ts → docs-B8-nCRaa.d.ts} +0 -0
  153. /package/dist/{docs-CNvEp0VL.js → docs-CXqi26jB.js} +0 -0
  154. /package/dist/{icons-DzBceOQw.js → icons-Ckod9aod.js} +0 -0
  155. /package/dist/{md-D5AxFoS4.js → md-oM2tUaCA.js} +0 -0
  156. /package/dist/{navigation-bydkHNUW.js → navigation-C5TN0SgC.js} +0 -0
  157. /package/dist/{style-D8hwSwrv.d.ts → style-D7RO5ymE.d.ts} +0 -0
  158. /package/dist/{style-0miv2y38.js → style-gnVEeXFj.js} +0 -0
  159. /package/dist/{utils-CiZXDoFR.js → utils-CqnL9Fc3.js} +0 -0
  160. /package/dist/{utils-BcWczffA.d.ts → utils-d8paVwKN.d.ts} +0 -0
@@ -1,4117 +0,0 @@
1
- import { t as __export } from "./chunk-BWfJHHBp.js";
2
- import { a as useLanguage, c as useSnippet, i as useDocs, l as useSpec, n as useContentPanelLayout, o as useResource, r as useDeclaration, s as useSettings, t as DocsProvider } from "./docs-CNvEp0VL.js";
3
- import { a as createStrictContext, i as useComponents$1, n as customizeComponents, r as useComponentContext, t as ComponentProvider$1 } from "./component-generics-F0_Dx7UT.js";
4
- import { n as useNavigation, t as NavigationProvider } from "./navigation-bydkHNUW.js";
5
- import { a as useRenderMarkdown, i as useMarkdownContext, n as MarkdownProvider, r as useHighlight, t as MarkdownContext } from "./markdown-Bx-mQFEj.js";
6
- import { _ as walkTree, c as getLanguageSnippet, f as parseStainlessPath, n as Languages, o as generateRoute, t as LanguageNames } from "./routing-BGBmkDBL.js";
7
- import { t as style_default } from "./style-0miv2y38.js";
8
- import { t as useComponents } from "./use-components-BAHidYIO.js";
9
- import { a as KotlinIcon, c as RubyIcon, i as JavaIcon, l as TerraformIcon, n as CurlIcon, o as PowershellIcon, r as GoIcon, s as PythonIcon, t as CSharpIcon, u as TypescriptIcon } from "./icons-DzBceOQw.js";
10
- import { n as getResourceFromSpec, r as isResourceEmpty, t as flatResources } from "./utils-0z34vxY4.js";
11
- import { a as item, c as parse, l as strong, n as fence, o as list, r as heading, s as paragraph, t as code, u as text } from "./md-D5AxFoS4.js";
12
- import { n as getSnippet, r as stripMarkup, t as getDecl } from "./utils-CiZXDoFR.js";
13
- import { i as SearchableAttributesProse, n as SearchableAttributes, r as SearchableAttributesChat } from "./types-mRzd9aqe.js";
14
- import * as React$1 from "react";
15
- import React, { Fragment, createElement, useState } from "react";
16
- import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
17
- import { searchClient } from "@algolia/client-search";
18
- import { renderToStaticMarkup } from "react-dom/server";
19
- import { ArrowDownLeft, ArrowDownWideNarrowIcon, ArrowUpNarrowWideIcon, ArrowUpRight, BookOpen, CheckIcon, ChevronDown, ChevronRight, CircleAlertIcon, Copy, CopyIcon, Github, MinusIcon, PlusIcon, X } from "lucide-react";
20
- import clsx from "clsx";
21
- import { Button, Callout } from "@stainless-api/ui-primitives";
22
- import Markdoc from "@markdoc/markdoc";
23
-
24
- //#region src/components/properties.tsx
25
- function PropertyToggle({ target }) {
26
- return /* @__PURE__ */ jsxs("span", {
27
- className: style_default.ExpandToggle,
28
- "data-stldocs-property-toggle-expanded": "false",
29
- "data-stldocs-property-toggle-target": target,
30
- children: [/* @__PURE__ */ jsxs("span", {
31
- className: style_default.ExpandToggleContent,
32
- children: ["Expand ", /* @__PURE__ */ jsx(ArrowDownWideNarrowIcon, {
33
- className: style_default.Icon,
34
- size: 16
35
- })]
36
- }), /* @__PURE__ */ jsxs("span", {
37
- className: style_default.ExpandToggleContent,
38
- children: ["Collapse ", /* @__PURE__ */ jsx(ArrowUpNarrowWideIcon, {
39
- className: style_default.Icon,
40
- size: 16
41
- })]
42
- })]
43
- });
44
- }
45
- function PropertyDescription({ description }) {
46
- const { Markdown: Markdown$1 } = useComponents();
47
- if (description) return /* @__PURE__ */ jsx("div", {
48
- className: style_default.PropertyDescription,
49
- children: /* @__PURE__ */ jsx(Markdown$1, { content: description })
50
- });
51
- }
52
- function PropertyTitle({ title }) {
53
- const { Markdown: Markdown$1 } = useComponents();
54
- if (title) return /* @__PURE__ */ jsx("div", {
55
- className: style_default.PropertyTitle,
56
- children: /* @__PURE__ */ jsx(Markdown$1, { content: title })
57
- });
58
- }
59
- function Property$7({ id, name, typeName: typeName$1, badges, type, declaration: declaration$2, description, title, deprecated, expand, additional, constraints, children }) {
60
- const Docs = useComponents();
61
- const language = useLanguage();
62
- const properties = useSettings()?.properties;
63
- const { collapseDescription, showTitle } = properties ?? {};
64
- const types = properties?.types;
65
- const textContent = /* @__PURE__ */ jsxs(Fragment$1, { children: [
66
- typeof deprecated === "string" && /* @__PURE__ */ jsx("div", {
67
- className: style_default.PropertyDeprecatedMessage,
68
- children: deprecated
69
- }),
70
- description && /* @__PURE__ */ jsx(Docs.PropertyDescription, { description }),
71
- constraints && /* @__PURE__ */ jsx("div", {
72
- className: style_default.PropertyContent,
73
- children: constraints
74
- })
75
- ] });
76
- const rich = /* @__PURE__ */ jsxs(Fragment$1, { children: [
77
- /* @__PURE__ */ jsxs("div", {
78
- className: style_default.PropertyDeclaration,
79
- children: [
80
- deprecated && /* @__PURE__ */ jsx("span", {
81
- className: style_default.PropertyDeprecated,
82
- children: "Deprecated"
83
- }),
84
- declaration$2,
85
- badges && /* @__PURE__ */ jsx("span", {
86
- className: style_default.PropertyBadges,
87
- children: badges
88
- })
89
- ]
90
- }),
91
- title && showTitle && /* @__PURE__ */ jsx(Docs.PropertyTitle, { title }),
92
- collapseDescription === false ? textContent : null
93
- ] });
94
- const simple = /* @__PURE__ */ jsxs(Fragment$1, { children: [
95
- name && /* @__PURE__ */ jsxs("div", {
96
- className: style_default.PropertyHeader,
97
- children: [
98
- deprecated && /* @__PURE__ */ jsx("span", {
99
- className: style_default.PropertyDeprecated,
100
- children: "Deprecated"
101
- }),
102
- name && /* @__PURE__ */ jsx("span", {
103
- className: style_default.PropertyName,
104
- children: name
105
- }),
106
- typeName$1 && /* @__PURE__ */ jsx("span", {
107
- className: style_default.PropertyTypeName,
108
- children: typeName$1
109
- }),
110
- badges && /* @__PURE__ */ jsx("span", {
111
- className: style_default.PropertyBadges,
112
- children: badges
113
- })
114
- ]
115
- }),
116
- type && /* @__PURE__ */ jsx("div", {
117
- className: style_default.PropertyType,
118
- children: type
119
- }),
120
- title && showTitle && /* @__PURE__ */ jsx(Docs.PropertyTitle, { title }),
121
- collapseDescription === false ? textContent : null
122
- ] });
123
- const content = /* @__PURE__ */ jsx("div", {
124
- id,
125
- className: style_default.PropertyInfo,
126
- children: types === "simple" ? simple : rich
127
- });
128
- return /* @__PURE__ */ jsx("div", {
129
- className: style_default.Property,
130
- "data-stldocs-language": language,
131
- children: children || collapseDescription !== false && description ? /* @__PURE__ */ jsxs(Docs.Expander, {
132
- summary: content,
133
- muted: !children,
134
- open: expand,
135
- children: [
136
- collapseDescription !== false ? textContent : null,
137
- additional,
138
- children && /* @__PURE__ */ jsx("div", {
139
- className: style_default.PropertyChildren,
140
- children
141
- })
142
- ]
143
- }) : content
144
- });
145
- }
146
-
147
- //#endregion
148
- //#region src/components/method.tsx
149
- const HttpMethods = [
150
- "get",
151
- "head",
152
- "put",
153
- "delete",
154
- "post",
155
- "patch"
156
- ];
157
- const HttpMethodIcons = {
158
- get: ArrowDownLeft,
159
- put: ArrowUpRight,
160
- post: ArrowUpRight,
161
- patch: ArrowUpRight,
162
- delete: X
163
- };
164
- function MethodIconBadge({ httpMethod, showName }) {
165
- if (!httpMethod || !HttpMethods.includes(httpMethod)) return null;
166
- return /* @__PURE__ */ jsxs("span", {
167
- className: clsx(style_default.MethodRouteHttpMethod, style_default.MethodRouteHttpMethodIconOnly),
168
- "data-method": httpMethod,
169
- children: [HttpMethodIcons[httpMethod] && React$1.createElement(HttpMethodIcons[httpMethod], {
170
- size: 14,
171
- strokeWidth: 3,
172
- className: style_default.Icon
173
- }), showName && httpMethod]
174
- });
175
- }
176
- function MethodHeader({ title, badges, signature, children, level }) {
177
- const Heading = level ?? "h5";
178
- return /* @__PURE__ */ jsxs("div", {
179
- className: style_default.MethodHeader,
180
- children: [
181
- /* @__PURE__ */ jsx(Heading, {
182
- className: style_default.MethodTitle,
183
- children: title
184
- }),
185
- badges && /* @__PURE__ */ jsx("div", {
186
- className: style_default.MethodBadges,
187
- children: badges
188
- }),
189
- signature,
190
- children
191
- ]
192
- });
193
- }
194
- function MethodRoute({ httpMethod, endpoint, iconOnly }) {
195
- return /* @__PURE__ */ jsxs("div", {
196
- className: style_default.MethodRoute,
197
- children: [/* @__PURE__ */ jsx(MethodIconBadge, {
198
- httpMethod,
199
- showName: !iconOnly
200
- }), endpoint && /* @__PURE__ */ jsx("span", {
201
- className: style_default.MethodRouteEndpoint,
202
- children: endpoint
203
- })]
204
- });
205
- }
206
- function MethodDescription({ description }) {
207
- const { Markdown: Markdown$1 } = useComponents();
208
- if (description) return /* @__PURE__ */ jsx("div", {
209
- className: style_default.MethodDescription,
210
- children: /* @__PURE__ */ jsx(Markdown$1, { content: description })
211
- });
212
- }
213
- function MethodInfo$1({ children, parameters, returns }) {
214
- return /* @__PURE__ */ jsxs("div", {
215
- className: style_default.MethodInfo,
216
- children: [
217
- children && /* @__PURE__ */ jsx("div", {
218
- className: style_default.MethodContent,
219
- children
220
- }),
221
- parameters && /* @__PURE__ */ jsxs("div", {
222
- className: style_default.MethodInfoSection,
223
- children: [/* @__PURE__ */ jsxs("h5", { children: ["Parameters", /* @__PURE__ */ jsx(PropertyToggle, { target: "parameters" })] }), /* @__PURE__ */ jsx("div", {
224
- className: style_default.MethodParameters,
225
- "data-stldocs-property-group": "parameters",
226
- children: parameters
227
- })]
228
- }),
229
- returns && /* @__PURE__ */ jsxs("div", {
230
- className: style_default.MethodInfoSection,
231
- children: [/* @__PURE__ */ jsxs("h5", { children: ["Returns", /* @__PURE__ */ jsx(PropertyToggle, { target: "returns" })] }), /* @__PURE__ */ jsx("div", {
232
- className: style_default.MethodReturns,
233
- "data-stldocs-property-group": "returns",
234
- children: returns
235
- })]
236
- })
237
- ]
238
- });
239
- }
240
- function Method({ id, header, children, className, ...props }) {
241
- return /* @__PURE__ */ jsxs("div", {
242
- id,
243
- className: clsx(style_default.Method, className),
244
- tabIndex: 0,
245
- ...props,
246
- children: [header, /* @__PURE__ */ jsx("div", {
247
- className: style_default.MethodBody,
248
- children
249
- })]
250
- });
251
- }
252
-
253
- //#endregion
254
- //#region src/components/primitives.tsx
255
- function Join({ items, limit, children }) {
256
- return (limit && items.length > limit + 1 ? [...items.slice(0, limit), /* @__PURE__ */ jsxs("span", {
257
- className: style_default.Truncation,
258
- children: [items.length - limit, " more"]
259
- }, "truncation")] : items).map((item$1, index) => /* @__PURE__ */ jsxs(Fragment, { children: [!!index && children, item$1] }, `iterator:${index}`));
260
- }
261
- function Expander({ id, open, summary, virtual, muted, children }) {
262
- const virtualExpanders = useSettings()?.virtualExpanders;
263
- if (virtual || virtualExpanders) return /* @__PURE__ */ jsx(VirtualExpander, {
264
- summary,
265
- open,
266
- muted,
267
- id,
268
- children
269
- });
270
- return /* @__PURE__ */ jsxs("details", {
271
- className: style_default.Expander,
272
- open,
273
- "data-stldocs-expander-muted": muted,
274
- "data-stldocs-expander-initial-state": open,
275
- children: [/* @__PURE__ */ jsxs("summary", {
276
- className: style_default.ExpanderSummary,
277
- children: [/* @__PURE__ */ jsxs("div", {
278
- className: style_default.ExpanderSummaryIcon,
279
- children: [/* @__PURE__ */ jsx(PlusIcon, {
280
- size: 16,
281
- strokeWidth: 1,
282
- className: style_default.Icon
283
- }), /* @__PURE__ */ jsx(MinusIcon, {
284
- size: 16,
285
- strokeWidth: 1,
286
- className: style_default.Icon
287
- })]
288
- }), /* @__PURE__ */ jsx("div", {
289
- className: style_default.ExpanderSummaryContent,
290
- children: summary
291
- })]
292
- }), /* @__PURE__ */ jsx("div", {
293
- className: style_default.ExpanderContent,
294
- id,
295
- children
296
- })]
297
- });
298
- }
299
- function VirtualExpander({ id, open: isOpen, muted, summary, children }) {
300
- const [open, setOpen] = useState(isOpen);
301
- React$1.useEffect(() => {
302
- if (isOpen) setOpen(true);
303
- }, [isOpen]);
304
- return /* @__PURE__ */ jsxs("div", {
305
- className: style_default.Expander,
306
- "data-open": open,
307
- "data-stldocs-expander-muted": muted,
308
- "data-stldocs-expander-initial-state": open,
309
- children: [/* @__PURE__ */ jsxs("div", {
310
- className: style_default.ExpanderSummary,
311
- onClick: () => setOpen(!open),
312
- children: [/* @__PURE__ */ jsxs("div", {
313
- className: style_default.ExpanderSummaryIcon,
314
- children: [/* @__PURE__ */ jsx(PlusIcon, {
315
- size: 16,
316
- className: style_default.Icon
317
- }), /* @__PURE__ */ jsx(MinusIcon, {
318
- size: 16,
319
- className: style_default.Icon
320
- })]
321
- }), /* @__PURE__ */ jsx("div", {
322
- className: style_default.ExpanderSummaryContent,
323
- children: summary
324
- })]
325
- }), open && /* @__PURE__ */ jsx("div", {
326
- className: style_default.ExpanderContent,
327
- id,
328
- children
329
- })]
330
- });
331
- }
332
- function Markdown({ content }) {
333
- const rendered = useRenderMarkdown(content);
334
- return rendered && /* @__PURE__ */ jsx("div", {
335
- className: clsx(style_default.Markdown, style_default.Content, "stl-ui-prose"),
336
- dangerouslySetInnerHTML: { __html: rendered }
337
- });
338
- }
339
- function Badge({ id, children }) {
340
- return /* @__PURE__ */ jsx("span", {
341
- className: style_default.Badge,
342
- "data-badge-id": id,
343
- children: children ?? id
344
- });
345
- }
346
- const TooltipNestingContext = React$1.createContext(false);
347
- function Tooltip({ content, children }) {
348
- if (React$1.useContext(TooltipNestingContext)) return children;
349
- return /* @__PURE__ */ jsxs("span", {
350
- className: style_default.Tooltip,
351
- children: [/* @__PURE__ */ jsx("span", {
352
- className: style_default.TooltipContent,
353
- children: /* @__PURE__ */ jsx(TooltipNestingContext.Provider, {
354
- value: true,
355
- children: content
356
- })
357
- }), /* @__PURE__ */ jsx("span", {
358
- className: style_default.TooltipHost,
359
- children
360
- })]
361
- });
362
- }
363
- function Link({ stainlessPath, scroll = true, children, ...props }) {
364
- const { basePath, onNavigate } = useNavigation();
365
- const language = useLanguage();
366
- const href = React$1.useMemo(() => {
367
- if (props.href) return props.href;
368
- if (stainlessPath && basePath) return generateRoute(basePath, language, stainlessPath);
369
- }, [
370
- basePath,
371
- language,
372
- stainlessPath,
373
- props.href
374
- ]);
375
- const handleClick = React$1.useCallback((e) => {
376
- if (props.onClick) props.onClick(e);
377
- if (e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) return;
378
- if (href) onNavigate?.(e, {
379
- href,
380
- language,
381
- stainlessPath,
382
- scroll
383
- });
384
- }, [
385
- href,
386
- scroll,
387
- onNavigate,
388
- language,
389
- props,
390
- stainlessPath
391
- ]);
392
- if (!href) return children;
393
- return /* @__PURE__ */ jsx("a", {
394
- href,
395
- onClick: handleClick,
396
- ...props,
397
- children
398
- });
399
- }
400
- const Input = React$1.forwardRef(function Input$1({ left, right, ...props }, ref) {
401
- return /* @__PURE__ */ jsxs("div", {
402
- className: style_default.Input,
403
- children: [
404
- left,
405
- /* @__PURE__ */ jsx("input", {
406
- ...props,
407
- ref,
408
- className: style_default.InputTextField
409
- }),
410
- right
411
- ]
412
- });
413
- });
414
- const ToggleButton = React$1.forwardRef(function ToggleButton$1({ children, selected, ...props }, ref) {
415
- return /* @__PURE__ */ jsx("button", {
416
- ...props,
417
- ref,
418
- className: style_default.ToggleButton,
419
- "data-stldocs-toggle-selected": selected,
420
- children
421
- });
422
- });
423
- function ListView({ items, itemDelegate, onSelectListItem, ...rest }) {
424
- const [selectedIndex, setSelectedIndex] = React$1.useState(0);
425
- const [keyboardIndex, setKeyboardIndex] = React$1.useState(0);
426
- const listRef = React$1.useRef(null);
427
- const itemRef = React$1.useRef(null);
428
- React$1.useEffect(() => {
429
- setSelectedIndex(0);
430
- setKeyboardIndex(0);
431
- }, [items]);
432
- const handleSelect = React$1.useCallback(() => {
433
- const item$1 = items[selectedIndex];
434
- if (item$1) onSelectListItem?.(item$1);
435
- }, [
436
- items,
437
- selectedIndex,
438
- onSelectListItem
439
- ]);
440
- React$1.useEffect(() => {
441
- function handleKeyPress(ev) {
442
- switch (ev.key) {
443
- case "ArrowUp": {
444
- ev.preventDefault();
445
- const value = Math.max(0, selectedIndex - 1);
446
- setSelectedIndex(value);
447
- setKeyboardIndex(value);
448
- break;
449
- }
450
- case "ArrowDown": {
451
- ev.preventDefault();
452
- const value = Math.min(items.length, selectedIndex + 1);
453
- setSelectedIndex(value);
454
- setKeyboardIndex(value);
455
- break;
456
- }
457
- case "Enter":
458
- ev.preventDefault();
459
- handleSelect();
460
- break;
461
- }
462
- }
463
- addEventListener("keydown", handleKeyPress);
464
- return () => removeEventListener("keydown", handleKeyPress);
465
- }, [
466
- items,
467
- selectedIndex,
468
- handleSelect
469
- ]);
470
- React$1.useEffect(() => {
471
- if (!keyboardIndex || !itemRef.current || !listRef.current) {
472
- listRef?.current?.scroll(0, 0);
473
- return;
474
- }
475
- const selectedBounds = itemRef.current.getBoundingClientRect();
476
- const listBounds = listRef.current.getBoundingClientRect();
477
- if (selectedBounds.top < listBounds.top || selectedBounds.bottom > listBounds.bottom) itemRef.current.scrollIntoView({ block: "nearest" });
478
- }, [
479
- keyboardIndex,
480
- items,
481
- listRef
482
- ]);
483
- return /* @__PURE__ */ jsx("div", {
484
- ref: listRef,
485
- className: style_default.ListView,
486
- tabIndex: 0,
487
- ...rest,
488
- children: items.map((item$1, index) => /* @__PURE__ */ jsx("div", {
489
- ref: index === selectedIndex ? itemRef : null,
490
- className: style_default.ListViewItem,
491
- "data-stldocs-listview-selected": index === selectedIndex,
492
- onClick: handleSelect,
493
- onMouseMove: () => setSelectedIndex(index),
494
- children: itemDelegate(item$1, index === selectedIndex)
495
- }, index))
496
- });
497
- }
498
-
499
- //#endregion
500
- //#region src/components/sdk.tsx
501
- const PropertyModelContext = React$1.createContext({});
502
- function usePropertyModel() {
503
- return React$1.useContext(PropertyModelContext);
504
- }
505
- const ReferenceNestingContext = React$1.createContext([]);
506
- function useReferenceNesting() {
507
- return React$1.useContext(ReferenceNestingContext);
508
- }
509
- const SDKSnippetLanguages = {
510
- "node.default": { name: "TypeScript" },
511
- "typescript.default": { name: "TypeScript" },
512
- "python.default": { name: "Python" },
513
- "go.default": { name: "Go" },
514
- "java.default": { name: "Java" },
515
- "kotlin.default": { name: "Kotlin" },
516
- "http.curl": { name: "cURL" },
517
- "http.powershell": { name: "Powershell" },
518
- "terraform.default": { name: "Terraform" },
519
- "ruby.default": { name: "Ruby" },
520
- "csharp.default": { name: "C#" },
521
- "php.default": { name: "PHP" }
522
- };
523
- function SDKChildren({ paths, expand, depth }) {
524
- const Docs = useComponents();
525
- return /* @__PURE__ */ jsx("div", {
526
- className: style_default.Properties,
527
- children: paths.map((path, i) => /* @__PURE__ */ jsx(Docs.SDKDeclaration, {
528
- path,
529
- expand,
530
- depth
531
- }, i))
532
- });
533
- }
534
- function SDKDeclaration({ path, expand, depth = 0 }) {
535
- const Lang = useLanguageComponents();
536
- const Docs = useComponents();
537
- const decl = useDeclaration(path, true);
538
- const settings = useSettings();
539
- const model = usePropertyModel();
540
- const nesting = useReferenceNesting();
541
- const { selectedPath } = useNavigation();
542
- if (decl.kind.endsWith("Reference")) {
543
- const refId = "type" in decl && typeof decl.type !== "string" && "$ref" in decl.type ? decl.type["$ref"] : void 0;
544
- if (refId && refId !== path && !nesting.includes(refId)) return /* @__PURE__ */ jsx(ReferenceNestingContext.Provider, {
545
- value: [...nesting, refId],
546
- children: /* @__PURE__ */ jsx(SDKDeclaration, {
547
- path: refId,
548
- expand,
549
- depth
550
- })
551
- });
552
- }
553
- const isUnion = "childrenParentSchema" in decl && decl.childrenParentSchema && ["enum", "union"].includes(decl.childrenParentSchema);
554
- const id = model?.propertyPath ? `${model.propertyPath} + ${path}` : path;
555
- const shouldExpand = selectedPath?.startsWith(path) && nesting.length < 1 || settings?.properties?.expandDepth && depth <= settings?.properties?.expandDepth && !isUnion || expand;
556
- const content = /* @__PURE__ */ jsx(Lang.Property, {
557
- decl,
558
- children: ({ ...props }) => /* @__PURE__ */ jsx(Docs.Property, {
559
- id,
560
- expand: shouldExpand,
561
- constraints: "constraints" in decl && /* @__PURE__ */ jsx(Docs.SDKConstraints, { constraints: decl["constraints"] }),
562
- declaration: /* @__PURE__ */ jsx(Lang.Declaration, { decl }),
563
- title: "title" in decl ? decl.title : void 0,
564
- description: "docstring" in decl ? decl["docstring"] : void 0,
565
- deprecated: decl.deprecated,
566
- ...props,
567
- children: "children" in decl && (decl.children?.length ?? 0) > 0 && !decl.children?.includes(path) && (settings?.properties?.includeModelProperties !== false || !("modelPath" in decl)) && /* @__PURE__ */ jsxs(Fragment$1, { children: [isUnion && /* @__PURE__ */ jsx("div", {
568
- className: style_default.PropertyAnnotation,
569
- children: "Accepts one of the following:"
570
- }), /* @__PURE__ */ jsx(Docs.SDKChildren, {
571
- paths: decl.children ?? [],
572
- depth: depth + 1
573
- })] })
574
- })
575
- });
576
- if ("modelPath" in decl) {
577
- const value = {
578
- modelPath: decl.modelPath,
579
- propertyPath: decl.stainlessPath
580
- };
581
- return /* @__PURE__ */ jsx(PropertyModelContext.Provider, {
582
- value,
583
- children: content
584
- });
585
- }
586
- return content;
587
- }
588
- function SDKConstraints({ constraints }) {
589
- if (constraints) return /* @__PURE__ */ jsx("div", {
590
- className: style_default.PropertyConstraints,
591
- children: Object.entries(constraints).map(([name, value]) => /* @__PURE__ */ jsxs("div", {
592
- className: style_default.PropertyConstraint,
593
- children: [/* @__PURE__ */ jsx("span", {
594
- className: style_default.PropertyConstraintName,
595
- children: name
596
- }), /* @__PURE__ */ jsx("span", {
597
- className: style_default.PropertyConstraintValue,
598
- children: value
599
- })]
600
- }, name))
601
- });
602
- }
603
- const snippetIcons = {
604
- "node.default": TypescriptIcon,
605
- "typescript.default": TypescriptIcon,
606
- "go.default": GoIcon,
607
- "python.default": PythonIcon,
608
- "terraform.default": TerraformIcon,
609
- "http.curl": CurlIcon,
610
- "http.powershell": PowershellIcon,
611
- "ruby.default": RubyIcon,
612
- "java.default": JavaIcon,
613
- "kotlin.default": KotlinIcon,
614
- "csharp.default": CSharpIcon,
615
- "php.default": CSharpIcon
616
- };
617
- function SDKIcon({ language }) {
618
- const LangIcon = snippetIcons[language];
619
- if (!LangIcon) return null;
620
- return /* @__PURE__ */ jsx(LangIcon, { className: clsx(style_default.Icon, language.split(".").shift()) });
621
- }
622
- function SDKRequestTitle({ snippetLanguage }) {
623
- const languageName = SDKSnippetLanguages[snippetLanguage]?.name;
624
- return /* @__PURE__ */ jsxs("span", {
625
- className: style_default.SnippetRequestTitleLanguage,
626
- children: [
627
- /* @__PURE__ */ jsx(SDKIcon, { language: snippetLanguage }),
628
- " ",
629
- languageName
630
- ]
631
- });
632
- }
633
- function SDKExample({ method, transformRequestSnippet }) {
634
- const Docs = useComponents();
635
- const snippetLanguage = getLanguageSnippet(useLanguage());
636
- return /* @__PURE__ */ jsx(Docs.Snippet, {
637
- requestTitle: /* @__PURE__ */ jsx(Docs.SDKRequestTitle, { snippetLanguage }),
638
- method,
639
- transformRequestSnippet
640
- });
641
- }
642
- function SDKMethodHeader({ method }) {
643
- const Docs = useComponents();
644
- const Lang = useLanguageComponents();
645
- const decl = useDeclaration(method.stainlessPath, true);
646
- return /* @__PURE__ */ jsx(Docs.MethodHeader, {
647
- level: "h1",
648
- title: method.summary ?? method.title,
649
- signature: /* @__PURE__ */ jsx(Lang.MethodSignature, { decl }),
650
- badges: method.deprecated && /* @__PURE__ */ jsx(Docs.Badge, {
651
- id: "deprecated",
652
- children: "Deprecated"
653
- }),
654
- children: /* @__PURE__ */ jsx(Docs.MethodRoute, {
655
- httpMethod: method.httpMethod,
656
- endpoint: method.endpoint.split(" ", 2).at(-1)
657
- })
658
- });
659
- }
660
- function SDKMethodInfo({ method }) {
661
- const Docs = useComponents();
662
- const Lang = useLanguageComponents();
663
- const decl = useDeclaration(method.stainlessPath, true);
664
- const spec = useSpec();
665
- const language = useLanguage();
666
- if (Lang.MethodInfo) return /* @__PURE__ */ jsx(Lang.MethodInfo, { decl });
667
- function shouldExpand(items) {
668
- if (items.length > 1) return false;
669
- const item$1 = items[0];
670
- if (!item$1) return false;
671
- const decl$1 = spec?.decls?.[language]?.[item$1];
672
- return decl$1 && "children" in decl$1 && decl$1.children && decl$1.children.length > 0;
673
- }
674
- return /* @__PURE__ */ jsx(Docs.MethodInfo, {
675
- parameters: "paramsChildren" in decl && Array.isArray(decl.paramsChildren) && decl.paramsChildren.length > 0 && /* @__PURE__ */ jsx(Docs.SDKChildren, {
676
- expand: shouldExpand(decl.paramsChildren),
677
- paths: decl.paramsChildren
678
- }),
679
- returns: "responseChildren" in decl && decl.responseChildren && decl.responseChildren.length > 0 && /* @__PURE__ */ jsx(Docs.SDKChildren, {
680
- expand: shouldExpand(decl.responseChildren),
681
- paths: decl.responseChildren
682
- })
683
- });
684
- }
685
- function SDKMethod({ method, transformRequestSnippet }) {
686
- const Docs = useComponents();
687
- const decl = useDeclaration(method?.stainlessPath, false);
688
- const layout = useContentPanelLayout();
689
- const language = useLanguage();
690
- if (!decl) return /* @__PURE__ */ jsxs("div", {
691
- className: style_default.Method,
692
- children: [/* @__PURE__ */ jsx(Docs.MethodHeader, {
693
- level: "h1",
694
- title: method.summary ?? method.title,
695
- children: /* @__PURE__ */ jsx(Docs.MethodRoute, {
696
- httpMethod: method.httpMethod,
697
- endpoint: method.endpoint.split(" ", 2).at(-1)
698
- })
699
- }), /* @__PURE__ */ jsxs(Callout, {
700
- variant: "warning",
701
- children: [
702
- "The method ",
703
- /* @__PURE__ */ jsx("code", { children: method.name }),
704
- " is not implemented in ",
705
- LanguageNames[language] ?? language,
706
- "."
707
- ]
708
- })]
709
- });
710
- return /* @__PURE__ */ jsxs(Docs.Method, {
711
- id: method.stainlessPath,
712
- header: /* @__PURE__ */ jsx(Docs.SDKMethodHeader, { method }),
713
- className: clsx({
714
- [style_default.MethodSinglePane]: layout === "single-pane",
715
- [style_default.MethodDoublePane]: layout === "double-pane"
716
- }),
717
- children: [
718
- /* @__PURE__ */ jsxs("div", {
719
- className: style_default.MethodContentColumn,
720
- children: [/* @__PURE__ */ jsx(Docs.MethodDescription, { description: method.description }), /* @__PURE__ */ jsx(Docs.SDKMethodInfo, { method })]
721
- }),
722
- /* @__PURE__ */ jsx("div", {
723
- className: clsx(style_default.MethodExample, "not-content", "stl-ui-not-prose"),
724
- children: /* @__PURE__ */ jsx(Docs.SDKExample, {
725
- method,
726
- transformRequestSnippet
727
- })
728
- }),
729
- /* @__PURE__ */ jsxs("div", {
730
- className: style_default.MethodResponseColumn,
731
- children: [/* @__PURE__ */ jsx("h5", { children: "Returns Examples" }), /* @__PURE__ */ jsx(Docs.SnippetResponse, { responses: method.exampleResponses })]
732
- })
733
- ]
734
- });
735
- }
736
- function SDKModel({ model }) {
737
- const Docs = useComponents();
738
- if (!useDeclaration(`${model.stainlessPath} > (schema)`, true)) return null;
739
- return /* @__PURE__ */ jsx("div", {
740
- className: style_default.Model,
741
- tabIndex: 0,
742
- children: /* @__PURE__ */ jsx("div", {
743
- className: style_default.ResourceContentProperties,
744
- children: /* @__PURE__ */ jsx(Docs.SDKDeclaration, { path: `${model.stainlessPath} > (schema)` })
745
- })
746
- });
747
- }
748
- function SDKReference({ stainlessPath, children }) {
749
- const Docs = useComponents();
750
- if (!stainlessPath || !stainlessPath.endsWith("(schema)")) return children;
751
- return /* @__PURE__ */ jsx("span", {
752
- className: style_default.TypeReference,
753
- children: /* @__PURE__ */ jsx(Docs.Link, {
754
- stainlessPath,
755
- children
756
- })
757
- });
758
- }
759
- function SDKLanguageBlock({ language, version, install, links }) {
760
- const Docs = useComponents();
761
- const lang = `${language}.default`;
762
- return /* @__PURE__ */ jsxs("div", {
763
- className: style_default.LanguageBlock,
764
- children: [
765
- /* @__PURE__ */ jsxs("div", {
766
- className: style_default.LanguageBlockContent,
767
- children: [/* @__PURE__ */ jsx("div", {
768
- className: style_default.LanguageBlockContentIcon,
769
- children: /* @__PURE__ */ jsx(Docs.SDKIcon, {
770
- language: lang,
771
- size: 24
772
- })
773
- }), /* @__PURE__ */ jsxs("div", {
774
- className: style_default.LanguageBlockContentInfo,
775
- children: [/* @__PURE__ */ jsx("div", {
776
- className: style_default.LanguageBlockContentInfoLanguage,
777
- children: Docs.SDKSnippetLanguages[lang].name
778
- }), /* @__PURE__ */ jsx("div", {
779
- className: style_default.LanguageBlockContentInfoVersion,
780
- children: version
781
- })]
782
- })]
783
- }),
784
- /* @__PURE__ */ jsxs("div", {
785
- className: style_default.LanguageBlockInstall,
786
- "data-stldocs-copy-parent": true,
787
- children: [
788
- /* @__PURE__ */ jsx("pre", {
789
- "data-stldocs-copy-content": true,
790
- children: install
791
- }),
792
- " ",
793
- /* @__PURE__ */ jsx(Button, {
794
- variant: "ghost",
795
- size: "sm",
796
- "data-stldocs-snippet-copy": true,
797
- children: /* @__PURE__ */ jsx(Copy, {
798
- size: 16,
799
- className: style_default.Icon
800
- })
801
- })
802
- ]
803
- }),
804
- /* @__PURE__ */ jsxs("div", {
805
- className: style_default.LanguageBlockLinks,
806
- children: [/* @__PURE__ */ jsx(Button, {
807
- href: links.repo,
808
- variant: "outline",
809
- children: /* @__PURE__ */ jsx(Button.Icon, { icon: Github })
810
- }), /* @__PURE__ */ jsxs(Button, {
811
- href: links.docs,
812
- variant: "outline",
813
- children: [/* @__PURE__ */ jsx(Button.Icon, { icon: BookOpen }), /* @__PURE__ */ jsx(Button.Label, { children: "Read Docs" })]
814
- })]
815
- })
816
- ]
817
- });
818
- }
819
-
820
- //#endregion
821
- //#region src/components/snippets.tsx
822
- function SnippetCode({ content, language }) {
823
- const lang = useLanguage();
824
- const highlighted = useHighlight(content, language || lang);
825
- return /* @__PURE__ */ jsx("div", {
826
- className: style_default.SnippetCode,
827
- children: /* @__PURE__ */ jsx("pre", {
828
- className: style_default.SnippetCodeContent,
829
- "data-stldocs-copy-content": true,
830
- children: /* @__PURE__ */ jsx("code", {
831
- className: language === "json" ? "snippet-json" : "snippet",
832
- dangerouslySetInnerHTML: { __html: highlighted }
833
- })
834
- })
835
- });
836
- }
837
- function SnippetContainer({ children }) {
838
- return /* @__PURE__ */ jsx("div", {
839
- className: clsx(style_default.Snippet),
840
- children
841
- });
842
- }
843
- function SnippetRequestContainer({ children }) {
844
- return /* @__PURE__ */ jsx("div", { children });
845
- }
846
- function Snippet({ requestTitle, method, transformRequestSnippet }) {
847
- const Docs = useComponents();
848
- const language = useLanguage();
849
- const originalSnippet = useSnippet(method.stainlessPath, void 0, language === "http" ? "curl" : "default");
850
- const decl = useDeclaration(method.stainlessPath, false);
851
- if (!originalSnippet) {
852
- console.warn(`Snippet not found for method '${method.stainlessPath}'`);
853
- return null;
854
- }
855
- const signature = decl && "qualified" in decl ? decl.qualified : void 0;
856
- const responses = method.exampleResponses;
857
- const snippet = transformRequestSnippet ? transformRequestSnippet({
858
- snippet: originalSnippet,
859
- language
860
- }) : originalSnippet;
861
- return /* @__PURE__ */ jsxs(Docs.SnippetContainer, {
862
- signature,
863
- children: [snippet && /* @__PURE__ */ jsx(Docs.SnippetRequestContainer, {
864
- signature,
865
- children: /* @__PURE__ */ jsxs("div", {
866
- className: style_default.SnippetRequest,
867
- "data-stldocs-copy-parent": true,
868
- children: [/* @__PURE__ */ jsxs("div", {
869
- className: style_default.SnippetRequestTitle,
870
- children: [
871
- /* @__PURE__ */ jsxs("div", {
872
- className: style_default.SnippetRequestTitleMethod,
873
- children: [/* @__PURE__ */ jsx(Docs.MethodRoute, {
874
- httpMethod: method.httpMethod,
875
- iconOnly: true
876
- }), /* @__PURE__ */ jsx("h5", { children: method.summary ?? method.title })]
877
- }),
878
- /* @__PURE__ */ jsx("div", {
879
- className: style_default.SnippetRequestTitleContent,
880
- children: requestTitle
881
- }),
882
- /* @__PURE__ */ jsx(Docs.SnippetButtons, { content: snippet })
883
- ]
884
- }), /* @__PURE__ */ jsx(Docs.SnippetCode, {
885
- content: snippet,
886
- signature
887
- })]
888
- })
889
- }), responses && /* @__PURE__ */ jsx(Docs.SnippetResponse, { responses })]
890
- });
891
- }
892
- function SnippetButtons({ content }) {
893
- const [CopyButtonIcon, setCopyIcon] = React$1.useState(CopyIcon);
894
- async function handleCopy() {
895
- try {
896
- await navigator.clipboard.writeText(content);
897
- setCopyIcon(CheckIcon);
898
- } catch {
899
- setCopyIcon(CircleAlertIcon);
900
- }
901
- setTimeout(() => setCopyIcon(CopyIcon), 1e3);
902
- }
903
- return /* @__PURE__ */ jsx(Button, {
904
- variant: "ghost",
905
- "data-stldocs-snippet-copy": true,
906
- children: /* @__PURE__ */ jsx(CopyButtonIcon, {
907
- size: 16,
908
- className: style_default.Icon,
909
- onClick: handleCopy
910
- })
911
- });
912
- }
913
- function SnippetResponse({ responses }) {
914
- const { SnippetCode: SnippetCode$1 } = useComponents();
915
- if (!responses) return null;
916
- const mappedResponses = Object.keys(responses).map((key) => {
917
- const responseContent = responses[key];
918
- if (!responseContent) return null;
919
- const responseType = Object.keys(responseContent)[0];
920
- if (!responseType) return null;
921
- const response = responseContent[responseType];
922
- if (!response) return null;
923
- const examples = response?.examples;
924
- if (!examples) return null;
925
- const exampleType = Object.keys(examples)[0];
926
- if (!exampleType) return null;
927
- let value = examples[exampleType]?.value;
928
- if (!value) return null;
929
- let language = "none";
930
- if (responseType === "application/json" || typeof value === "object") {
931
- language = "json";
932
- value = JSON.stringify(value, null, 2);
933
- }
934
- return {
935
- language,
936
- responseCode: key,
937
- content: value
938
- };
939
- }).filter(Boolean);
940
- if (mappedResponses.length === 0) return null;
941
- return /* @__PURE__ */ jsx("div", {
942
- className: style_default.SnippetMultiResponse,
943
- children: /* @__PURE__ */ jsxs("div", {
944
- className: clsx(style_default.Snippet),
945
- children: [/* @__PURE__ */ jsx("div", {
946
- className: clsx(style_default.SnippetResponseTab, mappedResponses.length === 1 && style_default.SnippetResponseTabSingleReturn),
947
- children: mappedResponses.map(({ responseCode }, index) => /* @__PURE__ */ jsx("div", {
948
- "data-snippet-response-tab-id": `snippet-response-tab-${responseCode}-${index}`,
949
- className: clsx(style_default.SnippetResponseTabItem, index === 0 && style_default.SnippetResponseTabItemActive),
950
- children: /* @__PURE__ */ jsxs(Button, {
951
- disabled: mappedResponses.length === 1,
952
- variant: "ghost",
953
- children: [responseCode, " example"]
954
- })
955
- }, `snippet-response-tab-item-${responseCode}-${index}`))
956
- }), mappedResponses.map(({ responseCode, content, language }, index) => {
957
- return /* @__PURE__ */ jsx("div", {
958
- className: clsx(style_default.SnippetResponsePane, index === 0 && style_default.SnippetResponsePaneActive),
959
- "data-snippet-response-pane-id": `snippet-response-tab-${responseCode}-${index}`,
960
- children: /* @__PURE__ */ jsx(SnippetCode$1, {
961
- content,
962
- language
963
- })
964
- }, `snippet-response-${responseCode}-${index}`);
965
- })]
966
- })
967
- });
968
- }
969
-
970
- //#endregion
971
- //#region src/components/overview.tsx
972
- function SDKResourceHeader({ resource, parents }) {
973
- const segments = parents?.map((parent, index) => /* @__PURE__ */ jsxs("span", {
974
- className: style_default.ResourceTitleSegment,
975
- children: [parent.title, index < parents.length && /* @__PURE__ */ jsx(ChevronRight, {
976
- size: 16,
977
- className: style_default.Icon
978
- })]
979
- }, parent.stainlessPath));
980
- if (!segments && !resource.description) return null;
981
- return /* @__PURE__ */ jsxs("div", {
982
- className: style_default.ResourceHeader,
983
- children: [segments && /* @__PURE__ */ jsxs("h4", {
984
- id: resource.stainlessPath,
985
- className: style_default.ResourceTitle,
986
- children: [segments, /* @__PURE__ */ jsx("span", {
987
- className: style_default.ResourceTitleSegment,
988
- children: resource.title
989
- })]
990
- }), resource.description && /* @__PURE__ */ jsx("div", {
991
- className: style_default.ResourceDescription,
992
- children: /* @__PURE__ */ jsx(Markdown, { content: resource.description })
993
- })]
994
- });
995
- }
996
- function SDKMethodSummary({ method }) {
997
- const Docs = useComponents();
998
- const Lang = useLanguageComponents();
999
- const decl = useDeclaration(method.stainlessPath, true);
1000
- return /* @__PURE__ */ jsx(Docs.MethodHeader, {
1001
- level: "h5",
1002
- title: /* @__PURE__ */ jsx(Docs.Link, {
1003
- stainlessPath: method.stainlessPath,
1004
- children: method.summary ?? method.title
1005
- }),
1006
- signature: /* @__PURE__ */ jsx(Lang.MethodSignature, { decl }),
1007
- badges: method.deprecated && /* @__PURE__ */ jsx(Docs.Badge, {
1008
- id: "deprecated",
1009
- children: "Deprecated"
1010
- }),
1011
- children: /* @__PURE__ */ jsx(Docs.MethodRoute, {
1012
- httpMethod: method.httpMethod,
1013
- endpoint: method.endpoint.split(" ", 2).at(-1)
1014
- })
1015
- });
1016
- }
1017
- function SDKResource({ resource, parents, showModels }) {
1018
- const Docs = useComponents();
1019
- const language = useLanguage();
1020
- const spec = useSpec();
1021
- const methods = Object.values(resource.methods).filter((method) => spec?.decls?.[language]?.[method.stainlessPath]);
1022
- const models = Object.values(resource.models).filter((model) => spec?.decls?.[language]?.[`${model.stainlessPath} > (schema)`]);
1023
- return /* @__PURE__ */ jsx("div", {
1024
- className: style_default.Resource,
1025
- children: /* @__PURE__ */ jsxs("div", {
1026
- className: style_default.ResourceContent,
1027
- children: [
1028
- /* @__PURE__ */ jsx(Docs.SDKResourceHeader, {
1029
- resource,
1030
- parents
1031
- }),
1032
- methods.length > 0 && /* @__PURE__ */ jsx("div", {
1033
- className: style_default.ResourceContentGroup,
1034
- children: methods.map((method) => /* @__PURE__ */ jsx("div", {
1035
- className: style_default.MethodSummary,
1036
- children: /* @__PURE__ */ jsx(Docs.SDKMethodSummary, { method })
1037
- }, method.stainlessPath))
1038
- }),
1039
- showModels !== false && models.length > 0 && /* @__PURE__ */ jsxs("div", {
1040
- className: style_default.ResourceContentGroup,
1041
- "data-stldocs-property-group": "models",
1042
- children: [/* @__PURE__ */ jsxs("h5", {
1043
- className: style_default.ResourceContentGroupModelTitle,
1044
- children: ["Models", /* @__PURE__ */ jsx(PropertyToggle, { target: "models" })]
1045
- }), models.map((model) => /* @__PURE__ */ jsx(Docs.SDKModel, { model }, model.stainlessPath))]
1046
- })
1047
- ]
1048
- })
1049
- });
1050
- }
1051
- function SDKOverview({ resource }) {
1052
- const { SDKResource: SDKResource$1 } = useComponents();
1053
- const nested = React$1.useMemo(() => flatResources(resource.subresources, [resource]), [resource]);
1054
- return /* @__PURE__ */ jsxs("div", {
1055
- className: style_default.Overview,
1056
- children: [
1057
- /* @__PURE__ */ jsx("div", {
1058
- className: style_default.OverviewHeader,
1059
- children: /* @__PURE__ */ jsx("h1", { children: resource.title })
1060
- }),
1061
- /* @__PURE__ */ jsx(SDKResource$1, { resource }),
1062
- nested.map((props, index) => /* @__PURE__ */ createElement(SDKResource$1, {
1063
- ...props,
1064
- key: index
1065
- }))
1066
- ]
1067
- });
1068
- }
1069
- function SDKRoot({ stainlessPath }) {
1070
- const spec = useSpec();
1071
- const Docs = useComponents();
1072
- const parsed = parseStainlessPath(stainlessPath);
1073
- const resource = spec && getResourceFromSpec(stainlessPath, spec);
1074
- if (!resource || !parsed) {
1075
- console.warn(`Could not find resource or parsed path for '${stainlessPath}'`);
1076
- return null;
1077
- }
1078
- if (parsed.method) {
1079
- const method = resource.methods[parsed.method];
1080
- if (!method) {
1081
- console.warn(`Method '${parsed.method}' not found in resource '${resource.stainlessPath}'`);
1082
- return null;
1083
- }
1084
- return /* @__PURE__ */ jsx("div", {
1085
- className: style_default.Root,
1086
- children: /* @__PURE__ */ jsx(Docs.SDKMethod, { method })
1087
- });
1088
- }
1089
- return /* @__PURE__ */ jsx("div", {
1090
- className: style_default.Root,
1091
- children: /* @__PURE__ */ jsx(Docs.SDKOverview, { resource })
1092
- });
1093
- }
1094
-
1095
- //#endregion
1096
- //#region src/components/breadcrumbs.tsx
1097
- function generateApiBreadcrumbs(fullPath, spec, basePath) {
1098
- const cleanBasePath = basePath.replace(/\/+$/, "");
1099
- const cleanPath = fullPath.replace(/\/+$/, "");
1100
- if (!cleanPath.startsWith(cleanBasePath)) return null;
1101
- const rest = cleanPath.slice(cleanBasePath.length).split("/").filter(Boolean);
1102
- const breadcrumbs = [];
1103
- let href = cleanBasePath;
1104
- let i = 0;
1105
- if (Languages.includes(rest[0])) {
1106
- href += `/${rest[0]}`;
1107
- i++;
1108
- }
1109
- breadcrumbs.push({
1110
- title: "API Reference",
1111
- href
1112
- });
1113
- let currentSpec = spec;
1114
- while (i < rest.length) {
1115
- const idType = rest[i];
1116
- const idValue = rest[i + 1];
1117
- if (!idType || !idValue || !currentSpec?.[idType]?.[idValue]) break;
1118
- currentSpec = currentSpec[idType][idValue];
1119
- href += `/${idType}/${idValue}`;
1120
- const title = (idType === "methods" ? currentSpec.summary : currentSpec.title) ?? idValue;
1121
- breadcrumbs.push({
1122
- title,
1123
- href
1124
- });
1125
- i += 2;
1126
- }
1127
- return breadcrumbs;
1128
- }
1129
- function SDKBreadcrumbs({ spec, currentPath, basePath = "/api", config = { includeCurrentPage: false } }) {
1130
- const breadcrumbs = generateApiBreadcrumbs(currentPath, spec, basePath);
1131
- if (!breadcrumbs || breadcrumbs.length === 0) return null;
1132
- if (!config?.includeCurrentPage && breadcrumbs.length > 1) breadcrumbs.pop();
1133
- const items = breadcrumbs.map((crumb, index) => /* @__PURE__ */ jsx("div", {
1134
- className: style_default.BreadcrumbsItem,
1135
- children: /* @__PURE__ */ jsx("a", {
1136
- href: crumb.href,
1137
- className: style_default.BreadcrumbsLink,
1138
- children: crumb.title
1139
- })
1140
- }, index));
1141
- return /* @__PURE__ */ jsx("div", {
1142
- className: style_default.Breadcrumbs,
1143
- children: /* @__PURE__ */ jsx(Join, {
1144
- limit: breadcrumbs.length,
1145
- items,
1146
- children: /* @__PURE__ */ jsx(ChevronRight, {})
1147
- })
1148
- });
1149
- }
1150
-
1151
- //#endregion
1152
- //#region src/components/sidebar.tsx
1153
- function SidebarExpander({ open, summary, children }) {
1154
- return /* @__PURE__ */ jsxs("details", {
1155
- className: style_default.SidebarExpander,
1156
- open,
1157
- children: [/* @__PURE__ */ jsxs("summary", {
1158
- className: style_default.ExpanderSummary,
1159
- children: [/* @__PURE__ */ jsx("div", {
1160
- className: style_default.ExpanderSummaryContent,
1161
- children: summary
1162
- }), /* @__PURE__ */ jsxs("div", {
1163
- className: style_default.ExpanderSummaryIcon,
1164
- children: [/* @__PURE__ */ jsx(ChevronRight, {
1165
- size: 16,
1166
- strokeWidth: 1,
1167
- className: style_default.Icon
1168
- }), /* @__PURE__ */ jsx(ChevronDown, {
1169
- size: 16,
1170
- strokeWidth: 1,
1171
- className: style_default.Icon
1172
- })]
1173
- })]
1174
- }), /* @__PURE__ */ jsx("div", {
1175
- className: style_default.ExpanderContent,
1176
- children
1177
- })]
1178
- });
1179
- }
1180
- function SidebarMethod({ method }) {
1181
- const Docs = useComponents();
1182
- const { selectedPath } = useNavigation();
1183
- return /* @__PURE__ */ jsxs("div", {
1184
- className: style_default.SidebarMethod,
1185
- "data-selected": method.stainlessPath === selectedPath,
1186
- children: [/* @__PURE__ */ jsx(MethodIconBadge, { httpMethod: method.httpMethod }), /* @__PURE__ */ jsx(Docs.Link, {
1187
- stainlessPath: method.stainlessPath,
1188
- children: method.summary
1189
- })]
1190
- });
1191
- }
1192
- function SidebarResource({ resource }) {
1193
- const Docs = useComponents();
1194
- const { selectedPath } = useNavigation();
1195
- const subresources = Object.values(resource.subresources ?? {}).map((sub) => /* @__PURE__ */ jsx(SidebarResource, { resource: sub }, sub.stainlessPath));
1196
- const methods = Object.values(resource.methods).map((method) => /* @__PURE__ */ jsx(SidebarMethod, { method }, method.stainlessPath));
1197
- const hasChildren = subresources.length > 0 || methods.length > 0;
1198
- const title = /* @__PURE__ */ jsx("div", {
1199
- className: style_default.SidebarResourceTitle,
1200
- children: /* @__PURE__ */ jsx(Docs.Link, {
1201
- stainlessPath: resource.stainlessPath,
1202
- children: resource.title
1203
- })
1204
- });
1205
- return /* @__PURE__ */ jsx("div", {
1206
- className: style_default.SidebarResource,
1207
- "data-selected": resource.stainlessPath === selectedPath,
1208
- children: hasChildren ? /* @__PURE__ */ jsxs(SidebarExpander, {
1209
- summary: title,
1210
- open: true,
1211
- children: [methods, subresources]
1212
- }) : title
1213
- });
1214
- }
1215
- function Sidebar({ resources }) {
1216
- return /* @__PURE__ */ jsx("div", {
1217
- className: `${style_default.Root} ${style_default.Sidebar}`,
1218
- children: resources.filter((resource) => !isResourceEmpty(resource)).map((resource) => /* @__PURE__ */ jsx(SidebarResource, { resource }, resource.stainlessPath))
1219
- });
1220
- }
1221
-
1222
- //#endregion
1223
- //#region src/components/index.ts
1224
- var components_exports = /* @__PURE__ */ __export({
1225
- Badge: () => Badge,
1226
- Expander: () => Expander,
1227
- HttpMethodIcons: () => HttpMethodIcons,
1228
- HttpMethods: () => HttpMethods,
1229
- Input: () => Input,
1230
- Join: () => Join,
1231
- Link: () => Link,
1232
- ListView: () => ListView,
1233
- Markdown: () => Markdown,
1234
- Method: () => Method,
1235
- MethodDescription: () => MethodDescription,
1236
- MethodHeader: () => MethodHeader,
1237
- MethodIconBadge: () => MethodIconBadge,
1238
- MethodInfo: () => MethodInfo$1,
1239
- MethodRoute: () => MethodRoute,
1240
- Property: () => Property$7,
1241
- PropertyDescription: () => PropertyDescription,
1242
- PropertyModelContext: () => PropertyModelContext,
1243
- PropertyTitle: () => PropertyTitle,
1244
- PropertyToggle: () => PropertyToggle,
1245
- ReferenceNestingContext: () => ReferenceNestingContext,
1246
- SDKBreadcrumbs: () => SDKBreadcrumbs,
1247
- SDKChildren: () => SDKChildren,
1248
- SDKConstraints: () => SDKConstraints,
1249
- SDKDeclaration: () => SDKDeclaration,
1250
- SDKExample: () => SDKExample,
1251
- SDKIcon: () => SDKIcon,
1252
- SDKLanguageBlock: () => SDKLanguageBlock,
1253
- SDKMethod: () => SDKMethod,
1254
- SDKMethodHeader: () => SDKMethodHeader,
1255
- SDKMethodInfo: () => SDKMethodInfo,
1256
- SDKMethodSummary: () => SDKMethodSummary,
1257
- SDKModel: () => SDKModel,
1258
- SDKOverview: () => SDKOverview,
1259
- SDKReference: () => SDKReference,
1260
- SDKRequestTitle: () => SDKRequestTitle,
1261
- SDKResource: () => SDKResource,
1262
- SDKResourceHeader: () => SDKResourceHeader,
1263
- SDKRoot: () => SDKRoot,
1264
- SDKSnippetLanguages: () => SDKSnippetLanguages,
1265
- Sidebar: () => Sidebar,
1266
- SidebarExpander: () => SidebarExpander,
1267
- SidebarMethod: () => SidebarMethod,
1268
- SidebarResource: () => SidebarResource,
1269
- Snippet: () => Snippet,
1270
- SnippetButtons: () => SnippetButtons,
1271
- SnippetCode: () => SnippetCode,
1272
- SnippetContainer: () => SnippetContainer,
1273
- SnippetRequestContainer: () => SnippetRequestContainer,
1274
- SnippetResponse: () => SnippetResponse,
1275
- ToggleButton: () => ToggleButton,
1276
- Tooltip: () => Tooltip,
1277
- VirtualExpander: () => VirtualExpander,
1278
- usePropertyModel: () => usePropertyModel,
1279
- useReferenceNesting: () => useReferenceNesting
1280
- });
1281
-
1282
- //#endregion
1283
- //#region src/languages/typescript.tsx
1284
- var typescript_exports = /* @__PURE__ */ __export({
1285
- Declaration: () => Declaration$6,
1286
- MethodSignature: () => MethodSignature$6,
1287
- Property: () => Property$6,
1288
- Type: () => Type$6,
1289
- TypeName: () => TypeName$6
1290
- });
1291
- const ComplexTypes$3 = {
1292
- TSTypeObject: "object",
1293
- TSTypeUnion: "union",
1294
- TSTypeInterface: "interface",
1295
- TSTypeIntersection: "intersection",
1296
- TSTypeArray: "array"
1297
- };
1298
- const constStyle$4 = {
1299
- string: style_default.LiteralString,
1300
- number: style_default.LiteralNumeric,
1301
- boolean: style_default.LiteralBoolean
1302
- };
1303
- function Identifier$1({ name, optional }) {
1304
- return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("span", {
1305
- className: style_default.TextIdentifier,
1306
- children: /^[_a-zA-Z][_a-zA-Z0-9]*$/.test(name) ? name : JSON.stringify(name)
1307
- }), optional && /* @__PURE__ */ jsx("span", {
1308
- className: style_default.TextPunctuation,
1309
- children: "?"
1310
- })] });
1311
- }
1312
- function TypeParams({ params }) {
1313
- const Lang = useLanguageComponents();
1314
- const { Join: Join$1 } = useComponents();
1315
- if (!params?.length) return null;
1316
- const typeParams = params?.map((param, key) => param.constraint ? /* @__PURE__ */ jsxs(React$1.Fragment, { children: [
1317
- /* @__PURE__ */ jsx("span", {
1318
- className: style_default.TypeReference,
1319
- children: param.name
1320
- }),
1321
- /* @__PURE__ */ jsx("span", {
1322
- className: style_default.TextKeyword,
1323
- children: "extends "
1324
- }),
1325
- /* @__PURE__ */ jsx(Lang.Type, { type: param.constraint })
1326
- ] }, key) : /* @__PURE__ */ jsx(React$1.Fragment, { children: "param.name" }, key));
1327
- return /* @__PURE__ */ jsxs(Fragment$1, { children: [
1328
- /* @__PURE__ */ jsx("span", {
1329
- className: style_default.TypeBracket,
1330
- children: "<"
1331
- }),
1332
- /* @__PURE__ */ jsx(Join$1, {
1333
- items: typeParams,
1334
- limit: 3,
1335
- children: /* @__PURE__ */ jsx("span", {
1336
- className: style_default.TextOperator,
1337
- children: ", "
1338
- })
1339
- }),
1340
- /* @__PURE__ */ jsx("span", {
1341
- className: style_default.TypeBracket,
1342
- children: ">"
1343
- })
1344
- ] });
1345
- }
1346
- function TypePreview$2({ path }) {
1347
- const spec = useSpec();
1348
- const language = useLanguage();
1349
- const decl = useDeclaration(path, false);
1350
- const { Join: Join$1 } = useComponents();
1351
- if (!(decl && "children" in decl && decl.children && decl.children.length > 0) || decl && "type" in decl && "kind" in decl["type"] && decl["type"]["kind"] === "TSTypeUnion") return;
1352
- const items = decl.children.map((prop, key) => {
1353
- const p = spec?.decls?.[language]?.[prop];
1354
- return /* @__PURE__ */ jsx("span", {
1355
- className: style_default.TypePropertyName,
1356
- children: /* @__PURE__ */ jsx("span", {
1357
- className: style_default.TextIdentifier,
1358
- children: p && "key" in p ? p["key"] : null
1359
- })
1360
- }, key);
1361
- });
1362
- return /* @__PURE__ */ jsxs("span", {
1363
- className: style_default.TypePreview,
1364
- "data-stldocs-type-preview": "properties",
1365
- children: [
1366
- /* @__PURE__ */ jsx("span", {
1367
- className: style_default.TypeBrace,
1368
- children: " {"
1369
- }),
1370
- /* @__PURE__ */ jsxs("span", {
1371
- className: style_default.TypePreviewContent,
1372
- children: [
1373
- " ",
1374
- /* @__PURE__ */ jsx(Join$1, {
1375
- items,
1376
- limit: 3,
1377
- children: /* @__PURE__ */ jsx("span", {
1378
- className: style_default.TextOperator,
1379
- children: ", "
1380
- })
1381
- }),
1382
- " "
1383
- ]
1384
- }),
1385
- /* @__PURE__ */ jsx("span", {
1386
- className: style_default.TypeBrace,
1387
- children: "} "
1388
- })
1389
- ]
1390
- });
1391
- }
1392
- function TypeName$6({ type }) {
1393
- const Lang = useLanguageComponents();
1394
- return ComplexTypes$3[type.kind] ?? /* @__PURE__ */ jsx(Lang.Type, { type });
1395
- }
1396
- function Type$6({ type }) {
1397
- const Lang = useLanguageComponents();
1398
- const { Join: Join$1, SDKReference: SDKReference$1 } = useComponents();
1399
- switch (type.kind) {
1400
- case "TSTypeUnknown":
1401
- case "TSTypeUndefined":
1402
- case "TSTypeNever":
1403
- case "TSTypeVoid":
1404
- case "TSTypeNull":
1405
- case "TSTypeAny":
1406
- case "TSTypeBoolean":
1407
- case "TSTypeNumber": return /* @__PURE__ */ jsx("span", {
1408
- className: style_default.Type,
1409
- children: /* @__PURE__ */ jsx("span", {
1410
- className: style_default.TypeKeyword,
1411
- children: type.kind.slice(6).toLowerCase()
1412
- })
1413
- });
1414
- case "TSTypeString": return /* @__PURE__ */ jsx("span", {
1415
- className: style_default.Type,
1416
- children: /* @__PURE__ */ jsx("span", {
1417
- className: style_default.TypeString,
1418
- children: "string"
1419
- })
1420
- });
1421
- case "TSTypeLiteral": return /* @__PURE__ */ jsx("span", {
1422
- className: style_default.Type,
1423
- children: /* @__PURE__ */ jsx("span", {
1424
- className: constStyle$4[typeof type.literal],
1425
- children: JSON.stringify(type.literal)
1426
- })
1427
- });
1428
- case "TSTypeArray": return /* @__PURE__ */ jsxs("span", {
1429
- className: style_default.Type,
1430
- children: [
1431
- /* @__PURE__ */ jsx("span", {
1432
- className: style_default.TypeArray,
1433
- children: "Array<"
1434
- }),
1435
- /* @__PURE__ */ jsx(Lang.Type, { type: type.elementType }),
1436
- /* @__PURE__ */ jsx("span", {
1437
- className: style_default.TypeArray,
1438
- children: ">"
1439
- })
1440
- ]
1441
- });
1442
- case "TSTypeReference": {
1443
- const name = type.ident.split(".").at(-1);
1444
- const params = type.typeParameters?.map((param, key) => /* @__PURE__ */ jsx(Lang.Type, { type: param }, key));
1445
- return /* @__PURE__ */ jsxs("span", {
1446
- className: style_default.Type,
1447
- children: [
1448
- /* @__PURE__ */ jsx(SDKReference$1, {
1449
- stainlessPath: type.$ref,
1450
- children: name
1451
- }),
1452
- params && params.length > 0 && /* @__PURE__ */ jsxs(Fragment$1, { children: [
1453
- /* @__PURE__ */ jsx("span", {
1454
- className: style_default.TypeBracket,
1455
- children: "<"
1456
- }),
1457
- /* @__PURE__ */ jsx(Join$1, {
1458
- items: params,
1459
- limit: 3,
1460
- children: /* @__PURE__ */ jsx("span", {
1461
- className: style_default.TextOperator,
1462
- children: ", "
1463
- })
1464
- }),
1465
- /* @__PURE__ */ jsx("span", {
1466
- className: style_default.TypeBracket,
1467
- children: ">"
1468
- })
1469
- ] }),
1470
- /* @__PURE__ */ jsx(TypePreview$2, { path: type.$ref })
1471
- ]
1472
- });
1473
- }
1474
- case "TSTypeIntersection":
1475
- case "TSTypeUnion": {
1476
- const items = type.types.map((t, key) => /* @__PURE__ */ jsx(Lang.Type, { type: t }, key));
1477
- const delimiter = type.kind === "TSTypeUnion" ? "|" : "&";
1478
- return /* @__PURE__ */ jsx("span", {
1479
- className: style_default.Type,
1480
- children: /* @__PURE__ */ jsx("span", {
1481
- className: style_default.TypePreview,
1482
- "data-stldocs-type-preview": "union",
1483
- children: /* @__PURE__ */ jsx("span", {
1484
- className: style_default.TypePreviewContent,
1485
- children: /* @__PURE__ */ jsx(Join$1, {
1486
- items,
1487
- limit: 3,
1488
- children: /* @__PURE__ */ jsxs("span", {
1489
- className: style_default.TextOperator,
1490
- children: [
1491
- " ",
1492
- delimiter,
1493
- " "
1494
- ]
1495
- })
1496
- })
1497
- })
1498
- })
1499
- });
1500
- }
1501
- case "TSTypeObject":
1502
- case "TSTypeInterface": {
1503
- const extend = type.kind === "TSTypeObject" ? null : type.extends?.map((ref, key) => /* @__PURE__ */ jsx(Lang.Type, { type: ref }, key));
1504
- const items = type.members.map((prop, key) => /* @__PURE__ */ jsxs(React$1.Fragment, { children: [
1505
- /* @__PURE__ */ jsx("span", {
1506
- className: style_default.TypePropertyName,
1507
- children: /* @__PURE__ */ jsx(Identifier$1, {
1508
- name: prop.ident,
1509
- optional: prop.optional
1510
- })
1511
- }),
1512
- /* @__PURE__ */ jsx("span", {
1513
- className: style_default.TextPunctuation,
1514
- children: ": "
1515
- }),
1516
- /* @__PURE__ */ jsx(Lang.Type, { type: prop.type })
1517
- ] }, key));
1518
- return /* @__PURE__ */ jsxs("span", {
1519
- className: style_default.Type,
1520
- children: [extend?.length && /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("span", {
1521
- className: style_default.TypeKeyword,
1522
- children: " extends "
1523
- }), /* @__PURE__ */ jsx(Join$1, {
1524
- items: extend,
1525
- limit: 3,
1526
- children: /* @__PURE__ */ jsx("span", {
1527
- className: style_default.TextOperator,
1528
- children: ", "
1529
- })
1530
- })] }), /* @__PURE__ */ jsxs("span", {
1531
- className: style_default.TypePreview,
1532
- "data-stldocs-type-preview": "properties",
1533
- children: [
1534
- /* @__PURE__ */ jsx("span", {
1535
- className: style_default.TypeBrace,
1536
- children: "{ "
1537
- }),
1538
- /* @__PURE__ */ jsx("span", {
1539
- className: style_default.TypePreviewContent,
1540
- children: /* @__PURE__ */ jsx(Join$1, {
1541
- items,
1542
- limit: 3,
1543
- children: /* @__PURE__ */ jsx("span", {
1544
- className: style_default.TextOperator,
1545
- children: ", "
1546
- })
1547
- })
1548
- }),
1549
- /* @__PURE__ */ jsx("span", {
1550
- className: style_default.TypeBrace,
1551
- children: "} "
1552
- })
1553
- ]
1554
- })]
1555
- });
1556
- }
1557
- }
1558
- }
1559
- function MethodSignature$6({ decl }) {
1560
- const Lang = useLanguageComponents();
1561
- const { Join: Join$1, Tooltip: Tooltip$1 } = useComponents();
1562
- const params = decl.signature.parameters.map((param, i) => /* @__PURE__ */ jsxs(React$1.Fragment, { children: [/* @__PURE__ */ jsx(Tooltip$1, {
1563
- content: /* @__PURE__ */ jsx(Lang.Type, { type: param.type }),
1564
- children: /* @__PURE__ */ jsx("span", {
1565
- className: style_default.TextIdentifier,
1566
- children: param.ident
1567
- })
1568
- }), param.optional && /* @__PURE__ */ jsx("span", {
1569
- className: style_default.TextPunctuation,
1570
- children: "?"
1571
- })] }, i));
1572
- return /* @__PURE__ */ jsx("div", {
1573
- className: style_default.MethodSignature,
1574
- children: /* @__PURE__ */ jsxs("span", {
1575
- className: style_default.SignatureTitle,
1576
- children: [
1577
- decl.signature.async && /* @__PURE__ */ jsx("span", {
1578
- className: style_default.TextKeyword,
1579
- children: "async "
1580
- }),
1581
- /* @__PURE__ */ jsx("span", {
1582
- className: style_default.SignatureQualified,
1583
- children: /* @__PURE__ */ jsx("span", {
1584
- className: style_default.TextIdentifier,
1585
- children: decl.qualified?.slice(0, -decl.ident.length)
1586
- })
1587
- }),
1588
- /* @__PURE__ */ jsx("span", {
1589
- className: style_default.SignatureName,
1590
- children: /* @__PURE__ */ jsx("span", {
1591
- className: style_default.TextIdentifier,
1592
- children: decl.ident
1593
- })
1594
- }),
1595
- /* @__PURE__ */ jsxs("span", {
1596
- className: style_default.MethodSignature,
1597
- children: [
1598
- decl.signature.typeParameters && /* @__PURE__ */ jsx(TypeParams, { params: decl.signature.typeParameters }),
1599
- /* @__PURE__ */ jsx("span", {
1600
- className: style_default.SignatureParen,
1601
- children: "("
1602
- }),
1603
- /* @__PURE__ */ jsx("span", {
1604
- className: style_default.SignatureParams,
1605
- children: /* @__PURE__ */ jsx(Join$1, {
1606
- items: params,
1607
- children: /* @__PURE__ */ jsx("span", {
1608
- className: style_default.TextOperator,
1609
- children: ", "
1610
- })
1611
- })
1612
- }),
1613
- /* @__PURE__ */ jsx("span", {
1614
- className: style_default.SignatureParen,
1615
- children: ")"
1616
- }),
1617
- decl.signature.returns && /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("span", {
1618
- className: style_default.TextPunctuation,
1619
- children: ": "
1620
- }), /* @__PURE__ */ jsx(Lang.Type, { type: decl.signature.returns })] })
1621
- ]
1622
- })
1623
- ]
1624
- })
1625
- });
1626
- }
1627
- function Property$6({ decl, children }) {
1628
- const Lang = useLanguageComponents();
1629
- if (!decl) return;
1630
- switch (decl.kind) {
1631
- case "TSDeclProperty": return children({
1632
- name: decl.key,
1633
- typeName: /* @__PURE__ */ jsx(Lang.TypeName, { type: decl.type }),
1634
- type: decl.type.kind in ComplexTypes$3 && /* @__PURE__ */ jsx(Lang.Type, { type: decl.type })
1635
- });
1636
- case "TSDeclTypeAlias": return children({
1637
- name: decl.ident,
1638
- typeName: "alias",
1639
- type: /* @__PURE__ */ jsx(Lang.Type, { type: decl.type })
1640
- });
1641
- case "TSDeclReference": return children({ type: /* @__PURE__ */ jsx(Lang.Type, { type: decl.type }) });
1642
- case "TSDeclInterface": return children({ type: /* @__PURE__ */ jsxs(Fragment$1, { children: [
1643
- /* @__PURE__ */ jsx("span", {
1644
- className: style_default.TextIdentifier,
1645
- children: decl.ident
1646
- }),
1647
- decl.typeParameters && /* @__PURE__ */ jsx(TypeParams, { params: decl.typeParameters }),
1648
- decl.extends?.flatMap((t, key) => /* @__PURE__ */ jsxs(React$1.Fragment, { children: [/* @__PURE__ */ jsx("span", {
1649
- className: style_default.TextKeyword,
1650
- children: " extends "
1651
- }), /* @__PURE__ */ jsx(Lang.Type, { type: t })] }, `extends:${key}`))
1652
- ] }) });
1653
- }
1654
- }
1655
- function Declaration$6({ decl }) {
1656
- const Lang = useLanguageComponents();
1657
- if (!decl) return;
1658
- switch (decl.kind) {
1659
- case "TSDeclProperty": return /* @__PURE__ */ jsxs(Fragment$1, { children: [
1660
- decl.declare && /* @__PURE__ */ jsx("span", {
1661
- className: style_default.TextKeyword,
1662
- children: "declare "
1663
- }),
1664
- /* @__PURE__ */ jsx("span", {
1665
- className: style_default.TypePropertyName,
1666
- children: /* @__PURE__ */ jsx(Identifier$1, {
1667
- name: decl.key,
1668
- optional: decl.optional
1669
- })
1670
- }),
1671
- /* @__PURE__ */ jsx("span", {
1672
- className: style_default.TextPunctuation,
1673
- children: ": "
1674
- }),
1675
- /* @__PURE__ */ jsx(Lang.Type, { type: decl.type })
1676
- ] });
1677
- case "TSDeclFunction": return /* @__PURE__ */ jsx(Lang.MethodSignature, { decl });
1678
- case "TSDeclTypeAlias": return /* @__PURE__ */ jsxs(Fragment$1, { children: [
1679
- /* @__PURE__ */ jsx(Identifier$1, { name: decl.ident }),
1680
- /* @__PURE__ */ jsx(TypeParams, { params: decl.typeParameters }),
1681
- /* @__PURE__ */ jsx("span", {
1682
- className: style_default.TextOperator,
1683
- children: " = "
1684
- }),
1685
- /* @__PURE__ */ jsx(Lang.Type, { type: decl.type })
1686
- ] });
1687
- case "TSDeclReference": return /* @__PURE__ */ jsx(Lang.Type, { type: decl.type });
1688
- case "TSDeclInterface": return /* @__PURE__ */ jsxs(Fragment$1, { children: [
1689
- /* @__PURE__ */ jsx("span", {
1690
- className: style_default.TextIdentifier,
1691
- children: decl.ident
1692
- }),
1693
- /* @__PURE__ */ jsx(TypeParams, { params: decl.typeParameters }),
1694
- decl.extends?.map((t, index) => /* @__PURE__ */ jsxs(React$1.Fragment, { children: [/* @__PURE__ */ jsx("span", {
1695
- className: style_default.TextKeyword,
1696
- children: " extends "
1697
- }), /* @__PURE__ */ jsx(Lang.Type, { type: t })] }, index)),
1698
- /* @__PURE__ */ jsx(TypePreview$2, { path: decl.stainlessPath })
1699
- ] });
1700
- case "TSDeclClass": return /* @__PURE__ */ jsxs(Fragment$1, { children: [
1701
- /* @__PURE__ */ jsx("span", {
1702
- className: style_default.TextKeyword,
1703
- children: "class "
1704
- }),
1705
- /* @__PURE__ */ jsx("span", {
1706
- className: style_default.TextIdentifier,
1707
- children: decl.ident
1708
- }),
1709
- /* @__PURE__ */ jsx(TypeParams, { params: decl.typeParameters }),
1710
- decl.superClass ? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("span", {
1711
- className: style_default.TextKeyword,
1712
- children: " extends "
1713
- }), /* @__PURE__ */ jsx(Lang.Type, { type: decl.superClass })] }) : null,
1714
- decl.implements?.map((t, index) => /* @__PURE__ */ jsxs(React$1.Fragment, { children: [/* @__PURE__ */ jsx("span", {
1715
- className: style_default.TextKeyword,
1716
- children: " implements "
1717
- }), /* @__PURE__ */ jsx(Lang.Type, { type: t })] }, index))
1718
- ] });
1719
- }
1720
- }
1721
-
1722
- //#endregion
1723
- //#region src/languages/java.tsx
1724
- var java_exports = /* @__PURE__ */ __export({
1725
- Declaration: () => Declaration$5,
1726
- MethodSignature: () => MethodSignature$5,
1727
- Property: () => Property$5,
1728
- Type: () => Type$5,
1729
- TypeName: () => TypeName$5
1730
- });
1731
- function showFullType$1(type) {
1732
- return type.kind === "JavaTypeReference" && (type.typeName === "List" || type.typeParameters && type.typeParameters.length > 0);
1733
- }
1734
- const constStyle$3 = {
1735
- string: style_default.LiteralString,
1736
- number: style_default.LiteralNumeric,
1737
- boolean: style_default.LiteralBoolean
1738
- };
1739
- function TypeName$5({ type, optional }) {
1740
- const Lang = useLanguageComponents();
1741
- if (type.kind === "JavaTypeReference" && type.typeName === "List") return "List";
1742
- return /* @__PURE__ */ jsx(Lang.Type, {
1743
- type,
1744
- optional
1745
- });
1746
- }
1747
- function Type$5({ type, optional }) {
1748
- const language = useLanguage();
1749
- const Lang = useLanguageComponents();
1750
- const { Join: Join$1, SDKReference: SDKReference$1 } = useComponents();
1751
- switch (type.kind) {
1752
- case "JavaTypeReference": {
1753
- const name = type.typeName.split(".").at(-1);
1754
- const params = type.typeParameters?.map((param, key) => /* @__PURE__ */ jsx(Lang.Type, {
1755
- type: param,
1756
- optional
1757
- }, key));
1758
- return /* @__PURE__ */ jsxs("span", {
1759
- className: style_default.Type,
1760
- children: [/* @__PURE__ */ jsx(SDKReference$1, {
1761
- stainlessPath: type.$ref,
1762
- children: name
1763
- }), params && params.length > 0 ? /* @__PURE__ */ jsxs(Fragment$1, { children: [
1764
- /* @__PURE__ */ jsx("span", {
1765
- className: style_default.TypeBracket,
1766
- children: "<"
1767
- }),
1768
- /* @__PURE__ */ jsx(Join$1, {
1769
- items: params,
1770
- limit: 3,
1771
- children: /* @__PURE__ */ jsx("span", {
1772
- className: style_default.TextOperator,
1773
- children: ", "
1774
- })
1775
- }),
1776
- /* @__PURE__ */ jsx("span", {
1777
- className: style_default.TypeBracket,
1778
- children: ">"
1779
- })
1780
- ] }) : null]
1781
- });
1782
- }
1783
- case "JavaTypeClass":
1784
- case "JavaTypeUnion": return /* @__PURE__ */ jsx("span", {
1785
- className: style_default.Type,
1786
- children: /* @__PURE__ */ jsx("span", {
1787
- className: style_default.TypeKeyword,
1788
- children: "class"
1789
- })
1790
- });
1791
- case "JavaTypeEnum": return /* @__PURE__ */ jsx("span", {
1792
- className: style_default.Type,
1793
- children: /* @__PURE__ */ jsx("span", {
1794
- className: style_default.TypeKeyword,
1795
- children: language === "kotlin" ? "enum class" : "enum"
1796
- })
1797
- });
1798
- case "JavaTypeVoid": return /* @__PURE__ */ jsx("span", {
1799
- className: style_default.Type,
1800
- children: /* @__PURE__ */ jsx("span", {
1801
- className: style_default.TypeKeyword,
1802
- children: language === "kotlin" ? "Nothing?" : "Void"
1803
- })
1804
- });
1805
- case "JavaTypeBoolean": return /* @__PURE__ */ jsx("span", {
1806
- className: style_default.Type,
1807
- children: /* @__PURE__ */ jsx("span", {
1808
- className: style_default.TypeKeyword,
1809
- children: language === "kotlin" || optional ? "Boolean" : "boolean"
1810
- })
1811
- });
1812
- case "JavaTypeDouble": return /* @__PURE__ */ jsx("span", {
1813
- className: style_default.Type,
1814
- children: /* @__PURE__ */ jsx("span", {
1815
- className: style_default.TypeKeyword,
1816
- children: language === "kotlin" || optional ? "Double" : "double"
1817
- })
1818
- });
1819
- case "JavaTypeLong": return /* @__PURE__ */ jsx("span", {
1820
- className: style_default.Type,
1821
- children: /* @__PURE__ */ jsx("span", {
1822
- className: style_default.TypeKeyword,
1823
- children: language === "kotlin" || optional ? "Long" : "long"
1824
- })
1825
- });
1826
- case "JavaTypeString": return /* @__PURE__ */ jsx("span", {
1827
- className: style_default.Type,
1828
- children: /* @__PURE__ */ jsx("span", {
1829
- className: style_default.TypeString,
1830
- children: "String"
1831
- })
1832
- });
1833
- case "JavaTypeConstant": return /* @__PURE__ */ jsxs("span", {
1834
- className: style_default.Type,
1835
- children: [/* @__PURE__ */ jsx("span", {
1836
- className: style_default.TypeKeyword,
1837
- children: "JsonValue"
1838
- }), ";"]
1839
- });
1840
- }
1841
- }
1842
- function MethodSignature$5({ decl }) {
1843
- const Lang = useLanguageComponents();
1844
- const language = useLanguage();
1845
- const { Join: Join$1, Tooltip: Tooltip$1 } = useComponents();
1846
- const params = decl.parameters.map((param, i) => /* @__PURE__ */ jsx(React$1.Fragment, { children: /* @__PURE__ */ jsxs(Tooltip$1, {
1847
- content: /* @__PURE__ */ jsx(Lang.Type, { type: param.typeAnnotation }),
1848
- children: [/* @__PURE__ */ jsx("span", {
1849
- className: style_default.TextIdentifier,
1850
- children: param.ident
1851
- }), param.hasDefault && /* @__PURE__ */ jsxs(Fragment$1, { children: [
1852
- " ",
1853
- /* @__PURE__ */ jsx("span", {
1854
- className: style_default.TextOperator,
1855
- children: "="
1856
- }),
1857
- " ",
1858
- /* @__PURE__ */ jsx(Lang.Type, { type: param.typeAnnotation }),
1859
- /* @__PURE__ */ jsx("span", {
1860
- className: style_default.TextOperator,
1861
- children: "."
1862
- }),
1863
- /* @__PURE__ */ jsx("span", {
1864
- className: style_default.TextIdentifier,
1865
- children: "none"
1866
- }),
1867
- /* @__PURE__ */ jsx("span", {
1868
- className: style_default.TextOperator,
1869
- children: "()"
1870
- })
1871
- ] })]
1872
- }) }, i));
1873
- return /* @__PURE__ */ jsx("div", {
1874
- className: style_default.MethodSignature,
1875
- children: /* @__PURE__ */ jsxs("span", {
1876
- className: style_default.SignatureTitle,
1877
- children: [
1878
- decl.returnType && language !== "kotlin" && /* @__PURE__ */ jsxs("span", {
1879
- className: style_default.SignatureReturns,
1880
- children: [/* @__PURE__ */ jsx(Lang.Type, { type: decl.returnType }), " "]
1881
- }),
1882
- decl.qualified && /* @__PURE__ */ jsx("span", {
1883
- className: style_default.SignatureQualified,
1884
- children: /* @__PURE__ */ jsx("span", {
1885
- className: style_default.TextIdentifier,
1886
- children: decl.qualified?.slice(0, -decl.ident.length)
1887
- })
1888
- }),
1889
- /* @__PURE__ */ jsx("span", {
1890
- className: style_default.SignatureName,
1891
- children: /* @__PURE__ */ jsx("span", {
1892
- className: style_default.TextIdentifier,
1893
- children: decl.ident
1894
- })
1895
- }),
1896
- /* @__PURE__ */ jsxs("span", {
1897
- className: style_default.MethodSignature,
1898
- children: [
1899
- /* @__PURE__ */ jsx("span", {
1900
- className: style_default.SignatureParen,
1901
- children: "("
1902
- }),
1903
- /* @__PURE__ */ jsx("span", {
1904
- className: style_default.SignatureParams,
1905
- children: /* @__PURE__ */ jsx(Join$1, {
1906
- items: params,
1907
- children: /* @__PURE__ */ jsx("span", {
1908
- className: style_default.TextOperator,
1909
- children: ", "
1910
- })
1911
- })
1912
- }),
1913
- /* @__PURE__ */ jsxs("span", {
1914
- className: style_default.SignatureParen,
1915
- children: [")", " "]
1916
- }),
1917
- decl.returnType && language === "kotlin" && /* @__PURE__ */ jsxs(Fragment$1, { children: [
1918
- /* @__PURE__ */ jsx("span", {
1919
- className: style_default.TextOperator,
1920
- children: ":"
1921
- }),
1922
- " ",
1923
- /* @__PURE__ */ jsx(Lang.Type, { type: decl.returnType })
1924
- ] })
1925
- ]
1926
- })
1927
- ]
1928
- })
1929
- });
1930
- }
1931
- function Property$5({ decl, children }) {
1932
- const Docs = useComponents();
1933
- const Lang = useLanguageComponents();
1934
- const language = useLanguage();
1935
- if (!decl) return null;
1936
- switch (decl.kind) {
1937
- case "JavaDeclProperty": {
1938
- const typeRaw = /* @__PURE__ */ jsx(Lang.Type, {
1939
- type: decl.type,
1940
- optional: decl.optional
1941
- });
1942
- const typeWrapped = decl.optional ? /* @__PURE__ */ jsxs(Fragment$1, { children: [
1943
- /* @__PURE__ */ jsx("span", {
1944
- className: style_default.TypeKeyword,
1945
- children: "Optional"
1946
- }),
1947
- /* @__PURE__ */ jsx("span", {
1948
- className: style_default.TypeBracket,
1949
- children: "<"
1950
- }),
1951
- typeRaw,
1952
- /* @__PURE__ */ jsx("span", {
1953
- className: style_default.TypeBracket,
1954
- children: ">"
1955
- })
1956
- ] }) : typeRaw;
1957
- const badges = /* @__PURE__ */ jsx(Fragment$1, { children: decl.type.kind === "JavaTypeConstant" && /* @__PURE__ */ jsx(Docs.Tooltip, {
1958
- content: /* @__PURE__ */ jsx("span", {
1959
- className: style_default.TextIdentifier,
1960
- children: decl.type.value
1961
- }),
1962
- children: /* @__PURE__ */ jsx("span", {
1963
- className: style_default.TextIdentifier,
1964
- children: "constant"
1965
- })
1966
- }) });
1967
- return children({
1968
- name: decl.ident,
1969
- typeName: /* @__PURE__ */ jsx(Lang.TypeName, {
1970
- type: decl.type,
1971
- optional: decl.optional
1972
- }),
1973
- type: showFullType$1(decl.type) && typeWrapped,
1974
- badges
1975
- });
1976
- }
1977
- case "JavaDeclConst": return children({
1978
- name: decl.ident,
1979
- typeName: "const",
1980
- type: /* @__PURE__ */ jsx("span", {
1981
- className: constStyle$3[typeof decl.value],
1982
- children: JSON.stringify(decl.value)
1983
- })
1984
- });
1985
- case "JavaDeclType": {
1986
- const typeName$1 = decl.type.kind === "JavaTypeUnion" ? "union" : decl.type.kind === "JavaTypeEnum" ? language === "kotlin" ? "enum class" : "enum" : "class";
1987
- return children({
1988
- name: decl.ident,
1989
- typeName: typeName$1
1990
- });
1991
- }
1992
- case "JavaDeclReference": return children({ type: /* @__PURE__ */ jsx(Lang.Type, { type: decl.type }) });
1993
- }
1994
- }
1995
- function Declaration$5({ decl }) {
1996
- const Docs = useComponents();
1997
- const Lang = useLanguageComponents();
1998
- const language = useLanguage();
1999
- if (!decl) return null;
2000
- switch (decl.kind) {
2001
- case "JavaDeclConst": return /* @__PURE__ */ jsxs(Fragment$1, { children: [
2002
- /* @__PURE__ */ jsx("span", {
2003
- className: style_default.TextIdentifier,
2004
- children: decl.ident
2005
- }),
2006
- /* @__PURE__ */ jsx("span", {
2007
- className: style_default.TextPunctuation,
2008
- children: "("
2009
- }),
2010
- JSON.stringify(decl.value),
2011
- /* @__PURE__ */ jsx("span", {
2012
- className: style_default.TextPunctuation,
2013
- children: ")"
2014
- })
2015
- ] });
2016
- case "JavaDeclType": {
2017
- const keyword = decl.type.kind === "JavaTypeEnum" ? language === "kotlin" ? "enum class" : "enum" : "class";
2018
- return /* @__PURE__ */ jsxs(Fragment$1, { children: [
2019
- /* @__PURE__ */ jsx("span", {
2020
- className: style_default.TextKeyword,
2021
- children: keyword
2022
- }),
2023
- " ",
2024
- /* @__PURE__ */ jsx("span", {
2025
- className: style_default.TextIdentifier,
2026
- children: decl.ident
2027
- }),
2028
- /* @__PURE__ */ jsx("span", {
2029
- className: style_default.TextPunctuation,
2030
- children: ":"
2031
- }),
2032
- decl.type.kind === "JavaTypeUnion" && /* @__PURE__ */ jsxs(Fragment$1, { children: [
2033
- " ",
2034
- /* @__PURE__ */ jsx(Docs.Tooltip, {
2035
- content: "A class that can be one of several variants.",
2036
- children: /* @__PURE__ */ jsx(Docs.Badge, {
2037
- id: "java-union",
2038
- children: "union"
2039
- })
2040
- }),
2041
- " "
2042
- ] })
2043
- ] });
2044
- }
2045
- case "JavaDeclProperty": {
2046
- const inlineType = /* @__PURE__ */ jsx(Lang.Type, {
2047
- type: decl.type,
2048
- optional: decl.optional
2049
- });
2050
- const ident = /* @__PURE__ */ jsx("span", {
2051
- className: style_default.TypePropertyName,
2052
- children: /* @__PURE__ */ jsx("span", {
2053
- className: style_default.TextIdentifier,
2054
- children: decl.ident
2055
- })
2056
- });
2057
- const suffix = decl.type.kind === "JavaTypeConstant" ? /* @__PURE__ */ jsxs(Fragment$1, { children: [" ", /* @__PURE__ */ jsx(Docs.Tooltip, {
2058
- content: /* @__PURE__ */ jsx("span", {
2059
- className: style_default.TextIdentifier,
2060
- children: decl.type.value
2061
- }),
2062
- children: /* @__PURE__ */ jsx(Docs.Badge, {
2063
- id: "java-constant",
2064
- children: "constant"
2065
- })
2066
- })] }) : null;
2067
- if (language === "kotlin") return /* @__PURE__ */ jsxs(Fragment$1, { children: [
2068
- ident,
2069
- /* @__PURE__ */ jsx("span", {
2070
- className: style_default.TextPunctuation,
2071
- children: ":"
2072
- }),
2073
- " ",
2074
- decl.optional ? /* @__PURE__ */ jsxs(Fragment$1, { children: [
2075
- /* @__PURE__ */ jsx("span", {
2076
- className: style_default.TypeReference,
2077
- children: "Optional"
2078
- }),
2079
- /* @__PURE__ */ jsx("span", {
2080
- className: style_default.TypeBracket,
2081
- children: "<"
2082
- }),
2083
- inlineType,
2084
- /* @__PURE__ */ jsx("span", {
2085
- className: style_default.TypeBracket,
2086
- children: ">"
2087
- })
2088
- ] }) : inlineType,
2089
- suffix
2090
- ] });
2091
- return /* @__PURE__ */ jsxs(Fragment$1, { children: [
2092
- decl.optional ? /* @__PURE__ */ jsxs(Fragment$1, { children: [
2093
- /* @__PURE__ */ jsx("span", {
2094
- className: style_default.TypeReference,
2095
- children: "Optional"
2096
- }),
2097
- /* @__PURE__ */ jsx("span", {
2098
- className: style_default.TypeBracket,
2099
- children: "<"
2100
- }),
2101
- inlineType,
2102
- /* @__PURE__ */ jsx("span", {
2103
- className: style_default.TypeBracket,
2104
- children: ">"
2105
- })
2106
- ] }) : inlineType,
2107
- " ",
2108
- ident,
2109
- suffix
2110
- ] });
2111
- }
2112
- case "JavaDeclReference": return /* @__PURE__ */ jsx(Lang.Type, { type: decl.type });
2113
- }
2114
- }
2115
-
2116
- //#endregion
2117
- //#region src/languages/go.tsx
2118
- var go_exports = /* @__PURE__ */ __export({
2119
- Declaration: () => Declaration$4,
2120
- MethodSignature: () => MethodSignature$4,
2121
- Property: () => Property$4,
2122
- Type: () => Type$4,
2123
- TypeName: () => TypeName$4
2124
- });
2125
- const ComplexTypes$2 = {
2126
- GoTypeMap: "map",
2127
- GoTypeArray: "array"
2128
- };
2129
- const Keywords$1 = {
2130
- GoTypeAny: "any",
2131
- GoTypeUnknown: "unknown",
2132
- GoTypeInt: "int64",
2133
- GoTypeFloat: "float64",
2134
- GoTypeBool: "bool",
2135
- GoTypeError: "error"
2136
- };
2137
- function isField(type) {
2138
- return type.kind === "GoTypeReference" && type.typeName === "param.Field";
2139
- }
2140
- function TypeName$4({ type }) {
2141
- const Lang = useLanguageComponents();
2142
- return isField(type) ? "field" : ComplexTypes$2[type.kind] ?? /* @__PURE__ */ jsx(Lang.Type, { type });
2143
- }
2144
- function Type$4({ type }) {
2145
- const Lang = useLanguageComponents();
2146
- const { Join: Join$1, SDKReference: SDKReference$1 } = useComponents();
2147
- switch (type.kind) {
2148
- case "GoTypeReference": {
2149
- const params = type.typeParameters?.map((param, key) => /* @__PURE__ */ jsx(Lang.Type, { type: param }, key));
2150
- return /* @__PURE__ */ jsxs("span", {
2151
- className: style_default.Type,
2152
- children: [type.$ref ? /* @__PURE__ */ jsx(SDKReference$1, {
2153
- stainlessPath: type.$ref,
2154
- children: type.typeName
2155
- }) : type.typeName, params && params.length > 0 ? /* @__PURE__ */ jsxs(Fragment$1, { children: [
2156
- /* @__PURE__ */ jsx("span", {
2157
- className: style_default.TypeBracket,
2158
- children: "["
2159
- }),
2160
- /* @__PURE__ */ jsx(Join$1, {
2161
- items: params,
2162
- limit: 3,
2163
- children: /* @__PURE__ */ jsx("span", {
2164
- className: style_default.TextOperator,
2165
- children: ", "
2166
- })
2167
- }),
2168
- /* @__PURE__ */ jsx("span", {
2169
- className: style_default.TypeBracket,
2170
- children: "]"
2171
- })
2172
- ] }) : null]
2173
- });
2174
- }
2175
- case "GoTypeAny":
2176
- case "GoTypeUnknown":
2177
- case "GoTypeInt":
2178
- case "GoTypeFloat":
2179
- case "GoTypeBool":
2180
- case "GoTypeError": return /* @__PURE__ */ jsx("span", {
2181
- className: style_default.Type,
2182
- children: /* @__PURE__ */ jsx("span", {
2183
- className: style_default.TypeKeyword,
2184
- children: Keywords$1[type.kind]
2185
- })
2186
- });
2187
- case "GoTypeString": return /* @__PURE__ */ jsx("span", {
2188
- className: style_default.Type,
2189
- children: /* @__PURE__ */ jsx("span", {
2190
- className: style_default.TypeString,
2191
- children: "string"
2192
- })
2193
- });
2194
- case "GoTypeArray": return /* @__PURE__ */ jsxs("span", {
2195
- className: style_default.Type,
2196
- children: [/* @__PURE__ */ jsx("span", {
2197
- className: style_default.TextOperator,
2198
- children: "[]"
2199
- }), /* @__PURE__ */ jsx(Lang.Type, { type: type.elementType })]
2200
- });
2201
- case "GoTypeStruct": return /* @__PURE__ */ jsx("span", {
2202
- className: style_default.Type,
2203
- children: /* @__PURE__ */ jsx("span", {
2204
- className: style_default.TypeKeyword,
2205
- children: "struct{…}"
2206
- })
2207
- });
2208
- case "GoTypeInterface": return /* @__PURE__ */ jsx("span", {
2209
- className: style_default.Type,
2210
- children: /* @__PURE__ */ jsx("span", {
2211
- className: style_default.TypeKeyword,
2212
- children: "interface{…}"
2213
- })
2214
- });
2215
- case "GoTypeMap": return /* @__PURE__ */ jsxs("span", {
2216
- className: style_default.Type,
2217
- children: [
2218
- /* @__PURE__ */ jsx("span", {
2219
- className: style_default.TypeKeyword,
2220
- children: "map"
2221
- }),
2222
- /* @__PURE__ */ jsx("span", {
2223
- className: style_default.TypeBracket,
2224
- children: "["
2225
- }),
2226
- /* @__PURE__ */ jsx(Lang.Type, { type: type.indexType }),
2227
- /* @__PURE__ */ jsx("span", {
2228
- className: style_default.TextPunctuation,
2229
- children: ","
2230
- }),
2231
- " ",
2232
- /* @__PURE__ */ jsx(Lang.Type, { type: type.itemType }),
2233
- /* @__PURE__ */ jsx("span", {
2234
- className: style_default.TypeBracket,
2235
- children: "]"
2236
- })
2237
- ]
2238
- });
2239
- case "GoTypePointer": return /* @__PURE__ */ jsxs("span", {
2240
- className: style_default.Type,
2241
- children: [/* @__PURE__ */ jsx("span", {
2242
- className: style_default.TextOperator,
2243
- children: "*"
2244
- }), /* @__PURE__ */ jsx(Lang.Type, { type: type.inner })]
2245
- });
2246
- }
2247
- }
2248
- function MethodSignature$4({ decl }) {
2249
- const Lang = useLanguageComponents();
2250
- const { Join: Join$1 } = useComponents();
2251
- const params = decl.parameters.map((param, i) => /* @__PURE__ */ jsxs(React$1.Fragment, { children: [/* @__PURE__ */ jsx("span", {
2252
- className: style_default.TextIdentifier,
2253
- children: param.ident
2254
- }), param.optional && /* @__PURE__ */ jsx("span", {
2255
- className: style_default.TextPunctuation,
2256
- children: "?"
2257
- })] }, i));
2258
- const returns = decl.returnType.map((t, key) => /* @__PURE__ */ jsx(Lang.Type, { type: t }, key));
2259
- return /* @__PURE__ */ jsx("div", {
2260
- className: style_default.MethodSignature,
2261
- children: /* @__PURE__ */ jsxs("span", {
2262
- className: style_default.SignatureTitle,
2263
- children: [
2264
- decl.async && /* @__PURE__ */ jsx("span", {
2265
- className: style_default.TextKeyword,
2266
- children: "async "
2267
- }),
2268
- decl.qualified && /* @__PURE__ */ jsx("span", {
2269
- className: style_default.SignatureQualified,
2270
- children: /* @__PURE__ */ jsx("span", {
2271
- className: style_default.TextIdentifier,
2272
- children: decl.qualified?.slice(0, -decl.ident.length)
2273
- })
2274
- }),
2275
- decl.kind === "GoDeclFunction" && /* @__PURE__ */ jsx("span", {
2276
- className: style_default.SignatureName,
2277
- children: /* @__PURE__ */ jsx("span", {
2278
- className: style_default.TextIdentifier,
2279
- children: decl.ident
2280
- })
2281
- }),
2282
- /* @__PURE__ */ jsxs("span", {
2283
- className: style_default.MethodSignature,
2284
- children: [
2285
- /* @__PURE__ */ jsx("span", {
2286
- className: style_default.SignatureParen,
2287
- children: "("
2288
- }),
2289
- /* @__PURE__ */ jsx("span", {
2290
- className: style_default.SignatureParams,
2291
- children: /* @__PURE__ */ jsx(Join$1, {
2292
- items: params,
2293
- children: /* @__PURE__ */ jsx("span", {
2294
- className: style_default.TextOperator,
2295
- children: ", "
2296
- })
2297
- })
2298
- }),
2299
- /* @__PURE__ */ jsxs("span", {
2300
- className: style_default.SignatureParen,
2301
- children: [")", " "]
2302
- }),
2303
- decl.returnType.length === 1 ? returns : /* @__PURE__ */ jsxs(Fragment$1, { children: [
2304
- /* @__PURE__ */ jsx("span", {
2305
- className: style_default.SignatureParen,
2306
- children: "("
2307
- }),
2308
- /* @__PURE__ */ jsx(Join$1, {
2309
- items: returns,
2310
- children: /* @__PURE__ */ jsx("span", {
2311
- className: style_default.TextOperator,
2312
- children: ", "
2313
- })
2314
- }),
2315
- /* @__PURE__ */ jsx("span", {
2316
- className: style_default.SignatureParen,
2317
- children: ")"
2318
- })
2319
- ] })
2320
- ]
2321
- })
2322
- ]
2323
- })
2324
- });
2325
- }
2326
- function Property$4({ decl, children }) {
2327
- const Docs = useComponents();
2328
- const Lang = useLanguageComponents();
2329
- if (!decl) return null;
2330
- switch (decl.kind) {
2331
- case "GoDeclProperty": return children({
2332
- name: decl.ident,
2333
- typeName: /* @__PURE__ */ jsx(Lang.TypeName, { type: decl.type }),
2334
- badges: decl.optional && /* @__PURE__ */ jsx(Docs.Badge, { id: "optional" }),
2335
- type: (isField(decl.type) || decl.type.kind in ComplexTypes$2) && /* @__PURE__ */ jsx(Lang.Type, { type: decl.type })
2336
- });
2337
- case "GoDeclConst": return children({
2338
- name: decl.ident,
2339
- typeName: "const",
2340
- type: /* @__PURE__ */ jsx(Lang.Type, { type: decl.type })
2341
- });
2342
- case "GoDeclReference": return children({ type: /* @__PURE__ */ jsx(Lang.Type, { type: decl.type }) });
2343
- case "GoDeclType":
2344
- case "GoDeclTypeAlias": {
2345
- const typeName$1 = decl.type.kind === "GoTypeStruct" ? "struct" : decl.type.kind === "GoTypeInterface" ? "interface" : decl.kind === "GoDeclTypeAlias" ? "alias" : "type";
2346
- return children({
2347
- name: decl.ident,
2348
- typeName: typeName$1,
2349
- type: ["GoTypeStruct", "GoTypeInterface"].includes(decl.type.kind) || /* @__PURE__ */ jsx(Lang.Type, { type: decl.type })
2350
- });
2351
- }
2352
- }
2353
- }
2354
- function Declaration$4({ decl }) {
2355
- const Lang = useLanguageComponents();
2356
- if (!decl) return;
2357
- switch (decl.kind) {
2358
- case "GoDeclType": return /* @__PURE__ */ jsxs(Fragment$1, { children: [
2359
- /* @__PURE__ */ jsx("span", {
2360
- className: style_default.TextKeyword,
2361
- children: "type "
2362
- }),
2363
- /* @__PURE__ */ jsxs("span", {
2364
- className: style_default.TextIdentifier,
2365
- children: [decl.ident, " "]
2366
- }),
2367
- /* @__PURE__ */ jsx(Lang.Type, { type: decl.type })
2368
- ] });
2369
- case "GoDeclTypeAlias": return /* @__PURE__ */ jsxs(Fragment$1, { children: [
2370
- /* @__PURE__ */ jsx("span", {
2371
- className: style_default.TextKeyword,
2372
- children: "type "
2373
- }),
2374
- /* @__PURE__ */ jsxs("span", {
2375
- className: style_default.TextIdentifier,
2376
- children: [decl.ident, " "]
2377
- }),
2378
- /* @__PURE__ */ jsx("span", {
2379
- className: style_default.TextOperator,
2380
- children: "= "
2381
- }),
2382
- /* @__PURE__ */ jsx(Lang.Type, { type: decl.type })
2383
- ] });
2384
- case "GoDeclProperty": return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("span", {
2385
- className: style_default.TypePropertyName,
2386
- children: /* @__PURE__ */ jsxs("span", {
2387
- className: style_default.TextIdentifier,
2388
- children: [decl.ident, " "]
2389
- })
2390
- }), /* @__PURE__ */ jsx(Lang.Type, { type: decl.type })] });
2391
- case "GoDeclReference": return /* @__PURE__ */ jsx(Lang.Type, { type: decl.type });
2392
- case "GoDeclConst": return /* @__PURE__ */ jsxs(Fragment$1, { children: [
2393
- /* @__PURE__ */ jsx("span", {
2394
- className: style_default.TextKeyword,
2395
- children: "const "
2396
- }),
2397
- /* @__PURE__ */ jsxs("span", {
2398
- className: style_default.TextIdentifier,
2399
- children: [decl.ident, " "]
2400
- }),
2401
- /* @__PURE__ */ jsx(Lang.Type, { type: decl.type }),
2402
- /* @__PURE__ */ jsx("span", {
2403
- className: style_default.TextOperator,
2404
- children: " = "
2405
- }),
2406
- JSON.stringify(decl.value)
2407
- ] });
2408
- }
2409
- }
2410
-
2411
- //#endregion
2412
- //#region src/languages/python.tsx
2413
- var python_exports = /* @__PURE__ */ __export({
2414
- Declaration: () => Declaration$3,
2415
- MethodSignature: () => MethodSignature$3,
2416
- Property: () => Property$3,
2417
- Type: () => Type$3,
2418
- TypeName: () => TypeName$3
2419
- });
2420
- const constStyle$2 = {
2421
- string: style_default.LiteralString,
2422
- number: style_default.LiteralNumeric,
2423
- boolean: style_default.LiteralBoolean
2424
- };
2425
- function showFullType(type) {
2426
- if (type.kind !== "PythonTypeReference") return false;
2427
- return type.typeName === "Optional" ? showFullType(type.typeParameters[0]) : type.typeParameters.length > 0;
2428
- }
2429
- function TypeName$3({ type }) {
2430
- const Lang = useLanguageComponents();
2431
- if (type.kind === "PythonTypeReference") switch (type.typeName) {
2432
- case "Optional": return /* @__PURE__ */ jsx(Lang.TypeName, { type: type.typeParameters[0] });
2433
- case "List":
2434
- case "Iterable":
2435
- case "Literal":
2436
- case "Union": return type.typeName.toLowerCase();
2437
- }
2438
- return /* @__PURE__ */ jsx(Lang.Type, { type });
2439
- }
2440
- function Type$3({ type }) {
2441
- const Lang = useLanguageComponents();
2442
- const { Join: Join$1, SDKReference: SDKReference$1 } = useComponents();
2443
- switch (type.kind) {
2444
- case "PythonTypeAny":
2445
- case "PythonTypeUnknown":
2446
- case "PythonTypeInt":
2447
- case "PythonTypeFloat":
2448
- case "PythonTypeBool": return /* @__PURE__ */ jsx("span", {
2449
- className: style_default.Type,
2450
- children: /* @__PURE__ */ jsx("span", {
2451
- className: style_default.TypeKeyword,
2452
- children: type.kind.slice(10).toLowerCase()
2453
- })
2454
- });
2455
- case "PythonTypeString": return /* @__PURE__ */ jsx("span", {
2456
- className: style_default.Type,
2457
- children: /* @__PURE__ */ jsx("span", {
2458
- className: style_default.TypeString,
2459
- children: "str"
2460
- })
2461
- });
2462
- case "PythonTypeLiteral": return /* @__PURE__ */ jsx("span", {
2463
- className: style_default.Type,
2464
- children: /* @__PURE__ */ jsx("span", {
2465
- className: constStyle$2[typeof type.literal.value],
2466
- children: JSON.stringify(type.literal.value)
2467
- })
2468
- });
2469
- case "PythonTypeArray": return /* @__PURE__ */ jsxs("span", {
2470
- className: style_default.Type,
2471
- children: [
2472
- /* @__PURE__ */ jsx("span", {
2473
- className: style_default.TypeArray,
2474
- children: "Array<"
2475
- }),
2476
- /* @__PURE__ */ jsx(Lang.Type, { type: type.elementType }),
2477
- /* @__PURE__ */ jsx("span", {
2478
- className: style_default.TypeArray,
2479
- children: ">"
2480
- })
2481
- ]
2482
- });
2483
- case "PythonTypeClass": return /* @__PURE__ */ jsx("span", {
2484
- className: style_default.Type,
2485
- children: /* @__PURE__ */ jsx("span", {
2486
- className: style_default.TypeKeyword,
2487
- children: "class"
2488
- })
2489
- });
2490
- case "PythonTypeMap": return /* @__PURE__ */ jsx("span", {
2491
- className: style_default.Type,
2492
- children: /* @__PURE__ */ jsx("span", {
2493
- className: style_default.TypeKeyword,
2494
- children: "Dict"
2495
- })
2496
- });
2497
- case "PythonTypeReference": {
2498
- const params = type.typeParameters?.map((param, key) => /* @__PURE__ */ jsx(Lang.Type, { type: param }, key));
2499
- return /* @__PURE__ */ jsxs("span", {
2500
- className: style_default.Type,
2501
- children: [/* @__PURE__ */ jsx("span", {
2502
- className: type.typeName === "Optional" ? style_default.TypeArray : "",
2503
- children: /* @__PURE__ */ jsx(SDKReference$1, {
2504
- stainlessPath: type.$ref,
2505
- children: type.typeName
2506
- })
2507
- }), params && params.length > 0 && /* @__PURE__ */ jsxs(Fragment$1, { children: [
2508
- /* @__PURE__ */ jsx("span", {
2509
- className: style_default.TypeBracket,
2510
- children: "["
2511
- }),
2512
- /* @__PURE__ */ jsx(Join$1, {
2513
- items: params,
2514
- limit: 3,
2515
- children: /* @__PURE__ */ jsx("span", {
2516
- className: style_default.TextOperator,
2517
- children: ", "
2518
- })
2519
- }),
2520
- /* @__PURE__ */ jsx("span", {
2521
- className: style_default.TypeBracket,
2522
- children: "]"
2523
- })
2524
- ] })]
2525
- });
2526
- }
2527
- }
2528
- }
2529
- function MethodSignature$3({ decl }) {
2530
- const Lang = useLanguageComponents();
2531
- const { Join: Join$1, Tooltip: Tooltip$1 } = useComponents();
2532
- const params = decl.parameters.map((param, i) => /* @__PURE__ */ jsx(React$1.Fragment, { children: /* @__PURE__ */ jsx(Tooltip$1, {
2533
- content: /* @__PURE__ */ jsx(Lang.Type, { type: param.type }),
2534
- children: /* @__PURE__ */ jsx("span", {
2535
- className: style_default.TextIdentifier,
2536
- children: param.ident
2537
- })
2538
- }) }, i));
2539
- return /* @__PURE__ */ jsx("div", {
2540
- className: style_default.MethodSignature,
2541
- children: /* @__PURE__ */ jsxs("span", {
2542
- className: style_default.SignatureTitle,
2543
- children: [
2544
- decl.async && /* @__PURE__ */ jsx("span", {
2545
- className: style_default.TextKeyword,
2546
- children: "async "
2547
- }),
2548
- decl.qualified && /* @__PURE__ */ jsx("span", {
2549
- className: style_default.SignatureQualified,
2550
- children: /* @__PURE__ */ jsx("span", {
2551
- className: style_default.TextIdentifier,
2552
- children: decl.qualified?.slice(0, -decl.ident.length)
2553
- })
2554
- }),
2555
- /* @__PURE__ */ jsx("span", {
2556
- className: style_default.SignatureName,
2557
- children: /* @__PURE__ */ jsx("span", {
2558
- className: style_default.TextIdentifier,
2559
- children: decl.ident
2560
- })
2561
- }),
2562
- /* @__PURE__ */ jsxs("span", {
2563
- className: style_default.MethodSignature,
2564
- children: [
2565
- /* @__PURE__ */ jsx("span", {
2566
- className: style_default.SignatureParen,
2567
- children: "("
2568
- }),
2569
- /* @__PURE__ */ jsx("span", {
2570
- className: style_default.SignatureParams,
2571
- children: /* @__PURE__ */ jsx(Join$1, {
2572
- items: params,
2573
- children: /* @__PURE__ */ jsx("span", {
2574
- className: style_default.TextOperator,
2575
- children: ", "
2576
- })
2577
- })
2578
- }),
2579
- /* @__PURE__ */ jsxs("span", {
2580
- className: style_default.SignatureParen,
2581
- children: [")", " "]
2582
- }),
2583
- decl.returns && /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("span", {
2584
- className: style_default.TextOperator,
2585
- children: " -> "
2586
- }), /* @__PURE__ */ jsx(Lang.Type, { type: decl.returns })] })
2587
- ]
2588
- })
2589
- ]
2590
- })
2591
- });
2592
- }
2593
- function Property$3({ decl, children }) {
2594
- const Lang = useLanguageComponents();
2595
- if (!decl) return;
2596
- switch (decl.kind) {
2597
- case "PythonDeclProperty": return children({
2598
- name: decl.ident,
2599
- typeName: /* @__PURE__ */ jsx(Lang.TypeName, { type: decl.type }),
2600
- type: showFullType(decl.type) && /* @__PURE__ */ jsx(Lang.Type, { type: decl.type })
2601
- });
2602
- case "PythonDeclClass": return children({
2603
- name: decl.ident,
2604
- typeName: "class"
2605
- });
2606
- case "PythonDeclType": return children({
2607
- name: decl.ident,
2608
- typeName: "type",
2609
- type: /* @__PURE__ */ jsx(Lang.Type, { type: decl.type })
2610
- });
2611
- case "PythonDeclReference": return children({ type: /* @__PURE__ */ jsx(Lang.Type, { type: decl.type }) });
2612
- }
2613
- }
2614
- function Declaration$3({ decl }) {
2615
- const Lang = useLanguageComponents();
2616
- if (!decl) return;
2617
- switch (decl.kind) {
2618
- case "PythonDeclProperty": {
2619
- const nullable = decl.type.kind === "PythonTypeReference" && decl.type.typeName === "Optional" && (decl.type.typeParameters ?? []).length > 0;
2620
- return /* @__PURE__ */ jsxs(Fragment$1, { children: [
2621
- /* @__PURE__ */ jsx("span", {
2622
- className: style_default.TypePropertyName,
2623
- children: /* @__PURE__ */ jsx("span", {
2624
- className: style_default.TextIdentifier,
2625
- children: decl.ident
2626
- })
2627
- }),
2628
- /* @__PURE__ */ jsx("span", {
2629
- className: style_default.TextPunctuation,
2630
- children: ": "
2631
- }),
2632
- decl.optional && !nullable ? /* @__PURE__ */ jsxs(Fragment$1, { children: [
2633
- /* @__PURE__ */ jsx("span", {
2634
- className: style_default.TypePlain,
2635
- children: "Optional"
2636
- }),
2637
- /* @__PURE__ */ jsx("span", {
2638
- className: style_default.TypeBracket,
2639
- children: "["
2640
- }),
2641
- /* @__PURE__ */ jsx(Lang.Type, { type: decl.type }),
2642
- /* @__PURE__ */ jsx("span", {
2643
- className: style_default.TypeBrace,
2644
- children: "]"
2645
- })
2646
- ] }) : /* @__PURE__ */ jsx(Lang.Type, { type: decl.type })
2647
- ] });
2648
- }
2649
- case "PythonDeclClass": return /* @__PURE__ */ jsxs(Fragment$1, { children: [
2650
- /* @__PURE__ */ jsx("span", {
2651
- className: style_default.TextKeyword,
2652
- children: "class "
2653
- }),
2654
- /* @__PURE__ */ jsx("span", {
2655
- className: style_default.TextIdentifier,
2656
- children: decl.ident
2657
- }),
2658
- /* @__PURE__ */ jsx("span", {
2659
- className: style_default.TextPunctuation,
2660
- children: ": "
2661
- }),
2662
- /* @__PURE__ */ jsx("span", {
2663
- className: `${style_default.TypePreviewContent} ${style_default.TextPunctuation}`,
2664
- children: "…"
2665
- })
2666
- ] });
2667
- case "PythonDeclType": return /* @__PURE__ */ jsxs(Fragment$1, { children: [
2668
- /* @__PURE__ */ jsx("span", {
2669
- className: style_default.TextIdentifier,
2670
- children: decl.ident
2671
- }),
2672
- /* @__PURE__ */ jsx("span", {
2673
- className: style_default.TextOperator,
2674
- children: " = "
2675
- }),
2676
- /* @__PURE__ */ jsx(Lang.Type, { type: decl.type })
2677
- ] });
2678
- case "PythonDeclReference": return /* @__PURE__ */ jsx(Lang.Type, { type: decl.type });
2679
- }
2680
- }
2681
-
2682
- //#endregion
2683
- //#region src/languages/ruby.tsx
2684
- var ruby_exports = /* @__PURE__ */ __export({
2685
- Declaration: () => Declaration$2,
2686
- MethodSignature: () => MethodSignature$2,
2687
- Property: () => Property$2,
2688
- Type: () => Type$2,
2689
- TypeName: () => TypeName$2
2690
- });
2691
- const ComplexTypes$1 = {
2692
- RubyTypeObject: "object",
2693
- RubyTypeUnion: "union",
2694
- RubyTypeIntersection: "intersection",
2695
- RubyTypeArray: "array",
2696
- RubyTypeMap: "hash"
2697
- };
2698
- const Keywords = {
2699
- RubyTypeBinary: "StringIO",
2700
- RubyTypeUnknown: "untyped",
2701
- RubyTypeNull: "nil",
2702
- RubyTypeInteger: "Integer",
2703
- RubyTypeFloat: "Float",
2704
- RubyTypeBoolean: "bool"
2705
- };
2706
- function TypeName$2({ type }) {
2707
- const Lang = useLanguageComponents();
2708
- return ComplexTypes$1[type.kind] ?? /* @__PURE__ */ jsx(Lang.Type, { type });
2709
- }
2710
- const VALID_IDENTIFIER = /^[_A-Za-z][_A-Za-z0-9]*$/;
2711
- function TypePreview$1({ path }) {
2712
- const spec = useSpec();
2713
- const language = useLanguage();
2714
- const decl = useDeclaration(path, false);
2715
- const { Join: Join$1 } = useComponents();
2716
- if (!(decl && "children" in decl && decl.children && decl.children.length > 0) || "type" in decl && decl["type"] && "kind" in decl["type"] && decl["type"]?.["kind"] === "RubyTypeUnion") return;
2717
- const items = decl.children.map((prop, key) => {
2718
- const p = spec?.decls?.[language]?.[prop];
2719
- return /* @__PURE__ */ jsx("span", {
2720
- className: style_default.TypePropertyName,
2721
- children: /* @__PURE__ */ jsx("span", {
2722
- className: style_default.TextIdentifier,
2723
- children: p && "ident" in p ? p["ident"] : null
2724
- })
2725
- }, key);
2726
- });
2727
- return /* @__PURE__ */ jsxs("span", {
2728
- className: style_default.TypePreview,
2729
- "data-stldocs-type-preview": "properties",
2730
- children: [
2731
- /* @__PURE__ */ jsx("span", {
2732
- className: style_default.TypeBrace,
2733
- children: " {"
2734
- }),
2735
- /* @__PURE__ */ jsxs("span", {
2736
- className: style_default.TypePreviewContent,
2737
- children: [
2738
- " ",
2739
- /* @__PURE__ */ jsx(Join$1, {
2740
- items,
2741
- limit: 3,
2742
- children: /* @__PURE__ */ jsx("span", {
2743
- className: style_default.TextOperator,
2744
- children: ", "
2745
- })
2746
- }),
2747
- " "
2748
- ]
2749
- }),
2750
- /* @__PURE__ */ jsx("span", {
2751
- className: style_default.TypeBrace,
2752
- children: "} "
2753
- })
2754
- ]
2755
- });
2756
- }
2757
- function Type$2({ type }) {
2758
- const Lang = useLanguageComponents();
2759
- const { SDKReference: SDKReference$1, Join: Join$1 } = useComponents();
2760
- switch (type.kind) {
2761
- case "RubyTypeBinary":
2762
- case "RubyTypeUnknown":
2763
- case "RubyTypeNull":
2764
- case "RubyTypeInteger":
2765
- case "RubyTypeFloat":
2766
- case "RubyTypeBoolean": return /* @__PURE__ */ jsx("span", {
2767
- className: style_default.Type,
2768
- children: /* @__PURE__ */ jsx("span", {
2769
- className: style_default.TypeKeyword,
2770
- children: Keywords[type.kind]
2771
- })
2772
- });
2773
- case "RubyTypeString": return /* @__PURE__ */ jsx("span", {
2774
- className: style_default.Type,
2775
- children: /* @__PURE__ */ jsx("span", {
2776
- className: style_default.TypeString,
2777
- children: "String"
2778
- })
2779
- });
2780
- case "RubyTypeLiteral":
2781
- switch (typeof type.literal) {
2782
- case "string": return /* @__PURE__ */ jsx("span", {
2783
- className: style_default.Type,
2784
- children: /* @__PURE__ */ jsxs("span", {
2785
- className: style_default.LiteralString,
2786
- children: [":", type.literal.match(VALID_IDENTIFIER) ? type.literal : JSON.stringify(type.literal)]
2787
- })
2788
- });
2789
- case "number": return /* @__PURE__ */ jsx("span", {
2790
- className: style_default.Type,
2791
- children: /* @__PURE__ */ jsx("span", {
2792
- className: style_default.LiteralNumeric,
2793
- children: JSON.stringify(type.literal)
2794
- })
2795
- });
2796
- case "boolean": return /* @__PURE__ */ jsx("span", {
2797
- className: style_default.Type,
2798
- children: /* @__PURE__ */ jsx("span", {
2799
- className: style_default.LiteralBoolean,
2800
- children: JSON.stringify(type.literal)
2801
- })
2802
- });
2803
- }
2804
- break;
2805
- case "RubyTypeArray": return /* @__PURE__ */ jsxs("span", {
2806
- className: style_default.Type,
2807
- children: [
2808
- /* @__PURE__ */ jsx("span", {
2809
- className: style_default.TypeArray,
2810
- children: "Array["
2811
- }),
2812
- /* @__PURE__ */ jsx(Lang.Type, { type: type.elementType }),
2813
- /* @__PURE__ */ jsx("span", {
2814
- className: style_default.TypeArray,
2815
- children: "]"
2816
- })
2817
- ]
2818
- });
2819
- case "RubyTypeMap": return /* @__PURE__ */ jsxs("span", {
2820
- className: style_default.Type,
2821
- children: [
2822
- /* @__PURE__ */ jsx("span", {
2823
- className: style_default.TypeArray,
2824
- children: "Hash["
2825
- }),
2826
- type.indexType.kind === "RubyTypeString" ? /* @__PURE__ */ jsx("span", {
2827
- className: style_default.TypeString,
2828
- children: "Symbol"
2829
- }) : /* @__PURE__ */ jsx(Lang.Type, { type: type.indexType }),
2830
- ", ",
2831
- /* @__PURE__ */ jsx(Lang.Type, { type: type.itemType }),
2832
- /* @__PURE__ */ jsx("span", {
2833
- className: style_default.TypeArray,
2834
- children: "]"
2835
- })
2836
- ]
2837
- });
2838
- case "RubyTypeReference": {
2839
- const name = type.ident.split(".").at(-1);
2840
- if (!type.typeParameters || type.typeParameters.length === 0) return /* @__PURE__ */ jsxs("span", {
2841
- className: style_default.Type,
2842
- children: [/* @__PURE__ */ jsx(SDKReference$1, {
2843
- stainlessPath: type.$ref,
2844
- children: name
2845
- }), /* @__PURE__ */ jsx(TypePreview$1, { path: type.$ref })]
2846
- });
2847
- const typeParameters = type.typeParameters.map((t, i) => /* @__PURE__ */ jsx(Lang.Type, { type: t }, i));
2848
- return /* @__PURE__ */ jsxs("span", {
2849
- className: style_default.Type,
2850
- children: [
2851
- /* @__PURE__ */ jsx(SDKReference$1, {
2852
- stainlessPath: type.$ref,
2853
- children: name
2854
- }),
2855
- /* @__PURE__ */ jsx("span", {
2856
- className: style_default.TypeBracket,
2857
- children: "<"
2858
- }),
2859
- /* @__PURE__ */ jsx(Join$1, {
2860
- items: typeParameters,
2861
- children: /* @__PURE__ */ jsx("span", {
2862
- className: style_default.TextOperator,
2863
- children: ", "
2864
- })
2865
- }),
2866
- /* @__PURE__ */ jsx("span", {
2867
- className: style_default.TypeBracket,
2868
- children: ">"
2869
- }),
2870
- /* @__PURE__ */ jsx(TypePreview$1, { path: type.$ref })
2871
- ]
2872
- });
2873
- }
2874
- case "RubyTypeIntersection":
2875
- case "RubyTypeUnion": {
2876
- const items = type.types.map((t, key) => /* @__PURE__ */ jsx(Lang.Type, { type: t }, key));
2877
- const delimiter = type.kind === "RubyTypeUnion" ? "|" : "&";
2878
- return /* @__PURE__ */ jsx("span", {
2879
- className: style_default.Type,
2880
- children: /* @__PURE__ */ jsx("span", {
2881
- className: style_default.TypePreview,
2882
- "data-stldocs-type-preview": "union",
2883
- children: /* @__PURE__ */ jsx("span", {
2884
- className: style_default.TypePreviewContent,
2885
- children: /* @__PURE__ */ jsx(Join$1, {
2886
- items,
2887
- limit: 3,
2888
- children: /* @__PURE__ */ jsxs("span", {
2889
- className: style_default.TextOperator,
2890
- children: [
2891
- " ",
2892
- delimiter,
2893
- " "
2894
- ]
2895
- })
2896
- })
2897
- })
2898
- })
2899
- });
2900
- }
2901
- case "RubyTypeBuiltinClass": return /* @__PURE__ */ jsx("span", {
2902
- className: style_default.TypeReference,
2903
- children: type.className
2904
- });
2905
- case "RubyTypeObject": {
2906
- const items = type.members.map((prop, key) => /* @__PURE__ */ jsx("span", {
2907
- className: style_default.TextIdentifier,
2908
- children: prop.ident
2909
- }, key));
2910
- return /* @__PURE__ */ jsx("span", {
2911
- className: style_default.Type,
2912
- children: /* @__PURE__ */ jsx("span", {
2913
- className: style_default.TypePreview,
2914
- "data-stldocs-type-preview": "properties",
2915
- children: /* @__PURE__ */ jsxs("span", {
2916
- className: style_default.TypePreviewContent,
2917
- children: [
2918
- /* @__PURE__ */ jsx("span", {
2919
- className: style_default.TypeBrace,
2920
- children: "{ "
2921
- }),
2922
- /* @__PURE__ */ jsx(Join$1, {
2923
- items,
2924
- limit: 3,
2925
- children: /* @__PURE__ */ jsx("span", {
2926
- className: style_default.TextOperator,
2927
- children: ", "
2928
- })
2929
- }),
2930
- /* @__PURE__ */ jsx("span", {
2931
- className: style_default.TypeBrace,
2932
- children: "}"
2933
- })
2934
- ]
2935
- })
2936
- })
2937
- });
2938
- }
2939
- }
2940
- }
2941
- function MethodSignature$2({ decl }) {
2942
- const Lang = useLanguageComponents();
2943
- const { Join: Join$1 } = useComponents();
2944
- const params = decl.args.map((param, i) => /* @__PURE__ */ jsx(React$1.Fragment, { children: /* @__PURE__ */ jsx("span", {
2945
- className: style_default.TextIdentifier,
2946
- children: param.ident
2947
- }) }, i));
2948
- return /* @__PURE__ */ jsx("div", {
2949
- className: style_default.MethodSignature,
2950
- children: /* @__PURE__ */ jsxs("span", {
2951
- className: style_default.SignatureTitle,
2952
- children: [
2953
- /* @__PURE__ */ jsx("span", {
2954
- className: style_default.SignatureQualified,
2955
- children: /* @__PURE__ */ jsx("span", {
2956
- className: style_default.TextIdentifier,
2957
- children: decl.qualified?.slice(0, -decl.ident.length)
2958
- })
2959
- }),
2960
- /* @__PURE__ */ jsx("span", {
2961
- className: style_default.SignatureName,
2962
- children: /* @__PURE__ */ jsx("span", {
2963
- className: style_default.TextIdentifier,
2964
- children: decl.ident
2965
- })
2966
- }),
2967
- /* @__PURE__ */ jsxs("span", {
2968
- className: style_default.MethodSignature,
2969
- children: [
2970
- /* @__PURE__ */ jsx("span", {
2971
- className: style_default.SignatureParen,
2972
- children: "("
2973
- }),
2974
- /* @__PURE__ */ jsx("span", {
2975
- className: style_default.SignatureParams,
2976
- children: /* @__PURE__ */ jsx(Join$1, {
2977
- items: params,
2978
- children: /* @__PURE__ */ jsx("span", {
2979
- className: style_default.TextOperator,
2980
- children: ", "
2981
- })
2982
- })
2983
- }),
2984
- /* @__PURE__ */ jsx("span", {
2985
- className: style_default.SignatureParen,
2986
- children: ")"
2987
- }),
2988
- " -> ",
2989
- decl.returns ? /* @__PURE__ */ jsx(Lang.Type, { type: decl.returns }) : "void"
2990
- ]
2991
- })
2992
- ]
2993
- })
2994
- });
2995
- }
2996
- function Property$2({ decl, children }) {
2997
- const Lang = useLanguageComponents();
2998
- switch (decl.kind) {
2999
- case "RubyDeclProperty": return children({
3000
- name: decl.ident,
3001
- typeName: /* @__PURE__ */ jsx(Lang.TypeName, { type: decl.type }),
3002
- type: decl.type.kind in ComplexTypes$1 && /* @__PURE__ */ jsx(Lang.Type, { type: decl.type })
3003
- });
3004
- case "RubyDeclTypeAlias": return children({
3005
- name: decl.ident,
3006
- typeName: "alias",
3007
- type: /* @__PURE__ */ jsx(Lang.Type, { type: decl.type })
3008
- });
3009
- case "RubyDeclReference": return children({ type: /* @__PURE__ */ jsx(Lang.Type, { type: decl.type }) });
3010
- case "RubyDeclClass": return children({
3011
- name: decl.ident,
3012
- typeName: "class"
3013
- });
3014
- }
3015
- }
3016
- function Declaration$2({ decl }) {
3017
- const Lang = useLanguageComponents();
3018
- if (!decl) return;
3019
- switch (decl.kind) {
3020
- case "RubyDeclProperty": return /* @__PURE__ */ jsxs(Fragment$1, { children: [
3021
- /* @__PURE__ */ jsx("span", {
3022
- className: style_default.TypePropertyName,
3023
- children: /* @__PURE__ */ jsx("span", {
3024
- className: style_default.TextIdentifier,
3025
- children: decl.ident
3026
- })
3027
- }),
3028
- /* @__PURE__ */ jsx("span", {
3029
- className: style_default.TextPunctuation,
3030
- children: ": "
3031
- }),
3032
- /* @__PURE__ */ jsx(Lang.Type, { type: decl.type })
3033
- ] });
3034
- case "RubyDeclTypeAlias": return /* @__PURE__ */ jsxs(Fragment$1, { children: [
3035
- /* @__PURE__ */ jsx("span", {
3036
- className: style_default.TextIdentifier,
3037
- children: decl.ident
3038
- }),
3039
- /* @__PURE__ */ jsx("span", {
3040
- className: style_default.TextOperator,
3041
- children: " = "
3042
- }),
3043
- /* @__PURE__ */ jsx(Lang.Type, { type: decl.type })
3044
- ] });
3045
- case "RubyDeclClass": return /* @__PURE__ */ jsxs(Fragment$1, { children: [
3046
- /* @__PURE__ */ jsx("span", {
3047
- className: style_default.TextKeyword,
3048
- children: "class "
3049
- }),
3050
- /* @__PURE__ */ jsx("span", {
3051
- className: style_default.TextIdentifier,
3052
- children: decl.ident
3053
- }),
3054
- /* @__PURE__ */ jsx(TypePreview$1, { path: decl.stainlessPath })
3055
- ] });
3056
- case "RubyDeclReference": return /* @__PURE__ */ jsx(Lang.Type, { type: decl.type });
3057
- }
3058
- }
3059
-
3060
- //#endregion
3061
- //#region src/languages/http.tsx
3062
- var http_exports = /* @__PURE__ */ __export({
3063
- Declaration: () => Declaration$1,
3064
- MethodInfo: () => MethodInfo,
3065
- MethodSignature: () => MethodSignature$1,
3066
- Property: () => Property$1,
3067
- Type: () => Type$1,
3068
- TypeName: () => TypeName$1
3069
- });
3070
- const ComplexTypes = {
3071
- HttpTypeUnion: "union",
3072
- HttpTypeIntersection: "intersection"
3073
- };
3074
- const constStyle$1 = {
3075
- string: style_default.LiteralString,
3076
- number: style_default.LiteralNumeric,
3077
- boolean: style_default.LiteralBoolean
3078
- };
3079
- function Identifier({ name }) {
3080
- return /* @__PURE__ */ jsx(Fragment$1, { children: /* @__PURE__ */ jsx("span", {
3081
- className: style_default.TextIdentifier,
3082
- children: /^[_a-zA-Z][_a-zA-Z0-9]*$/.test(name) ? name : JSON.stringify(name)
3083
- }) });
3084
- }
3085
- function TypePreview({ path }) {
3086
- const spec = useSpec();
3087
- const language = useLanguage();
3088
- const decl = useDeclaration(path, false);
3089
- const { Join: Join$1 } = useComponents();
3090
- if (!(decl && "children" in decl && decl.children && decl.children.length > 0) || "type" in decl && decl["type"] && "kind" in decl["type"] && decl["type"]["kind"] === "HttpTypeUnion") return;
3091
- const items = decl.children.map((prop, key) => {
3092
- const decl$1 = spec?.decls?.[language]?.[prop];
3093
- return /* @__PURE__ */ jsx("span", {
3094
- className: style_default.TypePropertyName,
3095
- children: /* @__PURE__ */ jsx("span", {
3096
- className: style_default.TextIdentifier,
3097
- children: decl$1 && "key" in decl$1 ? decl$1?.["key"] : null
3098
- })
3099
- }, key);
3100
- });
3101
- return /* @__PURE__ */ jsxs("span", {
3102
- className: style_default.TypePreview,
3103
- "data-stldocs-type-preview": "properties",
3104
- children: [
3105
- /* @__PURE__ */ jsx("span", {
3106
- className: style_default.TypeBrace,
3107
- children: " { "
3108
- }),
3109
- /* @__PURE__ */ jsx("span", {
3110
- className: style_default.TypePreviewContent,
3111
- children: /* @__PURE__ */ jsx(Join$1, {
3112
- items,
3113
- limit: 3,
3114
- children: /* @__PURE__ */ jsx("span", {
3115
- className: style_default.TextOperator,
3116
- children: ", "
3117
- })
3118
- })
3119
- }),
3120
- /* @__PURE__ */ jsx("span", {
3121
- className: style_default.TypeBrace,
3122
- children: " } "
3123
- })
3124
- ]
3125
- });
3126
- }
3127
- function TypeName$1({ type }) {
3128
- const Lang = useLanguageComponents();
3129
- if (type.kind === "HttpTypeArray") return /* @__PURE__ */ jsxs(Fragment$1, { children: ["array of ", /* @__PURE__ */ jsx(Lang.TypeName, { type: type.elementType })] });
3130
- if (type.kind === "HttpTypeUnion" && type.types.every((t) => t.kind === "HttpTypeLiteral")) return "enum";
3131
- if (type.kind === "HttpTypeReference" && type.ident.split(".").at(-1) === "Record") return "map";
3132
- return ComplexTypes[type.kind] ?? /* @__PURE__ */ jsx(Lang.Type, { type });
3133
- }
3134
- function Type$1({ type }) {
3135
- const Lang = useLanguageComponents();
3136
- const { Join: Join$1, SDKReference: SDKReference$1 } = useComponents();
3137
- switch (type.kind) {
3138
- case "HttpTypeUnknown":
3139
- case "HttpTypeUndefined":
3140
- case "HttpTypeNull":
3141
- case "HttpTypeBoolean":
3142
- case "HttpTypeNumber": return /* @__PURE__ */ jsx("span", {
3143
- className: style_default.Type,
3144
- children: /* @__PURE__ */ jsx("span", {
3145
- className: style_default.TypePlain,
3146
- children: type.kind.slice(8).toLowerCase()
3147
- })
3148
- });
3149
- case "HttpTypeString": return /* @__PURE__ */ jsx("span", {
3150
- className: style_default.Type,
3151
- children: /* @__PURE__ */ jsx("span", {
3152
- className: style_default.TypePlain,
3153
- children: "string"
3154
- })
3155
- });
3156
- case "HttpTypeLiteral": return /* @__PURE__ */ jsx("span", {
3157
- className: style_default.Type,
3158
- children: /* @__PURE__ */ jsx("span", {
3159
- className: constStyle$1[typeof type.literal],
3160
- children: JSON.stringify(type.literal)
3161
- })
3162
- });
3163
- case "HttpTypeArray": return /* @__PURE__ */ jsxs("span", {
3164
- className: style_default.Type,
3165
- children: [/* @__PURE__ */ jsx("span", {
3166
- className: style_default.TypeArray,
3167
- children: "array of "
3168
- }), /* @__PURE__ */ jsx(Lang.Type, { type: type.elementType })]
3169
- });
3170
- case "HttpTypeIntersection":
3171
- case "HttpTypeUnion": {
3172
- const items = type.types.map((t, key) => /* @__PURE__ */ jsx(Lang.Type, { type: t }, key));
3173
- const delimiter = type.kind === "HttpTypeUnion" ? "or" : "and";
3174
- return /* @__PURE__ */ jsx("span", {
3175
- className: style_default.Type,
3176
- children: /* @__PURE__ */ jsx("span", {
3177
- className: style_default.TypePreview,
3178
- "data-stldocs-type-preview": "union",
3179
- children: /* @__PURE__ */ jsx("span", {
3180
- className: style_default.TypePreviewContent,
3181
- children: /* @__PURE__ */ jsx(Join$1, {
3182
- items,
3183
- limit: 3,
3184
- children: /* @__PURE__ */ jsxs("span", {
3185
- className: style_default.TextOperator,
3186
- children: [
3187
- " ",
3188
- delimiter,
3189
- " "
3190
- ]
3191
- })
3192
- })
3193
- })
3194
- })
3195
- });
3196
- }
3197
- case "HttpTypeReference": {
3198
- const name = type.ident.split(".").at(-1);
3199
- const params = type.typeParameters?.map((param, key) => /* @__PURE__ */ jsx(Lang.Type, { type: param }, key));
3200
- if (name === "Record" && type.typeParameters?.length === 2 && type.typeParameters?.at(0).kind === "HttpTypeString") return /* @__PURE__ */ jsxs(Fragment$1, { children: [
3201
- /* @__PURE__ */ jsx("span", {
3202
- className: style_default.TypeArray,
3203
- children: "map"
3204
- }),
3205
- "[",
3206
- params?.[1],
3207
- "]"
3208
- ] });
3209
- return /* @__PURE__ */ jsxs("span", {
3210
- className: style_default.Type,
3211
- children: [
3212
- /* @__PURE__ */ jsx(SDKReference$1, {
3213
- stainlessPath: type.$ref,
3214
- children: name
3215
- }),
3216
- params && params.length > 0 && /* @__PURE__ */ jsxs(Fragment$1, { children: [
3217
- /* @__PURE__ */ jsx("span", {
3218
- className: style_default.TypeBracket,
3219
- children: "<"
3220
- }),
3221
- /* @__PURE__ */ jsx(Join$1, {
3222
- items: params,
3223
- limit: 3,
3224
- children: /* @__PURE__ */ jsx("span", {
3225
- className: style_default.TextOperator,
3226
- children: ", "
3227
- })
3228
- }),
3229
- /* @__PURE__ */ jsx("span", {
3230
- className: style_default.TypeBracket,
3231
- children: ">"
3232
- })
3233
- ] }),
3234
- /* @__PURE__ */ jsx(TypePreview, { path: type.$ref })
3235
- ]
3236
- });
3237
- }
3238
- case "HttpTypeObject": {
3239
- const items = type.members.map(({ ident }) => /* @__PURE__ */ jsx("span", {
3240
- className: style_default.TypePropertyName,
3241
- children: /* @__PURE__ */ jsx(Identifier, { name: ident })
3242
- }, ident));
3243
- return /* @__PURE__ */ jsxs("span", {
3244
- className: style_default.Type,
3245
- children: [/* @__PURE__ */ jsx("span", {
3246
- className: style_default.TypePlain,
3247
- children: "object"
3248
- }), /* @__PURE__ */ jsxs("span", {
3249
- className: style_default.TypePreview,
3250
- "data-stldocs-type-preview": "properties",
3251
- children: [
3252
- /* @__PURE__ */ jsx("span", {
3253
- className: style_default.TypeBrace,
3254
- children: " {"
3255
- }),
3256
- /* @__PURE__ */ jsxs("span", {
3257
- className: style_default.TypePreviewContent,
3258
- children: [
3259
- " ",
3260
- /* @__PURE__ */ jsx(Join$1, {
3261
- items,
3262
- limit: 3,
3263
- children: /* @__PURE__ */ jsx("span", {
3264
- className: style_default.TextOperator,
3265
- children: ", "
3266
- })
3267
- }),
3268
- " "
3269
- ]
3270
- }),
3271
- /* @__PURE__ */ jsx("span", {
3272
- className: style_default.TypeBrace,
3273
- children: "} "
3274
- })
3275
- ]
3276
- })]
3277
- });
3278
- }
3279
- }
3280
- }
3281
- function MethodSignature$1({ decl }) {
3282
- return null;
3283
- }
3284
- function MethodInfo({ decl, children }) {
3285
- const Docs = useComponents();
3286
- const params = Object.entries(decl.paramsChildren).filter(([, value]) => value.length).map(([location, value]) => /* @__PURE__ */ jsx(React.Fragment, { children: /* @__PURE__ */ jsxs("div", {
3287
- className: style_default.MethodParameters,
3288
- "data-stldocs-property-group": location.at(0),
3289
- children: [/* @__PURE__ */ jsxs("h5", { children: [
3290
- location.at(0).toUpperCase(),
3291
- location.slice(1),
3292
- " Parameters",
3293
- /* @__PURE__ */ jsx(PropertyToggle, { target: location.at(0) })
3294
- ] }), /* @__PURE__ */ jsx(Docs.SDKChildren, { paths: value })]
3295
- }) }, location));
3296
- if ((decl.bodyParamsChildren?.["application/json"]?.length ?? 0) > 0) params.push(/* @__PURE__ */ jsxs("div", {
3297
- className: style_default.MethodInfoSection,
3298
- children: [/* @__PURE__ */ jsxs("h5", { children: ["Body Parameters", /* @__PURE__ */ jsx(PropertyToggle, { target: "body" })] }), /* @__PURE__ */ jsx("div", {
3299
- className: style_default.MethodParameters,
3300
- "data-stldocs-property-group": "body",
3301
- children: /* @__PURE__ */ jsx(Docs.SDKChildren, { paths: decl.bodyParamsChildren?.["application/json"] ?? [] })
3302
- })]
3303
- }));
3304
- return /* @__PURE__ */ jsxs("div", {
3305
- className: style_default.MethodInfo,
3306
- children: [
3307
- children && /* @__PURE__ */ jsx("div", {
3308
- className: style_default.MethodContent,
3309
- children
3310
- }),
3311
- params.length > 0 && params,
3312
- (decl.responseChildren?.length ?? 0) > 0 && /* @__PURE__ */ jsxs("div", {
3313
- className: style_default.MethodInfoSection,
3314
- children: [/* @__PURE__ */ jsxs("h5", { children: ["Returns", /* @__PURE__ */ jsx(PropertyToggle, { target: "returns" })] }), /* @__PURE__ */ jsx("div", {
3315
- className: style_default.MethodReturns,
3316
- "data-stldocs-property-group": "returns",
3317
- children: /* @__PURE__ */ jsx(Docs.SDKChildren, { paths: decl.responseChildren ?? [] })
3318
- })]
3319
- })
3320
- ]
3321
- });
3322
- }
3323
- function renderVariantInfo(type) {
3324
- if (type.kind === "HttpTypeUnion" && type.types.every((t) => t.kind === "HttpTypeObject" || t.kind === "HttpTypeReference")) return /* @__PURE__ */ jsxs(Fragment$1, { children: [
3325
- "One of the following ",
3326
- type.types.length,
3327
- " object variants:"
3328
- ] });
3329
- }
3330
- function Property$1({ decl, children }) {
3331
- const Lang = useLanguageComponents();
3332
- if (!decl) return;
3333
- switch (decl.kind) {
3334
- case "HttpDeclProperty": {
3335
- const variants = renderVariantInfo(decl.type);
3336
- return children({
3337
- name: decl.key,
3338
- typeName: /* @__PURE__ */ jsx(Lang.TypeName, { type: decl.type }),
3339
- type: decl.type.kind in ComplexTypes && !variants && /* @__PURE__ */ jsx(Lang.Type, { type: decl.type })
3340
- });
3341
- }
3342
- case "HttpDeclTypeAlias": return children({
3343
- name: decl.ident,
3344
- typeName: /* @__PURE__ */ jsx(Lang.TypeName, { type: decl.type })
3345
- });
3346
- case "HttpDeclReference": return children({ type: /* @__PURE__ */ jsx(Lang.Type, { type: decl.type }) });
3347
- }
3348
- }
3349
- function Declaration$1({ decl }) {
3350
- const Lang = useLanguageComponents();
3351
- if (!decl) return;
3352
- switch (decl.kind) {
3353
- case "HttpDeclProperty": return /* @__PURE__ */ jsxs(Fragment$1, { children: [
3354
- /* @__PURE__ */ jsx("span", {
3355
- className: style_default.TypePropertyName,
3356
- children: /* @__PURE__ */ jsx(Identifier, { name: decl.key })
3357
- }),
3358
- /* @__PURE__ */ jsx("span", {
3359
- className: style_default.TextPunctuation,
3360
- children: ": "
3361
- }),
3362
- decl.optional && /* @__PURE__ */ jsx("span", {
3363
- className: style_default.TextPunctuation,
3364
- children: "optional "
3365
- }),
3366
- /* @__PURE__ */ jsx(Lang.Type, { type: decl.type })
3367
- ] });
3368
- case "HttpDeclTypeAlias": return /* @__PURE__ */ jsxs(Fragment$1, { children: [
3369
- /* @__PURE__ */ jsx(Identifier, { name: decl.ident }),
3370
- /* @__PURE__ */ jsx("span", {
3371
- className: style_default.TextOperator,
3372
- children: " = "
3373
- }),
3374
- /* @__PURE__ */ jsx(Lang.Type, { type: decl.type })
3375
- ] });
3376
- case "HttpDeclReference": return /* @__PURE__ */ jsx(Lang.Type, { type: decl.type });
3377
- }
3378
- }
3379
-
3380
- //#endregion
3381
- //#region src/languages/csharp.tsx
3382
- var csharp_exports = /* @__PURE__ */ __export({
3383
- Declaration: () => Declaration,
3384
- MethodSignature: () => MethodSignature,
3385
- Property: () => Property,
3386
- Type: () => Type,
3387
- TypeName: () => TypeName
3388
- });
3389
- const constStyle = {
3390
- string: style_default.LiteralString,
3391
- number: style_default.LiteralNumeric,
3392
- boolean: style_default.LiteralBoolean
3393
- };
3394
- function TypeName({ type, optional }) {
3395
- return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(useLanguageComponents().Type, { type }), optional && /* @__PURE__ */ jsx("span", {
3396
- className: style_default.TextOperator,
3397
- children: "? "
3398
- })] });
3399
- }
3400
- function Type({ type }) {
3401
- const Lang = useLanguageComponents();
3402
- const { Join: Join$1, SDKReference: SDKReference$1 } = useComponents();
3403
- switch (type.kind) {
3404
- case "CSharpTypeReference": {
3405
- const params = type.typeParameters?.map((param, key) => /* @__PURE__ */ jsx(Lang.Type, { type: param }, key));
3406
- return /* @__PURE__ */ jsxs("span", {
3407
- className: style_default.Type,
3408
- children: [
3409
- /* @__PURE__ */ jsx(SDKReference$1, {
3410
- stainlessPath: type.$ref,
3411
- children: type.typeName
3412
- }),
3413
- params && params.length > 0 ? /* @__PURE__ */ jsxs(Fragment$1, { children: [
3414
- /* @__PURE__ */ jsx("span", {
3415
- className: style_default.TypeBracket,
3416
- children: "<"
3417
- }),
3418
- /* @__PURE__ */ jsx(Join$1, {
3419
- items: params,
3420
- limit: 3,
3421
- children: /* @__PURE__ */ jsx("span", {
3422
- className: style_default.TextOperator,
3423
- children: ", "
3424
- })
3425
- }),
3426
- /* @__PURE__ */ jsx("span", {
3427
- className: style_default.TypeBracket,
3428
- children: ">"
3429
- })
3430
- ] }) : null,
3431
- type.nullable && /* @__PURE__ */ jsx("span", {
3432
- className: style_default.TextOperator,
3433
- children: "?"
3434
- })
3435
- ]
3436
- });
3437
- }
3438
- case "CSharpTypeClass":
3439
- case "CSharpTypeUnion": return /* @__PURE__ */ jsx("span", {
3440
- className: style_default.Type,
3441
- children: /* @__PURE__ */ jsx("span", {
3442
- className: style_default.TypeKeyword,
3443
- children: "class"
3444
- })
3445
- });
3446
- case "CSharpTypeEnum":
3447
- case "CSharpTypeBoolean":
3448
- case "CSharpTypeFloat":
3449
- case "CSharpTypeDouble":
3450
- case "CSharpTypeInt":
3451
- case "CSharpTypeLong": return /* @__PURE__ */ jsx("span", {
3452
- className: style_default.Type,
3453
- children: /* @__PURE__ */ jsx("span", {
3454
- className: style_default.TypeKeyword,
3455
- children: type.kind.slice(10)
3456
- })
3457
- });
3458
- case "CSharpTypeString": return /* @__PURE__ */ jsx("span", {
3459
- className: style_default.Type,
3460
- children: /* @__PURE__ */ jsx("span", {
3461
- className: style_default.TypeString,
3462
- children: "string"
3463
- })
3464
- });
3465
- case "CSharpTypeConstant": return /* @__PURE__ */ jsx("span", {
3466
- className: style_default.Type,
3467
- children: /* @__PURE__ */ jsx("span", {
3468
- className: style_default.TypeKeyword,
3469
- children: "JsonElement"
3470
- })
3471
- });
3472
- }
3473
- }
3474
- function MethodSignature({ decl }) {
3475
- const Lang = useLanguageComponents();
3476
- const { Join: Join$1, Tooltip: Tooltip$1 } = useComponents();
3477
- const params = decl.parameters.map((param, i) => /* @__PURE__ */ jsx(React$1.Fragment, { children: /* @__PURE__ */ jsxs(Tooltip$1, {
3478
- content: /* @__PURE__ */ jsx(Lang.Type, { type: param.typeAnnotation }),
3479
- children: [/* @__PURE__ */ jsx("span", {
3480
- className: style_default.TextIdentifier,
3481
- children: param.ident
3482
- }), param.hasDefault && /* @__PURE__ */ jsxs(Fragment$1, { children: [
3483
- " ",
3484
- /* @__PURE__ */ jsx("span", {
3485
- className: style_default.TextOperator,
3486
- children: "="
3487
- }),
3488
- " ",
3489
- /* @__PURE__ */ jsx("span", {
3490
- className: style_default.TextKeyword,
3491
- children: "default"
3492
- })
3493
- ] })]
3494
- }) }, i));
3495
- return /* @__PURE__ */ jsx("div", {
3496
- className: style_default.MethodSignature,
3497
- children: /* @__PURE__ */ jsxs("span", {
3498
- className: style_default.SignatureTitle,
3499
- children: [
3500
- decl.returnType && /* @__PURE__ */ jsxs("span", {
3501
- className: style_default.SignatureReturns,
3502
- children: [/* @__PURE__ */ jsx(Lang.Type, { type: decl.returnType }), " "]
3503
- }),
3504
- decl.qualified && /* @__PURE__ */ jsx("span", {
3505
- className: style_default.SignatureQualified,
3506
- children: /* @__PURE__ */ jsx("span", {
3507
- className: style_default.TextIdentifier,
3508
- children: decl.qualified?.slice(0, -decl.ident.length)
3509
- })
3510
- }),
3511
- /* @__PURE__ */ jsx("span", {
3512
- className: style_default.SignatureName,
3513
- children: /* @__PURE__ */ jsx("span", {
3514
- className: style_default.TextIdentifier,
3515
- children: decl.ident
3516
- })
3517
- }),
3518
- /* @__PURE__ */ jsxs("span", {
3519
- className: style_default.MethodSignature,
3520
- children: [
3521
- /* @__PURE__ */ jsx("span", {
3522
- className: style_default.SignatureParen,
3523
- children: "("
3524
- }),
3525
- /* @__PURE__ */ jsx("span", {
3526
- className: style_default.SignatureParams,
3527
- children: /* @__PURE__ */ jsx(Join$1, {
3528
- items: params,
3529
- children: /* @__PURE__ */ jsx("span", {
3530
- className: style_default.TextOperator,
3531
- children: ", "
3532
- })
3533
- })
3534
- }),
3535
- /* @__PURE__ */ jsxs("span", {
3536
- className: style_default.SignatureParen,
3537
- children: [")", " "]
3538
- })
3539
- ]
3540
- })
3541
- ]
3542
- })
3543
- });
3544
- }
3545
- function Property({ decl, children }) {
3546
- const Lang = useLanguageComponents();
3547
- if (!decl) return null;
3548
- switch (decl.kind) {
3549
- case "CSharpDeclProperty": {
3550
- const type = /* @__PURE__ */ jsx(Lang.Type, {
3551
- type: decl.type,
3552
- optional: decl.optional
3553
- });
3554
- return children({
3555
- name: decl.ident,
3556
- typeName: /* @__PURE__ */ jsx(Lang.TypeName, {
3557
- type: decl.type,
3558
- optional: decl.optional
3559
- }),
3560
- type
3561
- });
3562
- }
3563
- case "CSharpDeclConst": return children({
3564
- name: decl.ident,
3565
- typeName: "constant",
3566
- type: /* @__PURE__ */ jsx("span", {
3567
- className: constStyle[typeof decl.value],
3568
- children: JSON.stringify(decl.value)
3569
- })
3570
- });
3571
- case "CSharpDeclType": {
3572
- const typeName$1 = decl.type.kind === "CSharpTypeUnion" ? "union" : decl.type.kind === "CSharpTypeEnum" ? "enum" : "class";
3573
- return children({
3574
- name: decl.ident,
3575
- typeName: typeName$1
3576
- });
3577
- }
3578
- case "CSharpDeclReference": return children({ type: /* @__PURE__ */ jsx(Lang.Type, { type: decl.type }) });
3579
- }
3580
- }
3581
- function Declaration({ decl }) {
3582
- const Docs = useComponents();
3583
- const Lang = useLanguageComponents();
3584
- if (!decl) return null;
3585
- switch (decl.kind) {
3586
- case "CSharpDeclConst": return /* @__PURE__ */ jsxs(Fragment$1, { children: [" ", /* @__PURE__ */ jsx(Docs.Tooltip, {
3587
- content: /* @__PURE__ */ jsx("span", {
3588
- className: style_default.TextIdentifier,
3589
- children: decl.value
3590
- }),
3591
- children: /* @__PURE__ */ jsx(Docs.Badge, { id: "constant" })
3592
- })] });
3593
- case "CSharpDeclType": {
3594
- const keyword = decl.type.kind === "CSharpTypeEnum" ? "enum" : "class";
3595
- return /* @__PURE__ */ jsxs(Fragment$1, { children: [
3596
- /* @__PURE__ */ jsx("span", {
3597
- className: style_default.TextKeyword,
3598
- children: keyword
3599
- }),
3600
- " ",
3601
- /* @__PURE__ */ jsx("span", {
3602
- className: style_default.TextIdentifier,
3603
- children: decl.ident
3604
- }),
3605
- /* @__PURE__ */ jsx("span", {
3606
- className: style_default.TextPunctuation,
3607
- children: ":"
3608
- }),
3609
- decl.type.kind === "CSharpTypeUnion" && /* @__PURE__ */ jsxs(Fragment$1, { children: [
3610
- " ",
3611
- /* @__PURE__ */ jsx(Docs.Tooltip, {
3612
- content: "A class that can be one of several variants.",
3613
- children: /* @__PURE__ */ jsx(Docs.Badge, {
3614
- id: "csharp-union",
3615
- children: "union"
3616
- })
3617
- }),
3618
- " "
3619
- ] })
3620
- ] });
3621
- }
3622
- case "CSharpDeclProperty": return /* @__PURE__ */ jsxs(Fragment$1, { children: [
3623
- decl.optional === false && /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("span", {
3624
- className: style_default.TextKeyword,
3625
- children: "required"
3626
- }), " "] }),
3627
- /* @__PURE__ */ jsx(Lang.Type, {
3628
- type: decl.type,
3629
- optional: decl.optional
3630
- }),
3631
- decl.nullable && !("nullable" in decl.type && decl.type.nullable) && /* @__PURE__ */ jsx("span", {
3632
- className: style_default.TextOperator,
3633
- children: "?"
3634
- }),
3635
- " ",
3636
- /* @__PURE__ */ jsx("span", {
3637
- className: style_default.TextIdentifier,
3638
- children: decl.ident
3639
- }),
3640
- decl.type.kind === "CSharpTypeConstant" && /* @__PURE__ */ jsxs(Fragment$1, { children: [" ", /* @__PURE__ */ jsx(Docs.Tooltip, {
3641
- content: /* @__PURE__ */ jsx("span", {
3642
- className: style_default.TextIdentifier,
3643
- children: decl.type.value
3644
- }),
3645
- children: /* @__PURE__ */ jsx(Docs.Badge, {
3646
- id: "csharp-constant",
3647
- children: "constant"
3648
- })
3649
- })] })
3650
- ] });
3651
- case "CSharpDeclReference": return /* @__PURE__ */ jsx(Lang.Type, { type: decl.type });
3652
- }
3653
- }
3654
-
3655
- //#endregion
3656
- //#region src/languages/index.ts
3657
- var languages_exports = /* @__PURE__ */ __export({
3658
- csharp: () => csharp_exports,
3659
- go: () => go_exports,
3660
- http: () => http_exports,
3661
- java: () => java_exports,
3662
- kotlin: () => kotlin,
3663
- node: () => node,
3664
- python: () => python_exports,
3665
- ruby: () => ruby_exports,
3666
- typescript: () => typescript_exports
3667
- });
3668
- const node = typescript_exports;
3669
- const kotlin = java_exports;
3670
-
3671
- //#endregion
3672
- //#region src/contexts/component.tsx
3673
- const defaultContextValue = {
3674
- components: components_exports,
3675
- language: languages_exports
3676
- };
3677
- function ComponentProvider({ components, language, children }) {
3678
- return /* @__PURE__ */ jsx(ComponentProvider$1, {
3679
- value: React.useMemo(() => customizeComponents(defaultContextValue, {
3680
- components,
3681
- language
3682
- }), [components, language]),
3683
- children
3684
- });
3685
- }
3686
-
3687
- //#endregion
3688
- //#region src/search/printer.tsx
3689
- function Providers({ language, children }) {
3690
- return /* @__PURE__ */ jsx(DocsProvider, {
3691
- spec: null,
3692
- language,
3693
- children: /* @__PURE__ */ jsx(ComponentProvider, {
3694
- components: { SDKReference({ stainlessPath, children: children$1 }) {
3695
- if (!stainlessPath) return children$1;
3696
- return /* @__PURE__ */ jsx("span", {
3697
- className: style_default.TypeReference,
3698
- children: children$1
3699
- });
3700
- } },
3701
- children
3702
- })
3703
- });
3704
- }
3705
- function RenderType({ type, full }) {
3706
- const { Type: Type$7, TypeName: TypeName$7 } = useLanguageComponents();
3707
- return full ? /* @__PURE__ */ jsx(Type$7, { type }) : /* @__PURE__ */ jsx(TypeName$7, { type });
3708
- }
3709
- function typeName(language, type) {
3710
- return renderToStaticMarkup(/* @__PURE__ */ jsx(Providers, {
3711
- language,
3712
- children: /* @__PURE__ */ jsx(RenderType, { type })
3713
- }));
3714
- }
3715
- function RenderDeclaration({ decl }) {
3716
- const { Declaration: Declaration$7 } = useLanguageComponents();
3717
- return /* @__PURE__ */ jsx(Declaration$7, { decl });
3718
- }
3719
- function declaration$1(language, decl) {
3720
- return renderToStaticMarkup(/* @__PURE__ */ jsx(Providers, {
3721
- language,
3722
- children: /* @__PURE__ */ jsx(RenderDeclaration, { decl })
3723
- }));
3724
- }
3725
- function RenderMethod({ method }) {
3726
- const { MethodSignature: MethodSignature$7 } = useLanguageComponents();
3727
- return /* @__PURE__ */ jsx(MethodSignature$7, { decl: method });
3728
- }
3729
- function methodSignature(language, decl) {
3730
- return renderToStaticMarkup(/* @__PURE__ */ jsx(Providers, {
3731
- language,
3732
- children: /* @__PURE__ */ jsx(RenderMethod, { method: decl })
3733
- }));
3734
- }
3735
-
3736
- //#endregion
3737
- //#region src/markdown/index.ts
3738
- function declaration(env, decl) {
3739
- const content = declaration$1(env.language, decl);
3740
- return paragraph(code(stripMarkup(content)));
3741
- }
3742
- function renderChildren(env, children, nesting = []) {
3743
- return list(...children.map((child) => renderDecl(env, child, nesting)));
3744
- }
3745
- function renderDecl(env, path, nesting = []) {
3746
- const decl = getDecl(env, path);
3747
- const item$1 = item(declaration(env, decl));
3748
- const hasChildren = "children" in decl && decl.children && decl.children.length > 0;
3749
- const showModelProps = !("modelPath" in decl && decl["modelPath"]) || env.options.includeModelProperties;
3750
- if ("docstring" in decl && decl.docstring) item$1.children.push(...parse(decl.docstring));
3751
- if (hasChildren && showModelProps && !nesting.includes(path)) item$1.push(renderChildren(env, decl.children ?? [], [...nesting, path]));
3752
- return item$1;
3753
- }
3754
- function renderMethod(env, method) {
3755
- const decl = getDecl(env, method.stainlessPath);
3756
- if (!decl) return [paragraph(text("The method "), code(method.name), text(" is not available in this language."))];
3757
- const signature = methodSignature(env.language, decl);
3758
- const [httpMethod, endpoint] = method.endpoint.split(" ");
3759
- const output = [
3760
- heading(2, method.title),
3761
- ...env.language === "http" ? [] : [paragraph(code(stripMarkup(signature)))],
3762
- paragraph(strong(text(httpMethod)), text(" "), code(endpoint))
3763
- ];
3764
- if (method.description) output.push(...parse(method.description));
3765
- if (env.language === "http") {
3766
- const p = "paramsChildren" in decl && typeof decl.paramsChildren === "object" ? decl.paramsChildren : {};
3767
- for (const [location, value] of Object.entries(p)) {
3768
- if (value.length < 1) continue;
3769
- output.push(heading(3, [
3770
- text(location.at(0)?.toUpperCase() ?? ""),
3771
- text(location.slice(1)),
3772
- text(" Parameters")
3773
- ]), renderChildren(env, value));
3774
- }
3775
- const bp = "bodyParamsChildren" in decl ? decl.bodyParamsChildren?.["application/json"] : [];
3776
- if (bp && bp.length > 0) output.push(heading(3, "Body Parameters"), renderChildren(env, bp));
3777
- }
3778
- if ("paramsChildren" in decl && Array.isArray(decl.paramsChildren) && decl.paramsChildren.length > 0) output.push(heading(3, "Parameters"), renderChildren(env, decl.paramsChildren));
3779
- if ("responseChildren" in decl && decl.responseChildren && decl.responseChildren.length > 0) output.push(heading(3, "Returns"), renderChildren(env, decl.responseChildren));
3780
- const snippet = getSnippet(env, method.stainlessPath);
3781
- if (snippet) output.push(heading(3, "Example"), fence(env.language, snippet));
3782
- return output;
3783
- }
3784
- function renderModel(env, model) {
3785
- return [heading(3, model.title), list(renderDecl(env, `${model.stainlessPath} > (schema)`))];
3786
- }
3787
- function renderResource(env, resource) {
3788
- const methods = Object.values(resource.methods).filter((method) => getDecl(env, method.stainlessPath)).flatMap((method) => renderMethod(env, method));
3789
- const models = Object.values(resource.models).filter((model) => getDecl(env, `${model.stainlessPath} > (schema)`)).flatMap((model) => renderModel(env, model));
3790
- const doc = [heading(1, resource.title), ...methods];
3791
- if (models.length > 0) doc.push(heading(2, "Domain Types"), ...models);
3792
- if (!env.options.renderNestedResources) return doc;
3793
- const children = Object.values(resource.subresources ?? {}).flatMap((resource$1) => renderResource(env, resource$1));
3794
- return [...doc, ...children];
3795
- }
3796
- function render(env, node$1) {
3797
- switch (node$1.kind) {
3798
- case "resource": return renderResource(env, node$1);
3799
- case "http_method": return renderMethod(env, node$1);
3800
- case "model": return renderModel(env, node$1);
3801
- }
3802
- }
3803
- function renderMarkdown(env, node$1) {
3804
- const content = render(env, node$1);
3805
- const doc = new Markdoc.Ast.Node("document", {}, content);
3806
- return Markdoc.format(doc);
3807
- }
3808
-
3809
- //#endregion
3810
- //#region src/search/indexer.ts
3811
- function getResourceNames(resourceIds, topResources) {
3812
- let element = void 0;
3813
- let resources = topResources;
3814
- const resourceName = [];
3815
- for (const resource of resourceIds) {
3816
- element = resources?.[resource];
3817
- if (!element) break;
3818
- resourceName.push(element.title);
3819
- resources = element?.subresources;
3820
- }
3821
- return resourceName;
3822
- }
3823
- function chunkByLines(content, maxSize = 6e4) {
3824
- if (Buffer.byteLength(content, "utf8") < maxSize) return [content];
3825
- const lines = content.split("\n");
3826
- const chunks = [];
3827
- let currentChunk = [];
3828
- let currentSize = 0;
3829
- for (const line of lines) {
3830
- const lineSize = Buffer.byteLength(line + "\n", "utf8");
3831
- if (currentSize + lineSize > maxSize) {
3832
- chunks.push(currentChunk.join("\n"));
3833
- currentChunk = [];
3834
- currentSize = 0;
3835
- }
3836
- currentChunk.push(line);
3837
- currentSize += lineSize;
3838
- }
3839
- if (currentChunk.length > 0) chunks.push(currentChunk.join("\n"));
3840
- return chunks;
3841
- }
3842
- function* generateChatIndex(spec) {
3843
- for (const [language, readme] of Object.entries(spec.readme)) {
3844
- const chunks = chunkByLines(readme);
3845
- for (const chunk of chunks) yield {
3846
- language,
3847
- title: "Overview",
3848
- content: chunk,
3849
- url: `docs://BASE_PATH/${language}`
3850
- };
3851
- }
3852
- for (const { data } of walkTree(spec)) {
3853
- if (data.kind !== "http_method") continue;
3854
- const { title, name, stainlessPath, httpMethod, summary, description } = data;
3855
- const endpoint = data.endpoint.slice(httpMethod.length).trim();
3856
- for (const language of Languages) {
3857
- const decl = spec.decls[language]?.[stainlessPath];
3858
- if (!decl) continue;
3859
- const chunks = chunkByLines(renderMarkdown({
3860
- spec,
3861
- language,
3862
- options: { includeModelProperties: true }
3863
- }, data));
3864
- for (const chunk of chunks) yield {
3865
- language,
3866
- title,
3867
- name,
3868
- endpoint,
3869
- httpMethod,
3870
- summary,
3871
- description,
3872
- stainlessPath,
3873
- qualified: "qualified" in decl ? decl["qualified"] : void 0,
3874
- ident: "ident" in decl ? decl["ident"] : void 0,
3875
- content: chunk,
3876
- url: generateRoute("docs://BASE_PATH", language, stainlessPath)
3877
- };
3878
- }
3879
- }
3880
- }
3881
- function* generateIndex(spec, renderMarkdownFn, includeTypes) {
3882
- const parentCrumbs = {};
3883
- for (const { data } of walkTree(spec, true)) {
3884
- const { kind, name, title, stainlessPath } = data;
3885
- const common = {
3886
- name,
3887
- title,
3888
- stainlessPath
3889
- };
3890
- const crumbs = getResourceNames(parseStainlessPath(stainlessPath).resource, spec.resources);
3891
- switch (kind) {
3892
- case "resource":
3893
- for (const language of Languages) {
3894
- if (!data[language]) continue;
3895
- parentCrumbs[stainlessPath] = crumbs;
3896
- const { Name, QualifiedName } = data[language];
3897
- yield {
3898
- kind,
3899
- crumbs,
3900
- language,
3901
- Name,
3902
- QualifiedName,
3903
- priority: 0,
3904
- ...common
3905
- };
3906
- }
3907
- break;
3908
- case "http_method": {
3909
- const { summary, endpoint, httpMethod } = data;
3910
- for (const language of Languages) {
3911
- const found = spec.decls[language]?.[stainlessPath];
3912
- if (!found) continue;
3913
- parentCrumbs[stainlessPath] = [...crumbs, title];
3914
- const qualified = "qualified" in found ? found["qualified"] : void 0;
3915
- const ident = qualified?.split(".")?.at(-1);
3916
- yield {
3917
- kind,
3918
- crumbs: [...crumbs, title],
3919
- ident,
3920
- qualified,
3921
- language,
3922
- description: data.description ? renderMarkdownFn?.(data.description) ?? data.description : void 0,
3923
- endpoint: endpoint.slice(httpMethod.length).trim(),
3924
- httpMethod,
3925
- summary,
3926
- priority: 0,
3927
- ...common
3928
- };
3929
- }
3930
- break;
3931
- }
3932
- case "model": for (const language of Languages) {
3933
- if (!spec.decls[language]) continue;
3934
- parentCrumbs[stainlessPath] = [...crumbs, title];
3935
- const schema = spec.decls[language]?.[`${stainlessPath} > (schema)`];
3936
- const children = (schema && "children" in schema ? schema?.["children"] : void 0)?.map((childPath) => {
3937
- const child = spec.decls?.[language]?.[childPath];
3938
- return child?.["ident"] ?? child?.["name"] ?? child?.["key"] ?? child?.["type"]?.["literal"]?.["value"] ?? child?.["type"]?.["literal"] ?? child?.["type"]?.["value"];
3939
- })?.filter((child) => child) ?? [];
3940
- yield {
3941
- kind,
3942
- crumbs: [...crumbs, title],
3943
- children,
3944
- language,
3945
- priority: 2,
3946
- ident: schema && "ident" in schema ? schema?.["ident"] : void 0,
3947
- ...common
3948
- };
3949
- }
3950
- }
3951
- }
3952
- for (const language of Languages) {
3953
- const decls = spec.decls?.[language];
3954
- if (!decls) continue;
3955
- for (const decl of Object.values(decls)) switch (decl.kind) {
3956
- case "JavaDeclProperty":
3957
- case "GoDeclProperty":
3958
- case "PythonDeclProperty":
3959
- case "RubyDeclProperty":
3960
- case "HttpDeclProperty":
3961
- case "TSDeclProperty":
3962
- {
3963
- const parsedPath = parseStainlessPath(decl.stainlessPath);
3964
- const type = includeTypes === false ? void 0 : typeName(language, decl.type);
3965
- const name = decl["ident"] ?? decl["name"] ?? decl["key"];
3966
- const parent = parentCrumbs[parsedPath.routable];
3967
- if (parent === void 0) continue;
3968
- const matches = decl.stainlessPath.matchAll(/\((property|params|param)\) ([^\s]+)/g);
3969
- const props = Array.from(matches).map((p) => p[2]).filter((p) => p !== void 0);
3970
- yield {
3971
- kind: "property",
3972
- name,
3973
- stainlessPath: decl.stainlessPath,
3974
- crumbs: [...parent, ...props],
3975
- docstring: decl.docstring ? renderMarkdownFn?.(decl.docstring) ?? decl.docstring : void 0,
3976
- type,
3977
- language,
3978
- priority: 3
3979
- };
3980
- }
3981
- break;
3982
- }
3983
- }
3984
- }
3985
-
3986
- //#endregion
3987
- //#region src/search/providers/algolia.ts
3988
- async function buildIndex(appId, indexName, writeKey, spec, renderMarkdown$1) {
3989
- if (!appId || !indexName || !writeKey) return;
3990
- const objects = Array.from(generateIndex(spec, renderMarkdown$1));
3991
- const client = searchClient(appId, writeKey);
3992
- await client.setSettings({
3993
- indexName,
3994
- indexSettings: {
3995
- highlightPreTag: "<mark>",
3996
- highlightPostTag: "</mark>",
3997
- customRanking: ["asc(priority)"],
3998
- attributesForFaceting: ["language", "kind"],
3999
- searchableAttributes: [...SearchableAttributes]
4000
- }
4001
- });
4002
- await client.replaceAllObjects({
4003
- indexName,
4004
- objects
4005
- });
4006
- }
4007
- async function buildChatIndex(appId, indexName, writeKey, spec) {
4008
- if (!appId || !indexName || !writeKey) return;
4009
- const objects = Array.from(generateChatIndex(spec));
4010
- const client = searchClient(appId, writeKey);
4011
- await client.setSettings({
4012
- indexName,
4013
- indexSettings: {
4014
- attributesForFaceting: ["language"],
4015
- attributeForDistinct: "stainlessPath",
4016
- searchableAttributes: SearchableAttributesChat
4017
- }
4018
- });
4019
- await client.replaceAllObjects({
4020
- indexName,
4021
- objects
4022
- });
4023
- }
4024
- async function buildProseIndex(appId, indexName, writeKey, objects) {
4025
- if (!appId || !indexName || !writeKey) return;
4026
- const client = searchClient(appId, writeKey);
4027
- await client.setSettings({
4028
- indexName,
4029
- indexSettings: { searchableAttributes: SearchableAttributesProse }
4030
- });
4031
- await client.replaceAllObjects({
4032
- indexName,
4033
- objects
4034
- });
4035
- }
4036
- async function search({ settings: { appId, indexName, searchKey }, params: { query, language, kind } }) {
4037
- const client = searchClient(appId, searchKey);
4038
- const filters = language ? `language:${language}` : void 0;
4039
- const facetFilters = kind ? [`kind:${kind}`] : void 0;
4040
- const { results } = await client.search({ requests: [{
4041
- query,
4042
- indexName,
4043
- filters,
4044
- hitsPerPage: 5,
4045
- facets: ["kind"]
4046
- }, {
4047
- query,
4048
- indexName,
4049
- filters,
4050
- facetFilters,
4051
- facets: ["kind"],
4052
- hitsPerPage: 50
4053
- }] });
4054
- if ("hits" in results[0] && "hits" in results[1]) {
4055
- const [{ nbHits, facets }, { hits }] = results;
4056
- return {
4057
- hits,
4058
- nbHits: nbHits ?? 0,
4059
- facets
4060
- };
4061
- }
4062
- }
4063
-
4064
- //#endregion
4065
- //#region src/contexts/search.tsx
4066
- const [Provider, useSearchContext] = createStrictContext("SearchContext");
4067
- function useSearch() {
4068
- const { settings } = useSearchContext();
4069
- return (params) => search({
4070
- settings,
4071
- params
4072
- });
4073
- }
4074
- function SearchProvider({ children, ...props }) {
4075
- return /* @__PURE__ */ jsx(Provider, {
4076
- value: props,
4077
- children
4078
- });
4079
- }
4080
-
4081
- //#endregion
4082
- //#region src/contexts/index.tsx
4083
- var contexts_exports = /* @__PURE__ */ __export({
4084
- ComponentProvider: () => ComponentProvider$1,
4085
- DocsProvider: () => DocsProvider,
4086
- MarkdownContext: () => MarkdownContext,
4087
- MarkdownProvider: () => MarkdownProvider,
4088
- NavigationProvider: () => NavigationProvider,
4089
- SearchProvider: () => SearchProvider,
4090
- customizeComponents: () => customizeComponents,
4091
- useComponentContext: () => useComponentContext,
4092
- useComponents: () => useComponents$1,
4093
- useContentPanelLayout: () => useContentPanelLayout,
4094
- useDeclaration: () => useDeclaration,
4095
- useDocs: () => useDocs,
4096
- useHighlight: () => useHighlight,
4097
- useLanguage: () => useLanguage,
4098
- useLanguageComponents: () => useLanguageComponents,
4099
- useMarkdownContext: () => useMarkdownContext,
4100
- useNavigation: () => useNavigation,
4101
- useRenderMarkdown: () => useRenderMarkdown,
4102
- useResource: () => useResource,
4103
- useSearch: () => useSearch,
4104
- useSearchContext: () => useSearchContext,
4105
- useSettings: () => useSettings,
4106
- useSnippet: () => useSnippet,
4107
- useSpec: () => useSpec
4108
- });
4109
- function useLanguageComponents() {
4110
- const language = useLanguage();
4111
- const definition = useComponentContext().language[language];
4112
- if (!definition) throw new Error(`Language component definition not found for language: ${language}`);
4113
- return definition;
4114
- }
4115
-
4116
- //#endregion
4117
- export { Type$5 as $, HttpMethods as $t, TypeName$1 as A, SDKExample as At, Property$3 as B, usePropertyModel as Bt, TypeName as C, SnippetRequestContainer as Ct, MethodSignature$1 as D, SDKChildren as Dt, MethodInfo as E, ReferenceNestingContext as Et, Type$2 as F, SDKMethodInfo as Ft, MethodSignature$4 as G, Join as Gt, TypeName$3 as H, Badge as Ht, TypeName$2 as I, SDKModel as It, TypeName$4 as J, Markdown as Jt, Property$4 as K, Link as Kt, ruby_exports as L, SDKReference as Lt, Declaration$2 as M, SDKLanguageBlock as Mt, MethodSignature$2 as N, SDKMethod as Nt, Property$1 as O, SDKConstraints as Ot, Property$2 as P, SDKMethodHeader as Pt, Property$5 as Q, HttpMethodIcons as Qt, Declaration$3 as R, SDKRequestTitle as Rt, Type as S, SnippetContainer as St, Declaration$1 as T, PropertyModelContext as Tt, python_exports as U, Expander as Ut, Type$3 as V, useReferenceNesting as Vt, Declaration$4 as W, Input as Wt, Declaration$5 as X, Tooltip as Xt, go_exports as Y, ToggleButton as Yt, MethodSignature$5 as Z, VirtualExpander as Zt, languages_exports as _, SDKResourceHeader as _t, useSearchContext as a, MethodRoute as an, Type$6 as at, MethodSignature as b, SnippetButtons as bt, buildProseIndex as c, PropertyTitle as cn, components_exports as ct, declaration as d, SidebarMethod as dt, Method as en, TypeName$5 as et, render as f, SidebarResource as ft, kotlin as g, SDKResource as gt, defaultContextValue as h, SDKOverview as ht, useSearch as i, MethodInfo$1 as in, Property$6 as it, http_exports as j, SDKIcon as jt, Type$1 as k, SDKDeclaration as kt, search as l, PropertyToggle as ln, Sidebar as lt, ComponentProvider as m, SDKMethodSummary as mt, useLanguageComponents as n, MethodHeader as nn, Declaration$6 as nt, buildChatIndex as o, Property$7 as on, TypeName$6 as ot, renderMarkdown as p, SDKBreadcrumbs as pt, Type$4 as q, ListView as qt, SearchProvider as r, MethodIconBadge as rn, MethodSignature$6 as rt, buildIndex as s, PropertyDescription as sn, typescript_exports as st, contexts_exports as t, MethodDescription as tn, java_exports as tt, generateIndex as u, SidebarExpander as ut, node as v, SDKRoot as vt, csharp_exports as w, SnippetResponse as wt, Property as x, SnippetCode as xt, Declaration as y, Snippet as yt, MethodSignature$3 as z, SDKSnippetLanguages as zt };