@stainless-api/docs-search 0.1.0-beta.2 → 0.1.0-beta.21
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/dist/{algolia-BOY-OcxU.js → algolia-gvZUkKkS.js} +2 -2
- package/dist/{context-CBTWkDal.js → context-BeqLpg4u.js} +6 -6
- package/dist/context.d.ts +1 -2
- package/dist/context.js +3 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.js +51 -45
- package/dist/mcp.d.ts +3 -5
- package/dist/mcp.js +1 -1
- package/dist/providers/algolia.d.ts +3 -4
- package/dist/providers/algolia.js +2 -2
- package/dist/providers/fuse.d.ts +2 -3
- package/dist/providers/fuse.js +2 -2
- package/dist/providers/pagefind.d.ts +1 -1
- package/dist/providers/pagefind.js +1 -1
- package/dist/providers/walker.d.ts +2 -3
- package/dist/providers/walker.js +2 -2
- package/dist/{types-BhJLoaNF.js → types-DyGUPDP0.js} +2 -2
- package/dist/types-fPzO2V0p.d.ts +1585 -0
- package/dist/types.d.ts +1 -1
- package/dist/types.js +1 -1
- package/package.json +13 -12
- package/dist/types-Gg968wOz.d.ts +0 -91
- /package/dist/{indexer-DBU0POrK.js → indexer-BDmIxFRi.js} +0 -0
- /package/dist/{pagefind-Dcn-gjDe.js → pagefind-DCvI8YmZ.js} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as generateIndex, t as generateChatIndex } from "./indexer-
|
|
2
|
-
import { i as SearchableAttributesProse, n as SearchableAttributes, r as SearchableAttributesChat } from "./types-
|
|
1
|
+
import { n as generateIndex, t as generateChatIndex } from "./indexer-BDmIxFRi.js";
|
|
2
|
+
import { i as SearchableAttributesProse, n as SearchableAttributes, r as SearchableAttributesChat } from "./types-DyGUPDP0.js";
|
|
3
3
|
import { searchClient } from "@algolia/client-search";
|
|
4
4
|
|
|
5
5
|
//#region src/providers/algolia.ts
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { i as search } from "./algolia-
|
|
2
|
-
import
|
|
1
|
+
import { i as search } from "./algolia-gvZUkKkS.js";
|
|
2
|
+
import { createContext, useCallback, useContext } from "react";
|
|
3
3
|
import { jsx } from "react/jsx-runtime";
|
|
4
4
|
|
|
5
5
|
//#region src/context.tsx
|
|
6
6
|
function createStrictContext(displayName) {
|
|
7
|
-
const Context =
|
|
7
|
+
const Context = createContext(null);
|
|
8
8
|
Context.displayName = displayName;
|
|
9
9
|
function useStrictContext() {
|
|
10
|
-
const context =
|
|
10
|
+
const context = useContext(Context);
|
|
11
11
|
if (context === null) throw new Error(`use${displayName} must be used within a ${displayName}Provider`);
|
|
12
12
|
return context;
|
|
13
13
|
}
|
|
@@ -16,10 +16,10 @@ function createStrictContext(displayName) {
|
|
|
16
16
|
const [Provider, useSearchContext] = createStrictContext("SearchContext");
|
|
17
17
|
function useSearch() {
|
|
18
18
|
const { settings } = useSearchContext();
|
|
19
|
-
return (params) => search({
|
|
19
|
+
return useCallback((params) => search({
|
|
20
20
|
settings,
|
|
21
21
|
params
|
|
22
|
-
});
|
|
22
|
+
}), [settings]);
|
|
23
23
|
}
|
|
24
24
|
function SearchProvider({ children, ...props }) {
|
|
25
25
|
return /* @__PURE__ */ jsx(Provider, {
|
package/dist/context.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { f as ResultType, g as SearchSettings, h as SearchParams } from "./types-
|
|
2
|
-
import * as React from "react";
|
|
1
|
+
import { f as ResultType, g as SearchSettings, h as SearchParams } from "./types-fPzO2V0p.js";
|
|
3
2
|
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
4
3
|
|
|
5
4
|
//#region src/context.d.ts
|
package/dist/context.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "./indexer-
|
|
2
|
-
import "./algolia-
|
|
3
|
-
import { n as useSearch, r as useSearchContext, t as SearchProvider } from "./context-
|
|
1
|
+
import "./indexer-BDmIxFRi.js";
|
|
2
|
+
import "./algolia-gvZUkKkS.js";
|
|
3
|
+
import { n as useSearch, r as useSearchContext, t as SearchProvider } from "./context-BeqLpg4u.js";
|
|
4
4
|
|
|
5
5
|
export { SearchProvider, useSearch, useSearchContext };
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import "./indexer-
|
|
2
|
-
import { t as QueryKinds } from "./types-
|
|
3
|
-
import "./algolia-
|
|
4
|
-
import { n as useSearch, r as useSearchContext } from "./context-
|
|
5
|
-
import { t as guideSearch } from "./pagefind-
|
|
6
|
-
import
|
|
1
|
+
import "./indexer-BDmIxFRi.js";
|
|
2
|
+
import { t as QueryKinds } from "./types-DyGUPDP0.js";
|
|
3
|
+
import "./algolia-gvZUkKkS.js";
|
|
4
|
+
import { n as useSearch, r as useSearchContext } from "./context-BeqLpg4u.js";
|
|
5
|
+
import { t as guideSearch } from "./pagefind-DCvI8YmZ.js";
|
|
6
|
+
import { createElement, useEffect, useRef, useState } from "react";
|
|
7
7
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
-
import { BookOpenText, Box, Code, Folder, Search, Wrench
|
|
8
|
+
import { BookOpenText, Box, Code, Folder, Search, Wrench } from "lucide-react";
|
|
9
9
|
import { useLanguage } from "@stainless-api/docs-ui/contexts";
|
|
10
10
|
import { useComponents } from "@stainless-api/docs-ui/contexts/use-components";
|
|
11
11
|
import style from "@stainless-api/docs-ui/style";
|
|
12
|
+
import { Button } from "@stainless-api/ui-primitives";
|
|
12
13
|
|
|
13
14
|
//#region src/results.tsx
|
|
14
15
|
const QueryKindDisplay = {
|
|
@@ -223,35 +224,40 @@ function SearchForm() {
|
|
|
223
224
|
const search = useSearch();
|
|
224
225
|
const language = useLanguage();
|
|
225
226
|
const { onSelect, pageFind } = useSearchContext();
|
|
226
|
-
const [results, setResults] =
|
|
227
|
-
const [filterKind, setFilterKind] =
|
|
228
|
-
const [searchQuery, setSearchQuery] =
|
|
229
|
-
const inputRef =
|
|
230
|
-
|
|
231
|
-
const guideLimit =
|
|
232
|
-
const
|
|
233
|
-
const
|
|
227
|
+
const [results, setResults] = useState(null);
|
|
228
|
+
const [filterKind, setFilterKind] = useState("all");
|
|
229
|
+
const [searchQuery, setSearchQuery] = useState("");
|
|
230
|
+
const inputRef = useRef(null);
|
|
231
|
+
useEffect(() => {
|
|
232
|
+
const guideLimit = 25;
|
|
233
|
+
const apiKindFilter = ["all", "guide"].includes(filterKind) ? void 0 : filterKind;
|
|
234
|
+
const ac = new AbortController();
|
|
235
|
+
Promise.all([pageFind ? guideSearch(pageFind, searchQuery, guideLimit) : [], search({
|
|
234
236
|
query: searchQuery,
|
|
235
|
-
kind,
|
|
237
|
+
kind: apiKindFilter,
|
|
236
238
|
language
|
|
237
|
-
})])
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
239
|
+
})]).then(([guideResults, apiResults]) => {
|
|
240
|
+
if (ac.signal.aborted) return;
|
|
241
|
+
setResults({
|
|
242
|
+
items: filterKind === "guide" ? guideResults : filterKind === "all" ? [
|
|
243
|
+
...guideResults.slice(0, 5),
|
|
244
|
+
...apiResults?.hits ?? [],
|
|
245
|
+
...guideResults.slice(5)
|
|
246
|
+
] : apiResults?.hits ?? [],
|
|
247
|
+
counts: {
|
|
248
|
+
...apiResults?.facets?.["kind"],
|
|
249
|
+
guide: guideResults.length,
|
|
250
|
+
all: (apiResults?.nbHits ?? 0) + guideResults.length
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
}).catch(() => {});
|
|
254
|
+
return () => ac.abort();
|
|
255
|
+
}, [
|
|
252
256
|
searchQuery,
|
|
253
257
|
filterKind,
|
|
254
|
-
language
|
|
258
|
+
language,
|
|
259
|
+
search,
|
|
260
|
+
pageFind
|
|
255
261
|
]);
|
|
256
262
|
return /* @__PURE__ */ jsxs("div", {
|
|
257
263
|
className: style.SearchForm,
|
|
@@ -264,19 +270,13 @@ function SearchForm() {
|
|
|
264
270
|
size: 16,
|
|
265
271
|
className: style.Icon
|
|
266
272
|
}),
|
|
267
|
-
right: searchQuery && /* @__PURE__ */ jsx(X, {
|
|
268
|
-
cursor: "pointer",
|
|
269
|
-
onClick: () => clearInput(),
|
|
270
|
-
size: 16,
|
|
271
|
-
className: style.Icon
|
|
272
|
-
}),
|
|
273
273
|
value: searchQuery,
|
|
274
274
|
placeholder: "Search"
|
|
275
275
|
}),
|
|
276
276
|
/* @__PURE__ */ jsx(SearchFilter, {
|
|
277
277
|
results,
|
|
278
278
|
filterKind,
|
|
279
|
-
onChange: (filterKind
|
|
279
|
+
onChange: (filterKind) => setFilterKind(filterKind)
|
|
280
280
|
}),
|
|
281
281
|
/* @__PURE__ */ jsx(Docs.ListView, {
|
|
282
282
|
items: results?.items ?? [],
|
|
@@ -287,16 +287,15 @@ function SearchForm() {
|
|
|
287
287
|
});
|
|
288
288
|
}
|
|
289
289
|
function SearchFilter({ results, filterKind, onChange }) {
|
|
290
|
-
const Docs = useComponents();
|
|
291
290
|
const { pageFind } = useSearchContext();
|
|
292
|
-
const toggles = pageFind ? QueryKinds : QueryKinds.
|
|
291
|
+
const toggles = pageFind ? QueryKinds : QueryKinds.filter((k) => k !== "guide");
|
|
293
292
|
return /* @__PURE__ */ jsx("div", {
|
|
294
293
|
className: style.SearchFilter,
|
|
295
|
-
children: toggles.map((kind, index) => /* @__PURE__ */ jsxs(
|
|
296
|
-
|
|
294
|
+
children: toggles.map((kind, index) => /* @__PURE__ */ jsxs(Button, {
|
|
295
|
+
variant: filterKind === kind ? "accent" : "outline",
|
|
297
296
|
onClick: () => onChange?.(kind),
|
|
298
297
|
children: [
|
|
299
|
-
|
|
298
|
+
createElement(QueryKindDisplay[kind].icon, {
|
|
300
299
|
size: 16,
|
|
301
300
|
className: style.Icon
|
|
302
301
|
}),
|
|
@@ -313,7 +312,14 @@ function SearchFilter({ results, filterKind, onChange }) {
|
|
|
313
312
|
});
|
|
314
313
|
}
|
|
315
314
|
function SearchModal({ id, open: isOpen }) {
|
|
316
|
-
const [open, setOpen] =
|
|
315
|
+
const [open, setOpen] = useState(isOpen ?? false);
|
|
316
|
+
useEffect(() => {
|
|
317
|
+
if (open) document.body.style.overflow = "hidden";
|
|
318
|
+
else document.body.style.overflow = "";
|
|
319
|
+
return () => {
|
|
320
|
+
document.body.style.overflow = "";
|
|
321
|
+
};
|
|
322
|
+
}, [open]);
|
|
317
323
|
return /* @__PURE__ */ jsx("div", {
|
|
318
324
|
id,
|
|
319
325
|
onToggle: (ev) => setOpen(ev.newState === "open"),
|
package/dist/mcp.d.ts
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import { n as IndexEntry, r as IndexMethod } from "./types-
|
|
1
|
+
import { b as Spec, n as IndexEntry, r as IndexMethod } from "./types-fPzO2V0p.js";
|
|
2
2
|
import { DocsLanguage } from "@stainless-api/docs-ui/routing";
|
|
3
|
-
import * as SDKJSON from "@stainless/sdk-json";
|
|
4
3
|
|
|
5
4
|
//#region src/indexer.d.ts
|
|
6
|
-
|
|
7
|
-
declare function generateIndex(spec: SDKJSON.Spec, renderMarkdownFn?: (_: string) => string | null, includeTypes?: boolean): Generator<IndexEntry>;
|
|
5
|
+
declare function generateIndex(spec: Spec, renderMarkdownFn?: (_: string) => string | null, includeTypes?: boolean): Generator<IndexEntry>;
|
|
8
6
|
//#endregion
|
|
9
7
|
//#region src/mcp.d.ts
|
|
10
8
|
type Item = IndexEntry & IndexMethod;
|
|
11
|
-
declare function render(spec:
|
|
9
|
+
declare function render(spec: Spec, language: DocsLanguage, items: Item[], includeModelProperties: boolean): any;
|
|
12
10
|
//#endregion
|
|
13
11
|
export { generateIndex, render };
|
package/dist/mcp.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as generateIndex } from "./indexer-
|
|
1
|
+
import { n as generateIndex } from "./indexer-BDmIxFRi.js";
|
|
2
2
|
import { parseStainlessPath } from "@stainless-api/docs-ui/routing";
|
|
3
3
|
import { renderMarkdown } from "@stainless-api/docs-ui/markdown";
|
|
4
4
|
import { getResourceFromSpec } from "@stainless-api/docs-ui/utils";
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { f as ResultType, g as SearchSettings, h as SearchParams, s as ProseIndexEntry } from "../types-
|
|
2
|
-
import * as SDKJSON from "@stainless/sdk-json";
|
|
1
|
+
import { b as Spec, f as ResultType, g as SearchSettings, h as SearchParams, s as ProseIndexEntry } from "../types-fPzO2V0p.js";
|
|
3
2
|
|
|
4
3
|
//#region src/providers/algolia.d.ts
|
|
5
|
-
declare function buildIndex(appId: string, indexName: string, writeKey: string, spec:
|
|
6
|
-
declare function buildChatIndex(appId: string, indexName: string, writeKey: string, spec:
|
|
4
|
+
declare function buildIndex(appId: string, indexName: string, writeKey: string, spec: Spec, renderMarkdown: (_: string) => string | null): Promise<void>;
|
|
5
|
+
declare function buildChatIndex(appId: string, indexName: string, writeKey: string, spec: Spec): Promise<void>;
|
|
7
6
|
declare function buildProseIndex(appId: string, indexName: string, writeKey: string, objects: ProseIndexEntry[]): Promise<void>;
|
|
8
7
|
declare function search({
|
|
9
8
|
settings: {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "../indexer-
|
|
2
|
-
import { i as search, n as buildIndex, r as buildProseIndex, t as buildChatIndex } from "../algolia-
|
|
1
|
+
import "../indexer-BDmIxFRi.js";
|
|
2
|
+
import { i as search, n as buildIndex, r as buildProseIndex, t as buildChatIndex } from "../algolia-gvZUkKkS.js";
|
|
3
3
|
|
|
4
4
|
export { buildChatIndex, buildIndex, buildProseIndex, search };
|
package/dist/providers/fuse.d.ts
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import { n as IndexEntry } from "../types-
|
|
1
|
+
import { b as Spec, n as IndexEntry } from "../types-fPzO2V0p.js";
|
|
2
2
|
import { DocsLanguage } from "@stainless-api/docs-ui/routing";
|
|
3
3
|
import * as fuse_js0 from "fuse.js";
|
|
4
4
|
import { FuseIndex } from "fuse.js";
|
|
5
|
-
import * as SDKJSON from "@stainless/sdk-json";
|
|
6
5
|
|
|
7
6
|
//#region src/providers/fuse.d.ts
|
|
8
7
|
type FuseIndexData = {
|
|
9
8
|
content: IndexEntry[];
|
|
10
9
|
index: FuseIndex<IndexEntry>;
|
|
11
10
|
};
|
|
12
|
-
declare function buildIndex(spec:
|
|
11
|
+
declare function buildIndex(spec: Spec, language?: DocsLanguage): FuseIndexData;
|
|
13
12
|
declare function search({
|
|
14
13
|
content,
|
|
15
14
|
index
|
package/dist/providers/fuse.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as generateIndex } from "../indexer-
|
|
2
|
-
import { n as SearchableAttributes } from "../types-
|
|
1
|
+
import { n as generateIndex } from "../indexer-BDmIxFRi.js";
|
|
2
|
+
import { n as SearchableAttributes } from "../types-DyGUPDP0.js";
|
|
3
3
|
import Fuse from "fuse.js";
|
|
4
4
|
|
|
5
5
|
//#region src/providers/fuse.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as GuideResultType } from "../types-
|
|
1
|
+
import { t as GuideResultType } from "../types-fPzO2V0p.js";
|
|
2
2
|
|
|
3
3
|
//#region src/providers/pagefind.d.ts
|
|
4
4
|
declare function guideSearch(loadPath: string, query: string, limit?: number): Promise<GuideResultType[]>;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { n as IndexEntry } from "../types-
|
|
1
|
+
import { b as Spec, n as IndexEntry } from "../types-fPzO2V0p.js";
|
|
2
2
|
import { DocsLanguage } from "@stainless-api/docs-ui/routing";
|
|
3
|
-
import * as SDKJSON from "@stainless/sdk-json";
|
|
4
3
|
|
|
5
4
|
//#region src/providers/walker.d.ts
|
|
6
|
-
declare function buildIndex(spec:
|
|
5
|
+
declare function buildIndex(spec: Spec): Generator<IndexEntry, any, any>;
|
|
7
6
|
declare function search(index: Generator<IndexEntry>, language: DocsLanguage, query: string, limit?: number): IndexEntry[];
|
|
8
7
|
//#endregion
|
|
9
8
|
export { buildIndex, search };
|
package/dist/providers/walker.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as generateIndex } from "../indexer-
|
|
2
|
-
import { n as SearchableAttributes } from "../types-
|
|
1
|
+
import { n as generateIndex } from "../indexer-BDmIxFRi.js";
|
|
2
|
+
import { n as SearchableAttributes } from "../types-DyGUPDP0.js";
|
|
3
3
|
|
|
4
4
|
//#region src/providers/walker.ts
|
|
5
5
|
function buildIndex(spec) {
|