@stainless-api/docs 0.1.0-beta.13 → 0.1.0-beta.130

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 (188) hide show
  1. package/CHANGELOG.md +1102 -0
  2. package/ambient.d.ts +6 -0
  3. package/eslint-suppressions.json +90 -0
  4. package/{eslint.config.js → eslint.config.ts} +0 -2
  5. package/locals.d.ts +17 -0
  6. package/package.json +62 -44
  7. package/playground-virtual-modules.d.ts +96 -0
  8. package/plugin/assets/languages/cli.svg +14 -0
  9. package/plugin/assets/languages/csharp.svg +1 -0
  10. package/plugin/assets/languages/php.svg +4 -0
  11. package/plugin/buildAlgoliaIndex.ts +40 -39
  12. package/plugin/components/MethodDescription.tsx +54 -0
  13. package/plugin/components/RequestBuilder/ParamEditor.tsx +55 -0
  14. package/plugin/components/RequestBuilder/SnippetStainlessIsland.tsx +107 -0
  15. package/plugin/components/RequestBuilder/index.tsx +40 -0
  16. package/plugin/components/RequestBuilder/props.ts +9 -0
  17. package/plugin/components/RequestBuilder/spec-helpers.ts +47 -0
  18. package/plugin/components/RequestBuilder/styles.css +67 -0
  19. package/plugin/components/SDKSelect.astro +18 -111
  20. package/plugin/components/SnippetCode.tsx +112 -70
  21. package/plugin/components/StainlessIslands.tsx +126 -0
  22. package/plugin/components/search/SearchAlgolia.astro +46 -29
  23. package/plugin/components/search/SearchIsland.tsx +61 -37
  24. package/plugin/generateAPIReferenceLink.ts +0 -40
  25. package/plugin/globalJs/ai-dropdown-options.ts +248 -0
  26. package/plugin/globalJs/code-snippets.ts +45 -16
  27. package/plugin/globalJs/copy.ts +115 -27
  28. package/plugin/globalJs/create-playground.shim.ts +3 -0
  29. package/plugin/globalJs/method-descriptions.ts +33 -0
  30. package/plugin/globalJs/navigation.ts +24 -44
  31. package/plugin/globalJs/playground-data.shim.ts +1 -0
  32. package/plugin/globalJs/playground-data.ts +14 -0
  33. package/plugin/globalJs/summary-selection-tweak.ts +29 -0
  34. package/plugin/helpers/generateDocsRoutes.ts +59 -0
  35. package/plugin/helpers/multiSpec.ts +8 -0
  36. package/plugin/index.ts +317 -141
  37. package/plugin/languages.ts +8 -2
  38. package/plugin/loadPluginConfig.ts +284 -109
  39. package/plugin/markdown/highlighter.ts +100 -0
  40. package/plugin/markdown/index.ts +39 -0
  41. package/plugin/middlewareBuilder/stainlessMiddleware.d.ts +3 -1
  42. package/plugin/react/Routing.tsx +98 -263
  43. package/plugin/referencePlaceholderUtils.ts +17 -14
  44. package/plugin/replaceSidebarPlaceholderMiddleware.ts +39 -35
  45. package/plugin/routes/Docs.astro +72 -111
  46. package/plugin/routes/DocsStatic.astro +6 -5
  47. package/plugin/routes/Overview.astro +46 -22
  48. package/plugin/routes/llms.ts +186 -0
  49. package/plugin/routes/markdown.ts +13 -12
  50. package/plugin/{cms → sidebar-utils}/sidebar-builder.ts +84 -69
  51. package/plugin/specs/FileCache.ts +99 -0
  52. package/plugin/specs/fetchSpecSSR.ts +27 -0
  53. package/plugin/specs/generateSpec.ts +112 -0
  54. package/plugin/specs/index.ts +132 -0
  55. package/plugin/specs/inputResolver.ts +148 -0
  56. package/plugin/{cms → specs}/worker.ts +82 -5
  57. package/plugin/vendor/preview.worker.docs.js +27121 -16890
  58. package/plugin/vendor/templates/cli.md +1 -0
  59. package/plugin/vendor/templates/go.md +4 -2
  60. package/plugin/vendor/templates/java.md +5 -1
  61. package/plugin/vendor/templates/kotlin.md +5 -1
  62. package/plugin/vendor/templates/node.md +4 -2
  63. package/plugin/vendor/templates/python.md +4 -2
  64. package/plugin/vendor/templates/ruby.md +4 -2
  65. package/plugin/vendor/templates/terraform.md +1 -1
  66. package/plugin/vendor/templates/typescript.md +3 -1
  67. package/resolveSrcFile.ts +10 -0
  68. package/scripts/vendor_deps.ts +5 -5
  69. package/shared/conditionalIntegration.ts +28 -0
  70. package/shared/getProsePages.ts +41 -0
  71. package/shared/getSharedLogger.ts +15 -0
  72. package/shared/terminalUtils.ts +3 -0
  73. package/shared/virtualModule.ts +46 -1
  74. package/src/content.config.ts +9 -0
  75. package/stl-docs/aiChatExamples.ts +95 -0
  76. package/stl-docs/chat/docs-chat-handler.ts +18 -0
  77. package/stl-docs/chat/hook.ts +215 -0
  78. package/stl-docs/chat/schemas.ts +70 -0
  79. package/stl-docs/chat/stainless-handler/index.ts +126 -0
  80. package/stl-docs/chat/stream-util.ts +16 -0
  81. package/stl-docs/chat/ui/AiChat.module.css +591 -0
  82. package/stl-docs/chat/ui/AiChat.tsx +188 -0
  83. package/stl-docs/chat/ui/Trigger.tsx +154 -0
  84. package/stl-docs/chat/ui/components/ChatControls.tsx +51 -0
  85. package/stl-docs/chat/ui/components/ChatEmpty.tsx +42 -0
  86. package/stl-docs/chat/ui/components/ChatLog.tsx +96 -0
  87. package/stl-docs/chat/ui/components/ChatMessage.tsx +47 -0
  88. package/stl-docs/chat/ui/components/CodeBlock.tsx +33 -0
  89. package/stl-docs/chat/ui/components/MessageFeedback.tsx +109 -0
  90. package/stl-docs/chat/ui/components/Table.tsx +15 -0
  91. package/stl-docs/chat/ui/components/ToolCall.tsx +34 -0
  92. package/stl-docs/chat/ui/components/hljs-github.css +81 -0
  93. package/stl-docs/chat/ui/scroll-manager.ts +86 -0
  94. package/stl-docs/chat/ui/types.ts +45 -0
  95. package/stl-docs/components/AIDropdown.tsx +63 -0
  96. package/stl-docs/components/AiChatIsland.tsx +16 -0
  97. package/stl-docs/components/{content-panel/ContentBreadcrumbs.tsx → ContentBreadcrumbs.tsx} +2 -2
  98. package/stl-docs/components/ContentPanel.astro +9 -0
  99. package/stl-docs/components/Footer.astro +89 -0
  100. package/stl-docs/components/Head.astro +20 -0
  101. package/stl-docs/components/Header.astro +3 -9
  102. package/stl-docs/components/PageFrame.astro +37 -0
  103. package/stl-docs/components/PageSidebar.astro +11 -0
  104. package/stl-docs/components/PageTitle.astro +82 -0
  105. package/stl-docs/components/StainlessLogo.svg +4 -0
  106. package/stl-docs/components/ThemeProvider.astro +36 -0
  107. package/stl-docs/components/ThemeSelect.astro +84 -146
  108. package/stl-docs/components/TwoColumnContent.astro +2 -0
  109. package/stl-docs/components/headers/DefaultHeader.astro +6 -8
  110. package/stl-docs/components/headers/StackedHeader.astro +10 -53
  111. package/stl-docs/components/icons/chat-gpt.tsx +2 -2
  112. package/stl-docs/components/icons/cursor.tsx +10 -0
  113. package/stl-docs/components/icons/gemini.tsx +19 -0
  114. package/stl-docs/components/icons/markdown.tsx +1 -1
  115. package/stl-docs/components/index.ts +1 -0
  116. package/stl-docs/components/mintlify-compat/Accordion.astro +2 -2
  117. package/stl-docs/components/mintlify-compat/AccordionGroup.astro +0 -4
  118. package/stl-docs/components/mintlify-compat/Columns.astro +2 -2
  119. package/stl-docs/components/mintlify-compat/Frame.astro +6 -6
  120. package/stl-docs/components/mintlify-compat/Tab.astro +2 -2
  121. package/stl-docs/components/mintlify-compat/callouts/Callout.astro +2 -2
  122. package/stl-docs/components/mintlify-compat/callouts/Check.astro +0 -4
  123. package/stl-docs/components/mintlify-compat/callouts/Danger.astro +0 -4
  124. package/stl-docs/components/mintlify-compat/callouts/Info.astro +0 -4
  125. package/stl-docs/components/mintlify-compat/callouts/Note.astro +0 -4
  126. package/stl-docs/components/mintlify-compat/callouts/Tip.astro +0 -4
  127. package/stl-docs/components/mintlify-compat/callouts/Warning.astro +0 -4
  128. package/stl-docs/components/mintlify-compat/card.css +4 -4
  129. package/stl-docs/components/mintlify-compat/index.ts +2 -4
  130. package/stl-docs/components/nav-tabs/NavDropdown.astro +38 -77
  131. package/stl-docs/components/nav-tabs/NavTabs.astro +81 -81
  132. package/stl-docs/components/nav-tabs/SecondaryNavTabs.astro +1 -2
  133. package/stl-docs/components/nav-tabs/buildNavLinks.ts +5 -2
  134. package/stl-docs/components/pagination/HomeLink.astro +10 -0
  135. package/stl-docs/components/pagination/Pagination.astro +177 -0
  136. package/stl-docs/components/pagination/PaginationLinkEmphasized.astro +22 -0
  137. package/stl-docs/components/pagination/PaginationLinkQuiet.astro +13 -0
  138. package/stl-docs/components/pagination/util.ts +71 -0
  139. package/stl-docs/components/scripts.ts +1 -0
  140. package/stl-docs/components/sidebars/BaseSidebar.astro +80 -2
  141. package/stl-docs/components/sidebars/SidebarWithComponents.tsx +10 -0
  142. package/stl-docs/components/sidebars/convertAstroSidebarToStl.tsx +62 -0
  143. package/stl-docs/disableCalloutSyntax.ts +36 -0
  144. package/stl-docs/fonts.ts +186 -0
  145. package/stl-docs/index.ts +176 -58
  146. package/stl-docs/loadStlDocsConfig.ts +73 -8
  147. package/stl-docs/proseDocSync.test.ts +74 -0
  148. package/stl-docs/proseDocSync.ts +344 -0
  149. package/stl-docs/proseMarkdown/proseMarkdownIntegration.ts +53 -0
  150. package/stl-docs/proseMarkdown/proseMarkdownMiddleware.ts +41 -0
  151. package/stl-docs/proseMarkdown/toMarkdown.ts +158 -0
  152. package/stl-docs/proseSearchIndexing.ts +218 -0
  153. package/stl-docs/tabsMiddleware.ts +14 -5
  154. package/styles/code.css +53 -49
  155. package/styles/links.css +2 -37
  156. package/styles/method-descriptions.css +36 -0
  157. package/styles/overrides.css +28 -46
  158. package/styles/page.css +228 -38
  159. package/styles/sdk_select.css +9 -6
  160. package/styles/search.css +11 -21
  161. package/styles/sidebar.css +28 -215
  162. package/styles/{variables.css → sl-variables.css} +4 -8
  163. package/styles/stldocs-variables.css +6 -0
  164. package/styles/toc.css +19 -8
  165. package/theme.css +11 -9
  166. package/tsconfig.json +1 -4
  167. package/virtual-module.d.ts +66 -8
  168. package/components/variables.css +0 -112
  169. package/plugin/cms/client.ts +0 -62
  170. package/plugin/cms/server.ts +0 -268
  171. package/plugin/globalJs/ai-dropdown.ts +0 -57
  172. package/stl-docs/components/APIReferenceAIDropdown.tsx +0 -58
  173. package/stl-docs/components/ClientRouterHead.astro +0 -41
  174. package/stl-docs/components/content-panel/ContentPanel.astro +0 -69
  175. package/stl-docs/components/content-panel/ProseAIDropdown.tsx +0 -55
  176. package/stl-docs/components/headers/SplashMobileMenuToggle.astro +0 -49
  177. package/stl-docs/components/mintlify-compat/Step.astro +0 -56
  178. package/stl-docs/components/mintlify-compat/Steps.astro +0 -15
  179. package/styles/fonts.css +0 -68
  180. /package/{plugin/assets → assets}/fonts/geist/OFL.txt +0 -0
  181. /package/{plugin/assets → assets}/fonts/geist/geist-italic-latin-ext.woff2 +0 -0
  182. /package/{plugin/assets → assets}/fonts/geist/geist-italic-latin.woff2 +0 -0
  183. /package/{plugin/assets → assets}/fonts/geist/geist-latin-ext.woff2 +0 -0
  184. /package/{plugin/assets → assets}/fonts/geist/geist-latin.woff2 +0 -0
  185. /package/{plugin/assets → assets}/fonts/geist/geist-mono-italic-latin-ext.woff2 +0 -0
  186. /package/{plugin/assets → assets}/fonts/geist/geist-mono-italic-latin.woff2 +0 -0
  187. /package/{plugin/assets → assets}/fonts/geist/geist-mono-latin-ext.woff2 +0 -0
  188. /package/{plugin/assets → assets}/fonts/geist/geist-mono-latin.woff2 +0 -0
