@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.
- package/CHANGELOG.md +1102 -0
- package/ambient.d.ts +6 -0
- package/eslint-suppressions.json +90 -0
- package/{eslint.config.js → eslint.config.ts} +0 -2
- package/locals.d.ts +17 -0
- package/package.json +62 -44
- package/playground-virtual-modules.d.ts +96 -0
- package/plugin/assets/languages/cli.svg +14 -0
- package/plugin/assets/languages/csharp.svg +1 -0
- package/plugin/assets/languages/php.svg +4 -0
- package/plugin/buildAlgoliaIndex.ts +40 -39
- package/plugin/components/MethodDescription.tsx +54 -0
- package/plugin/components/RequestBuilder/ParamEditor.tsx +55 -0
- package/plugin/components/RequestBuilder/SnippetStainlessIsland.tsx +107 -0
- package/plugin/components/RequestBuilder/index.tsx +40 -0
- package/plugin/components/RequestBuilder/props.ts +9 -0
- package/plugin/components/RequestBuilder/spec-helpers.ts +47 -0
- package/plugin/components/RequestBuilder/styles.css +67 -0
- package/plugin/components/SDKSelect.astro +18 -111
- package/plugin/components/SnippetCode.tsx +112 -70
- package/plugin/components/StainlessIslands.tsx +126 -0
- package/plugin/components/search/SearchAlgolia.astro +46 -29
- package/plugin/components/search/SearchIsland.tsx +61 -37
- package/plugin/generateAPIReferenceLink.ts +0 -40
- package/plugin/globalJs/ai-dropdown-options.ts +248 -0
- package/plugin/globalJs/code-snippets.ts +45 -16
- package/plugin/globalJs/copy.ts +115 -27
- package/plugin/globalJs/create-playground.shim.ts +3 -0
- package/plugin/globalJs/method-descriptions.ts +33 -0
- package/plugin/globalJs/navigation.ts +24 -44
- package/plugin/globalJs/playground-data.shim.ts +1 -0
- package/plugin/globalJs/playground-data.ts +14 -0
- package/plugin/globalJs/summary-selection-tweak.ts +29 -0
- package/plugin/helpers/generateDocsRoutes.ts +59 -0
- package/plugin/helpers/multiSpec.ts +8 -0
- package/plugin/index.ts +317 -141
- package/plugin/languages.ts +8 -2
- package/plugin/loadPluginConfig.ts +284 -109
- package/plugin/markdown/highlighter.ts +100 -0
- package/plugin/markdown/index.ts +39 -0
- package/plugin/middlewareBuilder/stainlessMiddleware.d.ts +3 -1
- package/plugin/react/Routing.tsx +98 -263
- package/plugin/referencePlaceholderUtils.ts +17 -14
- package/plugin/replaceSidebarPlaceholderMiddleware.ts +39 -35
- package/plugin/routes/Docs.astro +72 -111
- package/plugin/routes/DocsStatic.astro +6 -5
- package/plugin/routes/Overview.astro +46 -22
- package/plugin/routes/llms.ts +186 -0
- package/plugin/routes/markdown.ts +13 -12
- package/plugin/{cms → sidebar-utils}/sidebar-builder.ts +84 -69
- package/plugin/specs/FileCache.ts +99 -0
- package/plugin/specs/fetchSpecSSR.ts +27 -0
- package/plugin/specs/generateSpec.ts +112 -0
- package/plugin/specs/index.ts +132 -0
- package/plugin/specs/inputResolver.ts +148 -0
- package/plugin/{cms → specs}/worker.ts +82 -5
- package/plugin/vendor/preview.worker.docs.js +27121 -16890
- package/plugin/vendor/templates/cli.md +1 -0
- package/plugin/vendor/templates/go.md +4 -2
- package/plugin/vendor/templates/java.md +5 -1
- package/plugin/vendor/templates/kotlin.md +5 -1
- package/plugin/vendor/templates/node.md +4 -2
- package/plugin/vendor/templates/python.md +4 -2
- package/plugin/vendor/templates/ruby.md +4 -2
- package/plugin/vendor/templates/terraform.md +1 -1
- package/plugin/vendor/templates/typescript.md +3 -1
- package/resolveSrcFile.ts +10 -0
- package/scripts/vendor_deps.ts +5 -5
- package/shared/conditionalIntegration.ts +28 -0
- package/shared/getProsePages.ts +41 -0
- package/shared/getSharedLogger.ts +15 -0
- package/shared/terminalUtils.ts +3 -0
- package/shared/virtualModule.ts +46 -1
- package/src/content.config.ts +9 -0
- package/stl-docs/aiChatExamples.ts +95 -0
- package/stl-docs/chat/docs-chat-handler.ts +18 -0
- package/stl-docs/chat/hook.ts +215 -0
- package/stl-docs/chat/schemas.ts +70 -0
- package/stl-docs/chat/stainless-handler/index.ts +126 -0
- package/stl-docs/chat/stream-util.ts +16 -0
- package/stl-docs/chat/ui/AiChat.module.css +591 -0
- package/stl-docs/chat/ui/AiChat.tsx +188 -0
- package/stl-docs/chat/ui/Trigger.tsx +154 -0
- package/stl-docs/chat/ui/components/ChatControls.tsx +51 -0
- package/stl-docs/chat/ui/components/ChatEmpty.tsx +42 -0
- package/stl-docs/chat/ui/components/ChatLog.tsx +96 -0
- package/stl-docs/chat/ui/components/ChatMessage.tsx +47 -0
- package/stl-docs/chat/ui/components/CodeBlock.tsx +33 -0
- package/stl-docs/chat/ui/components/MessageFeedback.tsx +109 -0
- package/stl-docs/chat/ui/components/Table.tsx +15 -0
- package/stl-docs/chat/ui/components/ToolCall.tsx +34 -0
- package/stl-docs/chat/ui/components/hljs-github.css +81 -0
- package/stl-docs/chat/ui/scroll-manager.ts +86 -0
- package/stl-docs/chat/ui/types.ts +45 -0
- package/stl-docs/components/AIDropdown.tsx +63 -0
- package/stl-docs/components/AiChatIsland.tsx +16 -0
- package/stl-docs/components/{content-panel/ContentBreadcrumbs.tsx → ContentBreadcrumbs.tsx} +2 -2
- package/stl-docs/components/ContentPanel.astro +9 -0
- package/stl-docs/components/Footer.astro +89 -0
- package/stl-docs/components/Head.astro +20 -0
- package/stl-docs/components/Header.astro +3 -9
- package/stl-docs/components/PageFrame.astro +37 -0
- package/stl-docs/components/PageSidebar.astro +11 -0
- package/stl-docs/components/PageTitle.astro +82 -0
- package/stl-docs/components/StainlessLogo.svg +4 -0
- package/stl-docs/components/ThemeProvider.astro +36 -0
- package/stl-docs/components/ThemeSelect.astro +84 -146
- package/stl-docs/components/TwoColumnContent.astro +2 -0
- package/stl-docs/components/headers/DefaultHeader.astro +6 -8
- package/stl-docs/components/headers/StackedHeader.astro +10 -53
- package/stl-docs/components/icons/chat-gpt.tsx +2 -2
- package/stl-docs/components/icons/cursor.tsx +10 -0
- package/stl-docs/components/icons/gemini.tsx +19 -0
- package/stl-docs/components/icons/markdown.tsx +1 -1
- package/stl-docs/components/index.ts +1 -0
- package/stl-docs/components/mintlify-compat/Accordion.astro +2 -2
- package/stl-docs/components/mintlify-compat/AccordionGroup.astro +0 -4
- package/stl-docs/components/mintlify-compat/Columns.astro +2 -2
- package/stl-docs/components/mintlify-compat/Frame.astro +6 -6
- package/stl-docs/components/mintlify-compat/Tab.astro +2 -2
- package/stl-docs/components/mintlify-compat/callouts/Callout.astro +2 -2
- package/stl-docs/components/mintlify-compat/callouts/Check.astro +0 -4
- package/stl-docs/components/mintlify-compat/callouts/Danger.astro +0 -4
- package/stl-docs/components/mintlify-compat/callouts/Info.astro +0 -4
- package/stl-docs/components/mintlify-compat/callouts/Note.astro +0 -4
- package/stl-docs/components/mintlify-compat/callouts/Tip.astro +0 -4
- package/stl-docs/components/mintlify-compat/callouts/Warning.astro +0 -4
- package/stl-docs/components/mintlify-compat/card.css +4 -4
- package/stl-docs/components/mintlify-compat/index.ts +2 -4
- package/stl-docs/components/nav-tabs/NavDropdown.astro +38 -77
- package/stl-docs/components/nav-tabs/NavTabs.astro +81 -81
- package/stl-docs/components/nav-tabs/SecondaryNavTabs.astro +1 -2
- package/stl-docs/components/nav-tabs/buildNavLinks.ts +5 -2
- package/stl-docs/components/pagination/HomeLink.astro +10 -0
- package/stl-docs/components/pagination/Pagination.astro +177 -0
- package/stl-docs/components/pagination/PaginationLinkEmphasized.astro +22 -0
- package/stl-docs/components/pagination/PaginationLinkQuiet.astro +13 -0
- package/stl-docs/components/pagination/util.ts +71 -0
- package/stl-docs/components/scripts.ts +1 -0
- package/stl-docs/components/sidebars/BaseSidebar.astro +80 -2
- package/stl-docs/components/sidebars/SidebarWithComponents.tsx +10 -0
- package/stl-docs/components/sidebars/convertAstroSidebarToStl.tsx +62 -0
- package/stl-docs/disableCalloutSyntax.ts +36 -0
- package/stl-docs/fonts.ts +186 -0
- package/stl-docs/index.ts +176 -58
- package/stl-docs/loadStlDocsConfig.ts +73 -8
- package/stl-docs/proseDocSync.test.ts +74 -0
- package/stl-docs/proseDocSync.ts +344 -0
- package/stl-docs/proseMarkdown/proseMarkdownIntegration.ts +53 -0
- package/stl-docs/proseMarkdown/proseMarkdownMiddleware.ts +41 -0
- package/stl-docs/proseMarkdown/toMarkdown.ts +158 -0
- package/stl-docs/proseSearchIndexing.ts +218 -0
- package/stl-docs/tabsMiddleware.ts +14 -5
- package/styles/code.css +53 -49
- package/styles/links.css +2 -37
- package/styles/method-descriptions.css +36 -0
- package/styles/overrides.css +28 -46
- package/styles/page.css +228 -38
- package/styles/sdk_select.css +9 -6
- package/styles/search.css +11 -21
- package/styles/sidebar.css +28 -215
- package/styles/{variables.css → sl-variables.css} +4 -8
- package/styles/stldocs-variables.css +6 -0
- package/styles/toc.css +19 -8
- package/theme.css +11 -9
- package/tsconfig.json +1 -4
- package/virtual-module.d.ts +66 -8
- package/components/variables.css +0 -112
- package/plugin/cms/client.ts +0 -62
- package/plugin/cms/server.ts +0 -268
- package/plugin/globalJs/ai-dropdown.ts +0 -57
- package/stl-docs/components/APIReferenceAIDropdown.tsx +0 -58
- package/stl-docs/components/ClientRouterHead.astro +0 -41
- package/stl-docs/components/content-panel/ContentPanel.astro +0 -69
- package/stl-docs/components/content-panel/ProseAIDropdown.tsx +0 -55
- package/stl-docs/components/headers/SplashMobileMenuToggle.astro +0 -49
- package/stl-docs/components/mintlify-compat/Step.astro +0 -56
- package/stl-docs/components/mintlify-compat/Steps.astro +0 -15
- package/styles/fonts.css +0 -68
- /package/{plugin/assets → assets}/fonts/geist/OFL.txt +0 -0
- /package/{plugin/assets → assets}/fonts/geist/geist-italic-latin-ext.woff2 +0 -0
- /package/{plugin/assets → assets}/fonts/geist/geist-italic-latin.woff2 +0 -0
- /package/{plugin/assets → assets}/fonts/geist/geist-latin-ext.woff2 +0 -0
- /package/{plugin/assets → assets}/fonts/geist/geist-latin.woff2 +0 -0
- /package/{plugin/assets → assets}/fonts/geist/geist-mono-italic-latin-ext.woff2 +0 -0
- /package/{plugin/assets → assets}/fonts/geist/geist-mono-italic-latin.woff2 +0 -0
- /package/{plugin/assets → assets}/fonts/geist/geist-mono-latin-ext.woff2 +0 -0
- /package/{plugin/assets → assets}/fonts/geist/geist-mono-latin.woff2 +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
SDK_Readme
|
|
@@ -7,6 +7,8 @@ from applications written in Go.
|
|
|
7
7
|
|
|
8
8
|
SDK_GeneratedByStainless
|
|
9
9
|
|
|
10
|
+
SDK_MCPReadmeSection
|
|
11
|
+
|
|
10
12
|
## Installation
|
|
11
13
|
|
|
12
14
|
SDK_ReleasePleaseMarkdownBlockStart
|
|
@@ -31,7 +33,7 @@ SDK_ReleasePleaseMarkdownBlockEnd
|
|
|
31
33
|
|
|
32
34
|
## Requirements
|
|
33
35
|
|
|
34
|
-
This library requires Go 1.
|
|
36
|
+
This library requires Go 1.22+.
|
|
35
37
|
|
|
36
38
|
## Usage
|
|
37
39
|
|
|
@@ -307,7 +309,7 @@ This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) con
|
|
|
307
309
|
|
|
308
310
|
We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.
|
|
309
311
|
|
|
310
|
-
We are keen for your feedback; please open an [issue](
|
|
312
|
+
We are keen for your feedback; please open an [issue](SDK_RepoURL/issues) with questions, bugs, or suggestions.
|
|
311
313
|
|
|
312
314
|
## Contributing
|
|
313
315
|
|
|
@@ -11,6 +11,8 @@ SDK_SectionSimilarToOtherSDK
|
|
|
11
11
|
|
|
12
12
|
SDK_GeneratedByStainless
|
|
13
13
|
|
|
14
|
+
SDK_MCPReadmeSection
|
|
15
|
+
|
|
14
16
|
SDK_SectionDocumentationReference
|
|
15
17
|
|
|
16
18
|
SDK_SectionInstallation
|
|
@@ -57,6 +59,8 @@ SDK_SectionTimeouts
|
|
|
57
59
|
|
|
58
60
|
SDK_SectionProxies
|
|
59
61
|
|
|
62
|
+
SDK_SectionConnectionPooling
|
|
63
|
+
|
|
60
64
|
SDK_SectionHTTPS
|
|
61
65
|
|
|
62
66
|
SDK_SectionEnvironments
|
|
@@ -84,4 +88,4 @@ This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) con
|
|
|
84
88
|
|
|
85
89
|
We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.
|
|
86
90
|
|
|
87
|
-
We are keen for your feedback; please open an [issue](
|
|
91
|
+
We are keen for your feedback; please open an [issue](SDK_RepoURL/issues) with questions, bugs, or suggestions.
|
|
@@ -11,6 +11,8 @@ SDK_SectionSimilarToOtherSDK
|
|
|
11
11
|
|
|
12
12
|
SDK_GeneratedByStainless
|
|
13
13
|
|
|
14
|
+
SDK_MCPReadmeSection
|
|
15
|
+
|
|
14
16
|
SDK_SectionDocumentationReference
|
|
15
17
|
|
|
16
18
|
SDK_SectionInstallation
|
|
@@ -57,6 +59,8 @@ SDK_SectionTimeouts
|
|
|
57
59
|
|
|
58
60
|
SDK_SectionProxies
|
|
59
61
|
|
|
62
|
+
SDK_SectionConnectionPooling
|
|
63
|
+
|
|
60
64
|
SDK_SectionHTTPS
|
|
61
65
|
|
|
62
66
|
SDK_SectionEnvironments
|
|
@@ -84,4 +88,4 @@ This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) con
|
|
|
84
88
|
|
|
85
89
|
We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.
|
|
86
90
|
|
|
87
|
-
We are keen for your feedback; please open an [issue](
|
|
91
|
+
We are keen for your feedback; please open an [issue](SDK_RepoURL/issues) with questions, bugs, or suggestions.
|
|
@@ -10,6 +10,8 @@ SDK_DocumentationReference
|
|
|
10
10
|
|
|
11
11
|
SDK_GeneratedByStainless
|
|
12
12
|
|
|
13
|
+
SDK_MCPReadmeSection
|
|
14
|
+
|
|
13
15
|
## Installation
|
|
14
16
|
|
|
15
17
|
SDK_NPMInstallInstructions
|
|
@@ -169,7 +171,7 @@ import SDK_PackageName from 'SDK_NPMPackage';
|
|
|
169
171
|
```
|
|
170
172
|
|
|
171
173
|
To do the inverse, add `import "SDK_NPMPackage/shims/node"` (which does import polyfills).
|
|
172
|
-
This can also be useful if you are getting the wrong TypeScript types for `Response` ([more details](
|
|
174
|
+
This can also be useful if you are getting the wrong TypeScript types for `Response` ([more details](SDK_RepoCodeURL/src/_shims#readme)).
|
|
173
175
|
|
|
174
176
|
### Logging and middleware
|
|
175
177
|
|
|
@@ -214,7 +216,7 @@ This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) con
|
|
|
214
216
|
|
|
215
217
|
We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.
|
|
216
218
|
|
|
217
|
-
We are keen for your feedback; please open an [issue](
|
|
219
|
+
We are keen for your feedback; please open an [issue](SDK_RepoURL/issues) with questions, bugs, or suggestions.
|
|
218
220
|
|
|
219
221
|
## Requirements
|
|
220
222
|
|
|
@@ -9,6 +9,8 @@ SDK_ScreencastURL
|
|
|
9
9
|
|
|
10
10
|
SDK_GeneratedByStainless
|
|
11
11
|
|
|
12
|
+
SDK_MCPReadmeSection
|
|
13
|
+
|
|
12
14
|
## Documentation
|
|
13
15
|
|
|
14
16
|
SDK_DocumentationCallout SDK_APIReferenceCallout
|
|
@@ -227,7 +229,7 @@ This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) con
|
|
|
227
229
|
|
|
228
230
|
We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.
|
|
229
231
|
|
|
230
|
-
We are keen for your feedback; please open an [issue](
|
|
232
|
+
We are keen for your feedback; please open an [issue](SDK_RepoURL/issues) with questions, bugs, or suggestions.
|
|
231
233
|
|
|
232
234
|
### Determining the installed version
|
|
233
235
|
|
|
@@ -242,7 +244,7 @@ print(SDK_PythonPackageImportName.__version__)
|
|
|
242
244
|
|
|
243
245
|
## Requirements
|
|
244
246
|
|
|
245
|
-
Python 3.
|
|
247
|
+
Python 3.9 or higher.
|
|
246
248
|
|
|
247
249
|
## Contributing
|
|
248
250
|
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
# SDK_PackageTitle API library
|
|
2
2
|
|
|
3
|
-
SDK_ReadmeOpening It ships with comprehensive types & docstrings in Yard, RBS, and RBI – [see below](
|
|
3
|
+
SDK_ReadmeOpening It ships with comprehensive types & docstrings in Yard, RBS, and RBI – [see below](SDK_RepoURL#Sorbet) for usage with Sorbet. The standard library's `net/http` is used as the HTTP transport, with connection pooling via the `connection_pool` gem.
|
|
4
4
|
|
|
5
5
|
SDK_ScreencastURL
|
|
6
6
|
|
|
7
7
|
SDK_GeneratedByStainless
|
|
8
8
|
|
|
9
|
+
SDK_MCPReadmeSection
|
|
10
|
+
|
|
9
11
|
## Documentation
|
|
10
12
|
|
|
11
13
|
Documentation for releases of this gem can be found [on RubyDoc](SDK_RubyDocInfoURL).
|
|
@@ -142,4 +144,4 @@ Ruby SDK_RubyMinVersion or higher.
|
|
|
142
144
|
|
|
143
145
|
## Contributing
|
|
144
146
|
|
|
145
|
-
See [the contributing documentation](
|
|
147
|
+
See [the contributing documentation](SDK_RepoAssetURL/CONTRIBUTING.md).
|
|
@@ -53,7 +53,7 @@ This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) con
|
|
|
53
53
|
|
|
54
54
|
We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.
|
|
55
55
|
|
|
56
|
-
We are keen for your feedback; please open an [issue](
|
|
56
|
+
We are keen for your feedback; please open an [issue](SDK_RepoURL/issues) with questions, bugs, or suggestions.
|
|
57
57
|
|
|
58
58
|
## Contributing
|
|
59
59
|
|
|
@@ -10,6 +10,8 @@ SDK_DocumentationReference
|
|
|
10
10
|
|
|
11
11
|
SDK_GeneratedByStainless
|
|
12
12
|
|
|
13
|
+
SDK_MCPReadmeSection
|
|
14
|
+
|
|
13
15
|
## Installation
|
|
14
16
|
|
|
15
17
|
SDK_NPMInstallInstructions
|
|
@@ -298,7 +300,7 @@ This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) con
|
|
|
298
300
|
|
|
299
301
|
We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.
|
|
300
302
|
|
|
301
|
-
We are keen for your feedback; please open an [issue](
|
|
303
|
+
We are keen for your feedback; please open an [issue](SDK_RepoURL/issues) with questions, bugs, or suggestions.
|
|
302
304
|
|
|
303
305
|
## Requirements
|
|
304
306
|
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { join } from 'path';
|
|
2
|
+
const dirName = import.meta.dirname;
|
|
3
|
+
/**
|
|
4
|
+
* Resolve a source file path relative to the stl-starlight package.
|
|
5
|
+
* @param projectPath - The relative path to the source file.
|
|
6
|
+
* @returns The absolute path to the source file.
|
|
7
|
+
*/
|
|
8
|
+
export function resolveSrcFile(...projectPath: string[]) {
|
|
9
|
+
return join(dirName, ...projectPath);
|
|
10
|
+
}
|
package/scripts/vendor_deps.ts
CHANGED
|
@@ -3,7 +3,7 @@ import fs from 'fs';
|
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
|
|
6
|
-
import { Languages } from '@stainless-api/docs-ui/
|
|
6
|
+
import { Languages } from '@stainless-api/docs-ui/routing';
|
|
7
7
|
|
|
8
8
|
const DEPS_DIR = './plugin/vendor';
|
|
9
9
|
|
|
@@ -11,12 +11,12 @@ config();
|
|
|
11
11
|
|
|
12
12
|
const envSchema = z.object({
|
|
13
13
|
// absolute path to the Stainless monorepo root
|
|
14
|
-
|
|
14
|
+
STAINLESS_ROOT: z.string(),
|
|
15
15
|
});
|
|
16
16
|
|
|
17
17
|
const env = envSchema.parse(process.env);
|
|
18
18
|
|
|
19
|
-
console.log(`Using Stainless monorepo at ${env.
|
|
19
|
+
console.log(`Using Stainless monorepo at ${env.STAINLESS_ROOT}`);
|
|
20
20
|
|
|
21
21
|
if (fs.existsSync(DEPS_DIR)) {
|
|
22
22
|
fs.rmSync(DEPS_DIR, { recursive: true });
|
|
@@ -25,11 +25,11 @@ if (fs.existsSync(DEPS_DIR)) {
|
|
|
25
25
|
fs.mkdirSync(DEPS_DIR, { recursive: true });
|
|
26
26
|
|
|
27
27
|
const previewWorkerPath = path.join(
|
|
28
|
-
env.
|
|
28
|
+
env.STAINLESS_ROOT,
|
|
29
29
|
'/packages/preview-worker/dist/stainless/preview.worker.docs.js',
|
|
30
30
|
);
|
|
31
31
|
|
|
32
|
-
const readmeTemplatePath = path.join(env.
|
|
32
|
+
const readmeTemplatePath = path.join(env.STAINLESS_ROOT, '/legacy-dir-root/templates');
|
|
33
33
|
|
|
34
34
|
fs.copyFileSync(previewWorkerPath, path.join(DEPS_DIR, 'preview.worker.docs.js'));
|
|
35
35
|
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { AstroIntegration, type AstroIntegrationLogger } from 'astro';
|
|
2
|
+
import { getSharedLogger } from './getSharedLogger';
|
|
3
|
+
|
|
4
|
+
export default function conditionalIntegration({
|
|
5
|
+
condition,
|
|
6
|
+
integration,
|
|
7
|
+
reason,
|
|
8
|
+
}: {
|
|
9
|
+
condition: boolean;
|
|
10
|
+
integration: AstroIntegration;
|
|
11
|
+
reason?: string | undefined;
|
|
12
|
+
}): AstroIntegration {
|
|
13
|
+
if (condition) {
|
|
14
|
+
return integration;
|
|
15
|
+
}
|
|
16
|
+
return {
|
|
17
|
+
name: integration.name,
|
|
18
|
+
hooks: Object.fromEntries(
|
|
19
|
+
Object.keys(integration.hooks).map((hookName) => [
|
|
20
|
+
hookName,
|
|
21
|
+
({ logger: localLogger }: { logger: AstroIntegrationLogger }) => {
|
|
22
|
+
const logger = getSharedLogger({ fallback: localLogger });
|
|
23
|
+
logger.info(`Skipping ${integration.name} integration. Reason: ${reason ?? 'not provided'}`);
|
|
24
|
+
},
|
|
25
|
+
]),
|
|
26
|
+
),
|
|
27
|
+
};
|
|
28
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { readdir } from 'fs/promises';
|
|
2
|
+
import { join, relative } from 'path';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Get all prose pages after a build, by reading all HTML files from the
|
|
6
|
+
* given output directory, and not from assets.
|
|
7
|
+
*
|
|
8
|
+
* We cannot use the `assets` map here because it is not guaranteed to
|
|
9
|
+
* contain all files, especially if they were generated by other integrations.
|
|
10
|
+
* Other astro integrations may hijack the "[...slug]" entrypoint, and any files
|
|
11
|
+
* previously in the [...slug] asset map entry would be lost (this is where starlight stores
|
|
12
|
+
* its prose HTML files).
|
|
13
|
+
*/
|
|
14
|
+
export async function getProsePages({
|
|
15
|
+
apiReferenceBasePath,
|
|
16
|
+
outputBasePath,
|
|
17
|
+
}: {
|
|
18
|
+
apiReferenceBasePath: string | null;
|
|
19
|
+
outputBasePath: string;
|
|
20
|
+
}): Promise<string[]> {
|
|
21
|
+
const allFiles = await readdir(outputBasePath, {
|
|
22
|
+
recursive: true,
|
|
23
|
+
withFileTypes: true,
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const htmlFiles = allFiles
|
|
27
|
+
.filter((file) => file.isFile() && file.name.endsWith('.html'))
|
|
28
|
+
.map((file) => join(file.parentPath, file.name));
|
|
29
|
+
|
|
30
|
+
if (!apiReferenceBasePath) return htmlFiles;
|
|
31
|
+
// Normalize by removing leading/trailing slashes from apiReferenceBasePath
|
|
32
|
+
const normalizedApiPath = apiReferenceBasePath.replace(/^\/+/g, '').replace(/\/+$/g, '');
|
|
33
|
+
const pagesToRender = htmlFiles.filter((absPath) => {
|
|
34
|
+
const relPath = relative(outputBasePath, absPath);
|
|
35
|
+
// Filter out API reference pages
|
|
36
|
+
if (relPath === normalizedApiPath || relPath.startsWith(`${normalizedApiPath}/`)) return false;
|
|
37
|
+
return true;
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
return pagesToRender;
|
|
41
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { AstroIntegrationLogger } from 'astro';
|
|
2
|
+
|
|
3
|
+
let sharedLogger: AstroIntegrationLogger | null = null;
|
|
4
|
+
|
|
5
|
+
// This is probably temporary, but it's a quick way to share a logger between our many integrations
|
|
6
|
+
// we want to share a logger so they have the same "stainless" label
|
|
7
|
+
|
|
8
|
+
export function setSharedLogger(logger: AstroIntegrationLogger) {
|
|
9
|
+
sharedLogger = logger;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// a fallback is probably not required, but it's a good safeguard in case we somehow call a logger before the shared logger is set
|
|
13
|
+
export function getSharedLogger({ fallback }: { fallback: AstroIntegrationLogger }) {
|
|
14
|
+
return sharedLogger ?? fallback;
|
|
15
|
+
}
|
package/shared/virtualModule.ts
CHANGED
|
@@ -1,7 +1,52 @@
|
|
|
1
|
-
|
|
1
|
+
import type { ViteUserConfig } from 'astro';
|
|
2
|
+
|
|
3
|
+
type VitePlugin = NonNullable<ViteUserConfig['plugins']>[number];
|
|
4
|
+
|
|
5
|
+
export function buildVirtualModuleString<T extends Record<string, unknown>>(vars: T) {
|
|
2
6
|
return Object.entries(vars)
|
|
3
7
|
.map(([key, value]) => {
|
|
4
8
|
return `export const ${key} = ${JSON.stringify(value)};`;
|
|
5
9
|
})
|
|
6
10
|
.join('\n');
|
|
7
11
|
}
|
|
12
|
+
|
|
13
|
+
export function makeVirtualModPlugin(bareId: string, content: string): VitePlugin {
|
|
14
|
+
return {
|
|
15
|
+
name: `stl-virtual-module-loader-${bareId}`,
|
|
16
|
+
resolveId(id) {
|
|
17
|
+
// The '\0' prefix tells Vite “this is a virtual module” and prevents it from being resolved again.
|
|
18
|
+
if (id === bareId) {
|
|
19
|
+
return `\0${bareId}`;
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
load(id) {
|
|
23
|
+
if (id === `\0${bareId}`) {
|
|
24
|
+
return content;
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function makeAsyncVirtualModPlugin<T extends Record<string, unknown>>(
|
|
31
|
+
bareId: string,
|
|
32
|
+
contentLoader: () => Promise<T | string>,
|
|
33
|
+
): VitePlugin {
|
|
34
|
+
return {
|
|
35
|
+
name: `stl-virtual-module-loader-${bareId}`,
|
|
36
|
+
resolveId(id) {
|
|
37
|
+
// The '\0' prefix tells Vite “this is a virtual module” and prevents it from being resolved again.
|
|
38
|
+
if (id === bareId) {
|
|
39
|
+
return `\0${bareId}`;
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
async load(id) {
|
|
43
|
+
if (id === `\0${bareId}`) {
|
|
44
|
+
const content = await contentLoader();
|
|
45
|
+
if (typeof content === 'string') {
|
|
46
|
+
return content;
|
|
47
|
+
}
|
|
48
|
+
return buildVirtualModuleString(content);
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Stub here so that `astro sync` generates the correct types for the `docs` content collection
|
|
2
|
+
|
|
3
|
+
import { defineCollection } from 'astro:content';
|
|
4
|
+
import { docsLoader } from '@astrojs/starlight/loaders';
|
|
5
|
+
import { docsSchema } from '@astrojs/starlight/schema';
|
|
6
|
+
|
|
7
|
+
export const collections = {
|
|
8
|
+
docs: defineCollection({ loader: docsLoader(), schema: docsSchema() }),
|
|
9
|
+
};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { AstroIntegrationLogger } from 'astro';
|
|
2
|
+
import z from 'zod';
|
|
3
|
+
import {
|
|
4
|
+
buildVirtualModuleString,
|
|
5
|
+
makeAsyncVirtualModPlugin,
|
|
6
|
+
makeVirtualModPlugin,
|
|
7
|
+
} from '../shared/virtualModule';
|
|
8
|
+
import type * as virtualExampleModule from 'virtual:stl-docs-ai-chat-examples';
|
|
9
|
+
type VirtualExampleModule = typeof virtualExampleModule;
|
|
10
|
+
|
|
11
|
+
const exampleSchema = z.array(
|
|
12
|
+
z.object({
|
|
13
|
+
shortPrompt: z.string(),
|
|
14
|
+
longPrompt: z.string(),
|
|
15
|
+
icon: z.string(),
|
|
16
|
+
}),
|
|
17
|
+
);
|
|
18
|
+
export type ExamplePromptResponse = z.infer<typeof exampleSchema>;
|
|
19
|
+
|
|
20
|
+
// handles actually retrieving the information via the Stainless API
|
|
21
|
+
async function loadExamples(
|
|
22
|
+
projectName: string,
|
|
23
|
+
logger: AstroIntegrationLogger,
|
|
24
|
+
): Promise<ExamplePromptResponse | undefined> {
|
|
25
|
+
try {
|
|
26
|
+
const response = await fetch(`https://api.stainless.com/api/ai/steelie-examples/${projectName}`, {
|
|
27
|
+
method: 'GET',
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const text = await response.text();
|
|
31
|
+
if (!response.ok) {
|
|
32
|
+
logger.error(`failed to fetch AI chat examples: ${text}`);
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
const examples = exampleSchema.parse(JSON.parse(text));
|
|
36
|
+
return examples;
|
|
37
|
+
} catch (error) {
|
|
38
|
+
if (error instanceof Error) logger.error(`failed to fetch AI chat examples: ${error.message}`);
|
|
39
|
+
else throw error;
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export default async function generateExamplesPlugin({
|
|
45
|
+
projectName,
|
|
46
|
+
logger,
|
|
47
|
+
exampleOverrides,
|
|
48
|
+
}: {
|
|
49
|
+
projectName: string | undefined;
|
|
50
|
+
logger: AstroIntegrationLogger;
|
|
51
|
+
exampleOverrides?: ExamplePromptResponse;
|
|
52
|
+
}) {
|
|
53
|
+
// if the user has specified any examples, return those immediately
|
|
54
|
+
// instead of loading them via the web.
|
|
55
|
+
if (exampleOverrides) {
|
|
56
|
+
return makeVirtualModPlugin(
|
|
57
|
+
'virtual:stl-docs-ai-chat-examples',
|
|
58
|
+
generateVirtualModuleString(exampleOverrides),
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
// if we don't have a defined project name, don't try to fetch examples
|
|
62
|
+
if (!projectName) {
|
|
63
|
+
return makeVirtualModPlugin(
|
|
64
|
+
'virtual:stl-docs-ai-chat-examples',
|
|
65
|
+
buildVirtualModuleString({ examples: undefined } satisfies VirtualExampleModule),
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// otherwise, promise to get the right examples at some point later on
|
|
70
|
+
const examplesPromise = loadExamples(projectName, logger);
|
|
71
|
+
return makeAsyncVirtualModPlugin<VirtualExampleModule>('virtual:stl-docs-ai-chat-examples', async () => {
|
|
72
|
+
const examples = await examplesPromise;
|
|
73
|
+
return generateVirtualModuleString(examples);
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function generateVirtualModuleString(examples: ExamplePromptResponse | undefined) {
|
|
78
|
+
if (!examples) return 'export const examples = undefined;';
|
|
79
|
+
|
|
80
|
+
// Generate icon imports
|
|
81
|
+
// prettier-ignore
|
|
82
|
+
const pascalToKebab = (str: string) => str.split(/(?=[A-Z])/).join('-').toLowerCase();
|
|
83
|
+
const iconImportPath = (iconName: string) =>
|
|
84
|
+
import.meta.resolve(`lucide-react/dist/esm/icons/${pascalToKebab(iconName)}.js`);
|
|
85
|
+
const iconImports = examples.map(
|
|
86
|
+
({ icon }) => `import ${icon} from ${JSON.stringify(iconImportPath(icon))}`,
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
// Reference icon imports in `examples` exported object
|
|
90
|
+
// "icon":"Sparkles" -> "icon":Sparkles
|
|
91
|
+
const iconStringsToIdents = (jsonBlob: string) => jsonBlob.replace(/"icon":\s*"(\w+)"/g, '"icon":$1');
|
|
92
|
+
const exportBody = `export const examples = ${iconStringsToIdents(JSON.stringify(examples))};`;
|
|
93
|
+
|
|
94
|
+
return [...iconImports, exportBody].join('\n');
|
|
95
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { FeedbackResponseBody, MetadataResponseBody, RequestBody, ResponseChunk } from './schemas';
|
|
2
|
+
|
|
3
|
+
export type DocsChatHandler = {
|
|
4
|
+
generateResponse: (
|
|
5
|
+
{
|
|
6
|
+
query,
|
|
7
|
+
priorMessages,
|
|
8
|
+
}: {
|
|
9
|
+
query: string;
|
|
10
|
+
priorMessages: NonNullable<RequestBody['additionalContext']>['prior_messages'];
|
|
11
|
+
},
|
|
12
|
+
abortSignal: AbortSignal,
|
|
13
|
+
) => AsyncGenerator<ResponseChunk>;
|
|
14
|
+
|
|
15
|
+
onRate: (spanId: string, score: 0 | 1) => Promise<FeedbackResponseBody>;
|
|
16
|
+
|
|
17
|
+
onAssignMetadata: (spanId: string, metadata: Record<string, string>) => Promise<MetadataResponseBody>;
|
|
18
|
+
};
|