@stainless-api/docs-ui 0.1.0-beta.12 → 0.1.0-beta.14

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 (142) hide show
  1. package/dist/index.js +7530 -16
  2. package/dist/mcp.js +15967 -0
  3. package/dist/routing.js +180 -3
  4. package/dist/styles/main.css +746 -739
  5. package/dist/styles/primitives.css +428 -436
  6. package/dist/styles/resets.css +41 -34
  7. package/dist/styles/search.css +248 -248
  8. package/dist/styles/sidebar.css +60 -59
  9. package/dist/styles/snippets.css +88 -87
  10. package/dist/styles/variables.css +90 -87
  11. package/package.json +4 -2
  12. package/src/components/overview.tsx +5 -7
  13. package/src/search/mcp.ts +100 -8
  14. package/src/styles/main.css +10 -8
  15. package/src/utils.ts +7 -9
  16. package/dist/breadcrumbs-Z-hEqjcp.d.ts +0 -19
  17. package/dist/chunk-Bp6m_JJh.js +0 -13
  18. package/dist/component-generics-DzI21jRn.js +0 -35
  19. package/dist/component-generics-q5Dqiu2D.d.ts +0 -30
  20. package/dist/components/breadcrumbs.d.ts +0 -2
  21. package/dist/components/breadcrumbs.js +0 -16
  22. package/dist/components/chat.d.ts +0 -14
  23. package/dist/components/chat.js +0 -144
  24. package/dist/components/dropdown.d.ts +0 -2
  25. package/dist/components/dropdown.js +0 -4
  26. package/dist/components/icons.d.ts +0 -50
  27. package/dist/components/icons.js +0 -3
  28. package/dist/components/index.d.ts +0 -12
  29. package/dist/components/index.js +0 -16
  30. package/dist/components/method.d.ts +0 -2
  31. package/dist/components/method.js +0 -16
  32. package/dist/components/overview.d.ts +0 -2
  33. package/dist/components/overview.js +0 -16
  34. package/dist/components/primitives.d.ts +0 -2
  35. package/dist/components/primitives.js +0 -16
  36. package/dist/components/properties.d.ts +0 -2
  37. package/dist/components/properties.js +0 -16
  38. package/dist/components/scripts/dropdown.d.ts +0 -12
  39. package/dist/components/scripts/dropdown.js +0 -50
  40. package/dist/components/sdk.d.ts +0 -3
  41. package/dist/components/sdk.js +0 -16
  42. package/dist/components/sidebar.d.ts +0 -2
  43. package/dist/components/sidebar.js +0 -16
  44. package/dist/components/snippets.d.ts +0 -4
  45. package/dist/components/snippets.js +0 -16
  46. package/dist/contexts/component-generics.d.ts +0 -2
  47. package/dist/contexts/component-generics.js +0 -3
  48. package/dist/contexts/component-types.d.ts +0 -18
  49. package/dist/contexts/component-types.js +0 -1
  50. package/dist/contexts/component.d.ts +0 -31
  51. package/dist/contexts/component.js +0 -16
  52. package/dist/contexts/docs.d.ts +0 -2
  53. package/dist/contexts/docs.js +0 -3
  54. package/dist/contexts/index.d.ts +0 -20
  55. package/dist/contexts/index.js +0 -16
  56. package/dist/contexts/markdown.d.ts +0 -2
  57. package/dist/contexts/markdown.js +0 -4
  58. package/dist/contexts/navigation.d.ts +0 -3
  59. package/dist/contexts/navigation.js +0 -3
  60. package/dist/contexts/search.d.ts +0 -4
  61. package/dist/contexts/search.js +0 -16
  62. package/dist/contexts/use-components.d.ts +0 -16
  63. package/dist/contexts/use-components.js +0 -4
  64. package/dist/contexts-DRxRO-xO.js +0 -3747
  65. package/dist/docs-Dh8kE1va.js +0 -50
  66. package/dist/docs-EUy-wfbA.d.ts +0 -43
  67. package/dist/dropdown-B7VyGMOw.d.ts +0 -43
  68. package/dist/dropdown-DtgAi6lb.js +0 -62
  69. package/dist/icons-DdKM-01E.js +0 -753
  70. package/dist/index-AicgPYKB.d.ts +0 -239
  71. package/dist/index-BhwLhiWk.d.ts +0 -14
  72. package/dist/index-YnpUtXLB.d.ts +0 -16
  73. package/dist/index.d.ts +0 -22
  74. package/dist/languages/go.d.ts +0 -13
  75. package/dist/languages/go.js +0 -16
  76. package/dist/languages/http.d.ts +0 -13
  77. package/dist/languages/http.js +0 -16
  78. package/dist/languages/index.d.ts +0 -13
  79. package/dist/languages/index.js +0 -16
  80. package/dist/languages/java.d.ts +0 -13
  81. package/dist/languages/java.js +0 -16
  82. package/dist/languages/python.d.ts +0 -13
  83. package/dist/languages/python.js +0 -16
  84. package/dist/languages/ruby.d.ts +0 -13
  85. package/dist/languages/ruby.js +0 -16
  86. package/dist/languages/typescript.d.ts +0 -13
  87. package/dist/languages/typescript.js +0 -16
  88. package/dist/markdown/index.d.ts +0 -11
  89. package/dist/markdown/index.js +0 -16
  90. package/dist/markdown/md.d.ts +0 -15
  91. package/dist/markdown/md.js +0 -3
  92. package/dist/markdown/utils.d.ts +0 -4
  93. package/dist/markdown/utils.js +0 -3
  94. package/dist/markdown-BXfX1D7C.js +0 -42
  95. package/dist/markdown-nFyAEX_K.d.ts +0 -22
  96. package/dist/md-Dg8aOyMA.js +0 -41
  97. package/dist/method-DpsVuzZW.d.ts +0 -71
  98. package/dist/navigation-aoYZ_tl4.js +0 -24
  99. package/dist/navigation-nyXBY-75.d.ts +0 -29
  100. package/dist/overview-C8e-6jGr.d.ts +0 -38
  101. package/dist/pagefind-ChrPfuVv.js +0 -15
  102. package/dist/primitives-DWz23_Ub.d.ts +0 -99
  103. package/dist/properties-CF71V58d.d.ts +0 -46
  104. package/dist/routing-DQjbRxdJ.js +0 -189
  105. package/dist/routing-qc0V00-j.d.ts +0 -51
  106. package/dist/routing.d.ts +0 -2
  107. package/dist/sdk-Zg3Rggk3.d.ts +0 -118
  108. package/dist/search/index.d.ts +0 -26
  109. package/dist/search/index.js +0 -332
  110. package/dist/search/providers/algolia.d.ts +0 -23
  111. package/dist/search/providers/algolia.js +0 -16
  112. package/dist/search/providers/fuse.d.ts +0 -17
  113. package/dist/search/providers/fuse.js +0 -31
  114. package/dist/search/providers/pagefind.d.ts +0 -7
  115. package/dist/search/providers/pagefind.js +0 -3
  116. package/dist/search/providers/walker.d.ts +0 -8
  117. package/dist/search/providers/walker.js +0 -32
  118. package/dist/search/types.d.ts +0 -3
  119. package/dist/search/types.js +0 -3
  120. package/dist/search-B6loAGmB.d.ts +0 -21
  121. package/dist/sidebar-C8KirYjg.d.ts +0 -35
  122. package/dist/snippets-EUzM4fRO.d.ts +0 -45
  123. package/dist/style-pN9hCoec.d.ts +0 -181
  124. package/dist/style-rYbbxIR_.js +0 -182
  125. package/dist/style.d.ts +0 -2
  126. package/dist/style.js +0 -3
  127. package/dist/styles/main.js +0 -1
  128. package/dist/styles/primitives.js +0 -1
  129. package/dist/styles/resets.js +0 -1
  130. package/dist/styles/search.js +0 -1
  131. package/dist/styles/sidebar.js +0 -1
  132. package/dist/styles/snippets.js +0 -1
  133. package/dist/styles/variables.js +0 -1
  134. package/dist/types-CTBDtD34.d.ts +0 -82
  135. package/dist/types-DFN4M1Sp.js +0 -34
  136. package/dist/use-components-D9E85p5x.js +0 -7
  137. package/dist/utils-BHwvUDKn.js +0 -30
  138. package/dist/utils-CJfFBNgT.js +0 -32
  139. package/dist/utils-DQhEbvUC.d.ts +0 -20
  140. package/dist/utils-nDazhti8.d.ts +0 -11
  141. package/dist/utils.d.ts +0 -2
  142. package/dist/utils.js +0 -4