package/ambient.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ import 'react';
2
+ declare module 'react' {
3
+ interface CSSProperties {
4
+ [key: `--${string}`]: string | number;
5
+ }
6
+ }
@@ -0,0 +1,90 @@
1
+ {
2
+ "plugin/components/SnippetCode.tsx": {
3
+ "@typescript-eslint/no-explicit-any": {
4
+ "count": 1
5
+ }
6
+ },
7
+ "plugin/components/StainlessIslands.tsx": {
8
+ "@typescript-eslint/no-unsafe-assignment": {
9
+ "count": 1
10
+ },
11
+ "@typescript-eslint/no-unsafe-member-access": {
12
+ "count": 2
13
+ }
14
+ },
15
+ "plugin/globalJs/copy.ts": {
16
+ "@typescript-eslint/no-explicit-any": {
17
+ "count": 4
18
+ },
19
+ "@typescript-eslint/no-floating-promises": {
20
+ "count": 1
21
+ },
22
+ "@typescript-eslint/no-unsafe-assignment": {
23
+ "count": 2
24
+ },
25
+ "@typescript-eslint/no-unsafe-member-access": {
26
+ "count": 3
27
+ }
28
+ },
29
+ "plugin/index.ts": {
30
+ "@typescript-eslint/no-explicit-any": {
31
+ "count": 1
32
+ },
33
+ "@typescript-eslint/no-unsafe-assignment": {
34
+ "count": 1
35
+ }
36
+ },
37
+ "plugin/languages.ts": {
38
+ "@typescript-eslint/no-explicit-any": {
39
+ "count": 1
40
+ }
41
+ },
42
+ "plugin/referencePlaceholderUtils.ts": {
43
+ "@typescript-eslint/no-unsafe-assignment": {
44
+ "count": 1
45
+ }
46
+ },
47
+ "plugin/specs/generateSpec.ts": {
48
+ "@typescript-eslint/no-unsafe-assignment": {
49
+ "count": 2
50
+ }
51
+ },
52
+ "plugin/specs/worker.ts": {
53
+ "@typescript-eslint/no-explicit-any": {
54
+ "count": 3
55
+ },
56
+ "@typescript-eslint/no-unsafe-argument": {
57
+ "count": 1
58
+ },
59
+ "@typescript-eslint/no-unsafe-assignment": {
60
+ "count": 7
61
+ },
62
+ "@typescript-eslint/no-unsafe-member-access": {
63
+ "count": 4
64
+ },
65
+ "@typescript-eslint/no-unsafe-return": {
66
+ "count": 1
67
+ },
68
+ "@typescript-eslint/prefer-promise-reject-errors": {
69
+ "count": 4
70
+ }
71
+ },
72
+ "stl-docs/components/sidebars/convertAstroSidebarToStl.tsx": {
73
+ "@typescript-eslint/no-unsafe-argument": {
74
+ "count": 1
75
+ },
76
+ "@typescript-eslint/no-unsafe-assignment": {
77
+ "count": 1
78
+ }
79
+ },
80
+ "stl-docs/proseDocSync.ts": {
81
+ "@typescript-eslint/restrict-template-expressions": {
82
+ "count": 4
83
+ }
84
+ },
85
+ "stl-docs/proseSearchIndexing.ts": {
86
+ "@typescript-eslint/restrict-template-expressions": {
87
+ "count": 1
88
+ }
89
+ }
90
+ }
@@ -1,5 +1,3 @@
1
- // @ts-check
2
-
3
1
  import { defineConfig } from 'eslint/config';
