@stainless-api/docs-search 0.1.0-beta.4 → 0.1.0-beta.41
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/context.d.ts +1 -2
- package/dist/context.js +30 -5
- package/dist/index.d.ts +1 -1
- package/dist/index.js +50 -49
- package/dist/indexer.d.ts +35 -0
- package/dist/{indexer-DBU0POrK.js → indexer.js} +10 -9
- package/dist/mcp.d.ts +3 -7
- package/dist/mcp.js +2 -4
- package/dist/providers/algolia.d.ts +3 -4
- package/dist/providers/algolia.js +81 -4
- package/dist/providers/fuse.d.ts +2 -3
- package/dist/providers/fuse.js +3 -5
- package/dist/providers/pagefind.d.ts +1 -1
- package/dist/providers/pagefind.js +19 -3
- package/dist/providers/walker.d.ts +2 -3
- package/dist/providers/walker.js +3 -5
- package/dist/types-O3Jwo7Us.d.ts +1604 -0
- package/dist/types.d.ts +1 -1
- package/dist/types.js +34 -3
- package/package.json +19 -16
- package/dist/algolia-BOY-OcxU.js +0 -83
- package/dist/context-CBTWkDal.js +0 -32
- package/dist/pagefind-Dcn-gjDe.js +0 -15
- package/dist/types-BhJLoaNF.js +0 -35
- package/dist/types-Gg968wOz.d.ts +0 -91
package/dist/types.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { _ as SearchableAttributes, a as IndexProperty, c as QueryKinds, d as ResultRecordType, f as ResultType, g as SearchSettings, h as SearchParams, i as IndexModel, l as QueryKindsType, m as SearchAttributeNames, n as IndexEntry, o as IndexResource, p as RoutableJsonNode, r as IndexMethod, s as ProseIndexEntry, t as GuideResultType, u as ResultData, v as SearchableAttributesChat, y as SearchableAttributesProse } from "./types-
|
|
1
|
+
import { _ as SearchableAttributes, a as IndexProperty, c as QueryKinds, d as ResultRecordType, f as ResultType, g as SearchSettings, h as SearchParams, i as IndexModel, l as QueryKindsType, m as SearchAttributeNames, n as IndexEntry, o as IndexResource, p as RoutableJsonNode, r as IndexMethod, s as ProseIndexEntry, t as GuideResultType, u as ResultData, v as SearchableAttributesChat, y as SearchableAttributesProse } from "./types-O3Jwo7Us.js";
|
|
2
2
|
export { GuideResultType, IndexEntry, IndexMethod, IndexModel, IndexProperty, IndexResource, ProseIndexEntry, QueryKinds, QueryKindsType, ResultData, ResultRecordType, ResultType, RoutableJsonNode, SearchAttributeNames, SearchParams, SearchSettings, SearchableAttributes, SearchableAttributesChat, SearchableAttributesProse };
|
package/dist/types.js
CHANGED
|
@@ -1,3 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
//#region src/types.ts
|
|
2
|
+
const QueryKinds = [
|
|
3
|
+
"all",
|
|
4
|
+
"guide",
|
|
5
|
+
"resource",
|
|
6
|
+
"http_method",
|
|
7
|
+
"model",
|
|
8
|
+
"property"
|
|
9
|
+
];
|
|
10
|
+
const SearchableAttributes = [
|
|
11
|
+
"name",
|
|
12
|
+
"title",
|
|
13
|
+
"ident",
|
|
14
|
+
"Name",
|
|
15
|
+
"qualified",
|
|
16
|
+
"QualifiedName",
|
|
17
|
+
"endpoint",
|
|
18
|
+
"summary",
|
|
19
|
+
"description",
|
|
20
|
+
"docstring"
|
|
21
|
+
];
|
|
22
|
+
const SearchableAttributesChat = [
|
|
23
|
+
"title",
|
|
24
|
+
"name",
|
|
25
|
+
"endpoint",
|
|
26
|
+
"summary",
|
|
27
|
+
"description",
|
|
28
|
+
"qualified",
|
|
29
|
+
"ident",
|
|
30
|
+
"content"
|
|
31
|
+
];
|
|
32
|
+
const SearchableAttributesProse = ["content"];
|
|
33
|
+
//#endregion
|
|
34
|
+
export { QueryKinds, SearchableAttributes, SearchableAttributesChat, SearchableAttributesProse };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stainless-api/docs-search",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.41",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -13,30 +13,33 @@
|
|
|
13
13
|
"react-dom": ">=19.0.0"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@algolia/client-search": "^5.
|
|
17
|
-
"@markdoc/markdoc": "^0.5.
|
|
18
|
-
"cheerio": "^1.
|
|
16
|
+
"@algolia/client-search": "^5.49.2",
|
|
17
|
+
"@markdoc/markdoc": "^0.5.6",
|
|
18
|
+
"cheerio": "^1.2.0",
|
|
19
19
|
"fuse.js": "^7.1.0",
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"@stainless-api/docs-ui": "0.1.0-beta.
|
|
20
|
+
"lucide-react": "^0.577.0",
|
|
21
|
+
"@stainless-api/ui-primitives": "0.1.0-beta.50",
|
|
22
|
+
"@stainless-api/docs-ui": "0.1.0-beta.88"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@types/node": "24.
|
|
26
|
-
"@types/react": "19.2.
|
|
25
|
+
"@types/node": "24.12.0",
|
|
26
|
+
"@types/react": "19.2.14",
|
|
27
27
|
"@types/react-dom": "^19.2.3",
|
|
28
|
-
"dotenv": "17.
|
|
29
|
-
"react": "^19.2.
|
|
30
|
-
"react-dom": "^19.2.
|
|
31
|
-
"tsdown": "^0.
|
|
28
|
+
"dotenv": "17.3.1",
|
|
29
|
+
"react": "^19.2.4",
|
|
30
|
+
"react-dom": "^19.2.4",
|
|
31
|
+
"tsdown": "^0.21.4",
|
|
32
32
|
"typescript": "5.9.3",
|
|
33
|
-
"@stainless/
|
|
34
|
-
"@stainless/
|
|
33
|
+
"@stainless/sdk-json": "^0.1.0-beta.9",
|
|
34
|
+
"@stainless/eslint-config": "0.1.0-beta.1"
|
|
35
35
|
},
|
|
36
36
|
"exports": {
|
|
37
37
|
".": {
|
|
38
38
|
"default": "./dist/index.js"
|
|
39
39
|
},
|
|
40
|
+
"./indexer": {
|
|
41
|
+
"default": "./dist/indexer.js"
|
|
42
|
+
},
|
|
40
43
|
"./context": {
|
|
41
44
|
"default": "./dist/context.js"
|
|
42
45
|
},
|
|
@@ -53,7 +56,7 @@
|
|
|
53
56
|
"scripts": {
|
|
54
57
|
"build": "tsdown",
|
|
55
58
|
"clean": "rm -rf dist",
|
|
56
|
-
"lint": "eslint .",
|
|
59
|
+
"lint": "eslint --flag unstable_native_nodejs_ts_config .",
|
|
57
60
|
"check:types": "tsc --noEmit"
|
|
58
61
|
}
|
|
59
62
|
}
|
package/dist/algolia-BOY-OcxU.js
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { n as generateIndex, t as generateChatIndex } from "./indexer-DBU0POrK.js";
|
|
2
|
-
import { i as SearchableAttributesProse, n as SearchableAttributes, r as SearchableAttributesChat } from "./types-BhJLoaNF.js";
|
|
3
|
-
import { searchClient } from "@algolia/client-search";
|
|
4
|
-
|
|
5
|
-
//#region src/providers/algolia.ts
|
|
6
|
-
async function buildIndex(appId, indexName, writeKey, spec, renderMarkdown) {
|
|
7
|
-
if (!appId || !indexName || !writeKey) return;
|
|
8
|
-
const objects = Array.from(generateIndex(spec, renderMarkdown));
|
|
9
|
-
const client = searchClient(appId, writeKey);
|
|
10
|
-
await client.setSettings({
|
|
11
|
-
indexName,
|
|
12
|
-
indexSettings: {
|
|
13
|
-
highlightPreTag: "<mark>",
|
|
14
|
-
highlightPostTag: "</mark>",
|
|
15
|
-
customRanking: ["asc(priority)"],
|
|
16
|
-
attributesForFaceting: ["language", "kind"],
|
|
17
|
-
searchableAttributes: [...SearchableAttributes]
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
await client.replaceAllObjects({
|
|
21
|
-
indexName,
|
|
22
|
-
objects
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
async function buildChatIndex(appId, indexName, writeKey, spec) {
|
|
26
|
-
if (!appId || !indexName || !writeKey) return;
|
|
27
|
-
const objects = Array.from(generateChatIndex(spec));
|
|
28
|
-
const client = searchClient(appId, writeKey);
|
|
29
|
-
await client.setSettings({
|
|
30
|
-
indexName,
|
|
31
|
-
indexSettings: {
|
|
32
|
-
attributesForFaceting: ["language"],
|
|
33
|
-
attributeForDistinct: "stainlessPath",
|
|
34
|
-
searchableAttributes: SearchableAttributesChat
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
await client.replaceAllObjects({
|
|
38
|
-
indexName,
|
|
39
|
-
objects
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
async function buildProseIndex(appId, indexName, writeKey, objects) {
|
|
43
|
-
if (!appId || !indexName || !writeKey) return;
|
|
44
|
-
const client = searchClient(appId, writeKey);
|
|
45
|
-
await client.setSettings({
|
|
46
|
-
indexName,
|
|
47
|
-
indexSettings: { searchableAttributes: SearchableAttributesProse }
|
|
48
|
-
});
|
|
49
|
-
await client.replaceAllObjects({
|
|
50
|
-
indexName,
|
|
51
|
-
objects
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
async function search({ settings: { appId, indexName, searchKey }, params: { query, language, kind } }) {
|
|
55
|
-
const client = searchClient(appId, searchKey);
|
|
56
|
-
const filters = language ? `language:${language}` : void 0;
|
|
57
|
-
const facetFilters = kind ? [`kind:${kind}`] : void 0;
|
|
58
|
-
const { results } = await client.search({ requests: [{
|
|
59
|
-
query,
|
|
60
|
-
indexName,
|
|
61
|
-
filters,
|
|
62
|
-
hitsPerPage: 5,
|
|
63
|
-
facets: ["kind"]
|
|
64
|
-
}, {
|
|
65
|
-
query,
|
|
66
|
-
indexName,
|
|
67
|
-
filters,
|
|
68
|
-
facetFilters,
|
|
69
|
-
facets: ["kind"],
|
|
70
|
-
hitsPerPage: 50
|
|
71
|
-
}] });
|
|
72
|
-
if ("hits" in results[0] && "hits" in results[1]) {
|
|
73
|
-
const [{ nbHits, facets }, { hits }] = results;
|
|
74
|
-
return {
|
|
75
|
-
hits,
|
|
76
|
-
nbHits: nbHits ?? 0,
|
|
77
|
-
facets
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
//#endregion
|
|
83
|
-
export { search as i, buildIndex as n, buildProseIndex as r, buildChatIndex as t };
|
package/dist/context-CBTWkDal.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { i as search } from "./algolia-BOY-OcxU.js";
|
|
2
|
-
import * as React from "react";
|
|
3
|
-
import { jsx } from "react/jsx-runtime";
|
|
4
|
-
|
|
5
|
-
//#region src/context.tsx
|
|
6
|
-
function createStrictContext(displayName) {
|
|
7
|
-
const Context = React.createContext(null);
|
|
8
|
-
Context.displayName = displayName;
|
|
9
|
-
function useStrictContext() {
|
|
10
|
-
const context = React.useContext(Context);
|
|
11
|
-
if (context === null) throw new Error(`use${displayName} must be used within a ${displayName}Provider`);
|
|
12
|
-
return context;
|
|
13
|
-
}
|
|
14
|
-
return [Context.Provider, useStrictContext];
|
|
15
|
-
}
|
|
16
|
-
const [Provider, useSearchContext] = createStrictContext("SearchContext");
|
|
17
|
-
function useSearch() {
|
|
18
|
-
const { settings } = useSearchContext();
|
|
19
|
-
return (params) => search({
|
|
20
|
-
settings,
|
|
21
|
-
params
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
function SearchProvider({ children, ...props }) {
|
|
25
|
-
return /* @__PURE__ */ jsx(Provider, {
|
|
26
|
-
value: props,
|
|
27
|
-
children
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
//#endregion
|
|
32
|
-
export { useSearch as n, useSearchContext as r, SearchProvider as t };
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
//#region src/providers/pagefind.ts
|
|
2
|
-
async function loadPagefind(path) {
|
|
3
|
-
return await import(new URL(path, import.meta.url).href);
|
|
4
|
-
}
|
|
5
|
-
async function guideSearch(loadPath, query, limit) {
|
|
6
|
-
const response = await (await loadPagefind(loadPath)).search(query);
|
|
7
|
-
const items = limit ? response.results.slice(0, limit) : response.results;
|
|
8
|
-
return Promise.all(items.map((result) => result.data().then((data) => ({
|
|
9
|
-
...result,
|
|
10
|
-
data
|
|
11
|
-
}))));
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
//#endregion
|
|
15
|
-
export { guideSearch as t };
|
package/dist/types-BhJLoaNF.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
//#region src/types.ts
|
|
2
|
-
const QueryKinds = [
|
|
3
|
-
"all",
|
|
4
|
-
"resource",
|
|
5
|
-
"http_method",
|
|
6
|
-
"model",
|
|
7
|
-
"property",
|
|
8
|
-
"guide"
|
|
9
|
-
];
|
|
10
|
-
const SearchableAttributes = [
|
|
11
|
-
"name",
|
|
12
|
-
"title",
|
|
13
|
-
"ident",
|
|
14
|
-
"Name",
|
|
15
|
-
"qualified",
|
|
16
|
-
"QualifiedName",
|
|
17
|
-
"endpoint",
|
|
18
|
-
"summary",
|
|
19
|
-
"description",
|
|
20
|
-
"docstring"
|
|
21
|
-
];
|
|
22
|
-
const SearchableAttributesChat = [
|
|
23
|
-
"title",
|
|
24
|
-
"name",
|
|
25
|
-
"endpoint",
|
|
26
|
-
"summary",
|
|
27
|
-
"description",
|
|
28
|
-
"qualified",
|
|
29
|
-
"ident",
|
|
30
|
-
"content"
|
|
31
|
-
];
|
|
32
|
-
const SearchableAttributesProse = ["content"];
|
|
33
|
-
|
|
34
|
-
//#endregion
|
|
35
|
-
export { SearchableAttributesProse as i, SearchableAttributes as n, SearchableAttributesChat as r, QueryKinds as t };
|
package/dist/types-Gg968wOz.d.ts
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import { DocsLanguage } from "@stainless-api/docs-ui/routing";
|
|
2
|
-
import * as SDKJSON from "@stainless/sdk-json";
|
|
3
|
-
|
|
4
|
-
//#region src/types.d.ts
|
|
5
|
-
type SearchSettings = {
|
|
6
|
-
appId: string;
|
|
7
|
-
searchKey: string;
|
|
8
|
-
indexName: string;
|
|
9
|
-
assistant?: string;
|
|
10
|
-
};
|
|
11
|
-
type SearchParams = {
|
|
12
|
-
query: string;
|
|
13
|
-
language?: DocsLanguage | null;
|
|
14
|
-
kind?: QueryKindsType | null;
|
|
15
|
-
};
|
|
16
|
-
declare const QueryKinds: readonly ["all", "resource", "http_method", "model", "property", "guide"];
|
|
17
|
-
type QueryKindsType = (typeof QueryKinds)[number];
|
|
18
|
-
type IndexModel = {
|
|
19
|
-
kind: 'model';
|
|
20
|
-
title: string;
|
|
21
|
-
children?: string[];
|
|
22
|
-
ident?: string;
|
|
23
|
-
};
|
|
24
|
-
type IndexProperty = {
|
|
25
|
-
kind: 'property';
|
|
26
|
-
docstring?: string;
|
|
27
|
-
type?: string;
|
|
28
|
-
};
|
|
29
|
-
type IndexResource = {
|
|
30
|
-
kind: 'resource';
|
|
31
|
-
title: string;
|
|
32
|
-
Name: string;
|
|
33
|
-
QualifiedName: string;
|
|
34
|
-
};
|
|
35
|
-
type IndexMethod = Pick<SDKJSON.Method, 'kind' | 'summary' | 'description' | 'endpoint' | 'httpMethod'> & {
|
|
36
|
-
title: string;
|
|
37
|
-
qualified?: string;
|
|
38
|
-
ident?: string;
|
|
39
|
-
};
|
|
40
|
-
declare const SearchableAttributes: readonly ["name", "title", "ident", "Name", "qualified", "QualifiedName", "endpoint", "summary", "description", "docstring"];
|
|
41
|
-
declare const SearchableAttributesChat: string[];
|
|
42
|
-
declare const SearchableAttributesProse: string[];
|
|
43
|
-
type SearchAttributeNames = (typeof SearchableAttributes)[number];
|
|
44
|
-
type RoutableJsonNode = SDKJSON.Method | SDKJSON.Model | SDKJSON.Resource;
|
|
45
|
-
type IndexEntry = Pick<RoutableJsonNode, 'name' | 'stainlessPath'> & (IndexProperty | IndexModel | IndexResource | IndexMethod) & {
|
|
46
|
-
language: DocsLanguage;
|
|
47
|
-
priority: number;
|
|
48
|
-
crumbs: string[];
|
|
49
|
-
};
|
|
50
|
-
type ResultRecordType = IndexEntry & {
|
|
51
|
-
objectID: string;
|
|
52
|
-
_highlightResult: Record<SearchAttributeNames, {
|
|
53
|
-
value: string;
|
|
54
|
-
}>;
|
|
55
|
-
};
|
|
56
|
-
type ResultType = {
|
|
57
|
-
hits: ResultRecordType[];
|
|
58
|
-
facets?: Record<string, Record<string, number>>;
|
|
59
|
-
nbHits: number;
|
|
60
|
-
};
|
|
61
|
-
type GuideResultType = {
|
|
62
|
-
id: string;
|
|
63
|
-
score: number;
|
|
64
|
-
words: number[];
|
|
65
|
-
data: {
|
|
66
|
-
excerpt: string;
|
|
67
|
-
url: string;
|
|
68
|
-
word_count: number;
|
|
69
|
-
meta: {
|
|
70
|
-
title: string;
|
|
71
|
-
};
|
|
72
|
-
sub_results: {
|
|
73
|
-
url: string;
|
|
74
|
-
title: string;
|
|
75
|
-
excerpt: string;
|
|
76
|
-
}[];
|
|
77
|
-
};
|
|
78
|
-
};
|
|
79
|
-
type ResultData = {
|
|
80
|
-
items: Array<ResultRecordType | GuideResultType>;
|
|
81
|
-
counts: Partial<Record<QueryKindsType, number>>;
|
|
82
|
-
};
|
|
83
|
-
type ProseIndexEntry = {
|
|
84
|
-
id?: string;
|
|
85
|
-
tag: string;
|
|
86
|
-
content: string;
|
|
87
|
-
source?: string;
|
|
88
|
-
[additional: string]: unknown;
|
|
89
|
-
};
|
|
90
|
-
//#endregion
|
|
91
|
-
export { SearchableAttributes as _, IndexProperty as a, QueryKinds as c, ResultRecordType as d, ResultType as f, SearchSettings as g, SearchParams as h, IndexModel as i, QueryKindsType as l, SearchAttributeNames as m, IndexEntry as n, IndexResource as o, RoutableJsonNode as p, IndexMethod as r, ProseIndexEntry as s, GuideResultType as t, ResultData as u, SearchableAttributesChat as v, SearchableAttributesProse as y };
|