@stainless-api/docs-ui 0.1.0-beta.21 → 0.1.0-beta.22

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