@se-studio/search 0.0.0-next16-20260822103555
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 +1352 -0
- package/README.md +255 -0
- package/dist/api/index.d.ts +2 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/index.js +2 -0
- package/dist/api/index.js.map +1 -0
- package/dist/api/route-handler.d.ts +71 -0
- package/dist/api/route-handler.d.ts.map +1 -0
- package/dist/api/route-handler.js +160 -0
- package/dist/api/route-handler.js.map +1 -0
- package/dist/client/index.d.ts +2 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +2 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/search-client.d.ts +12 -0
- package/dist/client/search-client.d.ts.map +1 -0
- package/dist/client/search-client.js +72 -0
- package/dist/client/search-client.js.map +1 -0
- package/dist/debug.d.ts +2 -0
- package/dist/debug.d.ts.map +1 -0
- package/dist/debug.js +12 -0
- package/dist/debug.js.map +1 -0
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +2 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/useSearch.d.ts +26 -0
- package/dist/hooks/useSearch.d.ts.map +1 -0
- package/dist/hooks/useSearch.js +73 -0
- package/dist/hooks/useSearch.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/indexable-content.d.ts +24 -0
- package/dist/indexable-content.d.ts.map +1 -0
- package/dist/indexable-content.js +2 -0
- package/dist/indexable-content.js.map +1 -0
- package/dist/indexing/article-indexable.d.ts +48 -0
- package/dist/indexing/article-indexable.d.ts.map +1 -0
- package/dist/indexing/article-indexable.js +93 -0
- package/dist/indexing/article-indexable.js.map +1 -0
- package/dist/indexing/content-extractor.d.ts +20 -0
- package/dist/indexing/content-extractor.d.ts.map +1 -0
- package/dist/indexing/content-extractor.js +55 -0
- package/dist/indexing/content-extractor.js.map +1 -0
- package/dist/indexing/document-builder.d.ts +33 -0
- package/dist/indexing/document-builder.d.ts.map +1 -0
- package/dist/indexing/document-builder.js +118 -0
- package/dist/indexing/document-builder.js.map +1 -0
- package/dist/indexing/index.d.ts +7 -0
- package/dist/indexing/index.d.ts.map +1 -0
- package/dist/indexing/index.js +6 -0
- package/dist/indexing/index.js.map +1 -0
- package/dist/indexing/readability.d.ts +14 -0
- package/dist/indexing/readability.d.ts.map +1 -0
- package/dist/indexing/readability.js +45 -0
- package/dist/indexing/readability.js.map +1 -0
- package/dist/indexing/rebuild.d.ts +21 -0
- package/dist/indexing/rebuild.d.ts.map +1 -0
- package/dist/indexing/rebuild.js +141 -0
- package/dist/indexing/rebuild.js.map +1 -0
- package/dist/rate-limit/check.d.ts +19 -0
- package/dist/rate-limit/check.d.ts.map +1 -0
- package/dist/rate-limit/check.js +88 -0
- package/dist/rate-limit/check.js.map +1 -0
- package/dist/rate-limit/index.d.ts +5 -0
- package/dist/rate-limit/index.d.ts.map +1 -0
- package/dist/rate-limit/index.js +4 -0
- package/dist/rate-limit/index.js.map +1 -0
- package/dist/rate-limit/ip.d.ts +5 -0
- package/dist/rate-limit/ip.d.ts.map +1 -0
- package/dist/rate-limit/ip.js +19 -0
- package/dist/rate-limit/ip.js.map +1 -0
- package/dist/rate-limit/memory-store.d.ts +18 -0
- package/dist/rate-limit/memory-store.d.ts.map +1 -0
- package/dist/rate-limit/memory-store.js +35 -0
- package/dist/rate-limit/memory-store.js.map +1 -0
- package/dist/rate-limit/types.d.ts +43 -0
- package/dist/rate-limit/types.d.ts.map +1 -0
- package/dist/rate-limit/types.js +2 -0
- package/dist/rate-limit/types.js.map +1 -0
- package/dist/types.d.ts +122 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/webhook/handler.d.ts +33 -0
- package/dist/webhook/handler.d.ts.map +1 -0
- package/dist/webhook/handler.js +141 -0
- package/dist/webhook/handler.js.map +1 -0
- package/dist/webhook/index.d.ts +2 -0
- package/dist/webhook/index.d.ts.map +1 -0
- package/dist/webhook/index.js +2 -0
- package/dist/webhook/index.js.map +1 -0
- package/docs/llms.md +136 -0
- package/package.json +75 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,EAAE,KAAK,eAAe,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+C,SAAS,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { SearchResult } from '../types';
|
|
2
|
+
export interface UseSearchOptions {
|
|
3
|
+
/** Debounce delay in milliseconds. Default: 300. */
|
|
4
|
+
debounceMs?: number;
|
|
5
|
+
/** Max results per query. Default: 20. */
|
|
6
|
+
limit?: number;
|
|
7
|
+
/** API endpoint path. Default: '/api/search'. */
|
|
8
|
+
apiPath?: string;
|
|
9
|
+
/** Seed the query on first render (e.g. from a URL param). Ignored after mount. */
|
|
10
|
+
initialQuery?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface UseSearchReturn {
|
|
13
|
+
query: string;
|
|
14
|
+
setQuery: (q: string) => void;
|
|
15
|
+
results: SearchResult[];
|
|
16
|
+
isLoading: boolean;
|
|
17
|
+
error: string | null;
|
|
18
|
+
totalCount: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Client-side hook for searching via the app's `/api/search` endpoint.
|
|
22
|
+
* Manages query state, debouncing, loading, and error handling.
|
|
23
|
+
* Apps build their own search UI on top of this hook.
|
|
24
|
+
*/
|
|
25
|
+
export declare function useSearch(options?: UseSearchOptions): UseSearchReturn;
|
|
26
|
+
//# sourceMappingURL=useSearch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSearch.d.ts","sourceRoot":"","sources":["../../src/hooks/useSearch.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAkB,YAAY,EAAE,MAAM,UAAU,CAAC;AAE7D,MAAM,WAAW,gBAAgB;IAC/B,oDAAoD;IACpD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,0CAA0C;IAC1C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iDAAiD;IACjD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,mFAAmF;IACnF,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9B,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,OAAO,CAAC,EAAE,gBAAgB,GAAG,eAAe,CA2ErE"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* Client-side hook for searching via the app's `/api/search` endpoint.
|
|
5
|
+
* Manages query state, debouncing, loading, and error handling.
|
|
6
|
+
* Apps build their own search UI on top of this hook.
|
|
7
|
+
*/
|
|
8
|
+
export function useSearch(options) {
|
|
9
|
+
const debounceMs = options?.debounceMs ?? 300;
|
|
10
|
+
const limit = options?.limit ?? 20;
|
|
11
|
+
const apiPath = options?.apiPath ?? '/api/search';
|
|
12
|
+
const [query, setQuery] = useState(options?.initialQuery ?? '');
|
|
13
|
+
const [results, setResults] = useState([]);
|
|
14
|
+
const [totalCount, setTotalCount] = useState(0);
|
|
15
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
16
|
+
const [error, setError] = useState(null);
|
|
17
|
+
const abortRef = useRef(null);
|
|
18
|
+
const timerRef = useRef(null);
|
|
19
|
+
const executeSearch = useCallback(async (q) => {
|
|
20
|
+
abortRef.current?.abort();
|
|
21
|
+
if (!q.trim()) {
|
|
22
|
+
setResults([]);
|
|
23
|
+
setTotalCount(0);
|
|
24
|
+
setError(null);
|
|
25
|
+
setIsLoading(false);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const controller = new AbortController();
|
|
29
|
+
abortRef.current = controller;
|
|
30
|
+
setIsLoading(true);
|
|
31
|
+
setError(null);
|
|
32
|
+
try {
|
|
33
|
+
const params = new URLSearchParams({ q, limit: String(limit) });
|
|
34
|
+
const res = await fetch(`${apiPath}?${params.toString()}`, {
|
|
35
|
+
signal: controller.signal,
|
|
36
|
+
});
|
|
37
|
+
if (!res.ok) {
|
|
38
|
+
throw new Error(`Search failed (${res.status})`);
|
|
39
|
+
}
|
|
40
|
+
const data = (await res.json());
|
|
41
|
+
setResults(data.results);
|
|
42
|
+
setTotalCount(data.totalCount);
|
|
43
|
+
}
|
|
44
|
+
catch (err) {
|
|
45
|
+
if (err instanceof DOMException && err.name === 'AbortError')
|
|
46
|
+
return;
|
|
47
|
+
setError(err instanceof Error ? err.message : 'Search failed');
|
|
48
|
+
setResults([]);
|
|
49
|
+
setTotalCount(0);
|
|
50
|
+
}
|
|
51
|
+
finally {
|
|
52
|
+
setIsLoading(false);
|
|
53
|
+
}
|
|
54
|
+
}, [limit, apiPath]);
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
if (timerRef.current)
|
|
57
|
+
clearTimeout(timerRef.current);
|
|
58
|
+
timerRef.current = setTimeout(() => {
|
|
59
|
+
executeSearch(query);
|
|
60
|
+
}, debounceMs);
|
|
61
|
+
return () => {
|
|
62
|
+
if (timerRef.current)
|
|
63
|
+
clearTimeout(timerRef.current);
|
|
64
|
+
};
|
|
65
|
+
}, [query, debounceMs, executeSearch]);
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
return () => {
|
|
68
|
+
abortRef.current?.abort();
|
|
69
|
+
};
|
|
70
|
+
}, []);
|
|
71
|
+
return { query, setQuery, results, isLoading, error, totalCount };
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=useSearch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSearch.js","sourceRoot":"","sources":["../../src/hooks/useSearch.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAuBjE;;;;GAIG;AACH,MAAM,UAAU,SAAS,CAAC,OAA0B;IAClD,MAAM,UAAU,GAAG,OAAO,EAAE,UAAU,IAAI,GAAG,CAAC;IAC9C,MAAM,KAAK,GAAG,OAAO,EAAE,KAAK,IAAI,EAAE,CAAC;IACnC,MAAM,OAAO,GAAG,OAAO,EAAE,OAAO,IAAI,aAAa,CAAC;IAElD,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,OAAO,EAAE,YAAY,IAAI,EAAE,CAAC,CAAC;IAChE,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAiB,EAAE,CAAC,CAAC;IAC3D,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IAChD,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAClD,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAgB,IAAI,CAAC,CAAC;IAExD,MAAM,QAAQ,GAAG,MAAM,CAAyB,IAAI,CAAC,CAAC;IACtD,MAAM,QAAQ,GAAG,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BAAE,OAAO;YACrE,QAAQ,CAAC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC;YAC/D,UAAU,CAAC,EAAE,CAAC,CAAC;YACf,aAAa,CAAC,CAAC,CAAC,CAAC;QACnB,CAAC;gBAAS,CAAC;YACT,YAAY,CAAC,KAAK,CAAC,CAAC;QACtB,CAAC;IACH,CAAC,EACD,CAAC,KAAK,EAAE,OAAO,CAAC,CACjB,CAAC;IAEF,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,QAAQ,CAAC,OAAO;YAAE,YAAY,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QAErD,QAAQ,CAAC,OAAO,GAAG,UAAU,CAAC,GAAG,EAAE;YACjC,aAAa,CAAC,KAAK,CAAC,CAAC;QACvB,CAAC,EAAE,UAAU,CAAC,CAAC;QAEf,OAAO,GAAG,EAAE;YACV,IAAI,QAAQ,CAAC,OAAO;gBAAE,YAAY,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QACvD,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,EAAE,aAAa,CAAC,CAAC,CAAC;IAEvC,SAAS,CAAC,GAAG,EAAE;QACb,OAAO,GAAG,EAAE;YACV,QAAQ,CAAC,OAAO,EAAE,KAAK,EAAE,CAAC;QAC5B,CAAC,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC;AACpE,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export type { ContentData } from '@se-studio/markdown-renderer/converter';
|
|
2
|
+
export type { IIndexableContent } from './indexable-content';
|
|
3
|
+
export type { ContentTypeIndexConfig, RebuildResult, SearchableContentType, SearchConfig, SearchDocument, SearchDocumentMetadata, SearchIndexConfig, SearchIndexingConfig, SearchOptions, SearchResponse, SearchResult, } from './types';
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,WAAW,EAAE,MAAM,wCAAwC,CAAC;AAC1E,YAAY,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,YAAY,EACV,sBAAsB,EACtB,aAAa,EACb,qBAAqB,EACrB,YAAY,EACZ,cAAc,EACd,sBAAsB,EACtB,iBAAiB,EACjB,oBAAoB,EACpB,aAAa,EACb,cAAc,EACd,YAAY,GACb,MAAM,SAAS,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flat document shape for building non-Upstash indexes (e.g. Lunr, blob-stored indexes).
|
|
3
|
+
* Use {@link SearchDocument} / {@link SearchDocumentMetadata} for Upstash Search instead.
|
|
4
|
+
*
|
|
5
|
+
* **href** must be the full path as used in `<a href>` (e.g. `/insights/my-article`), not a
|
|
6
|
+
* bare slug — URL topology must not be inferred from `slug` + `contentType` at query time.
|
|
7
|
+
*/
|
|
8
|
+
export interface IIndexableContent {
|
|
9
|
+
id: string;
|
|
10
|
+
/** Full canonical path for links, e.g. `/insights/my-article` */
|
|
11
|
+
href: string;
|
|
12
|
+
/** Logical type label (app-defined); e.g. `article`, `page`, `person` */
|
|
13
|
+
contentType: string;
|
|
14
|
+
title: string;
|
|
15
|
+
/** Plain-text body used for full-text indexing */
|
|
16
|
+
content: string;
|
|
17
|
+
/** Optional bare slug for tokenisation or legacy callers */
|
|
18
|
+
slug?: string;
|
|
19
|
+
date?: string;
|
|
20
|
+
tags?: string[];
|
|
21
|
+
author?: string;
|
|
22
|
+
metadata: Record<string, unknown>;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=indexable-content.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"indexable-content.d.ts","sourceRoot":"","sources":["../src/indexable-content.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,iEAAiE;IACjE,IAAI,EAAE,MAAM,CAAC;IACb,yEAAyE;IACzE,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,kDAAkD;IAClD,OAAO,EAAE,MAAM,CAAC;IAChB,4DAA4D;IAC5D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"indexable-content.js","sourceRoot":"","sources":["../src/indexable-content.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { type IArticleLink } from '@se-studio/core-data-types';
|
|
2
|
+
import { type ContentData, type IMarkdownExporter, type MarkdownConverterContext } from '@se-studio/markdown-renderer/converter';
|
|
3
|
+
import type { IIndexableContent } from '../indexable-content';
|
|
4
|
+
/** Same fields as {@link MarkdownConverterContext} except `contentContext` (supplied per fetch). */
|
|
5
|
+
export type ArticleMarkdownConverterParams = Omit<MarkdownConverterContext, 'contentContext'>;
|
|
6
|
+
export interface ArticleIndexableHooks {
|
|
7
|
+
/**
|
|
8
|
+
* Return false to skip a link. Defaults to {@link defaultShouldIndexArticleLink}
|
|
9
|
+
* when omitted.
|
|
10
|
+
*/
|
|
11
|
+
shouldIndexArticleLink?(link: IArticleLink): boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Override plain body after markdown conversion (e.g. custom truncation).
|
|
14
|
+
*/
|
|
15
|
+
mapPlainTextBody?(link: IArticleLink, plainText: string, contentData: ContentData | null): string;
|
|
16
|
+
/**
|
|
17
|
+
* Build metadata beyond defaults (`originalType`, `readingTime`, `link`).
|
|
18
|
+
*/
|
|
19
|
+
buildMetadata?(link: IArticleLink, plainTextBody: string, contentData: ContentData | null): Record<string, unknown>;
|
|
20
|
+
}
|
|
21
|
+
export interface IndexArticleLinksOptions {
|
|
22
|
+
exporter: IMarkdownExporter;
|
|
23
|
+
/**
|
|
24
|
+
* Passed into each `MarkdownConverter.convert()` together with `contentData.context`
|
|
25
|
+
* from `fetchContent` (the entry-specific context is required for correct markdown).
|
|
26
|
+
*/
|
|
27
|
+
markdownContext: ArticleMarkdownConverterParams;
|
|
28
|
+
/**
|
|
29
|
+
* Passed to `fetchContent('article', slug, { articleType })` when `link.articleType?.slug`
|
|
30
|
+
* is missing — mirrors {@link rebuildSearchIndex} (`blog` fallback in rebuild).
|
|
31
|
+
*/
|
|
32
|
+
defaultArticleTypeSlug?: string;
|
|
33
|
+
/** Label stored on each `IIndexableContent.contentType` (default: `article`). */
|
|
34
|
+
indexableContentType?: string;
|
|
35
|
+
hooks?: ArticleIndexableHooks;
|
|
36
|
+
onProgress?: (current: number, total: number, itemName: string) => Promise<void>;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Default article link filter: internal paths only, no download articles.
|
|
40
|
+
*/
|
|
41
|
+
export declare function defaultShouldIndexArticleLink(link: IArticleLink): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Builds {@link IIndexableContent} for each article link using **one**
|
|
44
|
+
* `MarkdownExporter.fetchContent()` call per article (avoids Contentful `includes` truncation
|
|
45
|
+
* from batched entry queries).
|
|
46
|
+
*/
|
|
47
|
+
export declare function indexArticleLinksToIndexableContent(links: readonly IArticleLink[], options: IndexArticleLinksOptions): Promise<IIndexableContent[]>;
|
|
48
|
+
//# sourceMappingURL=article-indexable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"article-indexable.d.ts","sourceRoot":"","sources":["../../src/indexing/article-indexable.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,YAAY,EAElB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,KAAK,WAAW,EAEhB,KAAK,iBAAiB,EAEtB,KAAK,wBAAwB,EAC9B,MAAM,wCAAwC,CAAC;AAChD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAG9D,oGAAoG;AACpG,MAAM,MAAM,8BAA8B,GAAG,IAAI,CAAC,wBAAwB,EAAE,gBAAgB,CAAC,CAAC;AAE9F,MAAM,WAAW,qBAAqB;IACpC;;;OAGG;IACH,sBAAsB,CAAC,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC;IACrD;;OAEG;IACH,gBAAgB,CAAC,CAAC,IAAI,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,WAAW,GAAG,IAAI,GAAG,MAAM,CAAC;IAClG;;OAEG;IACH,aAAa,CAAC,CACZ,IAAI,EAAE,YAAY,EAClB,aAAa,EAAE,MAAM,EACrB,WAAW,EAAE,WAAW,GAAG,IAAI,GAC9B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC5B;AAED,MAAM,WAAW,wBAAwB;IACvC,QAAQ,EAAE,iBAAiB,CAAC;IAC5B;;;OAGG;IACH,eAAe,EAAE,8BAA8B,CAAC;IAChD;;;OAGG;IACH,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,iFAAiF;IACjF,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,KAAK,CAAC,EAAE,qBAAqB,CAAC;IAC9B,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAClF;AAgBD;;GAEG;AACH,wBAAgB,6BAA6B,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAQzE;AAMD;;;;GAIG;AACH,wBAAsB,mCAAmC,CACvD,KAAK,EAAE,SAAS,YAAY,EAAE,EAC9B,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,iBAAiB,EAAE,CAAC,CA0E9B"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { formatArticleAuthorNames, } from '@se-studio/core-data-types';
|
|
2
|
+
import { cleanMarkdownText, MarkdownConverter, } from '@se-studio/markdown-renderer/converter';
|
|
3
|
+
import { calculateReadingTime, stripMarkdownToPlainText } from './readability';
|
|
4
|
+
function tagTitle(t) {
|
|
5
|
+
return t.title ?? t.name ?? t.slug ?? '';
|
|
6
|
+
}
|
|
7
|
+
function defaultTags(link) {
|
|
8
|
+
const raw = link.tags ?? [];
|
|
9
|
+
const names = raw.map(tagTitle).filter(Boolean);
|
|
10
|
+
return names.length > 0 ? names : ['article'];
|
|
11
|
+
}
|
|
12
|
+
function defaultAuthor(link) {
|
|
13
|
+
return formatArticleAuthorNames(link);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Default article link filter: internal paths only, no download articles.
|
|
17
|
+
*/
|
|
18
|
+
export function defaultShouldIndexArticleLink(link) {
|
|
19
|
+
if (!link.href || link.href.startsWith('http')) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
if (link.download) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
function resolveArticleTypeSlug(link, fallback) {
|
|
28
|
+
return link.articleType?.slug ?? fallback;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Builds {@link IIndexableContent} for each article link using **one**
|
|
32
|
+
* `MarkdownExporter.fetchContent()` call per article (avoids Contentful `includes` truncation
|
|
33
|
+
* from batched entry queries).
|
|
34
|
+
*/
|
|
35
|
+
export async function indexArticleLinksToIndexableContent(links, options) {
|
|
36
|
+
const { exporter, markdownContext, defaultArticleTypeSlug = 'blog', indexableContentType = 'article', hooks, onProgress, } = options;
|
|
37
|
+
const shouldIndex = hooks?.shouldIndexArticleLink ?? defaultShouldIndexArticleLink;
|
|
38
|
+
const converter = new MarkdownConverter();
|
|
39
|
+
const results = [];
|
|
40
|
+
const indexable = links.filter((l) => shouldIndex(l));
|
|
41
|
+
const total = indexable.length;
|
|
42
|
+
let current = 0;
|
|
43
|
+
for (const link of indexable) {
|
|
44
|
+
current++;
|
|
45
|
+
const articleType = resolveArticleTypeSlug(link, defaultArticleTypeSlug);
|
|
46
|
+
let contentData = null;
|
|
47
|
+
try {
|
|
48
|
+
contentData = await exporter.fetchContent('article', link.slug, { articleType });
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
contentData = null;
|
|
52
|
+
}
|
|
53
|
+
let plainBody = '';
|
|
54
|
+
if (contentData) {
|
|
55
|
+
const markdown = converter.convert(contentData, {
|
|
56
|
+
...markdownContext,
|
|
57
|
+
contentContext: contentData.context,
|
|
58
|
+
});
|
|
59
|
+
plainBody = stripMarkdownToPlainText(cleanMarkdownText(markdown));
|
|
60
|
+
}
|
|
61
|
+
if (hooks?.mapPlainTextBody) {
|
|
62
|
+
plainBody = hooks.mapPlainTextBody(link, plainBody, contentData);
|
|
63
|
+
}
|
|
64
|
+
const readingMinutes = plainBody.trim() ? calculateReadingTime(plainBody) : undefined;
|
|
65
|
+
const tagNames = defaultTags(link);
|
|
66
|
+
const authorName = defaultAuthor(link);
|
|
67
|
+
const baseMeta = {
|
|
68
|
+
originalType: 'article',
|
|
69
|
+
link: link.href,
|
|
70
|
+
...(readingMinutes !== undefined ? { readingTime: `${readingMinutes} min read` } : {}),
|
|
71
|
+
};
|
|
72
|
+
const metadata = hooks?.buildMetadata
|
|
73
|
+
? { ...baseMeta, ...hooks.buildMetadata(link, plainBody, contentData) }
|
|
74
|
+
: baseMeta;
|
|
75
|
+
results.push({
|
|
76
|
+
id: link.id,
|
|
77
|
+
href: link.href,
|
|
78
|
+
contentType: indexableContentType,
|
|
79
|
+
title: link.title ?? link.text ?? '',
|
|
80
|
+
content: plainBody,
|
|
81
|
+
slug: link.slug,
|
|
82
|
+
date: link.date ?? undefined,
|
|
83
|
+
tags: tagNames,
|
|
84
|
+
author: authorName,
|
|
85
|
+
metadata,
|
|
86
|
+
});
|
|
87
|
+
if (onProgress) {
|
|
88
|
+
await onProgress(current, total, link.title ?? link.text ?? '');
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return results;
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=article-indexable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"article-indexable.js","sourceRoot":"","sources":["../../src/indexing/article-indexable.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,GAGzB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAEL,iBAAiB,EAEjB,iBAAiB,GAElB,MAAM,wCAAwC,CAAC;AAEhD,OAAO,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AA2C/E,SAAS,QAAQ,CAAC,CAAW;IAC3B,OAAO,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC;AAC3C,CAAC;AAED,SAAS,WAAW,CAAC,IAAkB;IACrC,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,IAAI,EAAE,CAAC;IAC5B,MAAM,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAChD,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;AAChD,CAAC;AAED,SAAS,aAAa,CAAC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AE,WAAW,CAAC,EAAE;YACvE,CAAC,CAAC,QAAQ,CAAC;QAEb,OAAO,CAAC,IAAI,CAAC;YACX,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,WAAW,EAAE,oBAAoB;YACjC,KAAK,EAAE,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,IAAI,IAAI,EAAE;YACpC,OAAO,EAAE,SAAS;YAClB,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,IAAI,EAAE,IAAI,CAAC,IAAI,IAAI,SAAS;YAC5B,IAAI,EAAE,QAAQ;YACd,MAAM,EAAE,UAAU;YAClB,QAAQ;SACT,CAAC,CAAC;QAEH,IAAI,UAAU,EAAE,CAAC;YACf,MAAM,UAAU,CAAC,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;QAClE,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ContentData, MarkdownConverterContext } from '@se-studio/markdown-renderer/converter';
|
|
2
|
+
/**
|
|
3
|
+
* Calculates the maximum body length given the title and description
|
|
4
|
+
* that will also be included in the Upstash content object.
|
|
5
|
+
*/
|
|
6
|
+
export declare function calculateMaxBodyLength(titleLength: number, descriptionLength: number): number;
|
|
7
|
+
/**
|
|
8
|
+
* Converts CMS content to plain text, then splits it into chunks that each
|
|
9
|
+
* fit within `maxCharsPerChunk`, with `CHUNK_OVERLAP` characters of overlap
|
|
10
|
+
* between consecutive chunks for semantic continuity.
|
|
11
|
+
*
|
|
12
|
+
* @returns Array of body strings — one per chunk. Short content returns a single element.
|
|
13
|
+
*/
|
|
14
|
+
export declare function extractSearchableChunks(contentData: ContentData, converterContext: MarkdownConverterContext, maxCharsPerChunk: number): string[];
|
|
15
|
+
/**
|
|
16
|
+
* Extracts a minimal text body from just the title and description
|
|
17
|
+
* (no deep component traversal). Used when `includeComponents` is false.
|
|
18
|
+
*/
|
|
19
|
+
export declare function extractShallowText(title: string, description: string): string;
|
|
20
|
+
//# sourceMappingURL=content-extractor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-extractor.d.ts","sourceRoot":"","sources":["../../src/indexing/content-extractor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,wBAAwB,EAAE,MAAM,wCAAwC,CAAC;AAapG;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,GAAG,MAAM,CAE7F;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,WAAW,EAAE,WAAW,EACxB,gBAAgB,EAAE,wBAAwB,EAC1C,gBAAgB,EAAE,MAAM,GACvB,MAAM,EAAE,CA8BV;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CAE7E"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { cleanMarkdownText, MarkdownConverter } from '@se-studio/markdown-renderer/converter';
|
|
2
|
+
import { debugLog } from '../debug';
|
|
3
|
+
import { stripMarkdownToPlainText } from './readability';
|
|
4
|
+
/** Upstash Search hard limit for total content per document. */
|
|
5
|
+
const UPSTASH_CONTENT_LIMIT = 4096;
|
|
6
|
+
/** Buffer for JSON key names and structural overhead in the content object. */
|
|
7
|
+
const JSON_OVERHEAD = 100;
|
|
8
|
+
const CHUNK_OVERLAP = 300;
|
|
9
|
+
/**
|
|
10
|
+
* Calculates the maximum body length given the title and description
|
|
11
|
+
* that will also be included in the Upstash content object.
|
|
12
|
+
*/
|
|
13
|
+
export function calculateMaxBodyLength(titleLength, descriptionLength) {
|
|
14
|
+
return Math.max(0, UPSTASH_CONTENT_LIMIT - titleLength - descriptionLength - JSON_OVERHEAD);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Converts CMS content to plain text, then splits it into chunks that each
|
|
18
|
+
* fit within `maxCharsPerChunk`, with `CHUNK_OVERLAP` characters of overlap
|
|
19
|
+
* between consecutive chunks for semantic continuity.
|
|
20
|
+
*
|
|
21
|
+
* @returns Array of body strings — one per chunk. Short content returns a single element.
|
|
22
|
+
*/
|
|
23
|
+
export function extractSearchableChunks(contentData, converterContext, maxCharsPerChunk) {
|
|
24
|
+
const converter = new MarkdownConverter();
|
|
25
|
+
const markdown = converter.convert(contentData, converterContext);
|
|
26
|
+
debugLog('extractor', `Markdown length: ${markdown.length} chars`);
|
|
27
|
+
const plainText = stripMarkdownToPlainText(cleanMarkdownText(markdown));
|
|
28
|
+
debugLog('extractor', `Plain text length: ${plainText.length} chars (chunk limit ${maxCharsPerChunk})`);
|
|
29
|
+
if (plainText.length <= maxCharsPerChunk) {
|
|
30
|
+
return [plainText];
|
|
31
|
+
}
|
|
32
|
+
if (maxCharsPerChunk <= CHUNK_OVERLAP || maxCharsPerChunk <= 0) {
|
|
33
|
+
return [plainText.slice(0, Math.max(maxCharsPerChunk, 1))];
|
|
34
|
+
}
|
|
35
|
+
const chunks = [];
|
|
36
|
+
let offset = 0;
|
|
37
|
+
const step = maxCharsPerChunk - CHUNK_OVERLAP;
|
|
38
|
+
while (offset < plainText.length) {
|
|
39
|
+
const chunk = plainText.slice(offset, offset + maxCharsPerChunk);
|
|
40
|
+
chunks.push(chunk);
|
|
41
|
+
offset += step;
|
|
42
|
+
if (offset + CHUNK_OVERLAP >= plainText.length)
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
debugLog('extractor', `Split into ${chunks.length} chunks (overlap ${CHUNK_OVERLAP})`);
|
|
46
|
+
return chunks;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Extracts a minimal text body from just the title and description
|
|
50
|
+
* (no deep component traversal). Used when `includeComponents` is false.
|
|
51
|
+
*/
|
|
52
|
+
export function extractShallowText(title, description) {
|
|
53
|
+
return cleanMarkdownText(`${title}\n${description}`).trim();
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=content-extractor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-extractor.js","sourceRoot":"","sources":["../../src/indexing/content-extractor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAC9F,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAEzD,gEAAgE;AAChE,MAAM,qBAAqB,GAAG,IAAI,CAAC;AAEnC,+EAA+E;AAC/E,MAAM,aAAa,GAAG,GAAG,CAAC;AAE1B,MAAM,aAAa,GAAG,GAAG,CAAC;AAE1B;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CAAC,WAAmB,EAAE,iBAAyB;IACnF,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,qBAAqB,GAAG,WAAW,GAAG,iBAAiB,GAAG,aAAa,CAAC,CAAC;AAC9F,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,uBAAuB,CACrC,WAAwB,EACxB,gBAA0C,EAC1C,gBAAwB;IAExB,MAAM,SAAS,GAAG,IAAI,iBAAiB,EAAE,CAAC;IAC1C,MAAM,QAAQ,GAAG,SAAS,CAAC,OAAO,CAAC,WAAW,EAAE,gBAAgB,CAAC,CAAC;IAClE,QAAQ,CAAC,WAAW,EAAE,oBAAoB,QAAQ,CAAC,MAAM,QAAQ,CAAC,CAAC;IACnE,MAAM,SAAS,GAAG,wBAAwB,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC,CAAC;IACxE,QAAQ,CACN,WAAW,EACX,sBAAsB,SAAS,CAAC,MAAM,uBAAuB,gBAAgB,GAAG,CACjF,CAAC;IAEF,IAAI,SAAS,CAAC,MAAM,IAAI,gBAAgB,EAAE,CAAC;QACzC,OAAO,CAAC,SAAS,CAAC,CAAC;IACrB,CAAC;IACD,IAAI,gBAAgB,IAAI,aAAa,IAAI,gBAAgB,IAAI,CAAC,EAAE,CAAC;QAC/D,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7D,CAAC;IAED,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,MAAM,IAAI,GAAG,gBAAgB,GAAG,aAAa,CAAC;IAE9C,OAAO,MAAM,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC;QACjC,MAAM,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,gBAAgB,CAAC,CAAC;QACjE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACnB,MAAM,IAAI,IAAI,CAAC;QACf,IAAI,MAAM,GAAG,aAAa,IAAI,SAAS,CAAC,MAAM;YAAE,MAAM;IACxD,CAAC;IAED,QAAQ,CAAC,WAAW,EAAE,cAAc,MAAM,CAAC,MAAM,oBAAoB,aAAa,GAAG,CAAC,CAAC;IACvF,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAa,EAAE,WAAmB;IACnE,OAAO,iBAAiB,CAAC,GAAG,KAAK,KAAK,WAAW,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;AAC9D,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { ContentData, MarkdownConverterContext } from '@se-studio/markdown-renderer/converter';
|
|
2
|
+
import type { SearchableContentType, SearchDocument } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Generates the document ID for a given chunk.
|
|
5
|
+
* Chunk 0 uses the bare entry ID for backwards compatibility;
|
|
6
|
+
* subsequent chunks use `{entryId}__chunk_{n}`.
|
|
7
|
+
*/
|
|
8
|
+
export declare function chunkDocumentId(entryId: string, chunkIndex: number): string;
|
|
9
|
+
/**
|
|
10
|
+
* Generates all possible chunk IDs for an entry, used for cleanup on delete/re-publish.
|
|
11
|
+
*/
|
|
12
|
+
export declare function allChunkIds(entryId: string, totalChunks: number): string[];
|
|
13
|
+
/**
|
|
14
|
+
* Extracts the base entry ID from a (possibly chunked) document ID.
|
|
15
|
+
*/
|
|
16
|
+
export declare function baseEntryId(documentId: string): string;
|
|
17
|
+
/**
|
|
18
|
+
* Builds one or more `SearchDocument` chunks from CMS content data.
|
|
19
|
+
* Long content is split into multiple documents with overlapping body text.
|
|
20
|
+
* Short content produces a single document.
|
|
21
|
+
*
|
|
22
|
+
* @returns Array of search documents — one per chunk.
|
|
23
|
+
*/
|
|
24
|
+
export declare function buildSearchDocuments(contentData: ContentData, contentType: SearchableContentType, converterContext: MarkdownConverterContext, includeComponents: boolean): SearchDocument[];
|
|
25
|
+
/**
|
|
26
|
+
* Checks whether a content entry should be included in the search index
|
|
27
|
+
* based on its `indexed` and `hidden` flags.
|
|
28
|
+
*/
|
|
29
|
+
export declare function shouldIndex(data: {
|
|
30
|
+
indexed?: boolean | null;
|
|
31
|
+
hidden?: boolean | null;
|
|
32
|
+
}, respectIndexed: boolean, respectHidden: boolean): boolean;
|
|
33
|
+
//# sourceMappingURL=document-builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document-builder.d.ts","sourceRoot":"","sources":["../../src/indexing/document-builder.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,WAAW,EAAE,wBAAwB,EAAE,MAAM,wCAAwC,CAAC;AAEpG,OAAO,KAAK,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAoDtE;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAE3E;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE,CAE1E;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAGtD;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,WAAW,EAAE,WAAW,EACxB,WAAW,EAAE,qBAAqB,EAClC,gBAAgB,EAAE,wBAAwB,EAC1C,iBAAiB,EAAE,OAAO,GACzB,cAAc,EAAE,CAwClB;AAED;;;GAGG;AACH,wBAAgB,WAAW,CACzB,IAAI,EAAE;IAAE,OAAO,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,GAAG,IAAI,CAAA;CAAE,EAC3D,cAAc,EAAE,OAAO,EACvB,aAAa,EAAE,OAAO,GACrB,OAAO,CAIT"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { formatArticleAuthorNames, } from '@se-studio/core-data-types';
|
|
2
|
+
import { debugLog } from '../debug';
|
|
3
|
+
import { calculateMaxBodyLength, extractSearchableChunks, extractShallowText, } from './content-extractor';
|
|
4
|
+
function getImageUrl(featuredImage) {
|
|
5
|
+
if (!featuredImage?.image)
|
|
6
|
+
return undefined;
|
|
7
|
+
const img = featuredImage.image;
|
|
8
|
+
if (img.type === 'Picture')
|
|
9
|
+
return img.src;
|
|
10
|
+
if (img.type === 'Svg image')
|
|
11
|
+
return img.svgSrc;
|
|
12
|
+
return undefined;
|
|
13
|
+
}
|
|
14
|
+
function getImageAlt(featuredImage) {
|
|
15
|
+
return featuredImage?.image?.name ?? undefined;
|
|
16
|
+
}
|
|
17
|
+
function getImageDimensions(featuredImage) {
|
|
18
|
+
if (!featuredImage?.image)
|
|
19
|
+
return undefined;
|
|
20
|
+
const img = featuredImage.image;
|
|
21
|
+
if ('width' in img && 'height' in img) {
|
|
22
|
+
return { width: img.width, height: img.height };
|
|
23
|
+
}
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
function extractTags(data) {
|
|
27
|
+
const withTags = data;
|
|
28
|
+
if (!withTags.tags || withTags.tags.length === 0)
|
|
29
|
+
return undefined;
|
|
30
|
+
return withTags.tags.map((t) => t.title || t.name || t.slug).filter(Boolean);
|
|
31
|
+
}
|
|
32
|
+
function extractArticleType(data) {
|
|
33
|
+
const article = data;
|
|
34
|
+
return article.articleType?.name ?? article.articleType?.slug ?? undefined;
|
|
35
|
+
}
|
|
36
|
+
function extractAuthor(data) {
|
|
37
|
+
const article = data;
|
|
38
|
+
return formatArticleAuthorNames(article);
|
|
39
|
+
}
|
|
40
|
+
function extractDate(data) {
|
|
41
|
+
const article = data;
|
|
42
|
+
if (article.date)
|
|
43
|
+
return article.date;
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Generates the document ID for a given chunk.
|
|
48
|
+
* Chunk 0 uses the bare entry ID for backwards compatibility;
|
|
49
|
+
* subsequent chunks use `{entryId}__chunk_{n}`.
|
|
50
|
+
*/
|
|
51
|
+
export function chunkDocumentId(entryId, chunkIndex) {
|
|
52
|
+
return chunkIndex === 0 ? entryId : `${entryId}__chunk_${chunkIndex}`;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Generates all possible chunk IDs for an entry, used for cleanup on delete/re-publish.
|
|
56
|
+
*/
|
|
57
|
+
export function allChunkIds(entryId, totalChunks) {
|
|
58
|
+
return Array.from({ length: totalChunks }, (_, i) => chunkDocumentId(entryId, i));
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Extracts the base entry ID from a (possibly chunked) document ID.
|
|
62
|
+
*/
|
|
63
|
+
export function baseEntryId(documentId) {
|
|
64
|
+
const idx = documentId.indexOf('__chunk_');
|
|
65
|
+
return idx === -1 ? documentId : documentId.slice(0, idx);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Builds one or more `SearchDocument` chunks from CMS content data.
|
|
69
|
+
* Long content is split into multiple documents with overlapping body text.
|
|
70
|
+
* Short content produces a single document.
|
|
71
|
+
*
|
|
72
|
+
* @returns Array of search documents — one per chunk.
|
|
73
|
+
*/
|
|
74
|
+
export function buildSearchDocuments(contentData, contentType, converterContext, includeComponents) {
|
|
75
|
+
const data = contentData.data;
|
|
76
|
+
const title = data.title ?? '';
|
|
77
|
+
const description = data.description ?? '';
|
|
78
|
+
const maxBody = calculateMaxBodyLength(title.length, description.length);
|
|
79
|
+
const bodyChunks = includeComponents
|
|
80
|
+
? extractSearchableChunks(contentData, converterContext, maxBody)
|
|
81
|
+
: [extractShallowText(title, description)];
|
|
82
|
+
const totalChunks = bodyChunks.length;
|
|
83
|
+
const imageDimensions = getImageDimensions(data.featuredImage);
|
|
84
|
+
debugLog('builder', `${data.slug}: ${totalChunks} chunk(s) for entry ${data.id}`);
|
|
85
|
+
return bodyChunks.map((body, i) => ({
|
|
86
|
+
id: chunkDocumentId(data.id, i),
|
|
87
|
+
content: { title, description, body },
|
|
88
|
+
metadata: {
|
|
89
|
+
type: contentType,
|
|
90
|
+
slug: data.slug,
|
|
91
|
+
href: data.href,
|
|
92
|
+
tags: extractTags(data),
|
|
93
|
+
articleType: extractArticleType(data),
|
|
94
|
+
date: extractDate(data),
|
|
95
|
+
lastModified: data.lastUpdated?.toString(),
|
|
96
|
+
author: extractAuthor(data),
|
|
97
|
+
imageUrl: getImageUrl(data.featuredImage),
|
|
98
|
+
imageAlt: getImageAlt(data.featuredImage),
|
|
99
|
+
imageWidth: imageDimensions?.width,
|
|
100
|
+
imageHeight: imageDimensions?.height,
|
|
101
|
+
entryId: data.id,
|
|
102
|
+
chunkIndex: i,
|
|
103
|
+
totalChunks,
|
|
104
|
+
},
|
|
105
|
+
}));
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Checks whether a content entry should be included in the search index
|
|
109
|
+
* based on its `indexed` and `hidden` flags.
|
|
110
|
+
*/
|
|
111
|
+
export function shouldIndex(data, respectIndexed, respectHidden) {
|
|
112
|
+
if (respectIndexed && data.indexed === false)
|
|
113
|
+
return false;
|
|
114
|
+
if (respectHidden && data.hidden === true)
|
|
115
|
+
return false;
|
|
116
|
+
return true;
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=document-builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document-builder.js","sourceRoot":"","sources":["../../src/indexing/document-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,GAOzB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEpC,OAAO,EACL,sBAAsB,EACtB,uBAAuB,EACvB,kBAAkB,GACnB,MAAM,qBAAqB,CAAC;AAE7B,SAAS,WAAW,CAAC,aAAkC;IACrD,IAAI,CAAC,aAAa,EAAE,KAAK;QAAE,OAAO,SAAS,CAAC;IAC5C,MAAM,GAAG,GAAG,aAAa,CAAC,KAAK,CAAC;IAChC,IAAI,GAAG,CAAC,IAAI,KAAK,SAAS;QAAE,OAAQ,GAAgB,CAAC,GAAG,CAAC;IACzD,IAAI,GAAG,CAAC,IAAI,KAAK,WAAW;QAAE,OAAQ,GAAiB,CAAC,MAAM,CAAC;IAC/D,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,WAAW,CAAC,aAAkC;IACrD,OAAO,aAAa,EAAE,KAAK,EAAE,IAAI,IAAI,SAAS,CAAC;AACjD,CAAC;AAED,SAAS,kBAAkB,CACzB,aAAkC;IAElC,IAAI,CAAC,aAAa,EAAE,KAAK;QAAE,OAAO,SAAS,CAAC;IAC5C,MAAM,GAAG,GAAG,aAAa,CAAC,KAAK,CAAC;IAChC,IAAI,OAAO,IAAI,GAAG,IAAI,QAAQ,IAAI,GAAG,EAAE,CAAC;QACtC,OAAO,EAAE,KAAK,EAAE,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC;IAClD,CAAC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C,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;QAC/B,OAAO,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE;QACrC,QAAQ,EAAE;YACR,IAAI,EAAE,WAAW;YACjB,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,IAAI,EAAE,WAAW,CAAC,IAAI,CAAC;YACvB,WAAW,EAAE,kBAAkB,CAAC,IAAI,CAAC;YACrC,IAAI,EAAE,WAAW,CAAC,IAAI,CAAC;YACvB,YAAY,EAAE,IAAI,CAAC,WAAW,EAAE,QAAQ,EAAE;YAC1C,MAAM,EAAE,aAAa,CAAC,IAAI,CAAC;YAC3B,QAAQ,EAAE,WAAW,CAAC,IAAI,CAAC,aAAa,CAAC;YACzC,QAAQ,EAAE,WAAW,CAAC,IAAI,CAAC,aAAa,CAAC;YACzC,UAAU,EAAE,eAAe,EAAE,KAAK;YAClC,WAAW,EAAE,eAAe,EAAE,MAAM;YACpC,OAAO,EAAE,IAAI,CAAC,EAAE;YAChB,UAAU,EAAE,CAAC;YACb,WAAW;SACZ;KACF,CAAC,CACH,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,WAAW,CACzB,IAA2D,EAC3D,cAAuB,EACvB,aAAsB;IAEtB,IAAI,cAAc,IAAI,IAAI,CAAC,OAAO,KAAK,KAAK;QAAE,OAAO,KAAK,CAAC;IAC3D,IAAI,aAAa,IAAI,IAAI,CAAC,MAAM,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IACxD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type { ArticleIndexableHooks, ArticleMarkdownConverterParams, IndexArticleLinksOptions, } from './article-indexable';
|
|
2
|
+
export { defaultShouldIndexArticleLink, indexArticleLinksToIndexableContent, } from './article-indexable';
|
|
3
|
+
export { calculateMaxBodyLength, extractSearchableChunks, extractShallowText, } from './content-extractor';
|
|
4
|
+
export { allChunkIds, baseEntryId, buildSearchDocuments, chunkDocumentId, shouldIndex, } from './document-builder';
|
|
5
|
+
export { calculateReadingTime, DEFAULT_WORDS_PER_MINUTE, stripMarkdownToPlainText, } from './readability';
|
|
6
|
+
export { rebuildSearchIndex } from './rebuild';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/indexing/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,qBAAqB,EACrB,8BAA8B,EAC9B,wBAAwB,GACzB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,6BAA6B,EAC7B,mCAAmC,GACpC,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,sBAAsB,EACtB,uBAAuB,EACvB,kBAAkB,GACnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,WAAW,EACX,WAAW,EACX,oBAAoB,EACpB,eAAe,EACf,WAAW,GACZ,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,oBAAoB,EACpB,wBAAwB,EACxB,wBAAwB,GACzB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { defaultShouldIndexArticleLink, indexArticleLinksToIndexableContent, } from './article-indexable';
|
|
2
|
+
export { calculateMaxBodyLength, extractSearchableChunks, extractShallowText, } from './content-extractor';
|
|
3
|
+
export { allChunkIds, baseEntryId, buildSearchDocuments, chunkDocumentId, shouldIndex, } from './document-builder';
|
|
4
|
+
export { calculateReadingTime, DEFAULT_WORDS_PER_MINUTE, stripMarkdownToPlainText, } from './readability';
|
|
5
|
+
export { rebuildSearchIndex } from './rebuild';
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/indexing/index.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,6BAA6B,EAC7B,mCAAmC,GACpC,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,sBAAsB,EACtB,uBAAuB,EACvB,kBAAkB,GACnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,WAAW,EACX,WAAW,EACX,oBAAoB,EACpB,eAAe,EACf,WAAW,GACZ,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,oBAAoB,EACpB,wBAAwB,EACxB,wBAAwB,GACzB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** Default reading speed for {@link calculateReadingTime}. */
|
|
2
|
+
export declare const DEFAULT_WORDS_PER_MINUTE = 200;
|
|
3
|
+
/**
|
|
4
|
+
* Estimates reading time in minutes from plain text (e.g. after markdown stripping).
|
|
5
|
+
* Empty or whitespace-only input returns `1` (same convention as marketing-site reading time).
|
|
6
|
+
*/
|
|
7
|
+
export declare function calculateReadingTime(text: string, wordsPerMinute?: number): number;
|
|
8
|
+
/**
|
|
9
|
+
* Strip markdown syntax leaving only readable words for search indexing or word counts.
|
|
10
|
+
* Removes frontmatter, heading markers, bold/italic, links (keeping text), images,
|
|
11
|
+
* fenced and inline code, blockquotes, list markers, and horizontal rules.
|
|
12
|
+
*/
|
|
13
|
+
export declare function stripMarkdownToPlainText(markdown: string): string;
|
|
14
|
+
//# sourceMappingURL=readability.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"readability.d.ts","sourceRoot":"","sources":["../../src/indexing/readability.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAC9D,eAAO,MAAM,wBAAwB,MAAM,CAAC;AAE5C;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,MAAM,EACZ,cAAc,GAAE,MAAiC,GAChD,MAAM,CAGR;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CA8BjE"}
|