fumadocs-core
Version:
The React.js library for building a documentation website
133 lines (132 loc) • 4.84 kB
TypeScript
import { n as StructuredData } from "./remark-structure-RZD2gGKp.js";
import { t as I18nConfig } from "./index-Bw-DCOra.js";
import { SortedResult } from "./search/index.js";
import { i as LoaderConfig, o as LoaderOutput, u as Page } from "./index-2U6Tl4--.js";
import { Language, Orama, RawData, SearchParams, TypedDocument, create } from "@orama/orama";
//#region src/search/orama/create-db.d.ts
type SimpleDocument = TypedDocument<Orama<typeof simpleSchema>>;
declare const simpleSchema: {
readonly url: "string";
readonly title: "string";
readonly breadcrumbs: "string[]";
readonly description: "string";
readonly content: "string";
readonly keywords: "string";
};
type AdvancedDocument = TypedDocument<Orama<typeof advancedSchema>>;
declare const advancedSchema: {
readonly content: "string";
readonly page_id: "string";
readonly type: "string";
readonly breadcrumbs: "string[]";
readonly tags: "enum[]";
readonly url: "string";
readonly embeddings: "vector[512]";
};
//#endregion
//#region src/search/orama/create-from-source.d.ts
type Awaitable<T> = T | Promise<T>;
interface Options<C extends LoaderConfig> extends Omit<AdvancedOptions, 'indexes'> {
localeMap?: { [K in C['i18n'] extends I18nConfig<infer Languages> ? Languages : string]?: Partial<AdvancedOptions> | Language };
buildIndex?: (page: Page<C['source']['pageData']>) => Awaitable<AdvancedIndex>;
}
declare function createFromSource<C extends LoaderConfig>(source: LoaderOutput<C>, options?: Options<C>): SearchAPI;
//#endregion
//#region src/search/orama/create-i18n.d.ts
type I18nOptions<O extends SimpleOptions | AdvancedOptions, Idx> = Omit<O, 'language' | 'indexes'> & {
i18n: I18nConfig;
/**
* Map locale name from i18n config to Orama compatible `language` or options
*/
localeMap?: Record<string, Language | Partial<O> | undefined>;
indexes: WithLocale<Idx>[] | Dynamic<WithLocale<Idx>>;
};
type I18nSimpleOptions = I18nOptions<SimpleOptions, Index>;
type I18nAdvancedOptions = I18nOptions<AdvancedOptions, AdvancedIndex>;
type WithLocale<T> = T & {
locale: string;
};
declare function createI18nSearchAPI<T extends 'simple' | 'advanced'>(type: T, options: T extends 'simple' ? I18nSimpleOptions : I18nAdvancedOptions): SearchAPI;
//#endregion
//#region src/search/server.d.ts
type SearchType = 'simple' | 'advanced';
type ExportedData = (RawData & {
type: SearchType;
}) | {
type: 'i18n';
data: Record<string, RawData & {
type: SearchType;
}>;
};
interface SearchServer {
search: (query: string, options?: {
locale?: string;
tag?: string | string[];
mode?: 'vector' | 'full';
}) => Promise<SortedResult[]>;
/**
* Export the database
*
* You can reference the exported database to implement client-side search
*/
export: () => Promise<ExportedData>;
}
interface SearchAPI extends SearchServer {
GET: (request: Request) => Promise<Response>;
/**
* `GET` route handler that exports search indexes for static search.
*/
staticGET: () => Promise<Response>;
}
/**
* Resolve indexes dynamically
*/
type Dynamic<T> = () => T[] | Promise<T[]>;
type OramaInput = Parameters<typeof create>[0];
type SharedOptions = Pick<OramaInput, 'sort' | 'components' | 'plugins'> & {
language?: string;
tokenizer?: Required<OramaInput>['components']['tokenizer'];
};
interface SimpleOptions extends SharedOptions {
indexes: Index[] | Dynamic<Index>;
/**
* Customise search options on server
*/
search?: Partial<SearchParams<Orama<typeof simpleSchema>, SimpleDocument>>;
}
interface AdvancedOptions extends SharedOptions {
indexes: AdvancedIndex[] | Dynamic<AdvancedIndex>;
/**
* Customise search options on server
*/
search?: Partial<SearchParams<Orama<typeof advancedSchema>, AdvancedDocument>>;
}
declare function createSearchAPI<T extends SearchType>(type: T, options: T extends 'simple' ? SimpleOptions : AdvancedOptions): SearchAPI;
interface Index {
title: string;
description?: string;
breadcrumbs?: string[];
content: string;
url: string;
keywords?: string;
}
declare function initSimpleSearch(options: SimpleOptions): SearchServer;
interface AdvancedIndex {
id: string;
title: string;
description?: string;
breadcrumbs?: string[];
/**
* Required if tag filter is enabled
*/
tag?: string | string[];
/**
* preprocess mdx content with `structure`
*/
structuredData: StructuredData;
url: string;
}
declare function initAdvancedSearch(options: AdvancedOptions): SearchServer;
//#endregion
export { Index as a, SimpleOptions as c, initSimpleSearch as d, createI18nSearchAPI as f, ExportedData as i, createSearchAPI as l, AdvancedOptions as n, SearchAPI as o, createFromSource as p, Dynamic as r, SearchServer as s, AdvancedIndex as t, initAdvancedSearch as u };
//# sourceMappingURL=server-CPR_fgkH.d.ts.map