@stainless-api/docs 0.1.0-beta.9 → 0.1.0-beta.90
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 +748 -0
- package/eslint-suppressions.json +32 -0
- package/locals.d.ts +17 -0
- package/package.json +49 -40
- 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/buildAlgoliaIndex.ts +38 -11
- 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 +31 -0
- package/plugin/components/RequestBuilder/props.ts +9 -0
- package/plugin/components/RequestBuilder/spec-helpers.ts +50 -0
- package/plugin/components/RequestBuilder/styles.css +67 -0
- package/plugin/components/SDKSelect.astro +20 -104
- package/plugin/components/SnippetCode.tsx +111 -66
- package/plugin/components/StainlessIslands.tsx +126 -0
- package/plugin/components/search/SearchAlgolia.astro +45 -28
- package/plugin/components/search/SearchIsland.tsx +47 -29
- package/plugin/generateAPIReferenceLink.ts +2 -2
- package/plugin/globalJs/ai-dropdown-options.ts +243 -0
- package/plugin/globalJs/code-snippets.ts +15 -8
- package/plugin/globalJs/copy.ts +94 -17
- package/plugin/globalJs/create-playground.shim.ts +3 -0
- package/plugin/globalJs/method-descriptions.ts +33 -0
- package/plugin/globalJs/navigation.ts +10 -29
- package/plugin/globalJs/playground-data.shim.ts +1 -0
- package/plugin/globalJs/playground-data.ts +14 -0
- package/plugin/helpers/generateDocsRoutes.ts +27 -0
- package/plugin/helpers/getDocsLanguages.ts +9 -0
- package/plugin/index.ts +292 -116
- package/plugin/languages.ts +7 -2
- package/plugin/loadPluginConfig.ts +155 -79
- package/plugin/middlewareBuilder/stainlessMiddleware.d.ts +1 -1
- package/plugin/react/Routing.tsx +204 -132
- package/plugin/referencePlaceholderUtils.ts +18 -15
- package/plugin/replaceSidebarPlaceholderMiddleware.ts +38 -34
- package/plugin/routes/Docs.astro +65 -117
- package/plugin/routes/DocsStatic.astro +7 -4
- package/plugin/routes/Overview.astro +20 -24
- package/plugin/routes/markdown.ts +12 -11
- package/plugin/{cms → sidebar-utils}/sidebar-builder.ts +30 -54
- package/plugin/specs/fetchSpecSSR.ts +21 -0
- package/plugin/specs/generateSpec.ts +50 -0
- package/plugin/specs/index.ts +238 -0
- package/plugin/{cms → specs}/worker.ts +82 -5
- package/plugin/vendor/preview.worker.docs.js +20928 -17830
- package/plugin/vendor/templates/go.md +1 -1
- package/plugin/vendor/templates/python.md +1 -1
- package/resolveSrcFile.ts +10 -0
- package/scripts/vendor_deps.ts +5 -5
- package/shared/getProsePages.ts +42 -0
- package/shared/getSharedLogger.ts +15 -0
- package/shared/terminalUtils.ts +3 -0
- package/shared/virtualModule.ts +54 -1
- package/src/content.config.ts +9 -0
- package/stl-docs/components/AIDropdown.tsx +63 -0
- package/stl-docs/components/AiChatIsland.tsx +14 -0
- package/stl-docs/components/{content-panel/ContentBreadcrumbs.tsx → ContentBreadcrumbs.tsx} +2 -2
- package/stl-docs/components/Head.astro +20 -0
- package/stl-docs/components/Header.astro +6 -8
- package/stl-docs/components/PageFrame.astro +18 -0
- package/stl-docs/components/PageTitle.astro +82 -0
- package/stl-docs/components/TableOfContents.astro +34 -0
- package/stl-docs/components/ThemeProvider.astro +36 -0
- package/stl-docs/components/ThemeSelect.astro +84 -139
- package/stl-docs/components/content-panel/ContentPanel.astro +16 -46
- package/stl-docs/components/headers/SplashMobileMenuToggle.astro +17 -1
- package/stl-docs/components/headers/StackedHeader.astro +29 -24
- 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 +7 -5
- package/stl-docs/components/mintlify-compat/AccordionGroup.astro +7 -3
- package/stl-docs/components/mintlify-compat/Columns.astro +40 -42
- package/stl-docs/components/mintlify-compat/Frame.astro +16 -18
- package/stl-docs/components/mintlify-compat/callouts/Callout.astro +1 -1
- package/stl-docs/components/mintlify-compat/callouts/Check.astro +1 -1
- package/stl-docs/components/mintlify-compat/callouts/Danger.astro +1 -1
- package/stl-docs/components/mintlify-compat/callouts/Info.astro +1 -1
- package/stl-docs/components/mintlify-compat/callouts/Note.astro +1 -1
- package/stl-docs/components/mintlify-compat/callouts/Tip.astro +1 -1
- package/stl-docs/components/mintlify-compat/callouts/Warning.astro +1 -1
- package/stl-docs/components/mintlify-compat/card.css +33 -35
- package/stl-docs/components/mintlify-compat/index.ts +2 -4
- package/stl-docs/components/nav-tabs/NavDropdown.astro +31 -70
- package/stl-docs/components/nav-tabs/NavTabs.astro +78 -80
- package/stl-docs/components/nav-tabs/SecondaryNavTabs.astro +15 -8
- package/stl-docs/components/nav-tabs/buildNavLinks.ts +3 -2
- package/stl-docs/components/pagination/HomeLink.astro +10 -0
- package/stl-docs/components/pagination/Pagination.astro +175 -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 +9 -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 +153 -50
- package/stl-docs/loadStlDocsConfig.ts +51 -7
- package/stl-docs/proseMarkdown/proseMarkdownIntegration.ts +61 -0
- package/stl-docs/proseMarkdown/proseMarkdownMiddleware.ts +41 -0
- package/stl-docs/proseMarkdown/toMarkdown.ts +158 -0
- package/stl-docs/proseSearchIndexing.ts +606 -0
- package/stl-docs/tabsMiddleware.ts +13 -4
- package/styles/code.css +128 -136
- package/styles/links.css +11 -48
- package/styles/method-descriptions.css +36 -0
- package/styles/overrides.css +49 -57
- package/styles/page.css +100 -59
- package/styles/sdk_select.css +9 -7
- package/styles/search.css +57 -69
- package/styles/sidebar.css +26 -156
- package/styles/{variables.css → sl-variables.css} +3 -2
- package/styles/stldocs-variables.css +6 -0
- package/styles/toc.css +41 -34
- package/theme.css +11 -11
- package/tsconfig.json +2 -5
- package/virtual-module.d.ts +47 -7
- package/components/variables.css +0 -135
- 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/content-panel/ProseAIDropdown.tsx +0 -55
- package/stl-docs/components/mintlify-compat/Step.astro +0 -58
- package/stl-docs/components/mintlify-compat/Steps.astro +0 -17
- 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
package/theme.css
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
@layer starlight.base, starlight.reset, starlight.core, starlight.content, starlight.components, starlight.utils;
|
|
2
2
|
@layer starlight;
|
|
3
|
-
@layer stl-ui.starlight-compat, stl-ui.typography, stl-ui.components;
|
|
4
|
-
@layer stl-ui, docs-ui, stainless;
|
|
5
3
|
|
|
6
|
-
@import './styles/fonts.css';
|
|
7
|
-
@import './styles/variables.css';
|
|
8
4
|
@import './styles/links.css';
|
|
9
5
|
@import './styles/sidebar.css';
|
|
10
6
|
@import './styles/search.css';
|
|
@@ -13,13 +9,17 @@
|
|
|
13
9
|
@import './styles/overrides.css';
|
|
14
10
|
@import './styles/code.css';
|
|
15
11
|
@import './styles/sdk_select.css';
|
|
12
|
+
@import './styles/method-descriptions.css';
|
|
13
|
+
|
|
16
14
|
@import '@stainless-api/ui-primitives/styles.css';
|
|
17
|
-
@import './styles/mintlify-compat.css';
|
|
18
15
|
|
|
19
|
-
@import '
|
|
20
|
-
@import '@stainless-api/
|
|
21
|
-
@import '
|
|
22
|
-
@import '@stainless-api/docs-ui/src/styles/snippets.css';
|
|
23
|
-
@import '@stainless-api/docs-ui/src/styles/search.css';
|
|
16
|
+
@import './styles/sl-variables.css';
|
|
17
|
+
@import '@stainless-api/ui-primitives/styles/starlight-compat.css';
|
|
18
|
+
@import './styles/mintlify-compat.css';
|
|
24
19
|
|
|
25
|
-
@import './
|
|
20
|
+
@import './styles/stldocs-variables.css';
|
|
21
|
+
@import '@stainless-api/docs-ui/styles/resets.css';
|
|
22
|
+
@import '@stainless-api/docs-ui/styles/primitives.css';
|
|
23
|
+
@import '@stainless-api/docs-ui/styles/main.css';
|
|
24
|
+
@import '@stainless-api/docs-ui/styles/search.css';
|
|
25
|
+
@import '@stainless-api/docs-ui/styles/sidebar.css';
|
package/tsconfig.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"extends": "
|
|
2
|
+
"extends": "../../tsconfig.base.json",
|
|
3
3
|
"include": [
|
|
4
4
|
".astro/*",
|
|
5
5
|
"node_modules/@astrojs/starlight/**/*.d.ts",
|
|
@@ -7,11 +7,8 @@
|
|
|
7
7
|
".stl-docs/**/*",
|
|
8
8
|
"./plugin/**/*"
|
|
9
9
|
],
|
|
10
|
-
"exclude": ["dist"],
|
|
10
|
+
"exclude": ["dist", "**/preview.worker.docs.js"],
|
|
11
11
|
"compilerOptions": {
|
|
12
|
-
"paths": {
|
|
13
|
-
"~/*": ["../../../stainless/legacy-dir-root/*"]
|
|
14
|
-
},
|
|
15
12
|
"jsx": "react-jsx",
|
|
16
13
|
"jsxImportSource": "react"
|
|
17
14
|
}
|
package/virtual-module.d.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
declare module 'virtual:stl-starlight-virtual-module' {
|
|
2
2
|
import type { CreateShikiHighlighterOptions } from '@astrojs/markdown-remark';
|
|
3
|
-
import type { PropertySettingsType } from '@stainless-api/docs-ui/
|
|
3
|
+
import type { PropertySettingsType } from '@stainless-api/docs-ui/contexts';
|
|
4
4
|
import type { StlStarlightMiddleware } from '@stainless-api/docs/plugin/MiddlewareTypes';
|
|
5
|
-
import type {
|
|
5
|
+
import type { DocsLanguage } from '@stainless-api/docs-ui/routing';
|
|
6
6
|
|
|
7
|
-
export const
|
|
8
|
-
export const
|
|
9
|
-
export const EXCLUDE_LANGUAGES: string[];
|
|
7
|
+
export const RESOLVED_API_REFERENCE_PATH: string;
|
|
8
|
+
export const EXCLUDE_LANGUAGES: DocsLanguage[];
|
|
10
9
|
export const DEFAULT_LANGUAGE: string;
|
|
11
10
|
export const BREADCRUMB_CONFIG: {
|
|
12
11
|
includeCurrentPage?: boolean;
|
|
@@ -15,15 +14,19 @@ declare module 'virtual:stl-starlight-virtual-module' {
|
|
|
15
14
|
export const HIGHLIGHT_THEMES: CreateShikiHighlighterOptions['themes'];
|
|
16
15
|
export const CONTENT_PANEL_LAYOUT: 'double-pane' | 'single-pane';
|
|
17
16
|
export const EXPERIMENTAL_COLLAPSIBLE_SNIPPETS: boolean | undefined;
|
|
17
|
+
export const EXPERIMENTAL_COLLAPSIBLE_METHOD_DESCRIPTIONS: boolean | undefined;
|
|
18
|
+
export const EXPERIMENTAL_PLAYGROUNDS: boolean | undefined;
|
|
19
|
+
export const EXPERIMENTAL_REQUEST_BUILDER: boolean | undefined;
|
|
18
20
|
export const PROPERTY_SETTINGS: PropertySettingsType;
|
|
19
21
|
export const MIDDLEWARE: StlStarlightMiddleware;
|
|
20
|
-
export const
|
|
21
|
-
export const
|
|
22
|
+
export const ENABLE_CONTEXT_MENU: boolean;
|
|
23
|
+
export const STAINLESS_PROJECT: string | undefined;
|
|
22
24
|
}
|
|
23
25
|
|
|
24
26
|
declare module 'virtual:stl-docs-virtual-module' {
|
|
25
27
|
import type { ButtonVariant } from '@stainless-api/ui-primitives';
|
|
26
28
|
import type { AnchorHTMLAttributes } from 'react';
|
|
29
|
+
import { FontPreloadFilter } from 'astro:assets';
|
|
27
30
|
|
|
28
31
|
type Tab = {
|
|
29
32
|
label: string;
|
|
@@ -31,6 +34,11 @@ declare module 'virtual:stl-docs-virtual-module' {
|
|
|
31
34
|
hidden?: boolean;
|
|
32
35
|
};
|
|
33
36
|
|
|
37
|
+
type FontConfig = {
|
|
38
|
+
cssVariable: string;
|
|
39
|
+
preload?: FontPreloadFilter;
|
|
40
|
+
};
|
|
41
|
+
|
|
34
42
|
export const HEADER_LINKS: {
|
|
35
43
|
label: string;
|
|
36
44
|
link: string;
|
|
@@ -41,4 +49,36 @@ declare module 'virtual:stl-docs-virtual-module' {
|
|
|
41
49
|
export const SPLIT_TABS_ENABLED: boolean;
|
|
42
50
|
export const HEADER_LAYOUT: 'default' | 'stacked';
|
|
43
51
|
export const ENABLE_CLIENT_ROUTER: boolean;
|
|
52
|
+
export const API_REFERENCE_BASE_PATH: string;
|
|
53
|
+
export const ENABLE_PROSE_MARKDOWN_RENDERING: boolean;
|
|
54
|
+
export const ENABLE_CONTEXT_MENU: boolean;
|
|
55
|
+
export const RENDER_PAGE_DESCRIPTIONS: boolean;
|
|
56
|
+
export const FONTS: {
|
|
57
|
+
primary?: FontConfig;
|
|
58
|
+
heading?: FontConfig;
|
|
59
|
+
mono?: FontConfig;
|
|
60
|
+
additional?: FontConfig[];
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
declare module 'virtual:stl-docs/components/AiChat.tsx' {
|
|
65
|
+
const AiChatComponent:
|
|
66
|
+
| import('react').ComponentType<{
|
|
67
|
+
projectId: string;
|
|
68
|
+
language: import('@stainless-api/docs-ui/routing').DocsLanguage | undefined;
|
|
69
|
+
siteTitle: string | undefined;
|
|
70
|
+
}>
|
|
71
|
+
| null;
|
|
72
|
+
export default AiChatComponent;
|
|
73
|
+
export const STAINLESS_PROJECT: string | undefined;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
declare module 'virtual:stainless-sdk-json-manifest' {
|
|
77
|
+
export const specPath: string;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
declare module 'virtual:stl-starlight-reference-sidebars' {
|
|
81
|
+
import type { DocsLanguage } from '@stainless-api/docs-ui/routing';
|
|
82
|
+
import type { StarlightRouteData } from '@astrojs/starlight/route-data';
|
|
83
|
+
export const sidebars: { id: number; language: DocsLanguage; entries: StarlightRouteData['sidebar'] }[];
|
|
44
84
|
}
|
package/components/variables.css
DELETED
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
:root {
|
|
2
|
-
--stldocs-font: var(--sl-font, system-ui, sans-serif);
|
|
3
|
-
--stldocs-font-mono: var(--sl-font-mono, ui-monospace, monospace);
|
|
4
|
-
|
|
5
|
-
--stldocs-color-white: var(--sl-color-white);
|
|
6
|
-
--stldocs-color-gray-1: var(--sl-color-gray-1);
|
|
7
|
-
--stldocs-color-gray-2: var(--sl-color-gray-2);
|
|
8
|
-
--stldocs-color-gray-3: var(--sl-color-gray-3);
|
|
9
|
-
--stldocs-color-gray-4: var(--sl-color-gray-4);
|
|
10
|
-
--stldocs-color-gray-5: var(--sl-color-gray-5);
|
|
11
|
-
--stldocs-color-gray-6: var(--sl-color-gray-6);
|
|
12
|
-
--stldocs-color-gray-7: var(--sl-color-gray-7);
|
|
13
|
-
--stldocs-color-gray-8: var(--sl-color-gray-8);
|
|
14
|
-
|
|
15
|
-
--stldocs-color-accent-low: var(--sl-color-accent-low);
|
|
16
|
-
--stldocs-color-accent-high: var(--sl-color-accent-high);
|
|
17
|
-
--stldocs-color-accent: var(--sl-color-accent);
|
|
18
|
-
--stldocs-color-red: var(--sl-color-red);
|
|
19
|
-
|
|
20
|
-
--stldocs-color-text: var(--sl-color-text);
|
|
21
|
-
--stldocs-color-text-accent: var(--sl-color-text-accent);
|
|
22
|
-
--stldocs-color-text-invert: var(--sl-color-text-invert);
|
|
23
|
-
--stldocs-color-text-secondary: var(--sl-color-text-secondary);
|
|
24
|
-
--stldocs-color-text-tertiary: var(--sl-color-text-tertiary);
|
|
25
|
-
|
|
26
|
-
--stldocs-color-bg: var(--sl-color-bg);
|
|
27
|
-
--stldocs-color-bg-nav: var(--sl-color-bg-nav);
|
|
28
|
-
--stldocs-color-bg-ui: var(--sl-color-bg-ui);
|
|
29
|
-
|
|
30
|
-
--stldocs-color-bg-inline-code: var(--sl-color-bg-inline-code);
|
|
31
|
-
--stldocs-color-bg-accent: var(--sl-color-bg-accent);
|
|
32
|
-
--stldocs-color-hairline: var(--sl-color-hairline);
|
|
33
|
-
--stldocs-color-hairline-shade: var(--sl-color-hairline-shade);
|
|
34
|
-
--stldocs-color-hairline-light: var(--sl-color-hairline-light);
|
|
35
|
-
|
|
36
|
-
--stldocs-badge-default-text: var(--sl-badge-default-text);
|
|
37
|
-
--stldocs-color-bg-inline-code-dark: var(--sl-color-bg-inline-code-dark);
|
|
38
|
-
|
|
39
|
-
--stldocs-font-size-h1: var(--sl-text-h1);
|
|
40
|
-
--stldocs-font-size-h2: var(--sl-text-h2);
|
|
41
|
-
--stldocs-font-size-h3: var(--sl-text-h3);
|
|
42
|
-
--stldocs-font-size-h4: var(--sl-text-h4);
|
|
43
|
-
--stldocs-font-size-h5: var(--sl-text-h5);
|
|
44
|
-
|
|
45
|
-
--stlodcs-font-size-body: var(--sl-text-body);
|
|
46
|
-
--stldocs-font-size-small: var(--sl-text-body-sm);
|
|
47
|
-
--stldocs-font-size-code: var(--sl-text-code);
|
|
48
|
-
|
|
49
|
-
--stldocs-content-width: var(--sl-content-width);
|
|
50
|
-
--stldocs-content-padding: var(--sl-content-pad-x);
|
|
51
|
-
|
|
52
|
-
--stldocs-color-http-get-bg: var(--sl-color-green-low);
|
|
53
|
-
--stldocs-color-http-get: var(--sl-color-green);
|
|
54
|
-
--stldocs-color-http-put-bg: var(--sl-color-orange-low);
|
|
55
|
-
--stldocs-color-http-put: var(--sl-color-orange);
|
|
56
|
-
--stldocs-color-http-post-bg: var(--sl-color-blue-low);
|
|
57
|
-
--stldocs-color-http-post: var(--sl-color-blue);
|
|
58
|
-
--stldocs-color-http-delete-bg: var(--sl-color-red-low);
|
|
59
|
-
--stldocs-color-http-delete: var(--sl-color-red);
|
|
60
|
-
|
|
61
|
-
--stldocs-syntax-color-red: var(--sl-color-red);
|
|
62
|
-
--stldocs-syntax-color-green: var(--sl-color-green);
|
|
63
|
-
--stldocs-syntax-color-blue: var(--sl-color-blue);
|
|
64
|
-
--stldocs-syntax-color-orange: var(--sl-color-orange);
|
|
65
|
-
--stldocs-syntax-color-teal: var(--sl-color-teal);
|
|
66
|
-
--stldocs-syntax-color-magenta: var(--sl-color-magenta);
|
|
67
|
-
--stldocs-syntax-color-purple: var(--sl-color-purple);
|
|
68
|
-
|
|
69
|
-
--stldocs-color-backdrop-overlay: var(--sl-color-backdrop-overlay);
|
|
70
|
-
--stldocs-expander-margin-shift: 24px;
|
|
71
|
-
--stldocs-expander-right-margin: 8px;
|
|
72
|
-
--stldocs-font-size-body: 14px;
|
|
73
|
-
--stldocs-font-size-body-xs: 12px;
|
|
74
|
-
|
|
75
|
-
/* UI Overrides */
|
|
76
|
-
--stl-ui-button-border-radius: var(--sl-button-border-radius);
|
|
77
|
-
--stl-ui-text-body: var(--sl-text-sm);
|
|
78
|
-
--stl-ui-button-size: var(--sl-button-size);
|
|
79
|
-
|
|
80
|
-
--stl-ui-color-accent-low: var(--sl-color-accent-low);
|
|
81
|
-
--stl-ui-color-accent: var(--sl-color-accent);
|
|
82
|
-
--stl-ui-color-accent-high: var(--sl-color-accent-high);
|
|
83
|
-
|
|
84
|
-
--stl-ui-color-text: var(--sl-color-text);
|
|
85
|
-
--stl-ui-color-text-secondary: var(--sl-color-text-secondary);
|
|
86
|
-
--stl-ui-color-text-tertiary: var(--sl-color-text-tertiary);
|
|
87
|
-
--stl-ui-color-text-invert: var(--sl-color-text-invert);
|
|
88
|
-
--stl-ui-color-text-accent: var(--sl-color-text-accent);
|
|
89
|
-
|
|
90
|
-
--stl-ui-color-bg: var(--sl-color-bg);
|
|
91
|
-
--stl-ui-color-bg-ui: var(--sl-color-bg-ui);
|
|
92
|
-
--stl-ui-color-bg-inline-code: var(--sl-color-bg-inline-code);
|
|
93
|
-
|
|
94
|
-
--stl-ui-color-hairline-light: var(--sl-color-hairline-light);
|
|
95
|
-
--stl-ui-color-hairline: var(--sl-color-hairline);
|
|
96
|
-
--stl-ui-color-hairline-shade: var(--sl-color-hairline-shade);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/* These are the theme overrides - we need to come up with a good way to do this in starlight */
|
|
100
|
-
:root {
|
|
101
|
-
/*
|
|
102
|
-
tmp remove the theme color in favor of the Shiki default theme background
|
|
103
|
-
commented out values are the original values in case we want them again
|
|
104
|
-
*/
|
|
105
|
-
/* --stldocs-color-snippet-box-bg: #272727; */
|
|
106
|
-
--stldocs-color-snippet-box-bg: #1f1f1f;
|
|
107
|
-
/* --stldocs-color-snippet-title-bg: #161616; */
|
|
108
|
-
--stldocs-color-snippet-title-bg: #24292f;
|
|
109
|
-
--stldocs-color-snippet-title-muted: #8b8b8b;
|
|
110
|
-
--stldocs-color-snippet-title-bright: #ffffff;
|
|
111
|
-
--stldocs-color-snippet-code-bg: #1d1d1d;
|
|
112
|
-
|
|
113
|
-
--stldocs-title-padding-y: 2.5rem;
|
|
114
|
-
|
|
115
|
-
--stldocs-z-index-theme-select: 1000;
|
|
116
|
-
--stldocs-button-border-radius: var(--sl-button-border-radius);
|
|
117
|
-
--stldocs-button-size: var(--sl-button-size);
|
|
118
|
-
--stldocs-button-padding-x: var(--sl-button-padding-x);
|
|
119
|
-
--stldocs-button-padding-y: var(--sl-button-padding-y);
|
|
120
|
-
|
|
121
|
-
--sl-content-pad-x: 1rem;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
:root[data-theme='light'] {
|
|
125
|
-
--stldocs-color-snippet-box-bg: #eeeeee;
|
|
126
|
-
/*
|
|
127
|
-
tmp remove the theme color in favor of the Shiki default theme background
|
|
128
|
-
commented out value is the original value in case we want it again
|
|
129
|
-
*/
|
|
130
|
-
/* --stldocs-color-snippet-title-bg: #2a2a2a; */
|
|
131
|
-
--stldocs-color-snippet-title-bg: #24292f;
|
|
132
|
-
--stldocs-color-snippet-title-muted: #959595;
|
|
133
|
-
--stldocs-color-snippet-title-bright: #000;
|
|
134
|
-
--stldocs-color-snippet-code-bg: #383838;
|
|
135
|
-
}
|
package/plugin/cms/client.ts
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { CMS_PORT } from 'virtual:stl-starlight-virtual-module';
|
|
2
|
-
import type { SpecResp } from './server';
|
|
3
|
-
import type { StarlightRouteData } from '@astrojs/starlight/route-data';
|
|
4
|
-
import type { BuildSidebarParams } from './sidebar-builder';
|
|
5
|
-
|
|
6
|
-
const SERVER_URL = `http://localhost:${CMS_PORT}`;
|
|
7
|
-
|
|
8
|
-
async function makeRequest<T>(method: 'POST' | 'GET', endpoint: string, body?: any) {
|
|
9
|
-
const response = await fetch(`${SERVER_URL}${endpoint}`, {
|
|
10
|
-
method,
|
|
11
|
-
headers: {
|
|
12
|
-
'Content-Type': 'application/json',
|
|
13
|
-
},
|
|
14
|
-
body: body ? JSON.stringify(body) : undefined,
|
|
15
|
-
});
|
|
16
|
-
return response.json() as T;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
class Client {
|
|
20
|
-
private specCache: SpecResp | null = null;
|
|
21
|
-
private clientId: string;
|
|
22
|
-
|
|
23
|
-
get id() {
|
|
24
|
-
return this.clientId;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
async buildSidebar(params: BuildSidebarParams & { sidebarId: number }) {
|
|
28
|
-
const response = await makeRequest<{ data: StarlightRouteData['sidebar'] }>(
|
|
29
|
-
'POST',
|
|
30
|
-
'/build_sidebar',
|
|
31
|
-
params,
|
|
32
|
-
);
|
|
33
|
-
return response.data;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
async getSpec() {
|
|
37
|
-
const cached = this.specCache;
|
|
38
|
-
|
|
39
|
-
const response = await makeRequest<SpecResp>('POST', '/retrieve_spec', {
|
|
40
|
-
currentId: cached?.id,
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
if (response.data === null) {
|
|
44
|
-
if (!cached) {
|
|
45
|
-
throw new Error('Cache should not be null');
|
|
46
|
-
}
|
|
47
|
-
if (cached.data === null) {
|
|
48
|
-
throw new Error('Cached spec should not be null');
|
|
49
|
-
}
|
|
50
|
-
return cached.data;
|
|
51
|
-
}
|
|
52
|
-
// console.log("invalidating spec cache", this.clientId);
|
|
53
|
-
this.specCache = response;
|
|
54
|
-
return response.data;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
constructor() {
|
|
58
|
-
this.clientId = crypto.randomUUID();
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export const cmsClient = new Client();
|
package/plugin/cms/server.ts
DELETED
|
@@ -1,268 +0,0 @@
|
|
|
1
|
-
import { createServer, IncomingMessage } from 'http';
|
|
2
|
-
import { readFile } from 'fs/promises';
|
|
3
|
-
|
|
4
|
-
import type * as SDKJSON from '~/lib/json-spec-v2/types';
|
|
5
|
-
import { createSDKJSON, parseInputs, transformOAS } from './worker';
|
|
6
|
-
import { Languages, parseRoute, type DocsLanguage } from '@stainless-api/docs-ui/src/routing';
|
|
7
|
-
import Stainless from '@stainless-api/sdk';
|
|
8
|
-
|
|
9
|
-
import {
|
|
10
|
-
toStarlightSidebar,
|
|
11
|
-
type GeneratedSidebarConfig,
|
|
12
|
-
SidebarConfigItemsBuilder,
|
|
13
|
-
} from './sidebar-builder';
|
|
14
|
-
import type { VersionUserConfig } from '../loadPluginConfig';
|
|
15
|
-
|
|
16
|
-
export type InputFilePaths = {
|
|
17
|
-
oasPath?: string;
|
|
18
|
-
configPath?: string;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
async function versionInfo(project: string, apiKey: string) {
|
|
22
|
-
const data = await fetch(`https://api.stainless.com/api/projects/${project}/package-versions`, {
|
|
23
|
-
headers: { Authorization: `Bearer ${apiKey}` },
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
const content = await data.text();
|
|
27
|
-
return JSON.parse(content);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
async function loadSpec({
|
|
31
|
-
apiKey,
|
|
32
|
-
devPaths,
|
|
33
|
-
version,
|
|
34
|
-
}: {
|
|
35
|
-
apiKey: string;
|
|
36
|
-
devPaths: InputFilePaths;
|
|
37
|
-
version: VersionUserConfig;
|
|
38
|
-
}) {
|
|
39
|
-
let oasStr: string;
|
|
40
|
-
let configStr: string;
|
|
41
|
-
let versions: Record<DocsLanguage, string> | undefined;
|
|
42
|
-
|
|
43
|
-
if (devPaths.oasPath && devPaths.configPath) {
|
|
44
|
-
[oasStr, configStr] = await Promise.all([
|
|
45
|
-
readFile(devPaths.oasPath, 'utf-8'),
|
|
46
|
-
readFile(devPaths.configPath, 'utf-8'),
|
|
47
|
-
]);
|
|
48
|
-
} else {
|
|
49
|
-
const client = new Stainless({ apiKey });
|
|
50
|
-
const configs = await client.projects.configs.retrieve({
|
|
51
|
-
project: version.stainlessProject,
|
|
52
|
-
branch: version.branch,
|
|
53
|
-
include: 'openapi',
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
versions = await versionInfo(version.stainlessProject, apiKey);
|
|
57
|
-
|
|
58
|
-
const configYML = Object.values(configs)[0] as { content: any };
|
|
59
|
-
const oasJson = Object.values(configs)[1] as { content: any };
|
|
60
|
-
oasStr = oasJson['content'];
|
|
61
|
-
configStr = configYML['content'];
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const { oas, config } = await parseInputs({
|
|
65
|
-
oas: oasStr,
|
|
66
|
-
config: configStr,
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
const transformedOAS = await transformOAS({ oas, config });
|
|
70
|
-
|
|
71
|
-
const languages =
|
|
72
|
-
config.docs?.languages ??
|
|
73
|
-
(Object.entries(config.targets)
|
|
74
|
-
// @ts-expect-error we don't have the actual Stainless config type here
|
|
75
|
-
.filter(([name, target]) => Languages.includes(name) && !target.skip)
|
|
76
|
-
.map(([name]) => name) as SDKJSON.SpecLanguage[]);
|
|
77
|
-
|
|
78
|
-
const sdkJson = await createSDKJSON({
|
|
79
|
-
oas: transformedOAS,
|
|
80
|
-
config,
|
|
81
|
-
languages,
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
if (versions) {
|
|
85
|
-
for (const [lang, version] of Object.entries(versions)) {
|
|
86
|
-
const meta = sdkJson.metadata[lang as DocsLanguage];
|
|
87
|
-
if (meta?.version) meta.version = version;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
const id = crypto.randomUUID();
|
|
92
|
-
|
|
93
|
-
return {
|
|
94
|
-
data: sdkJson,
|
|
95
|
-
id,
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
class Spec {
|
|
100
|
-
private specPromise: Promise<{ id: string; data: SDKJSON.Spec }>;
|
|
101
|
-
private devPaths: InputFilePaths;
|
|
102
|
-
private apiKey: string;
|
|
103
|
-
private version: VersionUserConfig;
|
|
104
|
-
|
|
105
|
-
reload() {
|
|
106
|
-
this.specPromise = loadSpec({
|
|
107
|
-
apiKey: this.apiKey,
|
|
108
|
-
devPaths: this.devPaths,
|
|
109
|
-
version: this.version,
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
async forceGetSpec() {
|
|
114
|
-
const spec = await this.specPromise;
|
|
115
|
-
return spec;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
async getSpec(currentId: string | undefined | null) {
|
|
119
|
-
const spec = await this.specPromise;
|
|
120
|
-
|
|
121
|
-
if (currentId === spec.id) {
|
|
122
|
-
return {
|
|
123
|
-
id: spec.id,
|
|
124
|
-
data: null,
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
return spec;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
constructor(apiKey: string, version: VersionUserConfig, devPaths: InputFilePaths) {
|
|
132
|
-
this.specPromise = loadSpec({
|
|
133
|
-
apiKey,
|
|
134
|
-
devPaths,
|
|
135
|
-
version,
|
|
136
|
-
});
|
|
137
|
-
this.devPaths = devPaths;
|
|
138
|
-
this.apiKey = apiKey;
|
|
139
|
-
this.version = version;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
export type SpecResp = Awaited<ReturnType<Spec['getSpec']>>;
|
|
144
|
-
|
|
145
|
-
// will be necessary once we add POST methods
|
|
146
|
-
function readJsonBody(req: IncomingMessage): Promise<any> {
|
|
147
|
-
return new Promise((resolve, reject) => {
|
|
148
|
-
let body = '';
|
|
149
|
-
req.on('data', (chunk) => {
|
|
150
|
-
body += chunk.toString();
|
|
151
|
-
});
|
|
152
|
-
req.on('end', () => {
|
|
153
|
-
try {
|
|
154
|
-
const data = JSON.parse(body);
|
|
155
|
-
resolve(data);
|
|
156
|
-
} catch (error) {
|
|
157
|
-
reject(error);
|
|
158
|
-
}
|
|
159
|
-
});
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
export function startDevServer({
|
|
164
|
-
port,
|
|
165
|
-
version,
|
|
166
|
-
devPaths,
|
|
167
|
-
apiKey,
|
|
168
|
-
getGeneratedSidebarConfig,
|
|
169
|
-
}: {
|
|
170
|
-
port: number;
|
|
171
|
-
version: VersionUserConfig;
|
|
172
|
-
devPaths: InputFilePaths;
|
|
173
|
-
apiKey: string;
|
|
174
|
-
getGeneratedSidebarConfig: (id: number) => GeneratedSidebarConfig | null;
|
|
175
|
-
}) {
|
|
176
|
-
const spec = new Spec(apiKey, version, devPaths);
|
|
177
|
-
|
|
178
|
-
const server = createServer(async (req, res) => {
|
|
179
|
-
// Add CORS headers
|
|
180
|
-
res.setHeader('Access-Control-Allow-Origin', '*');
|
|
181
|
-
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');
|
|
182
|
-
res.setHeader('Access-Control-Allow-Headers', 'Content-Type, Authorization');
|
|
183
|
-
|
|
184
|
-
// Handle preflight requests
|
|
185
|
-
if (req.method === 'OPTIONS') {
|
|
186
|
-
res.writeHead(204);
|
|
187
|
-
res.end();
|
|
188
|
-
return;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
function respond(code: number, body: any) {
|
|
192
|
-
res.setHeader('Content-Type', 'application/json');
|
|
193
|
-
res.writeHead(code);
|
|
194
|
-
res.end(JSON.stringify(body));
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
try {
|
|
198
|
-
if (req.method === 'POST' && req.url === '/retrieve_spec') {
|
|
199
|
-
const body = await readJsonBody(req);
|
|
200
|
-
|
|
201
|
-
const currentSpec = await spec.getSpec(body.currentId);
|
|
202
|
-
|
|
203
|
-
return respond(200, currentSpec);
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
if (req.method === 'POST' && req.url === '/build_sidebar') {
|
|
207
|
-
const currentSpec = await spec.forceGetSpec();
|
|
208
|
-
const body = await readJsonBody(req);
|
|
209
|
-
const sidebarId: number = body.sidebarId;
|
|
210
|
-
|
|
211
|
-
const sidebarConfig = getGeneratedSidebarConfig(sidebarId);
|
|
212
|
-
|
|
213
|
-
const sidebarGenerateOptions = sidebarConfig?.options;
|
|
214
|
-
|
|
215
|
-
const { stainlessPath: currentStainlessPath, language } = parseRoute(body.basePath, body.currentSlug);
|
|
216
|
-
|
|
217
|
-
const configItemsBuilder = new SidebarConfigItemsBuilder(
|
|
218
|
-
currentSpec.data,
|
|
219
|
-
language,
|
|
220
|
-
sidebarGenerateOptions,
|
|
221
|
-
);
|
|
222
|
-
|
|
223
|
-
let userSidebarConfig = configItemsBuilder.generateItems();
|
|
224
|
-
|
|
225
|
-
if (sidebarConfig && sidebarConfig.transformFn) {
|
|
226
|
-
const transformedSidebarConfig = sidebarConfig.transformFn(userSidebarConfig, language);
|
|
227
|
-
// the user may not have returned, but they may have mutated the config in place
|
|
228
|
-
// if they did return, we use that
|
|
229
|
-
if (transformedSidebarConfig) {
|
|
230
|
-
userSidebarConfig = transformedSidebarConfig;
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
const starlightSidebar = toStarlightSidebar({
|
|
235
|
-
basePath: body.basePath,
|
|
236
|
-
currentSlug: body.currentSlug,
|
|
237
|
-
spec: currentSpec.data,
|
|
238
|
-
entries: userSidebarConfig,
|
|
239
|
-
currentStainlessPath,
|
|
240
|
-
currentLanguage: language,
|
|
241
|
-
});
|
|
242
|
-
|
|
243
|
-
return respond(200, { data: starlightSidebar });
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
return respond(404, { message: 'Not found' });
|
|
247
|
-
} catch (e) {
|
|
248
|
-
return respond(500, { message: 'Unexpected error', error: e });
|
|
249
|
-
}
|
|
250
|
-
});
|
|
251
|
-
|
|
252
|
-
server.listen(port, () => {
|
|
253
|
-
console.log(`Server is running on port ${port}`);
|
|
254
|
-
});
|
|
255
|
-
|
|
256
|
-
return {
|
|
257
|
-
invalidate: () => {
|
|
258
|
-
spec.reload();
|
|
259
|
-
},
|
|
260
|
-
destroy: function destroy() {
|
|
261
|
-
return new Promise<void>((resolve) => {
|
|
262
|
-
server.close(() => {
|
|
263
|
-
resolve();
|
|
264
|
-
});
|
|
265
|
-
});
|
|
266
|
-
},
|
|
267
|
-
};
|
|
268
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
export const copyCurrentPageAsMarkdown = async () => {
|
|
2
|
-
const currentUrl = new URL(window.location.href);
|
|
3
|
-
const markdownUrl = `${currentUrl.origin}${currentUrl.pathname}.md`;
|
|
4
|
-
|
|
5
|
-
try {
|
|
6
|
-
const response = await fetch(markdownUrl);
|
|
7
|
-
if (!response.ok) {
|
|
8
|
-
throw new Error('Network response was not ok');
|
|
9
|
-
}
|
|
10
|
-
const markdown = await response.text();
|
|
11
|
-
await navigator.clipboard.writeText(markdown);
|
|
12
|
-
console.log('Markdown copied to clipboard');
|
|
13
|
-
} catch (error) {
|
|
14
|
-
console.error('There has been a problem with your fetch operation:', error);
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export function onSelectAIOption(value: string, makeMarkdownLink: boolean = true) {
|
|
19
|
-
if (value === 'copy-markdown') {
|
|
20
|
-
copyCurrentPageAsMarkdown();
|
|
21
|
-
}
|
|
22
|
-
if (value === 'view-as-markdown') {
|
|
23
|
-
const currentUrl = new URL(window.location.href);
|
|
24
|
-
const markdownUrl = `${currentUrl.origin}${currentUrl.pathname}.md`;
|
|
25
|
-
window.open(markdownUrl, '_blank');
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
if (value === 'chat-gpt') {
|
|
29
|
-
const currentUrl = new URL(window.location.href);
|
|
30
|
-
const llmUrl = makeMarkdownLink ? `${currentUrl.origin}${currentUrl.pathname}.md` : currentUrl.href;
|
|
31
|
-
|
|
32
|
-
const prompt = `Read from ${llmUrl} so I can ask questions about it.`;
|
|
33
|
-
|
|
34
|
-
const chatGptUrl = `https://chatgpt.com/?hints=search&prompt=${encodeURIComponent(prompt)}`;
|
|
35
|
-
window.open(chatGptUrl, '_blank');
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if (value === 'claude') {
|
|
39
|
-
const currentUrl = new URL(window.location.href);
|
|
40
|
-
const llmUrl = makeMarkdownLink ? `${currentUrl.origin}${currentUrl.pathname}.md` : currentUrl.href;
|
|
41
|
-
|
|
42
|
-
const prompt = `Read from ${llmUrl} so I can ask questions about it.`;
|
|
43
|
-
|
|
44
|
-
const claudeUrl = `https://claude.ai/new?q=${encodeURIComponent(prompt)}`;
|
|
45
|
-
window.open(claudeUrl, '_blank');
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
if (value === 'cursor') {
|
|
49
|
-
const currentUrl = new URL(window.location.href);
|
|
50
|
-
const llmUrl = makeMarkdownLink ? `${currentUrl.origin}${currentUrl.pathname}.md` : currentUrl.href;
|
|
51
|
-
|
|
52
|
-
const prompt = `Read from ${llmUrl} so I can ask questions about it.`;
|
|
53
|
-
|
|
54
|
-
const cursorUrl = `https://www.cursor.so/?prompt=${encodeURIComponent(prompt)}`;
|
|
55
|
-
window.open(cursorUrl, '_blank');
|
|
56
|
-
}
|
|
57
|
-
}
|