@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,45 @@
|
|
|
1
|
+
/** Default reading speed for {@link calculateReadingTime}. */
|
|
2
|
+
export 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 function calculateReadingTime(text, wordsPerMinute = DEFAULT_WORDS_PER_MINUTE) {
|
|
8
|
+
const words = text.trim().split(/\s+/).filter(Boolean);
|
|
9
|
+
return Math.max(1, Math.round(words.length / wordsPerMinute));
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Strip markdown syntax leaving only readable words for search indexing or word counts.
|
|
13
|
+
* Removes frontmatter, heading markers, bold/italic, links (keeping text), images,
|
|
14
|
+
* fenced and inline code, blockquotes, list markers, and horizontal rules.
|
|
15
|
+
*/
|
|
16
|
+
export function stripMarkdownToPlainText(markdown) {
|
|
17
|
+
return (markdown
|
|
18
|
+
// Remove YAML frontmatter block
|
|
19
|
+
.replace(/^---[\s\S]*?---\n?/, '')
|
|
20
|
+
// Fenced blocks before inline backticks (avoids corrupting ``` fences)
|
|
21
|
+
.replace(/```[\s\S]*?```/g, '')
|
|
22
|
+
// Remove images before links (order matters)
|
|
23
|
+
.replace(/!\[[^\]]*\]\([^)]+\)/g, '')
|
|
24
|
+
// Remove links, keep display text
|
|
25
|
+
.replace(/\[([^\]]*)\]\([^)]*\)/g, '$1')
|
|
26
|
+
// Remove heading markers
|
|
27
|
+
.replace(/^#{1,6}\s+/gm, '')
|
|
28
|
+
// Remove bold/italic (triple, double, single asterisk/underscore)
|
|
29
|
+
.replace(/\*{1,3}([^*\n]*)\*{1,3}/g, '$1')
|
|
30
|
+
.replace(/_{1,3}([^_\n]*)_{1,3}/g, '$1')
|
|
31
|
+
// Remove inline code backticks
|
|
32
|
+
.replace(/`([^`]+)`/g, '$1')
|
|
33
|
+
// Remove blockquote markers
|
|
34
|
+
.replace(/^>\s*/gm, '')
|
|
35
|
+
// Remove unordered list markers
|
|
36
|
+
.replace(/^[-*+]\s+/gm, '')
|
|
37
|
+
// Remove ordered list markers
|
|
38
|
+
.replace(/^\d+\.\s+/gm, '')
|
|
39
|
+
// Remove horizontal rules
|
|
40
|
+
.replace(/^[-*_]{3,}\s*$/gm, '')
|
|
41
|
+
// Collapse excess whitespace
|
|
42
|
+
.replace(/\n{3,}/g, '\n\n')
|
|
43
|
+
.trim());
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=readability.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"readability.js","sourceRoot":"","sources":["../../src/indexing/readability.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAC9D,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAG,CAAC;AAE5C;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAClC,IAAY,EACZ,iBAAyB,wBAAwB;IAEjD,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACvD,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,cAAc,CAAC,CAAC,CAAC;AAChE,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,wBAAwB,CAAC,QAAgB;IACvD,OAAO,CACL,QAAQ;QACN,gCAAgC;SAC/B,OAAO,CAAC,oBAAoB,EAAE,EAAE,CAAC;QAClC,uEAAuE;SACtE,OAAO,CAAC,iBAAiB,EAAE,EAAE,CAAC;QAC/B,6CAA6C;SAC5C,OAAO,CAAC,uBAAuB,EAAE,EAAE,CAAC;QACrC,kCAAkC;SACjC,OAAO,CAAC,wBAAwB,EAAE,IAAI,CAAC;QACxC,yBAAyB;SACxB,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC;QAC5B,kEAAkE;SACjE,OAAO,CAAC,0BAA0B,EAAE,IAAI,CAAC;SACzC,OAAO,CAAC,wBAAwB,EAAE,IAAI,CAAC;QACxC,+BAA+B;SAC9B,OAAO,CAAC,YAAY,EAAE,IAAI,CAAC;QAC5B,4BAA4B;SAC3B,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC;QACvB,gCAAgC;SAC/B,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC;QAC3B,8BAA8B;SAC7B,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC;QAC3B,0BAA0B;SACzB,OAAO,CAAC,kBAAkB,EAAE,EAAE,CAAC;QAChC,6BAA6B;SAC5B,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC;SAC1B,IAAI,EAAE,CACV,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { BaseConverterContext, ContentfulConfig, FetchOptions, UrlCalculators } from '@se-studio/contentful-rest-api';
|
|
2
|
+
import type { MarkdownItemConverter, SiteConfig } from '@se-studio/markdown-renderer/converter';
|
|
3
|
+
import type { SearchClient } from '../client/search-client';
|
|
4
|
+
import type { RebuildResult, SearchIndexingConfig } from '../types';
|
|
5
|
+
/**
|
|
6
|
+
* Performs a full rebuild of the search index for all configured content types.
|
|
7
|
+
* Enumerates content from Contentful, extracts text, and upserts to Upstash Search.
|
|
8
|
+
*/
|
|
9
|
+
export declare function rebuildSearchIndex(config: {
|
|
10
|
+
client: SearchClient;
|
|
11
|
+
indexName: string;
|
|
12
|
+
indexingConfig: SearchIndexingConfig;
|
|
13
|
+
converterContext: BaseConverterContext;
|
|
14
|
+
contentfulConfig: ContentfulConfig;
|
|
15
|
+
fetchOptions: FetchOptions;
|
|
16
|
+
urlCalculators: UrlCalculators;
|
|
17
|
+
siteConfig: SiteConfig;
|
|
18
|
+
/** Optional custom converters for markdown generation (e.g. for custom data types like 'plan'). */
|
|
19
|
+
customConverters?: Record<string, MarkdownItemConverter>;
|
|
20
|
+
}): Promise<RebuildResult>;
|
|
21
|
+
//# sourceMappingURL=rebuild.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rebuild.d.ts","sourceRoot":"","sources":["../../src/indexing/rebuild.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,gBAAgB,EAChB,YAAY,EACZ,cAAc,EACf,MAAM,gCAAgC,CAAC;AASxC,OAAO,KAAK,EAEV,qBAAqB,EACrB,UAAU,EACX,MAAM,wCAAwC,CAAC;AAChD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAE5D,OAAO,KAAK,EAEV,aAAa,EAEb,oBAAoB,EACrB,MAAM,UAAU,CAAC;AAoIlB;;;GAGG;AACH,wBAAsB,kBAAkB,CAAC,MAAM,EAAE;IAC/C,MAAM,EAAE,YAAY,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,oBAAoB,CAAC;IACrC,gBAAgB,EAAE,oBAAoB,CAAC;IACvC,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,YAAY,EAAE,YAAY,CAAC;IAC3B,cAAc,EAAE,cAAc,CAAC;IAC/B,UAAU,EAAE,UAAU,CAAC;IACvB,mGAAmG;IACnG,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC;CAC1D,GAAG,OAAO,CAAC,aAAa,CAAC,CA4DzB"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { contentfulAllArticleLinks, contentfulAllArticleTypeLinks, contentfulAllPageLinks, contentfulAllPersonLinks, } from '@se-studio/contentful-rest-api';
|
|
2
|
+
import { MarkdownExporter } from '@se-studio/markdown-renderer';
|
|
3
|
+
import { debugLog } from '../debug';
|
|
4
|
+
import { buildSearchDocuments, shouldIndex } from './document-builder';
|
|
5
|
+
function getEnabledConfig(indexingConfig, type) {
|
|
6
|
+
return indexingConfig.contentTypes.find((ct) => ct.type === type && ct.enabled);
|
|
7
|
+
}
|
|
8
|
+
function resolveIncludeComponents(ctConfig, indexingConfig) {
|
|
9
|
+
return ctConfig.includeComponents ?? indexingConfig.indexComponents ?? true;
|
|
10
|
+
}
|
|
11
|
+
async function fetchLinks(type, ctx) {
|
|
12
|
+
const { converterContext, contentfulConfig, fetchOptions } = ctx;
|
|
13
|
+
switch (type) {
|
|
14
|
+
case 'page': {
|
|
15
|
+
const res = await contentfulAllPageLinks(converterContext, contentfulConfig, fetchOptions);
|
|
16
|
+
return res.data;
|
|
17
|
+
}
|
|
18
|
+
case 'article': {
|
|
19
|
+
const res = await contentfulAllArticleLinks(converterContext, contentfulConfig, fetchOptions);
|
|
20
|
+
return res.data;
|
|
21
|
+
}
|
|
22
|
+
case 'articleType': {
|
|
23
|
+
const res = await contentfulAllArticleTypeLinks(converterContext, contentfulConfig, fetchOptions);
|
|
24
|
+
return res.data;
|
|
25
|
+
}
|
|
26
|
+
case 'person': {
|
|
27
|
+
const res = await contentfulAllPersonLinks(converterContext, contentfulConfig, fetchOptions);
|
|
28
|
+
return res.data;
|
|
29
|
+
}
|
|
30
|
+
default:
|
|
31
|
+
return [];
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
async function indexContentType(type, ctx, result) {
|
|
35
|
+
const ctConfig = getEnabledConfig(ctx.indexingConfig, type);
|
|
36
|
+
if (!ctConfig)
|
|
37
|
+
return [];
|
|
38
|
+
const respectIndexed = ctx.indexingConfig.respectIndexedFlag ?? true;
|
|
39
|
+
const respectHidden = ctx.indexingConfig.respectHiddenFlag ?? true;
|
|
40
|
+
const includeComponents = resolveIncludeComponents(ctConfig, ctx.indexingConfig);
|
|
41
|
+
const links = await fetchLinks(type, ctx);
|
|
42
|
+
debugLog('rebuild', `${type}: fetched ${links.length} links`);
|
|
43
|
+
const exporter = new MarkdownExporter(ctx.contentfulConfig, ctx.converterContext, ctx.fetchOptions);
|
|
44
|
+
const documents = [];
|
|
45
|
+
for (const link of links) {
|
|
46
|
+
if (!shouldIndex(link, respectIndexed, respectHidden)) {
|
|
47
|
+
debugLog('rebuild', `${type}/${link.slug}: skipped (indexed/hidden)`);
|
|
48
|
+
result.skipped++;
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
try {
|
|
52
|
+
const articleType = type === 'article' && 'articleType' in link
|
|
53
|
+
? (link.articleType?.slug ?? 'blog')
|
|
54
|
+
: undefined;
|
|
55
|
+
debugLog('rebuild', `${type}/${link.slug}: fetching content...`);
|
|
56
|
+
const contentData = await exporter.fetchContent(type, link.slug, {
|
|
57
|
+
articleType,
|
|
58
|
+
});
|
|
59
|
+
if (!contentData) {
|
|
60
|
+
debugLog('rebuild', `${type}/${link.slug}: no content data returned, skipping`);
|
|
61
|
+
result.skipped++;
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
const docs = buildSearchDocuments(contentData, ctConfig.type, ctx.converterCtx, includeComponents);
|
|
65
|
+
const { documentTransformer } = ctx.indexingConfig;
|
|
66
|
+
const transformedDocs = documentTransformer
|
|
67
|
+
? docs
|
|
68
|
+
.map((doc) => documentTransformer(doc, contentData))
|
|
69
|
+
.filter((doc) => doc !== null)
|
|
70
|
+
: docs;
|
|
71
|
+
debugLog('rebuild', `${type}/${link.slug}: built ${transformedDocs.length} chunk(s)`);
|
|
72
|
+
documents.push(...transformedDocs);
|
|
73
|
+
}
|
|
74
|
+
catch (err) {
|
|
75
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
76
|
+
debugLog('rebuild', `${type}/${link.slug}: ERROR - ${message}`);
|
|
77
|
+
result.errors.push(`${type}/${link.slug}: ${message}`);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
debugLog('rebuild', `${type}: ${documents.length} documents built`);
|
|
81
|
+
return documents;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Performs a full rebuild of the search index for all configured content types.
|
|
85
|
+
* Enumerates content from Contentful, extracts text, and upserts to Upstash Search.
|
|
86
|
+
*/
|
|
87
|
+
export async function rebuildSearchIndex(config) {
|
|
88
|
+
debugLog('rebuild', 'Starting full rebuild', {
|
|
89
|
+
indexName: config.indexName,
|
|
90
|
+
enabledTypes: config.indexingConfig.contentTypes
|
|
91
|
+
.filter((ct) => ct.enabled)
|
|
92
|
+
.map((ct) => ct.type),
|
|
93
|
+
hasUrl: !!config.contentfulConfig,
|
|
94
|
+
});
|
|
95
|
+
const result = { indexed: 0, skipped: 0, errors: [] };
|
|
96
|
+
// Minimal content context for indexing — page-specific fields (article, person, etc.)
|
|
97
|
+
// are not needed since the MarkdownExporter fetches each entry independently.
|
|
98
|
+
const indexingContentContext = {
|
|
99
|
+
pageContext: {},
|
|
100
|
+
current: { type: 'Component', id: '' },
|
|
101
|
+
};
|
|
102
|
+
const converterCtx = {
|
|
103
|
+
contentContext: indexingContentContext,
|
|
104
|
+
config: config.contentfulConfig,
|
|
105
|
+
siteConfig: config.siteConfig,
|
|
106
|
+
urlCalculators: config.urlCalculators,
|
|
107
|
+
primaryTagSelector: config.converterContext?.primaryTagSelector,
|
|
108
|
+
customConverters: config.customConverters,
|
|
109
|
+
};
|
|
110
|
+
const ctx = {
|
|
111
|
+
client: config.client,
|
|
112
|
+
indexName: config.indexName,
|
|
113
|
+
converterContext: config.converterContext,
|
|
114
|
+
contentfulConfig: config.contentfulConfig,
|
|
115
|
+
fetchOptions: config.fetchOptions,
|
|
116
|
+
converterCtx,
|
|
117
|
+
indexingConfig: config.indexingConfig,
|
|
118
|
+
};
|
|
119
|
+
const contentTypes = ['page', 'article', 'articleType', 'person'];
|
|
120
|
+
const allDocuments = [];
|
|
121
|
+
for (const type of contentTypes) {
|
|
122
|
+
debugLog('rebuild', `Processing content type: ${type}`);
|
|
123
|
+
const docs = await indexContentType(type, ctx, result);
|
|
124
|
+
allDocuments.push(...docs);
|
|
125
|
+
}
|
|
126
|
+
debugLog('rebuild', `Total documents to upsert: ${allDocuments.length}`);
|
|
127
|
+
try {
|
|
128
|
+
// client.upsert handles batching internally (100 docs per request)
|
|
129
|
+
await config.client.upsert(config.indexName, allDocuments);
|
|
130
|
+
result.indexed = allDocuments.length;
|
|
131
|
+
debugLog('rebuild', `Upserted ${allDocuments.length} docs to "${config.indexName}"`);
|
|
132
|
+
}
|
|
133
|
+
catch (err) {
|
|
134
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
135
|
+
debugLog('rebuild', `Upsert FAILED: ${message}`);
|
|
136
|
+
result.errors.push(`Upsert: ${message}`);
|
|
137
|
+
}
|
|
138
|
+
debugLog('rebuild', 'Rebuild complete', result);
|
|
139
|
+
return result;
|
|
140
|
+
}
|
|
141
|
+
//# sourceMappingURL=rebuild.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rebuild.js","sourceRoot":"","sources":["../../src/indexing/rebuild.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,yBAAyB,EACzB,6BAA6B,EAC7B,sBAAsB,EACtB,wBAAwB,GACzB,MAAM,gCAAgC,CAAC;AAExC,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAOhE,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAOpC,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAYvE,SAAS,gBAAgB,CACvB,cAAoC,EACpC,IAAY;IAEZ,OAAO,cAAc,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,KAAK,IAAI,IAAI,EAAE,CAAC,OAAO,CAAC,CAAC;AAClF,CAAC;AAED,SAAS,wBAAwB,CAC/B,QAAgC,EAChC,cAAoC;IAEpC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|
1
|
+
import type { CheckSearchRateLimitOptions, SearchRateLimitConfig, SearchRateLimitResult } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Resolve max / window from explicit options, then env, then defaults.
|
|
4
|
+
* `SEARCH_RATE_LIMIT_MAX=0` disables limiting.
|
|
5
|
+
*/
|
|
6
|
+
export declare function resolveSearchRateLimitConfig(overrides?: SearchRateLimitConfig): {
|
|
7
|
+
max: number;
|
|
8
|
+
windowMs: number;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Fixed-window rate limit for billable Upstash search queries.
|
|
12
|
+
* Empty-query API paths should call this only after a non-empty `q` is validated.
|
|
13
|
+
*/
|
|
14
|
+
export declare function checkSearchRateLimit(options: CheckSearchRateLimitOptions): Promise<SearchRateLimitResult>;
|
|
15
|
+
/**
|
|
16
|
+
* Build standard rate-limit response headers.
|
|
17
|
+
*/
|
|
18
|
+
export declare function searchRateLimitHeaders(result: SearchRateLimitResult): Record<string, string>;
|
|
19
|
+
//# sourceMappingURL=check.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check.d.ts","sourceRoot":"","sources":["../../src/rate-limit/check.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,2BAA2B,EAC3B,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,SAAS,CAAC;AAYjB;;;GAGG;AACH,wBAAgB,4BAA4B,CAAC,SAAS,CAAC,EAAE,qBAAqB,GAAG;IAC/E,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;CAClB,CASA;AAED;;;GAGG;AACH,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,2BAA2B,GACnC,OAAO,CAAC,qBAAqB,CAAC,CA+ChC;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,qBAAqB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAY5F"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { debugLog } from '../debug';
|
|
2
|
+
import { getSearchClientIp } from './ip';
|
|
3
|
+
import { defaultMemorySearchRateLimitStore } from './memory-store';
|
|
4
|
+
const DEFAULT_MAX = 10;
|
|
5
|
+
const DEFAULT_WINDOW_MS = 60_000;
|
|
6
|
+
function parsePositiveInt(value, fallback) {
|
|
7
|
+
if (value == null || value === '')
|
|
8
|
+
return fallback;
|
|
9
|
+
const n = Number(value);
|
|
10
|
+
if (!Number.isFinite(n) || n < 0)
|
|
11
|
+
return fallback;
|
|
12
|
+
return Math.floor(n);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Resolve max / window from explicit options, then env, then defaults.
|
|
16
|
+
* `SEARCH_RATE_LIMIT_MAX=0` disables limiting.
|
|
17
|
+
*/
|
|
18
|
+
export function resolveSearchRateLimitConfig(overrides) {
|
|
19
|
+
const max = overrides?.max ?? parsePositiveInt(process.env.SEARCH_RATE_LIMIT_MAX, DEFAULT_MAX);
|
|
20
|
+
const windowMs = overrides?.windowMs ??
|
|
21
|
+
parsePositiveInt(process.env.SEARCH_RATE_LIMIT_WINDOW_MS, DEFAULT_WINDOW_MS);
|
|
22
|
+
return {
|
|
23
|
+
max,
|
|
24
|
+
windowMs: windowMs > 0 ? windowMs : DEFAULT_WINDOW_MS,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Fixed-window rate limit for billable Upstash search queries.
|
|
29
|
+
* Empty-query API paths should call this only after a non-empty `q` is validated.
|
|
30
|
+
*/
|
|
31
|
+
export async function checkSearchRateLimit(options) {
|
|
32
|
+
const { max, windowMs } = resolveSearchRateLimitConfig({
|
|
33
|
+
max: options.max,
|
|
34
|
+
windowMs: options.windowMs,
|
|
35
|
+
});
|
|
36
|
+
if (max === 0) {
|
|
37
|
+
return {
|
|
38
|
+
allowed: true,
|
|
39
|
+
limit: 0,
|
|
40
|
+
remaining: Number.POSITIVE_INFINITY,
|
|
41
|
+
retryAfterSeconds: 0,
|
|
42
|
+
resetAt: Date.now(),
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
const namespace = options.namespace ?? 'api';
|
|
46
|
+
const ip = getSearchClientIp(options.request);
|
|
47
|
+
const key = `${namespace}:${ip}`;
|
|
48
|
+
const store = options.store ?? defaultMemorySearchRateLimitStore;
|
|
49
|
+
const { count, resetAt } = await store.hit(key, windowMs);
|
|
50
|
+
const retryAfterSeconds = Math.max(1, Math.ceil((resetAt - Date.now()) / 1000));
|
|
51
|
+
const allowed = count <= max;
|
|
52
|
+
const remaining = allowed ? Math.max(0, max - count) : 0;
|
|
53
|
+
if (!allowed) {
|
|
54
|
+
debugLog('rate-limit', 'Search rate limited', {
|
|
55
|
+
namespace,
|
|
56
|
+
// Truncate IP for logs (still useful, less PII than full dump in some cases)
|
|
57
|
+
ipPrefix: ip.length > 8 ? `${ip.slice(0, 8)}…` : ip,
|
|
58
|
+
count,
|
|
59
|
+
max,
|
|
60
|
+
retryAfterSeconds,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
allowed,
|
|
65
|
+
limit: max,
|
|
66
|
+
remaining,
|
|
67
|
+
retryAfterSeconds: allowed ? 0 : retryAfterSeconds,
|
|
68
|
+
resetAt,
|
|
69
|
+
message: allowed
|
|
70
|
+
? undefined
|
|
71
|
+
: `Rate limited: too many search requests. Try again in ${retryAfterSeconds} seconds.`,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Build standard rate-limit response headers.
|
|
76
|
+
*/
|
|
77
|
+
export function searchRateLimitHeaders(result) {
|
|
78
|
+
const headers = {
|
|
79
|
+
'X-RateLimit-Limit': String(result.limit),
|
|
80
|
+
'X-RateLimit-Remaining': String(Number.isFinite(result.remaining) ? result.remaining : result.limit),
|
|
81
|
+
'X-RateLimit-Reset': String(Math.ceil(result.resetAt / 1000)),
|
|
82
|
+
};
|
|
83
|
+
if (!result.allowed && result.retryAfterSeconds > 0) {
|
|
84
|
+
headers['Retry-After'] = String(result.retryAfterSeconds);
|
|
85
|
+
}
|
|
86
|
+
return headers;
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=check.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check.js","sourceRoot":"","sources":["../../src/rate-limit/check.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AACzC,OAAO,EAAE,iCAAiC,EAAE,MAAM,gBAAgB,CAAC;AAOnE,MAAM,WAAW,GAAG,EAAE,CAAC;AACvB,MAAM,iBAAiB,GAAG,MAAM,CAAC;AAEjC,SAAS,gBAAgB,CAAC,KAAyB,EAAE,QAAgB;IACnE,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,KAAK,EAAE;QAAE,OAAO,QAAQ,CAAC;IACnD,MAAM,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IACxB,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;QAAE,OAAO,QAAQ,CAAC;IAClD,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACvB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,4BAA4B,CAAC,SAAiC;IAI5E,MAAM,GAAG,GAAG,SAAS,EAAE,GAAG,IAAI,gBAAgB,CAAC,OAAO,CAAC,GAAG,CAAC,qBAAqB,EAAE,WAAW,CAAC,CAAC;IAC/F,MAAM,QAAQ,GACZ,SAAS,EAAE,QAAQ;QACnB,gBAAgB,CAAC,OAAO,CAAC,GAAG,CAAC,2BAA2B,EAAE,iBAAiB,CAAC,CAAC;IAC/E,OAAO;QACL,GAAG;QACH,QAAQ,EAAE,QAAQ,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,iBAAiB;KACtD,CAAC;AACJ,CAAC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
|
2
|
+
export { getSearchClientIp } from './ip';
|
|
3
|
+
export { defaultMemorySearchRateLimitStore, MemorySearchRateLimitStore, } from './memory-store';
|
|
4
|
+
export type { CheckSearchRateLimitOptions, SearchRateLimitConfig, SearchRateLimitResult, SearchRateLimitStore, } from './types';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/rate-limit/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,4BAA4B,EAC5B,sBAAsB,GACvB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AACzC,OAAO,EACL,iCAAiC,EACjC,0BAA0B,GAC3B,MAAM,gBAAgB,CAAC;AACxB,YAAY,EACV,2BAA2B,EAC3B,qBAAqB,EACrB,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { checkSearchRateLimit, resolveSearchRateLimitConfig, searchRateLimitHeaders, } from './check';
|
|
2
|
+
export { getSearchClientIp } from './ip';
|
|
3
|
+
export { defaultMemorySearchRateLimitStore, MemorySearchRateLimitStore, } from './memory-store';
|
|
4
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/rate-limit/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,4BAA4B,EAC5B,sBAAsB,GACvB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AACzC,OAAO,EACL,iCAAiC,EACjC,0BAA0B,GAC3B,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ip.d.ts","sourceRoot":"","sources":["../../src/rate-limit/ip.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAc1D"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Best-effort client IP for rate limiting (Vercel / proxies).
|
|
3
|
+
*/
|
|
4
|
+
export function getSearchClientIp(request) {
|
|
5
|
+
const forwarded = request.headers.get('x-forwarded-for');
|
|
6
|
+
if (forwarded) {
|
|
7
|
+
const first = forwarded.split(',')[0]?.trim();
|
|
8
|
+
if (first)
|
|
9
|
+
return first;
|
|
10
|
+
}
|
|
11
|
+
const realIp = request.headers.get('x-real-ip')?.trim();
|
|
12
|
+
if (realIp)
|
|
13
|
+
return realIp;
|
|
14
|
+
const cf = request.headers.get('cf-connecting-ip')?.trim();
|
|
15
|
+
if (cf)
|
|
16
|
+
return cf;
|
|
17
|
+
return 'unknown';
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=ip.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ip.js","sourceRoot":"","sources":["../../src/rate-limit/ip.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAAgB;IAChD,MAAM,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;IACzD,IAAI,SAAS,EAAE,CAAC;QACd,MAAM,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC;QAC9C,IAAI,KAAK;YAAE,OAAO,KAAK,CAAC;IAC1B,CAAC;IAED,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,IAAI,EAAE,CAAC;IACxD,IAAI,MAAM;QAAE,OAAO,MAAM,CAAC;IAE1B,MAAM,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,EAAE,IAAI,EAAE,CAAC;IAC3D,IAAI,EAAE;QAAE,OAAO,EAAE,CAAC;IAElB,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { SearchRateLimitStore } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Process-local fixed-window store. Sufficient for cost control on low
|
|
4
|
+
* instance counts; each Vercel isolate has its own map.
|
|
5
|
+
*/
|
|
6
|
+
export declare class MemorySearchRateLimitStore implements SearchRateLimitStore {
|
|
7
|
+
private readonly windows;
|
|
8
|
+
hit(key: string, windowMs: number): Promise<{
|
|
9
|
+
count: number;
|
|
10
|
+
resetAt: number;
|
|
11
|
+
}>;
|
|
12
|
+
/** Test helper: clear all windows. */
|
|
13
|
+
clear(): void;
|
|
14
|
+
private gc;
|
|
15
|
+
}
|
|
16
|
+
/** Shared default store (API + MCP on the same isolate share memory). */
|
|
17
|
+
export declare const defaultMemorySearchRateLimitStore: MemorySearchRateLimitStore;
|
|
18
|
+
//# sourceMappingURL=memory-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory-store.d.ts","sourceRoot":"","sources":["../../src/rate-limit/memory-store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAOpD;;;GAGG;AACH,qBAAa,0BAA2B,YAAW,oBAAoB;IACrE,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAkC;IAEpD,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAerF,sCAAsC;IACtC,KAAK,IAAI,IAAI;IAIb,OAAO,CAAC,EAAE;CAOX;AAED,yEAAyE;AACzE,eAAO,MAAM,iCAAiC,4BAAmC,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Process-local fixed-window store. Sufficient for cost control on low
|
|
3
|
+
* instance counts; each Vercel isolate has its own map.
|
|
4
|
+
*/
|
|
5
|
+
export class MemorySearchRateLimitStore {
|
|
6
|
+
windows = new Map();
|
|
7
|
+
async hit(key, windowMs) {
|
|
8
|
+
const now = Date.now();
|
|
9
|
+
this.gc(now);
|
|
10
|
+
const existing = this.windows.get(key);
|
|
11
|
+
if (!existing || existing.resetAt <= now) {
|
|
12
|
+
const resetAt = now + windowMs;
|
|
13
|
+
this.windows.set(key, { count: 1, resetAt });
|
|
14
|
+
return { count: 1, resetAt };
|
|
15
|
+
}
|
|
16
|
+
existing.count += 1;
|
|
17
|
+
return { count: existing.count, resetAt: existing.resetAt };
|
|
18
|
+
}
|
|
19
|
+
/** Test helper: clear all windows. */
|
|
20
|
+
clear() {
|
|
21
|
+
this.windows.clear();
|
|
22
|
+
}
|
|
23
|
+
gc(now) {
|
|
24
|
+
// Occasional cleanup to avoid unbounded growth in long-lived processes
|
|
25
|
+
if (this.windows.size < 64)
|
|
26
|
+
return;
|
|
27
|
+
for (const [k, v] of this.windows) {
|
|
28
|
+
if (v.resetAt <= now)
|
|
29
|
+
this.windows.delete(k);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/** Shared default store (API + MCP on the same isolate share memory). */
|
|
34
|
+
export const defaultMemorySearchRateLimitStore = new MemorySearchRateLimitStore();
|
|
35
|
+
//# sourceMappingURL=memory-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory-store.js","sourceRoot":"","sources":["../../src/rate-limit/memory-store.ts"],"names":[],"mappings":"AAOA;;;GAGG;AACH,MAAM,OAAO,0BAA0B;IACpB,OAAO,GAAG,IAAI,GAAG,EAAuB,CAAC;IAE1D,KAAK,CAAC,GAAG,CAAC,GAAW,EAAE,QAAgB;QACrC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACvB,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;QAEb,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACvC,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,OAAO,IAAI,GAAG,EAAE,CAAC;YACzC,MAAM,OAAO,GAAG,GAAG,GAAG,QAAQ,CAAC;YAC/B,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;YAC7C,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC;QAC/B,CAAC;QAED,QAAQ,CAAC,KAAK,IAAI,CAAC,CAAC;QACpB,OAAO,EAAE,KAAK,EAAE,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,CAAC,OAAO,EAAE,CAAC;IAC9D,CAAC;IAED,sCAAsC;IACtC,KAAK;QACH,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;IACvB,CAAC;IAEO,EAAE,CAAC,GAAW;QACpB,uEAAuE;QACvE,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,GAAG,EAAE;YAAE,OAAO;QACnC,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YAClC,IAAI,CAAC,CAAC,OAAO,IAAI,GAAG;gBAAE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QAC/C,CAAC;IACH,CAAC;CACF;AAED,yEAAyE;AACzE,MAAM,CAAC,MAAM,iCAAiC,GAAG,IAAI,0BAA0B,EAAE,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pluggable store for fixed-window search rate limits.
|
|
3
|
+
* Memory is default; Redis can be swapped in later for multi-instance accuracy.
|
|
4
|
+
*/
|
|
5
|
+
export interface SearchRateLimitStore {
|
|
6
|
+
/**
|
|
7
|
+
* Record a hit in the current window for `key`.
|
|
8
|
+
* @returns count after this hit and when the window resets (epoch ms)
|
|
9
|
+
*/
|
|
10
|
+
hit(key: string, windowMs: number): Promise<{
|
|
11
|
+
count: number;
|
|
12
|
+
resetAt: number;
|
|
13
|
+
}>;
|
|
14
|
+
}
|
|
15
|
+
export interface SearchRateLimitResult {
|
|
16
|
+
allowed: boolean;
|
|
17
|
+
/** Configured max hits per window (0 means disabled). */
|
|
18
|
+
limit: number;
|
|
19
|
+
/** Hits remaining in this window after this check (0 when denied). */
|
|
20
|
+
remaining: number;
|
|
21
|
+
/** Seconds until the window resets (for Retry-After). */
|
|
22
|
+
retryAfterSeconds: number;
|
|
23
|
+
/** Epoch ms when the current window ends. */
|
|
24
|
+
resetAt: number;
|
|
25
|
+
/** Human message when denied. */
|
|
26
|
+
message?: string;
|
|
27
|
+
}
|
|
28
|
+
export interface CheckSearchRateLimitOptions {
|
|
29
|
+
request: Request;
|
|
30
|
+
/** Distinguishes API vs MCP budgets (same IP can have separate counters). */
|
|
31
|
+
namespace?: 'api' | 'mcp' | string;
|
|
32
|
+
/** Max hits per window. Default from env or 10. `0` disables. */
|
|
33
|
+
max?: number;
|
|
34
|
+
/** Window length in ms. Default from env or 60_000. */
|
|
35
|
+
windowMs?: number;
|
|
36
|
+
store?: SearchRateLimitStore;
|
|
37
|
+
}
|
|
38
|
+
export interface SearchRateLimitConfig {
|
|
39
|
+
max?: number;
|
|
40
|
+
windowMs?: number;
|
|
41
|
+
store?: SearchRateLimitStore;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/rate-limit/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACjF;AAED,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,OAAO,CAAC;IACjB,yDAAyD;IACzD,KAAK,EAAE,MAAM,CAAC;IACd,sEAAsE;IACtE,SAAS,EAAE,MAAM,CAAC;IAClB,yDAAyD;IACzD,iBAAiB,EAAE,MAAM,CAAC;IAC1B,6CAA6C;IAC7C,OAAO,EAAE,MAAM,CAAC;IAChB,iCAAiC;IACjC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,2BAA2B;IAC1C,OAAO,EAAE,OAAO,CAAC;IACjB,6EAA6E;IAC7E,SAAS,CAAC,EAAE,KAAK,GAAG,KAAK,GAAG,MAAM,CAAC;IACnC,iEAAiE;IACjE,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,uDAAuD;IACvD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,oBAAoB,CAAC;CAC9B;AAED,MAAM,WAAW,qBAAqB;IACpC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,oBAAoB,CAAC;CAC9B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/rate-limit/types.ts"],"names":[],"mappings":""}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import type { ContentData } from '@se-studio/markdown-renderer/converter';
|
|
2
|
+
/**
|
|
3
|
+
* Upstash Search connection credentials.
|
|
4
|
+
* A single database is shared; separate index names distinguish published vs preview.
|
|
5
|
+
*/
|
|
6
|
+
export interface SearchConfig {
|
|
7
|
+
url: string;
|
|
8
|
+
token: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Index configuration: one Upstash database with two named indexes.
|
|
12
|
+
*/
|
|
13
|
+
export interface SearchIndexConfig {
|
|
14
|
+
connection: SearchConfig;
|
|
15
|
+
publishedIndexName: string;
|
|
16
|
+
previewIndexName: string;
|
|
17
|
+
}
|
|
18
|
+
/** Supported content types for search indexing. */
|
|
19
|
+
export type SearchableContentType = 'page' | 'article' | 'person' | 'articleType' | 'customType';
|
|
20
|
+
/**
|
|
21
|
+
* Per-content-type indexing configuration.
|
|
22
|
+
*/
|
|
23
|
+
export interface ContentTypeIndexConfig {
|
|
24
|
+
type: SearchableContentType;
|
|
25
|
+
enabled: boolean;
|
|
26
|
+
/** Override the global `indexComponents` flag for this content type. */
|
|
27
|
+
includeComponents?: boolean;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Full search indexing configuration provided by each app.
|
|
31
|
+
*/
|
|
32
|
+
export interface SearchIndexingConfig {
|
|
33
|
+
searchIndex: SearchIndexConfig;
|
|
34
|
+
contentTypes: ContentTypeIndexConfig[];
|
|
35
|
+
/** Whether to extract text from nested components/collections. Default: true. */
|
|
36
|
+
indexComponents?: boolean;
|
|
37
|
+
/** Skip entries where `indexed === false`. Default: true. */
|
|
38
|
+
respectIndexedFlag?: boolean;
|
|
39
|
+
/** Skip entries where `hidden === true`. Default: true. */
|
|
40
|
+
respectHiddenFlag?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Optional callback invoked for every SearchDocument after it has been built
|
|
43
|
+
* by `buildSearchDocuments`. Apps can use this to patch or augment metadata
|
|
44
|
+
* (e.g. substitute a hero image, add custom fields) before the document is
|
|
45
|
+
* upserted into the index.
|
|
46
|
+
*
|
|
47
|
+
* Return the (optionally modified) document. Returning `null` drops the document.
|
|
48
|
+
*/
|
|
49
|
+
documentTransformer?: (doc: SearchDocument, contentData: ContentData) => SearchDocument | null;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* A document ready to be upserted into Upstash Search.
|
|
53
|
+
*/
|
|
54
|
+
export interface SearchDocument {
|
|
55
|
+
id: string;
|
|
56
|
+
content: {
|
|
57
|
+
title: string;
|
|
58
|
+
description: string;
|
|
59
|
+
body: string;
|
|
60
|
+
};
|
|
61
|
+
metadata: SearchDocumentMetadata;
|
|
62
|
+
}
|
|
63
|
+
export interface SearchDocumentMetadata {
|
|
64
|
+
type: SearchableContentType;
|
|
65
|
+
slug: string;
|
|
66
|
+
href: string;
|
|
67
|
+
tags?: string[];
|
|
68
|
+
articleType?: string;
|
|
69
|
+
date?: string;
|
|
70
|
+
lastModified?: string;
|
|
71
|
+
author?: string;
|
|
72
|
+
imageUrl?: string;
|
|
73
|
+
imageAlt?: string;
|
|
74
|
+
imageWidth?: number;
|
|
75
|
+
imageHeight?: number;
|
|
76
|
+
/** The base entry ID (without chunk suffix). Used for deduplication. */
|
|
77
|
+
entryId: string;
|
|
78
|
+
/** 0-based index of this chunk within the entry. */
|
|
79
|
+
chunkIndex: number;
|
|
80
|
+
/** Total number of chunks for this entry. */
|
|
81
|
+
totalChunks: number;
|
|
82
|
+
[key: string]: unknown;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* A single result returned from a search query.
|
|
86
|
+
*/
|
|
87
|
+
export interface SearchResult {
|
|
88
|
+
id: string;
|
|
89
|
+
content: {
|
|
90
|
+
title: string;
|
|
91
|
+
description: string;
|
|
92
|
+
body: string;
|
|
93
|
+
};
|
|
94
|
+
metadata: SearchDocumentMetadata;
|
|
95
|
+
score: number;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Full response from a search query.
|
|
99
|
+
*/
|
|
100
|
+
export interface SearchResponse {
|
|
101
|
+
results: SearchResult[];
|
|
102
|
+
query: string;
|
|
103
|
+
totalCount: number;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Options for performing a search query.
|
|
107
|
+
*/
|
|
108
|
+
export interface SearchOptions {
|
|
109
|
+
query: string;
|
|
110
|
+
limit?: number;
|
|
111
|
+
filter?: string;
|
|
112
|
+
semanticWeight?: number;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Result of a full index rebuild.
|
|
116
|
+
*/
|
|
117
|
+
export interface RebuildResult {
|
|
118
|
+
indexed: number;
|
|
119
|
+
skipped: number;
|
|
120
|
+
errors: string[];
|
|
121
|
+
}
|
|
122
|
+
//# sourceMappingURL=types.d.ts.map
|