4
2
  import { config } from '@stainless/eslint-config/astro';
5
3
 
package/locals.d.ts ADDED
@@ -0,0 +1,17 @@
1
+ type SidebarEntry = App.Locals['starlightRoute']['sidebar'][number];
2
+
3
+ /**
4
+ * Extending Astro’s `App.Locals` interface
5
+ */
6
+ declare namespace App {
7
+ interface Locals {
8
+ _stlStarlightPage?: {
9
+ skipRenderingStarlightTitle?: boolean;
10
+ hasMarkdownRoute?: boolean;
11
+ fullSidebar?: SidebarEntry[];
12
+ };
13
+
14
+ stainlessProject?: string;
15
+ language?: import('@stainless-api/docs-ui/routing').DocsLanguage;
16
+ }
17
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stainless-api/docs",
3
- "version": "0.1.0-beta.13",
3
+ "version": "0.1.0-beta.130",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -9,68 +9,86 @@
9
9
  "exports": {
10
10
  ".": "./stl-docs/index.ts",
11
11
  "./plugin": "./plugin/index.ts",
12
- "./OverviewRoute": "./plugin/routes/Overview.astro",
13
- "./DocsRoute": "./plugin/routes/Docs.astro",
14
- "./DocsStaticRoute": "./plugin/routes/DocsStatic.astro",
15
- "./MarkdownRoute": "./plugin/routes/markdown.ts",
16
- "./Search": "./plugin/components/search/Search.astro",
17
- "./replaceSidebarPlaceholderMiddleware": "./plugin/replaceSidebarPlaceholderMiddleware.ts",
18
12
  "./plugin/middleware": "./plugin/middlewareBuilder/stlStarlightMiddleware.ts",
19
13
  "./plugin/MiddlewareTypes": "./plugin/middlewareBuilder/stainlessMiddleware.d.ts",
20
- "./Header": "./stl-docs/components/Header.astro",
21
- "./ThemeSelect": "./stl-docs/components/ThemeSelect.astro",
22
- "./BaseSidebar": "./stl-docs/components/sidebars/BaseSidebar.astro",
23
- "./SDKSelectSidebar": "./stl-docs/components/sidebars/SDKSelectSidebar.astro",
24
- "./ContentPanel": "./stl-docs/components/content-panel/ContentPanel.astro",
25
- "./TableOfContents": "./stl-docs/components/TableOfContents.astro",
26
- "./tabsMiddleware": "./stl-docs/tabsMiddleware.ts",
14
+ "./plugin/languages": "./plugin/languages.ts",
27
15
  "./stainless-docs/mintlify-compat": "./stl-docs/components/mintlify-compat/index.ts",
28
- "./theme": "./theme.css",
29
16
  "./mintlify-compat.css": "./styles/mintlify-compat.css",
30
- "./font-imports": "./styles/fonts.css"
17
+ "./docs-config": "./stl-docs/loadStlDocsConfig.ts",
18
+ "./specs/fetchSpecSSR": "./plugin/specs/fetchSpecSSR.ts",
19
+ "./generate-docs-routes": "./plugin/helpers/generateDocsRoutes.ts",
20
+ "./components": "./stl-docs/components/index.ts",
21
+ "./components/scripts": "./stl-docs/components/scripts.ts",
22
+ "./components/Head": "./stl-docs/components/Head.astro",
23
+ "./components/PageFrame": "./stl-docs/components/PageFrame.astro",
24
+ "./components/PageTitle": "./stl-docs/components/PageTitle.astro",
25
+ "./components/ContentBreadcrumbs": "./stl-docs/components/ContentBreadcrumbs.tsx",
26
+ "./components/AIDropdown": "./stl-docs/components/AIDropdown.tsx",
27
+ "./components/Footer": "./stl-docs/components/Footer.astro",
28
+ "./components/Pagination": "./stl-docs/components/pagination/Pagination.astro"
31
29
  },
32
30
  "keywords": [],
33
31
  "author": "",
34
32
  "license": "ISC",
35
33
  "engines": {
36
- "node": ">=18.17.1"
34
+ "node": ">=22.12.0"
37
35
  },
38
36
  "peerDependencies": {
39
- "@astrojs/starlight": ">=0.36.1",
40
- "astro": ">=5.15.3"
37
+ "@astrojs/starlight": ">=0.38.0",
38
+ "astro": ">=6.0.0",
39
+ "react": ">=19.0.0",
40
+ "react-dom": ">=19.0.0",
41
+ "vite": ">=7.3.1"
41
42
  },
42
43
  "dependencies": {
43
- "@astrojs/markdown-remark": "^6.3.2",
44
- "@astrojs/react": "^4.4.1",
45
- "@stainless-api/sdk": "0.1.0-alpha.12",
46
- "cheerio": "^1.1.2",
44
+ "@astrojs/markdown-remark": "^7.1.0",
45
+ "@astrojs/react": "^5.0.3",
46
+ "@markdoc/markdoc": "^0.5.7",
47
+ "@stainless-api/sdk": "0.5.0",
48
+ "@streamparser/json-whatwg": "^0.0.22",
49
+ "cheerio": "^1.2.0",
47
50
  "clsx": "^2.1.1",
48
- "dotenv": "17.2.3",
49
- "get-port": "^7.1.0",
50
- "highlight.js": "^11.11.1",
51
- "lucide-react": "^0.544.0",
52
- "marked": "^16.0.0",
53
- "react": "^19.2.0",
54
- "react-dom": "^19.2.0",
51
+ "dotenv": "17.4.1",
52
+ "lucide-react": "^0.577.0",
53
+ "motion": "^12.38.0",
54
+ "node-html-parser": "^7.1.0",
55
+ "rehype-parse": "^9.0.1",
56
+ "rehype-remark": "^10.0.1",
57
+ "react-markdown": "^10.1.0",
58
+ "react-syntax-highlighter": "^16.1.1",
59
+ "remark-gfm": "^4.0.1",
55
60
  "remark-github-alerts": "^0.1.1",
56
- "shiki": "^3.9.2",
61
+ "remark-stringify": "^11.0.0",
62
+ "remend": "^1.3.0",
63
+ "shiki": "^4.0.2",
64
+ "unified": "^11.0.5",
65
+ "vite-plugin-prebundle-workers": "^0.2.0",
57
66
  "web-worker": "^1.5.0",
58
- "yaml": "^2.8.0",
59
- "@stainless-api/docs-ui": "0.1.0-beta.10",
60
- "@stainless-api/ui-primitives": "0.1.0-beta.11"
67
+ "@stainless-api/docs-search": "0.1.0-beta.46",
68
+ "@stainless-api/docs-ui": "0.1.0-beta.93",
69
+ "@stainless-api/ui-primitives": "0.1.0-beta.53"
61
70
  },
62
71
  "devDependencies": {
63
- "@markdoc/markdoc": "^0.5.2",
64
- "@types/node": "^24.4.0",
65
- "@types/react": "^19.2.2",
66
- "@types/react-dom": "^19.2.2",
67
- "tsx": "^4.20.3",
68
- "zod": "^4.0.0",
69
- "@stainless/eslint-config": "0.0.0"
72
+ "@astrojs/check": "^0.9.8",
73
+ "@types/node": "24.12.2",
74
+ "@types/react": "19.2.14",
75
+ "@types/react-dom": "^19.2.3",
76
+ "@types/react-syntax-highlighter": "^15.5.13",
77
+ "astro": "^6.1.5",
78
+ "react": "^19.2.4",
79
+ "react-dom": "^19.2.4",
80
+ "typescript": "6.0.2",
81
+ "vite": "^7.3.2",
82
+ "vitest": "^4.1.3",
83
+ "zod": "^4.3.6",
84
+ "@stainless/eslint-config": "0.1.0-beta.2",
85
+ "@stainless/sdk-json": "^0.1.0-beta.10"
70
86
  },
71
87
  "scripts": {
72
- "vendor-deps": "pnpm tsx scripts/vendor_deps.ts",
73
- "lint": "eslint . --max-warnings 0",
74
- "sync": "astro sync"
88
+ "vendor-deps": "node scripts/vendor_deps.ts",
89
+ "lint": "eslint --flag unstable_native_nodejs_ts_config . --max-warnings 0",
90
+ "sync": "astro sync",
91
+ "check:types": "astro check",
92
+ "test": "vitest run"
75
93
  }
76
94
  }