package/src/search/mcp.ts CHANGED
@@ -1,10 +1,20 @@
1
+ import { BM25Retriever } from '@langchain/community/retrievers/bm25';
1
2
  import { renderMarkdown } from '../markdown';
2
3
  import { DocsLanguage, parseStainlessPath } from '../routing';
3
4
  import { getResourceFromSpec } from '../utils';
4
- import { buildIndex, search } from './providers/fuse';
5
- import type { IndexEntry } from './types';
5
+ import { buildIndex, search as fuseSearch } from './providers/fuse';
6
+ import type { IndexEntry, IndexMethod } from './types';
7
+ import natural from 'natural';
6
8
  import type * as SDKJSON from '~/lib/json-spec-v2/types';
7
9
 
10
+ type Item = IndexEntry & IndexMethod;
11
+
12
+ export interface SearchResult {
13
+ item: Item;
14
+ score?: number;
15
+ refIndex: number;
16
+ }
17
+
8
18
  export function consolidate(results: IndexEntry[]) {
9
19
  const resources = new Set<string>();
10
20
  const methods = new Set<string>();
@@ -22,7 +32,7 @@ export function consolidate(results: IndexEntry[]) {
22
32
  export function render(
23
33
  spec: SDKJSON.Spec,
24
34
  language: DocsLanguage,
25
- items: IndexEntry[],
35
+ items: Item[],
26
36
  includeModelProperties: boolean,
27
37
  ) {
28
38
  const env = {
@@ -46,16 +56,98 @@ export function render(
46
56
  return Object.fromEntries(output);
47
57
  }
48
58
 
49
- export function searchAndRender(
59
+ export async function searchAndRender(
50
60
  spec: SDKJSON.Spec,
51
61
  language: DocsLanguage,
52
62
  query: string,
53
63
  limit?: number,
54
64
  includeModelProperties: boolean = false,
55
65
  ) {
56
- const idx = buildIndex(spec, language);
57
- const results = search(idx, query, limit).map(({ item }) => item);
58
- return render(spec, language, results, includeModelProperties);
66
+ const results = await search(spec, language, query, limit);
67
+ const items = results.map(({ item }) => item);
68
+ return render(spec, language, items, includeModelProperties);
69
+ }
70
+
71
+ export async function search(
72
+ spec: SDKJSON.Spec,
73
+ language: DocsLanguage,
74
+ query: string,
75
+ limit: number = 100,
76
+ ): Promise<SearchResult[]> {
77
+ const fuseIndex = buildIndex(spec, language);
78
+
79
+ // only HTTP methods are useful for MCP
80
+ const httpMethodEntries = fuseIndex.content.filter((entry) => entry.kind === 'http_method') as Item[];
81
+
82
+ // build BM25 retriever if we have HTTP methods
83
+ let bm25Retriever: BM25Retriever | null = null;
84
+ if (httpMethodEntries.length > 0) {
85
+ const documents = httpMethodEntries.map((entry) => {
86
+ // empirically, endpoint + summary seems to be a reasonable semantic encapsulation of what the endpoint does
87
+ const content = `${entry.endpoint} ${entry.summary}`;
88
+ return {
89
+ // stem the content - we will be stemming the query as well
90
+ pageContent: stemText(content),
91
+ metadata: {
92
+ stainlessPath: entry.stainlessPath,
93
+ },
94
+ };
95
+ });
96
+
97
+ bm25Retriever = BM25Retriever.fromDocuments(documents, { k: 100 });
98
+ }
99
+
100
+ // get initial results from Fuse
101
+ const rawResults = fuseSearch(fuseIndex, query, 100).filter(
102
+ (r) => r.item.kind === 'http_method',
103
+ ) as SearchResult[];
104
+
105
+ // only keep HTTP methods
106
+ const filtered = rawResults.filter((r) => r.item.kind === 'http_method');
107
+
108
+ // stem the query and apply BM25 reranking
109
+ if (filtered.length > 0 && bm25Retriever) {
110
+ const stemmedQuery = stemText(query);
111
+
112
+ // get BM25-ranked result
113
+ const results = await bm25Retriever.invoke(stemmedQuery);
114
+ const reranked = results.map((doc) => doc.metadata);
115
+
116
+ // build a map of Fuse results by path for fast lookup
117
+ const sortStart = Date.now();
118
+ const fuseResultsByPath = new Map(filtered.map((r) => [r.item.stainlessPath, r]));
119
+
120
+ // use BM25 ordering to reorder Fuse results
121
+ const reorderedResults: SearchResult[] = [];
122
+ for (const doc of reranked) {
123
+ const fuseResult = fuseResultsByPath.get(doc.stainlessPath);
124
+ if (fuseResult) {
125
+ reorderedResults.push(fuseResult);
126
+ }
127
+ }
128
+
129
+ // replace filtered with reordered results
130
+ filtered.length = 0;
131
+ filtered.push(...reorderedResults);
132
+ console.debug(` [SORT] Reranked in ${Date.now() - sortStart}ms`);
133
+ }
134
+
135
+ return filtered.slice(0, limit);
59
136
  }
60
137
 
61
- export { buildIndex };
138
+ function stemText(text: string): string {
139
+ if (!text) return '';
140
+
141
+ // tokenize manually and stem each word
142
+ const words = text.toLowerCase().split(/\s+/);
143
+ const stemmedWords = words
144
+ .map((word) => {
145
+ // remove punctuation and stem
146
+ const cleaned = word.replace(/[^\w]/g, '');
147
+ if (!cleaned) return '';
148
+ return natural.LancasterStemmer.stem(cleaned);
149
+ })
150
+ .filter((w) => w);
151
+
152
+ return stemmedWords.join(' ');
153
+ }
@@ -1,7 +1,7 @@
1
1
  /* Overview page content */
2
2
  .stldocs-root .stldocs-overview {
3
3
  .stldocs-overview-header {
4
- padding: var(--stldocs-title-padding-y) var(--stldocs-content-padding) var(--stldocs-content-padding);
4
+ padding: var(--stldocs-title-padding-y) 0;
5
5
 
6
6
  & > * {
7
7
  max-width: var(--stldocs-content-width);
@@ -27,7 +27,6 @@
27
27
 
28
28
  .stldocs-resource-content {
29
29
  max-width: var(--stldocs-content-width);
30
- padding: 0 calc(var(--stldocs-content-padding));
31
30
  margin: auto 0;
32
31
  }
33
32
 
@@ -534,7 +533,7 @@
534
533
  gap: 2rem;
535
534
  grid-template-columns: minmax(0, 1fr);
536
535
  grid-template-rows: repeat(4, auto);
537
- padding: var(--stldocs-content-padding) 0 var(--stldocs-content-padding) var(--stldocs-content-padding);
536
+ padding: var(--stldocs-content-padding) 0;
538
537
 
539
538
  .stldocs-method-description p {
540
539
  color: var(--stldocs-color-text-secondary);
@@ -874,11 +873,6 @@ starlight-theme-select select {
874
873
  @media (max-width: 50rem) {
875
874
  .stldocs-root .stldocs-method-body {
876
875
  padding: 1rem var(--stldocs-content-padding) !important;
877
-
878
- .stldocs-method-parameters,
879
- .stldocs-method-returns {
880
- margin-left: 0 !important;
881
- }
882
876
  }
883
877
 
884
878
  .stldocs-root .stldocs-resource .stldocs-resource-content {
@@ -899,6 +893,14 @@ starlight-theme-select select {
899
893
  }
900
894
  }
901
895
 
896
+ @media (min-width: 50rem) {
897
+ .stldocs-root .stldocs-method {
898
+ .stldocs-method-header {
899
+ padding: var(--stldocs-title-padding-y) 0;
900
+ }
901
+ }
902
+ }
903
+
902
904
  @media (min-width: 1280px) {
903
905
  .stldocs-root {
904
906
  .stldocs-method.stldocs-method-double-pane .stldocs-method-content-column {
package/src/utils.ts CHANGED
@@ -5,15 +5,13 @@ export function flatResources(
5
5
  resources: Record<string, SDKJSON.Resource>,
6
6
  parents: SDKJSON.Resource[],
7
7
  ): { resource: SDKJSON.Resource; parents: SDKJSON.Resource[] }[] {
8
- return Object.keys(resources)
9
- .toSorted()
10
- .flatMap((key: string | number) => {
11
- const resource = resources[key]!;
12
- return [
13
- { resource, parents },
14
- ...(resource.subresources ? flatResources(resource.subresources, [...parents, resource]) : []),
15
- ];
16
- });
8
+ return Object.keys(resources).flatMap((key: string | number) => {
9
+ const resource = resources[key]!;
10
+ return [
11
+ { resource, parents },
12
+ ...(resource.subresources ? flatResources(resource.subresources, [...parents, resource]) : []),
13
+ ];
14
+ });
17
15
  }
18
16
 
19
17
  export function getResourceFromSpec(
@@ -1,19 +0,0 @@
1
- import * as react_jsx_runtime0 from "react/jsx-runtime";
2
-
3
- //#region src/components/breadcrumbs.d.ts
4
- type BreadcrumbConfig = {
5
- includeCurrentPage?: boolean;
6
- };
7
- declare function SDKBreadcrumbs({
8
- spec,
9
- currentPath,
10
- basePath,
11
- config
12
- }: {
13
- spec: SDKJSON.Spec;
14
- currentPath: string;
15
- basePath?: string;
16
- config?: BreadcrumbConfig | null;
17
- }): react_jsx_runtime0.JSX.Element | null;
18
- //#endregion
19
- export { SDKBreadcrumbs as t };
@@ -1,13 +0,0 @@
1
- //#region rolldown:runtime
2
- var __defProp = Object.defineProperty;
3
- var __export = (all) => {
4
- let target = {};
5
- for (var name in all) __defProp(target, name, {
6
- get: all[name],
7
- enumerable: true
8
- });
9
- return target;
10
- };
11
-
12
- //#endregion
13
- export { __export as t };
@@ -1,35 +0,0 @@
1
- import * as React$1 from "react";
2
- import { jsx } from "react/jsx-runtime";
3
-
4
- //#region src/contexts/component-generics.tsx
5
- const ComponentContext = React$1.createContext(null);
6
- ComponentContext.displayName = "ComponentContext";
7
- function useComponents() {
8
- const ctx = React$1.useContext(ComponentContext);
9
- if (!ctx) throw new Error("useComponents must be used within a ComponentContext.Provider");
10
- return ctx.components;
11
- }
12
- function customizeComponents(defaults, overrides = {}) {
13
- return {
14
- components: {
15
- ...defaults.components,
16
- ...overrides.components ?? {}
17
- },
18
- language: Object.keys(defaults.language).reduce((acc, key) => {
19
- acc[key] = {
20
- ...defaults.language[key],
21
- ...overrides.language?.[key] ?? {}
22
- };
23
- return acc;
24
- }, {})
25
- };
26
- }
27
- function ComponentProvider({ value, children }) {
28
- return /* @__PURE__ */ jsx(ComponentContext.Provider, {
29
- value,
30
- children
31
- });
32
- }
33
-
34
- //#endregion
35
- export { useComponents as i, ComponentProvider as n, customizeComponents as r, ComponentContext as t };
@@ -1,30 +0,0 @@
1
- import * as React$1 from "react";
2
- import * as react_jsx_runtime29 from "react/jsx-runtime";
3
-
4
- //#region src/contexts/component-generics.d.ts
5
- type DeepPartialMap<L> = { [K in keyof L]?: Partial<L[K]> };
6
- type ComponentsContextType<C, L> = {
7
- components: C;
8
- language: L;
9
- };
10
- declare const ComponentContext: React$1.Context<ComponentsContextType<any, any> | null>;
11
- declare function useComponents<C = unknown>(): C;
12
- declare function customizeComponents<C, L>(defaults: {
13
- components: C;
14
- language: L;
15
- }, overrides?: {
16
- components?: Partial<C>;
17
- language?: DeepPartialMap<L>;
18
- }): {
19
- components: C;
20
- language: L;
21
- };
22
- declare function ComponentProvider<C, L>({
23
- value,
24
- children
25
- }: {
26
- value: ComponentsContextType<C, L>;
27
- children: React$1.ReactNode;
28
- }): react_jsx_runtime29.JSX.Element;
29
- //#endregion
30
- export { useComponents as a, customizeComponents as i, ComponentProvider as n, ComponentsContextType as r, ComponentContext as t };
@@ -1,2 +0,0 @@
1
- import { t as SDKBreadcrumbs } from "../breadcrumbs-Z-hEqjcp.js";
2
- export { SDKBreadcrumbs };
@@ -1,16 +0,0 @@
1
- import "../component-generics-DzI21jRn.js";
2
- import "../docs-Dh8kE1va.js";
3
- import "../navigation-aoYZ_tl4.js";
4
- import "../markdown-BXfX1D7C.js";
5
- import "../routing-DQjbRxdJ.js";
6
- import "../style-rYbbxIR_.js";
7
- import "../use-components-D9E85p5x.js";
8
- import { ot as SDKBreadcrumbs } from "../contexts-DRxRO-xO.js";
9
- import "../icons-DdKM-01E.js";
10
- import "../utils-CJfFBNgT.js";
11
- import "../dropdown-DtgAi6lb.js";
12
- import "../md-Dg8aOyMA.js";
13
- import "../utils-BHwvUDKn.js";
14
- import "../types-DFN4M1Sp.js";
15
-
16
- export { SDKBreadcrumbs };
@@ -1,14 +0,0 @@
1
- import * as react_jsx_runtime65 from "react/jsx-runtime";
2
-
3
- //#region src/components/chat.d.ts
4
- declare function Chat(): react_jsx_runtime65.JSX.Element;
5
- type ChatModalProps = {
6
- id?: string;
7
- open?: boolean;
8
- };
9
- declare function ChatModal({
10
- id,
11
- open: isOpen
12
- }: ChatModalProps): react_jsx_runtime65.JSX.Element;
13
- //#endregion
14
- export { Chat, ChatModal, ChatModalProps };
@@ -1,144 +0,0 @@
1
- import "../component-generics-DzI21jRn.js";
2
- import { a as useLanguage } from "../docs-Dh8kE1va.js";
3
- import "../navigation-aoYZ_tl4.js";
4
- import "../markdown-BXfX1D7C.js";
5
- import "../routing-DQjbRxdJ.js";
6
- import { t as style_default } from "../style-rYbbxIR_.js";
7
- import "../use-components-D9E85p5x.js";
8
- import { Bt as Markdown, a as useSearchContext } from "../contexts-DRxRO-xO.js";
9
- import "../icons-DdKM-01E.js";
10
- import "../utils-CJfFBNgT.js";
11
- import "../dropdown-DtgAi6lb.js";
12
- import "../md-Dg8aOyMA.js";
13
- import "../utils-BHwvUDKn.js";
14
- import "../types-DFN4M1Sp.js";
15
- import * as React$1 from "react";
16
- import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
17
- import { ArrowUpIcon, BotMessageSquareIcon, LoaderCircleIcon, SquareIcon, TrashIcon } from "lucide-react";
18
- import { useChat } from "ai/react";
19
-
20
- //#region src/components/chat.tsx
21
- const BASEURL = "https://askai.algolia.com";
22
- function buildFetch({ appId, searchKey, indexName, assistant }) {
23
- const headers = {
24
- "X-Algolia-Application-Id": appId,
25
- "X-Algolia-API-Key": searchKey,
26
- "X-Algolia-Index-Name": `${indexName}-chat`,
27
- "X-Algolia-Assistant-Id": assistant
28
- };
29
- return async (input, init) => {
30
- const data = await (await fetch(`${BASEURL}/chat/token`, {
31
- method: "POST",
32
- headers
33
- })).json();
34
- return fetch(input, {
35
- ...init,
36
- headers: {
37
- ...init.headers,
38
- ...headers,
39
- Authorization: `TOKEN ${data["token"]}`
40
- }
41
- });
42
- };
43
- }
44
- function RenderMessage({ message }) {
45
- return message.parts.filter((part) => part.type === "text").map((part, key) => /* @__PURE__ */ jsx(Markdown, { content: part["text"] }, key));
46
- }
47
- function Chat() {
48
- const language = useLanguage();
49
- const { settings } = useSearchContext();
50
- const messageListRef = React$1.useRef(null);
51
- const { messages, setMessages, status, input, setInput, append, stop } = useChat({
52
- body: { searchParameters: { filters: `language:${language ?? "http"}` } },
53
- sendExtraMessageFields: true,
54
- fetch: buildFetch(settings),
55
- api: `${BASEURL}/chat`
56
- });
57
- React$1.useEffect(() => {
58
- const content = sessionStorage.getItem("stldocs-chat-messages");
59
- if (!content) return;
60
- setMessages(JSON.parse(content));
61
- setTimeout(() => {
62
- if (!messageListRef.current) return;
63
- messageListRef.current.scrollTop = messageListRef.current.scrollHeight;
64
- }, 10);
65
- }, [setMessages]);
66
- React$1.useEffect(() => {
67
- if (status !== "submitted") return;
68
- [...messageListRef?.current.querySelectorAll("[data-stldocs-chat-message]")].at(-1)?.scrollIntoView({
69
- behavior: "smooth",
70
- block: "start"
71
- });
72
- }, [status]);
73
- React$1.useEffect(() => {
74
- sessionStorage.setItem("stldocs-chat-messages", JSON.stringify(messages));
75
- }, [messages]);
76
- function handleSend() {
77
- append({
78
- role: "user",
79
- content: input
80
- });
81
- setInput("");
82
- }
83
- function handleKeyUp(ev) {
84
- if (ev.key === "Enter" && !ev.shiftKey) {
85
- ev.preventDefault();
86
- handleSend();
87
- }
88
- }
89
- return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs("div", {
90
- className: style_default.ChatMessages,
91
- ref: messageListRef,
92
- children: [
93
- messages.map((message) => /* @__PURE__ */ jsx("div", {
94
- className: style_default.ChatMessage,
95
- "data-stldocs-chat-message": message.role,
96
- children: /* @__PURE__ */ jsx(RenderMessage, { message })
97
- }, message.id)),
98
- status === "submitted" && /* @__PURE__ */ jsx("div", {
99
- className: style_default.LoadingSpinner,
100
- children: /* @__PURE__ */ jsx(LoaderCircleIcon, {})
101
- }),
102
- ["submitted", "streaming"].includes(status) && /* @__PURE__ */ jsx("div", { style: { height: "800px" } })
103
- ]
104
- }), /* @__PURE__ */ jsxs("div", {
105
- className: style_default.ChatInput,
106
- children: [/* @__PURE__ */ jsx("textarea", {
107
- value: input,
108
- placeholder: "Ask a question",
109
- onKeyUp: handleKeyUp,
110
- onChange: (ev) => setInput(ev.target.value),
111
- autoFocus: true
112
- }), /* @__PURE__ */ jsxs("div", {
113
- className: style_default.ChatInputButtons,
114
- children: [status === "submitted" ? /* @__PURE__ */ jsx("button", {
115
- onClick: stop,
116
- children: /* @__PURE__ */ jsx(SquareIcon, {})
117
- }) : /* @__PURE__ */ jsx("button", {
118
- onClick: handleSend,
119
- disabled: input.length < 1,
120
- children: /* @__PURE__ */ jsx(ArrowUpIcon, {})
121
- }), /* @__PURE__ */ jsx("button", {
122
- onClick: () => setMessages([]),
123
- children: /* @__PURE__ */ jsx(TrashIcon, {})
124
- })]
125
- })]
126
- })] });
127
- }
128
- function ChatModal({ id, open: isOpen }) {
129
- const [open, setOpen] = React$1.useState(isOpen);
130
- return /* @__PURE__ */ jsxs("div", {
131
- id,
132
- onToggle: (ev) => setOpen(ev.newState === "open"),
133
- className: style_default.SearchModal,
134
- popover: "auto",
135
- "data-stldocs-modal-open": open,
136
- children: [/* @__PURE__ */ jsxs("div", {
137
- className: style_default.ChatHeader,
138
- children: [/* @__PURE__ */ jsx(BotMessageSquareIcon, {}), /* @__PURE__ */ jsx("h5", { children: "Docs Assistant" })]
139
- }), open && /* @__PURE__ */ jsx(Chat, {})]
140
- });
141
- }
142
-
143
- //#endregion
144
- export { Chat, ChatModal };
@@ -1,2 +0,0 @@
1
- import { i as DropdownTrigger, n as DropdownItem, r as DropdownMenu, t as Dropdown } from "../dropdown-B7VyGMOw.js";
2
- export { Dropdown, DropdownItem, DropdownMenu, DropdownTrigger };
@@ -1,4 +0,0 @@
1
- import "../style-rYbbxIR_.js";
2
- import { i as DropdownTrigger, n as DropdownItem, r as DropdownMenu, t as Dropdown } from "../dropdown-DtgAi6lb.js";
3
-
4
- export { Dropdown, DropdownItem, DropdownMenu, DropdownTrigger };
@@ -1,50 +0,0 @@
1
- import * as react_jsx_runtime79 from "react/jsx-runtime";
2
-
3
- //#region src/components/icons.d.ts
4
- declare function GoIcon({
5
- className
6
- }: {
7
- className?: string;
8
- }): react_jsx_runtime79.JSX.Element;
9
- declare function JavaIcon({
10
- className
11
- }: {
12
- className?: string;
13
- }): react_jsx_runtime79.JSX.Element;
14
- declare function KotlinIcon({
15
- className
16
- }: {
17
- className?: string;
18
- }): react_jsx_runtime79.JSX.Element;
19
- declare function PythonIcon({
20
- className
21
- }: {
22
- className?: string;
23
- }): react_jsx_runtime79.JSX.Element;
24
- declare function RubyIcon({
25
- className
26
- }: {
27
- className?: string;
28
- }): react_jsx_runtime79.JSX.Element;
29
- declare function TerraformIcon({
30
- className
31
- }: {
32
- className?: string;
33
- }): react_jsx_runtime79.JSX.Element;
34
- declare function TypescriptIcon({
35
- className
36
- }: {
37
- className?: string;
38
- }): react_jsx_runtime79.JSX.Element;
39
- declare function CurlIcon({
40
- className
41
- }: {
42
- className?: string;
43
- }): react_jsx_runtime79.JSX.Element;
44
- declare function PowershellIcon({
45
- className
46
- }: {
47
- className?: string;
48
- }): react_jsx_runtime79.JSX.Element;
49
- //#endregion
50
- export { CurlIcon, GoIcon, JavaIcon, KotlinIcon, PowershellIcon, PythonIcon, RubyIcon, TerraformIcon, TypescriptIcon };
@@ -1,3 +0,0 @@
1
- import { a as PowershellIcon, c as TerraformIcon, i as KotlinIcon, l as TypescriptIcon, n as GoIcon, o as PythonIcon, r as JavaIcon, s as RubyIcon, t as CurlIcon } from "../icons-DdKM-01E.js";
2
-
3
- export { CurlIcon, GoIcon, JavaIcon, KotlinIcon, PowershellIcon, PythonIcon, RubyIcon, TerraformIcon, TypescriptIcon };
@@ -1,12 +0,0 @@
1
- import { t as SDKBreadcrumbs } from "../breadcrumbs-Z-hEqjcp.js";
2
- import { i as DropdownTrigger, n as DropdownItem, r as DropdownMenu, t as Dropdown } from "../dropdown-B7VyGMOw.js";
3
- import { a as MethodDescription, c as MethodHeaderProps, d as MethodInfo, f as MethodInfoProps, h as MethodRouteProps, i as Method, l as MethodIconBadge, m as MethodRoute, n as HttpMethodIcons, o as MethodDescriptionProps, p as MethodProps, r as HttpMethods, s as MethodHeader, t as HTTPMethod, u as MethodIconProps } from "../method-DpsVuzZW.js";
4
- import { a as Join, c as ListViewProps, d as ToggleButtonProps, f as Tooltip, i as InputProps, l as Markdown, n as Expander, o as Link, p as VirtualExpander, r as Input, s as ListView, t as Badge, u as ToggleButton } from "../primitives-DWz23_Ub.js";
5
- import { a as PropertyToggle, i as PropertyProps, n as PropertyDescription, o as PropertyToggleProps, r as PropertyDescriptionProps, t as Property } from "../properties-CF71V58d.js";
6
- import "../routing-qc0V00-j.js";
7
- import { C as TransformRequestSnippetFn, S as SDKSnippetLanguagesType, T as useReferenceNesting, _ as SDKModelProps, a as SDKChildren, b as SDKRequestTitleProps, c as SDKDeclaration, d as SDKLanguageBlock, f as SDKMethod, g as SDKModel, h as SDKMethodProps, i as ReferenceNestingContextType, l as SDKExample, m as SDKMethodInfo, n as PropertyModelContextType, o as SDKConstraints, p as SDKMethodHeader, r as ReferenceNestingContext, s as SDKConstraintsProps, t as PropertyModelContext, u as SDKIcon, v as SDKReference, w as usePropertyModel, x as SDKSnippetLanguages, y as SDKRequestTitle } from "../sdk-Zg3Rggk3.js";
8
- import { a as SnippetContainerProps, c as SnippetRequestContainerProps, i as SnippetContainer, l as SnippetResponse, n as SnippetCode, o as SnippetProps, r as SnippetCodeProps, s as SnippetRequestContainer, t as Snippet } from "../snippets-EUzM4fRO.js";
9
- import { a as SDKResource, c as SDKRoot, i as SDKOverviewProps, l as SDKRootProps, n as SDKMethodSummaryProps, o as SDKResourceHeader, r as SDKOverview, s as SDKResourceProps, t as SDKMethodSummary } from "../overview-C8e-6jGr.js";
10
- import { a as SidebarProps, i as SidebarMethodProps, n as SidebarExpander, o as SidebarResource, r as SidebarMethod, s as SidebarResourceProps, t as Sidebar } from "../sidebar-C8KirYjg.js";
11
- import "../index-YnpUtXLB.js";
12
- export { Badge, Dropdown, DropdownItem, DropdownMenu, DropdownTrigger, Expander, HTTPMethod, HttpMethodIcons, HttpMethods, Input, InputProps, Join, Link, ListView, ListViewProps, Markdown, Method, MethodDescription, MethodDescriptionProps, MethodHeader, MethodHeaderProps, MethodIconBadge, MethodIconProps, MethodInfo, MethodInfoProps, MethodProps, MethodRoute, MethodRouteProps, Property, PropertyDescription, PropertyDescriptionProps, PropertyModelContext, PropertyModelContextType, PropertyProps, PropertyToggle, PropertyToggleProps, ReferenceNestingContext, ReferenceNestingContextType, SDKBreadcrumbs, SDKChildren, SDKConstraints, SDKConstraintsProps, SDKDeclaration, SDKExample, SDKIcon, SDKLanguageBlock, SDKMethod, SDKMethodHeader, SDKMethodInfo, SDKMethodProps, SDKMethodSummary, SDKMethodSummaryProps, SDKModel, SDKModelProps, SDKOverview, SDKOverviewProps, SDKReference, SDKRequestTitle, SDKRequestTitleProps, SDKResource, SDKResourceHeader, SDKResourceProps, SDKRoot, SDKRootProps, SDKSnippetLanguages, SDKSnippetLanguagesType, Sidebar, SidebarExpander, SidebarMethod, SidebarMethodProps, SidebarProps, SidebarResource, SidebarResourceProps, Snippet, SnippetCode, SnippetCodeProps, SnippetContainer, SnippetContainerProps, SnippetProps, SnippetRequestContainer, SnippetRequestContainerProps, SnippetResponse, ToggleButton, ToggleButtonProps, Tooltip, TransformRequestSnippetFn, VirtualExpander, usePropertyModel, useReferenceNesting };
@@ -1,16 +0,0 @@
1
- import "../component-generics-DzI21jRn.js";
2
- import "../docs-Dh8kE1va.js";
3
- import "../navigation-aoYZ_tl4.js";
4
- import "../markdown-BXfX1D7C.js";
5
- import "../routing-DQjbRxdJ.js";
6
- import "../style-rYbbxIR_.js";
7
- import "../use-components-D9E85p5x.js";
8
- import { $t as PropertyDescription, At as SDKRequestTitle, Bt as Markdown, Ct as SDKIcon, Dt as SDKMethodInfo, Et as SDKMethodHeader, Ft as Expander, Gt as HttpMethods, Ht as Tooltip, It as Input, Jt as MethodHeader, Kt as Method, Lt as Join, Mt as usePropertyModel, Nt as useReferenceNesting, Ot as SDKModel, Pt as Badge, Qt as Property, Rt as Link, St as SDKExample, Tt as SDKMethod, Ut as VirtualExpander, Vt as ToggleButton, Wt as HttpMethodIcons, Xt as MethodInfo, Yt as MethodIconBadge, Zt as MethodRoute, _t as PropertyModelContext, at as SidebarResource, bt as SDKConstraints, ct as SDKOverview, dt as SDKRoot, en as PropertyToggle, ft as Snippet, gt as SnippetResponse, ht as SnippetRequestContainer, it as SidebarMethod, jt as SDKSnippetLanguages, kt as SDKReference, lt as SDKResource, mt as SnippetContainer, nt as Sidebar, ot as SDKBreadcrumbs, pt as SnippetCode, qt as MethodDescription, rt as SidebarExpander, st as SDKMethodSummary, ut as SDKResourceHeader, vt as ReferenceNestingContext, wt as SDKLanguageBlock, xt as SDKDeclaration, yt as SDKChildren, zt as ListView } from "../contexts-DRxRO-xO.js";
9
- import "../icons-DdKM-01E.js";
10
- import "../utils-CJfFBNgT.js";
11
- import { i as DropdownTrigger, n as DropdownItem, r as DropdownMenu, t as Dropdown } from "../dropdown-DtgAi6lb.js";
12
- import "../md-Dg8aOyMA.js";
13
- import "../utils-BHwvUDKn.js";
14
- import "../types-DFN4M1Sp.js";
15
-
16
- export { Badge, Dropdown, DropdownItem, DropdownMenu, DropdownTrigger, Expander, HttpMethodIcons, HttpMethods, Input, Join, Link, ListView, Markdown, Method, MethodDescription, MethodHeader, MethodIconBadge, MethodInfo, MethodRoute, Property, PropertyDescription, PropertyModelContext, PropertyToggle, ReferenceNestingContext, SDKBreadcrumbs, SDKChildren, SDKConstraints, SDKDeclaration, SDKExample, SDKIcon, SDKLanguageBlock, SDKMethod, SDKMethodHeader, SDKMethodInfo, SDKMethodSummary, SDKModel, SDKOverview, SDKReference, SDKRequestTitle, SDKResource, SDKResourceHeader, SDKRoot, SDKSnippetLanguages, Sidebar, SidebarExpander, SidebarMethod, SidebarResource, Snippet, SnippetCode, SnippetContainer, SnippetRequestContainer, SnippetResponse, ToggleButton, Tooltip, VirtualExpander, usePropertyModel, useReferenceNesting };
@@ -1,2 +0,0 @@
1
- import { a as MethodDescription, c as MethodHeaderProps, d as MethodInfo, f as MethodInfoProps, h as MethodRouteProps, i as Method, l as MethodIconBadge, m as MethodRoute, n as HttpMethodIcons, o as MethodDescriptionProps, p as MethodProps, r as HttpMethods, s as MethodHeader, t as HTTPMethod, u as MethodIconProps } from "../method-DpsVuzZW.js";
2
- export { HTTPMethod, HttpMethodIcons, HttpMethods, Method, MethodDescription, MethodDescriptionProps, MethodHeader, MethodHeaderProps, MethodIconBadge, MethodIconProps, MethodInfo, MethodInfoProps, MethodProps, MethodRoute, MethodRouteProps };
@@ -1,16 +0,0 @@
1
- import "../component-generics-DzI21jRn.js";
2
- import "../docs-Dh8kE1va.js";
3
- import "../navigation-aoYZ_tl4.js";
4
- import "../markdown-BXfX1D7C.js";
5
- import "../routing-DQjbRxdJ.js";
6
- import "../style-rYbbxIR_.js";
7
- import "../use-components-D9E85p5x.js";
8
- import { Gt as HttpMethods, Jt as MethodHeader, Kt as Method, Wt as HttpMethodIcons, Xt as MethodInfo, Yt as MethodIconBadge, Zt as MethodRoute, qt as MethodDescription } from "../contexts-DRxRO-xO.js";
9
- import "../icons-DdKM-01E.js";
10
- import "../utils-CJfFBNgT.js";
11
- import "../dropdown-DtgAi6lb.js";
12
- import "../md-Dg8aOyMA.js";
13
- import "../utils-BHwvUDKn.js";
14
- import "../types-DFN4M1Sp.js";
15
-
16
- export { HttpMethodIcons, HttpMethods, Method, MethodDescription, MethodHeader, MethodIconBadge, MethodInfo, MethodRoute };
@@ -1,2 +0,0 @@
1
- import { a as SDKResource, c as SDKRoot, i as SDKOverviewProps, l as SDKRootProps, n as SDKMethodSummaryProps, o as SDKResourceHeader, r as SDKOverview, s as SDKResourceProps, t as SDKMethodSummary } from "../overview-C8e-6jGr.js";
2
- export { SDKMethodSummary, SDKMethodSummaryProps, SDKOverview, SDKOverviewProps, SDKResource, SDKResourceHeader, SDKResourceProps, SDKRoot, SDKRootProps };
@@ -1,16 +0,0 @@
1
- import "../component-generics-DzI21jRn.js";
2
- import "../docs-Dh8kE1va.js";
3
- import "../navigation-aoYZ_tl4.js";
4
- import "../markdown-BXfX1D7C.js";
5
- import "../routing-DQjbRxdJ.js";
6
- import "../style-rYbbxIR_.js";
7
- import "../use-components-D9E85p5x.js";
8
- import { ct as SDKOverview, dt as SDKRoot, lt as SDKResource, st as SDKMethodSummary, ut as SDKResourceHeader } from "../contexts-DRxRO-xO.js";
9
- import "../icons-DdKM-01E.js";
10
- import "../utils-CJfFBNgT.js";
11
- import "../dropdown-DtgAi6lb.js";
12
- import "../md-Dg8aOyMA.js";
13
- import "../utils-BHwvUDKn.js";
14
- import "../types-DFN4M1Sp.js";
15
-
16
- export { SDKMethodSummary, SDKOverview, SDKResource, SDKResourceHeader, SDKRoot };
@@ -1,2 +0,0 @@
1
- import { a as Join, c as ListViewProps, d as ToggleButtonProps, f as Tooltip, i as InputProps, l as Markdown, n as Expander, o as Link, p as VirtualExpander, r as Input, s as ListView, t as Badge, u as ToggleButton } from "../primitives-DWz23_Ub.js";
2
- export { Badge, Expander, Input, InputProps, Join, Link, ListView, ListViewProps, Markdown, ToggleButton, ToggleButtonProps, Tooltip, VirtualExpander };
@@ -1,16 +0,0 @@
1
- import "../component-generics-DzI21jRn.js";
2
- import "../docs-Dh8kE1va.js";
3
- import "../navigation-aoYZ_tl4.js";
4
- import "../markdown-BXfX1D7C.js";
5
- import "../routing-DQjbRxdJ.js";
6
- import "../style-rYbbxIR_.js";
7
- import "../use-components-D9E85p5x.js";
8
- import { Bt as Markdown, Ft as Expander, Ht as Tooltip, It as Input, Lt as Join, Pt as Badge, Rt as Link, Ut as VirtualExpander, Vt as ToggleButton, zt as ListView } from "../contexts-DRxRO-xO.js";
9
- import "../icons-DdKM-01E.js";
10
- import "../utils-CJfFBNgT.js";
11
- import "../dropdown-DtgAi6lb.js";
12
- import "../md-Dg8aOyMA.js";
13
- import "../utils-BHwvUDKn.js";
14
- import "../types-DFN4M1Sp.js";
15
-
16
- export { Badge, Expander, Input, Join, Link, ListView, Markdown, ToggleButton, Tooltip, VirtualExpander };