@@ -0,0 +1,96 @@
1
+ declare module 'virtual:stl-playground/typescript.json' {
2
+ const data: {
3
+ links: [string, string][];
4
+ files: [string, string][];
5
+ } | null;
6
+ export { data as default };
7
+ }
8
+ declare module 'virtual:stl-playground/python.json' {
9
+ const data: { files: Record<string, string>; wheel: string } | null;
10
+ export { data as default };
11
+ }
12
+ declare module 'virtual:stl-playground/auth.json' {
13
+ const data:
14
+ | ({
15
+ type: 'http_bearer' | 'query' | 'header' | 'oauth2' | 'http_basic' | 'http_digest';
16
+ description?: string;
17
+ name: string;
18
+ title: string;
19
+ header: string | undefined;
20
+ example: string | undefined;
21
+ } & {
22
+ opts: {
23
+ name: string;
24
+ type: 'string' | 'number' | 'boolean' | 'null' | 'integer';
25
+ nullable: boolean;
26
+ description?: string | undefined;
27
+ example?: unknown;
28
+ default?: unknown;
29
+ read_env?: string | undefined;
30
+ auth?:
31
+ | {
32
+ security_scheme: string;
33
+ role?: 'value' | 'password' | 'username' | 'client_id' | 'client_secret' | undefined;
34
+ }
35
+ | undefined;
36
+ }[];
37
+ })[]
38
+ | null;
39
+ export { data as default };
40
+ }
41
+ declare module 'virtual:stl-playground/data' {
42
+ import type { Config } from 'virtual:stl-playground/create';
43
+ declare const data: Config;
44
+ export { data as default };
45
+ }
46
+ declare module 'virtual:stl-playground/create' {
47
+ export type PlaygroundLanguage = 'python' | 'typescript' | 'http';
48
+ export type Config = {
49
+ wheelUrl: string;
50
+ pyTypes: {
51
+ files: Record<string, string>;
52
+ wheel: string;
53
+ } | null;
54
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
55
+ HIGHLIGHT_THEMES: any;
56
+ tsTypes: {
57
+ links: [string, string][];
58
+ files: [string, string][];
59
+ } | null;
60
+ authData:
61
+ | ({
62
+ type: 'http_bearer' | 'query' | 'header' | 'oauth2' | 'http_basic' | 'http_digest';
63
+ description?: string;
64
+ name: string;
65
+ title: string;
66
+ header: string | undefined;
67
+ example: string | undefined;
68
+ } & {
69
+ opts: {
70
+ name: string;
71
+ type: 'string' | 'number' | 'boolean' | 'null' | 'integer';
72
+ nullable: boolean;
73
+ description?: string | undefined;
74
+ example?: unknown;
75
+ default?: unknown;
76
+ read_env?: string | undefined;
77
+ auth?:
78
+ | {
79
+ security_scheme: string;
80
+ role?: 'value' | 'password' | 'username' | 'client_id' | 'client_secret' | undefined;
81
+ }
82
+ | undefined;
83
+ }[];
84
+ })[]
85
+ | null;
86
+ };
87
+ export function createPlayground(
88
+ props: {
89
+ lang: PlaygroundLanguage;
90
+ doc: string;
91
+ /** div.stl-snippet-request-container */
92
+ container: HTMLElement;
93
+ onLanguageSelect: (value: string) => void;
94
+ } & Config,
95
+ ): () => Promise<void>;
96
+ }
@@ -0,0 +1,14 @@
1
+ <svg
2
+ xmlns="http://www.w3.org/2000/svg"
3
+ viewBox="0 0 20 20"
4
+ width="24"
5
+ height="24"
6
+ fill="nopne"
7
+ >
8
+ <path
9
+ fill-rule="evenodd"
10
+ d="M3.25 3A2.25 2.25 0 0 0 1 5.25v9.5A2.25 2.25 0 0 0 3.25 17h13.5A2.25 2.25 0 0 0 19 14.75v-9.5A2.25 2.25 0 0 0 16.75 3zm.943 8.752a.75.75 0 0 1 .055-1.06L6.128 9l-1.88-1.693a.75.75 0 1 1 1.004-1.114l2.5 2.25a.75.75 0 0 1 0 1.114l-2.5 2.25a.75.75 0 0 1-1.06-.055M9.75 10.25a.75.75 0 0 0 0 1.5h2.5a.75.75 0 0 0 0-1.5z"
11
+ clip-rule="evenodd"
12
+ fill="#a2a1a1"
13
+ />
14
+ </svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" fill="none"><defs><linearGradient id="a-_r_1_" x1="46.77" x2="69.91" y1="86.46" y2="126.73" gradientTransform="matrix(8.78996,0,0,8.78996,-233.98,-518.97)" gradientUnits="userSpaceOnUse"><stop stop-color="#927be5"></stop><stop offset="1" stop-color="#512bd4"></stop></linearGradient><filter id="b-_r_1_" width="42.84" height="39.14" x="44.63" y="91.89" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"></feFlood><feColorMatrix in="SourceAlpha" result="hardAlpha" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0"></feColorMatrix><feOffset></feOffset><feColorMatrix values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.1 0"></feColorMatrix><feBlend in2="BackgroundImageFix" result="effect1_dropShadow_2037_2800"></feBlend><feColorMatrix in="SourceAlpha" result="hardAlpha" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0"></feColorMatrix><feOffset dy="1"></feOffset><feGaussianBlur stdDeviation="2.5"></feGaussianBlur><feColorMatrix values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.1 0"></feColorMatrix><feBlend in2="effect1_dropShadow_2037_2800" result="effect2_dropShadow_2037_2800"></feBlend><feColorMatrix in="SourceAlpha" result="hardAlpha" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0"></feColorMatrix><feOffset dy="4"></feOffset><feGaussianBlur stdDeviation="2"></feGaussianBlur><feColorMatrix values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.09 0"></feColorMatrix><feBlend in2="effect2_dropShadow_2037_2800" result="effect3_dropShadow_2037_2800"></feBlend><feColorMatrix in="SourceAlpha" result="hardAlpha" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0"></feColorMatrix><feOffset dy="9"></feOffset><feGaussianBlur stdDeviation="2.5"></feGaussianBlur><feColorMatrix values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.05 0"></feColorMatrix><feBlend in2="effect3_dropShadow_2037_2800" result="effect4_dropShadow_2037_2800"></feBlend><feColorMatrix in="SourceAlpha" result="hardAlpha" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0"></feColorMatrix><feOffset dy="15"></feOffset><feGaussianBlur stdDeviation="3"></feGaussianBlur><feColorMatrix values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.01 0"></feColorMatrix><feBlend in2="effect4_dropShadow_2037_2800" result="effect5_dropShadow_2037_2800"></feBlend><feBlend in="SourceGraphic" in2="effect5_dropShadow_2037_2800" result="shape"></feBlend></filter></defs><path fill="url(#a-_r_1_)" d="M135.73 285.85v173.93a60.2 60.2 0 0 0 30.13 52.17l150.62 86.97a60.2 60.2 0 0 0 60.25 0l150.62-86.97a60.2 60.2 0 0 0 30.13-52.17V285.85a60.2 60.2 0 0 0-30.13-52.18l-150.62-86.95a60.2 60.2 0 0 0-60.25 0l-150.62 86.95a60.3 60.3 0 0 0-30.13 52.18" transform="scale(0.44288615) matrix(0.1,0,0,0.1,-7.57,-10.19)"></path><path fill="#fff" d="M54.06 98.03v6.86a1.7 1.7 0 0 0 1.71 1.7 1.7 1.7 0 0 0 1.71-1.7 1.71 1.71 0 1 1 3.43 0 5.14 5.14 0 1 1-10.28 0v-6.86a5.14 5.14 0 1 1 10.28 0 1.71 1.71 0 1 1-3.43 0 1.71 1.71 0 1 0-3.42 0zm27.41 6.86a1.7 1.7 0 0 1-1.71 1.7h-1.71v1.72c0 .46-.18.9-.5 1.21a1.7 1.7 0 0 1-2.43 0 1.7 1.7 0 0 1-.5-1.2v-1.72h-3.43v1.71a1.7 1.7 0 0 1-1.71 1.72 1.7 1.7 0 0 1-1.72-1.72v-1.71h-1.71a1.71 1.71 0 1 1 0-3.43h1.71v-3.43h-1.71a1.71 1.71 0 1 1 0-3.42h1.71V94.6a1.71 1.71 0 1 1 3.43 0v1.72h3.43V94.6a1.71 1.71 0 1 1 3.43 0v1.72h1.7c.46 0 .9.18 1.22.5a1.7 1.7 0 0 1 0 2.42 1.7 1.7 0 0 1-1.21.5h-1.71v3.43h1.7a1.7 1.7 0 0 1 1.72 1.71m-6.85-5.14h-3.43v3.42h3.43z" filter="url(#b-_r_1_)" style="mix-blend-mode: screen;" transform="scale(0.44288615) matrix(0.879,0,0,0.879,-30.96,-62.09)"></path></svg>
@@ -0,0 +1,4 @@
1
+
2
+ <svg viewBox="0 0 128 128" width="24" height="24">
3
+ <path fill="url(#a)" d="M0 64c0 18.593 28.654 33.667 64 33.667 35.346 0 64-15.074 64-33.667 0-18.593-28.655-33.667-64-33.667C28.654 30.333 0 45.407 0 64Z"></path><path fill="#777bb3" d="M64 95.167c33.965 0 61.5-13.955 61.5-31.167 0-17.214-27.535-31.167-61.5-31.167S2.5 46.786 2.5 64c0 17.212 27.535 31.167 61.5 31.167Z"></path><path d="M34.772 67.864c2.793 0 4.877-.515 6.196-1.53 1.306-1.006 2.207-2.747 2.68-5.175.44-2.27.272-3.854-.5-4.71-.788-.874-2.493-1.317-5.067-1.317h-4.464l-2.473 12.732zM20.173 83.547a.694.694 0 0 1-.68-.828l6.557-33.738a.695.695 0 0 1 .68-.561h14.134c4.442 0 7.748 1.206 9.827 3.585 2.088 2.39 2.734 5.734 1.917 9.935-.333 1.711-.905 3.3-1.7 4.724a15.818 15.818 0 0 1-3.128 3.92c-1.531 1.432-3.264 2.472-5.147 3.083-1.852.604-4.232.91-7.07.91h-5.724l-1.634 8.408a.695.695 0 0 1-.682.562z"></path><path fill="#fff" d="M34.19 55.826h3.891c3.107 0 4.186.682 4.553 1.089.607.674.723 2.097.331 4.112-.439 2.257-1.253 3.858-2.42 4.756-1.194.92-3.138 1.386-5.773 1.386h-2.786l2.205-11.342zm6.674-8.1H26.731a1.39 1.39 0 0 0-1.364 1.123L18.81 82.588a1.39 1.39 0 0 0 1.363 1.653h7.35a1.39 1.39 0 0 0 1.363-1.124l1.525-7.846h5.151c2.912 0 5.364-.318 7.287-.944 1.977-.642 3.796-1.731 5.406-3.237a16.522 16.522 0 0 0 3.259-4.087c.831-1.487 1.429-3.147 1.775-4.931.86-4.423.161-7.964-2.076-10.524-2.216-2.537-5.698-3.823-10.349-3.823zM30.301 68.557h4.471c2.963 0 5.17-.557 6.62-1.675 1.451-1.116 2.428-2.98 2.938-5.591.485-2.508.264-4.277-.665-5.308-.931-1.03-2.791-1.546-5.584-1.546h-5.036l-2.743 14.12m10.563-19.445c4.252 0 7.353 1.117 9.303 3.348 1.95 2.232 2.536 5.347 1.76 9.346-.322 1.648-.863 3.154-1.625 4.518-.764 1.366-1.76 2.614-2.991 3.747-1.468 1.373-3.097 2.352-4.892 2.935-1.794.584-4.08.875-6.857.875h-6.296l-1.743 8.97h-7.35l6.558-33.739h14.133"></path><path d="M69.459 74.577a.694.694 0 0 1-.682-.827l2.9-14.928c.277-1.42.209-2.438-.19-2.87-.245-.263-.979-.704-3.15-.704h-5.256l-3.646 18.768a.695.695 0 0 1-.683.56h-7.29a.695.695 0 0 1-.683-.826l6.558-33.739a.695.695 0 0 1 .682-.561h7.29a.695.695 0 0 1 .683.826L64.41 48.42h5.653c4.307 0 7.227.758 8.928 2.321 1.733 1.593 2.275 4.14 1.608 7.573l-3.051 15.702a.695.695 0 0 1-.682.56h-7.407z"></path><path fill="#fff" d="M65.31 38.755h-7.291a1.39 1.39 0 0 0-1.364 1.124l-6.557 33.738a1.39 1.39 0 0 0 1.363 1.654h7.291a1.39 1.39 0 0 0 1.364-1.124l3.537-18.205h4.682c2.168 0 2.624.463 2.641.484.132.14.305.795.019 2.264l-2.9 14.927a1.39 1.39 0 0 0 1.364 1.654h7.408a1.39 1.39 0 0 0 1.363-1.124l3.051-15.7c.715-3.686.103-6.45-1.82-8.217-1.836-1.686-4.91-2.505-9.398-2.505h-4.81l1.421-7.315a1.39 1.39 0 0 0-1.364-1.655zm0 1.39-1.743 8.968h6.496c4.087 0 6.907.714 8.457 2.14 1.553 1.426 2.017 3.735 1.398 6.93l-3.052 15.699h-7.407l2.901-14.928c.33-1.698.208-2.856-.365-3.474-.573-.617-1.793-.926-3.658-.926h-5.829l-3.756 19.327H51.46l6.558-33.739h7.292z"></path><path d="M92.136 67.864c2.793 0 4.878-.515 6.198-1.53 1.304-1.006 2.206-2.747 2.679-5.175.44-2.27.273-3.854-.5-4.71-.788-.874-2.493-1.317-5.067-1.317h-4.463l-2.475 12.732zM77.54 83.547a.694.694 0 0 1-.682-.828l6.557-33.738a.695.695 0 0 1 .682-.561H98.23c4.442 0 7.748 1.206 9.826 3.585 2.089 2.39 2.734 5.734 1.917 9.935a15.878 15.878 0 0 1-1.699 4.724 15.838 15.838 0 0 1-3.128 3.92c-1.53 1.432-3.265 2.472-5.147 3.083-1.852.604-4.232.91-7.071.91h-5.723l-1.633 8.408a.695.695 0 0 1-.683.562z"></path><path fill="#fff" d="M91.555 55.826h3.891c3.107 0 4.186.682 4.552 1.089.61.674.724 2.097.333 4.112-.44 2.257-1.254 3.858-2.421 4.756-1.195.92-3.139 1.386-5.773 1.386h-2.786l2.204-11.342zm6.674-8.1H84.096a1.39 1.39 0 0 0-1.363 1.123l-6.558 33.739a1.39 1.39 0 0 0 1.364 1.653h7.35a1.39 1.39 0 0 0 1.363-1.124l1.525-7.846h5.15c2.911 0 5.364-.318 7.286-.944 1.978-.642 3.797-1.731 5.408-3.238a16.52 16.52 0 0 0 3.258-4.086c.832-1.487 1.428-3.147 1.775-4.931.86-4.423.162-7.964-2.076-10.524-2.216-2.537-5.697-3.823-10.35-3.823zM87.666 68.557h4.47c2.964 0 5.17-.557 6.622-1.675 1.45-1.116 2.428-2.98 2.936-5.591.487-2.508.266-4.277-.665-5.308-.93-1.03-2.791-1.546-5.583-1.546h-5.035Zm10.563-19.445c4.251 0 7.354 1.117 9.303 3.348 1.95 2.232 2.537 5.347 1.759 9.346-.32 1.648-.862 3.154-1.624 4.518-.763 1.366-1.76 2.614-2.992 3.747-1.467 1.373-3.097 2.352-4.892 2.935-1.793.584-4.078.875-6.856.875h-6.295l-1.745 8.97h-7.35l6.558-33.739h14.133"></path><defs><radialGradient id="a" cx="0" cy="0" r="1" gradientTransform="matrix(84.04136 0 0 84.04136 38.426 42.169)" gradientUnits="userSpaceOnUse"><stop stop-color="#AEB2D5"></stop><stop offset=".3" stop-color="#AEB2D5"></stop><stop offset=".75" stop-color="#484C89"></stop><stop offset="1" stop-color="#484C89"></stop></radialGradient></defs>
4
+ </svg>
@@ -1,10 +1,8 @@
1
1
  import Markdoc from '@markdoc/markdoc';
2
- import Stainless from '@stainless-api/sdk';
3
- import { createSDKJSON, parseInputs, transformOAS } from './cms/worker';
4
- import type * as SDKJSON from '~/lib/json-spec-v2/types';
5
- import { Languages } from '@stainless-api/docs-ui/src/routing';
6
- import { buildIndex } from '@stainless-api/docs-ui/src/search/providers/algolia';
7
- import type { VersionUserConfig } from './loadPluginConfig';
2
+ import { buildIndex } from '@stainless-api/docs-search/providers/algolia';
3
+ import type { AstroIntegrationLogger } from 'astro';
4
+ import { generateIndex } from '@stainless-api/docs-search/indexer';
5
+ import { SpecComposite } from './specs';
8
6
 
9
7
  const markdocConfig = {
10
8
  nodes: {
@@ -20,37 +18,28 @@ function renderMarkdown(content?: string) {
20
18
  return Markdoc.renderers.html(transformed);
21
19
  }
22
20
 
23
- export async function buildAlgoliaIndex({ version, apiKey }: { version: VersionUserConfig; apiKey: string }) {
24
- const client = new Stainless({ apiKey });
25
- const configs = await client.projects.configs.retrieve({
26
- project: version.stainlessProject,
27
- branch: version.branch,
28
- include: 'openapi',
29
- });
30
-
31
- const configYML = Object.values(configs)[0] as { content: any };
32
- const oasJson = Object.values(configs)[1] as { content: any };
33
- const configStr = configYML['content'];
34
- const oasStr = oasJson['content'];
35
- const { oas, config } = await parseInputs({
36
- oas: oasStr,
37
- config: configStr,
38
- });
39
-
40
- const transformedOAS = await transformOAS({ oas, config });
41
-
42
- const languages =
43
- config.docs?.languages ??
44
- (Object.entries(config.targets)
45
- // @ts-expect-error we don't have the actual Stainless config type here
46
- .filter(([name, target]) => Languages.includes(name) && !target.skip)
47
- .map(([name]) => name) as SDKJSON.SpecLanguage[]);
21
+ export async function buildAlgoliaIndex({
22
+ specComposite,
23
+ logger,
24
+ }: {
25
+ specComposite: SpecComposite;
26
+ logger?: AstroIntegrationLogger;
27
+ }) {
28
+ function warnLog(message: string) {
29
+ if (logger) {
30
+ logger.warn(message);
31
+ } else {
32
+ console.warn(message);
33
+ }
34
+ }
48
35
 
49
- const sdkJson = await createSDKJSON({
50
- oas: transformedOAS,
51
- config,
52
- languages,
53
- });
36
+ function infoLog(message: string) {
37
+ if (logger) {
38
+ logger.info(message);
39
+ } else {
40
+ console.log(message);
41
+ }
42
+ }
54
43
 
55
44
  const {
56
45
  PUBLIC_ALGOLIA_APP_ID: appId,
@@ -64,9 +53,21 @@ export async function buildAlgoliaIndex({ version, apiKey }: { version: VersionU
64
53
  !indexName && 'PUBLIC_ALGOLIA_INDEX',
65
54
  !algoliaWriteKey && 'PRIVATE_ALGOLIA_WRITE_KEY',
66
55
  ].filter(Boolean);
67
- console.warn(`⚠️ Skipping Algolia indexing due to missing environment variables: ${missing.join(', ')}`);
56
+ warnLog(`Skipping Algolia indexing due to missing environment variables: ${missing.join(', ')}`);
68
57
  return;
69
58
  }
70
- await buildIndex(appId, indexName, algoliaWriteKey, sdkJson, renderMarkdown);
71
- console.log('Indexing complete.');
59
+
60
+ const indexEntries = specComposite.listUniqueSpecs().flatMap((spec) =>
61
+ Array.from(
62
+ generateIndex(
63
+ spec.data.sdkJson,
64
+ renderMarkdown,
65
+ true,
66
+ spec.data.languages.filter((l) => l !== 'sql' && l !== 'openapi'),
67
+ ),
68
+ ),
69
+ );
70
+
71
+ await buildIndex(appId, indexName, algoliaWriteKey, indexEntries, renderMarkdown);
72
+ infoLog('Indexing complete.');
72
73
  }
@@ -0,0 +1,54 @@
1
+ import { MethodDescriptionProps } from '@stainless-api/docs-ui/components';
2
+ import { useComponents } from '@stainless-api/docs-ui/contexts/use-components';
3
+ import style from '@stainless-api/docs-ui/style';
4
+ import { Button } from '@stainless-api/ui-primitives';
5
+
6
+ function shouldCollapseDescription(description: string) {
7
+ const MIN_CHARS = 400;
8
+ const MIN_LINES = 6;
9
+
10
+ const lineCount = description.split('\n').length;
11
+
12
+ if (description.length >= MIN_CHARS) return true;
13
+ if (lineCount >= MIN_LINES) return true;
14
+
15
+ // Markdown structure often means longer content
16
+ if (/#\s/.test(description)) return true; // has headings
17
+ if (/```/.test(description)) return true; // has code blocks
18
+ if (/^\s*[-*]\s+/m.test(description)) return true; // has lists
19
+
20
+ return false;
21
+ }
22
+
23
+ export function MethodDescription({ description }: MethodDescriptionProps) {
24
+ const { Markdown } = useComponents();
25
+
26
+ if (description) {
27
+ // Attempt to determine if we should make the description collapsible initially
28
+ // or not. If we get this right, there will be no FOUC.
29
+ const collapsible = shouldCollapseDescription(description);
30
+
31
+ return (
32
+ <div className="stl-method-description">
33
+ <div
34
+ className={style.MethodDescription}
35
+ data-stldocs-property-group="method-description"
36
+ data-collapsed={collapsible ? 'true' : 'false'}
37
+ >
38
+ <Markdown content={description} />
39
+ </div>
40
+ <div className="stl-method-description-overflow-wrapper">
41
+ <Button
42
+ type="button"
43
+ data-method-description-toggle
44
+ size="sm"
45
+ variant="ghost"
46
+ hidden={!collapsible}
47
+ >
48
+ Show more
49
+ </Button>
50
+ </div>
51
+ </div>
52
+ );
53
+ }
54
+ }
@@ -0,0 +1,55 @@
1
+ import { useMemo } from 'react';
2
+ import { Button } from '@stainless-api/ui-primitives';
3
+ import type { Param } from './spec-helpers';
4
+ import { InfoIcon } from 'lucide-react';
5
+ import { Input } from '@stainless-api/docs-ui/components';
6
+
7
+ function setHighlight(stainlessPath: string, highlighted: boolean) {
8
+ const ele = document.getElementById(stainlessPath);
9
+ if (!ele) return;
10
+ ele.classList.toggle('stldocs-property-highlighted', highlighted);
11
+ if (highlighted) {
12
+ if (location.hash) {
13
+ const prevScroll = document.documentElement.scrollTop;
14
+ location.hash = '';
15
+ document.documentElement.scrollTop = prevScroll;
16
+ }
17
+ if (document.body.clientWidth >= 1280) {
18
+ ele.scrollIntoView({
19
+ behavior: 'smooth',
20
+ });
21
+ }
22
+ }
23
+ }
24
+
25
+ function htmlToText(html: string) {
26
+ const template = document.createElement('template');
27
+ template.innerHTML = html;
28
+ return template.content.textContent;
29
+ }
30
+
31
+ export function ParamEditor({ param }: { param: Param }) {
32
+ const type = useMemo(() => htmlToText(param.type), [param.type]);
33
+
34
+ return (
35
+ <label className="request-builder-param">
36
+ <Button
37
+ className="request-builder-param-info-button"
38
+ variant="ghost"
39
+ href={`#${encodeURIComponent(param.stainlessPath)}`}
40
+ >
41
+ <Button.Icon icon={InfoIcon} size={16} />
42
+ </Button>
43
+
44
+ <span className="request-builder-param-label">{param.key}</span>
45
+ <span className="request-builder-param-colon">:</span>
46
+
47
+ <Input
48
+ className="request-builder-param-value"
49
+ onFocus={() => setHighlight(param.stainlessPath, true)}
50
+ onBlur={() => setHighlight(param.stainlessPath, false)}
51
+ placeholder={type}
52
+ />
53
+ </label>
54
+ );
55
+ }