searchsocket 0.5.0 → 0.6.1

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/index.d.cts CHANGED
@@ -1,7 +1,7 @@
1
- import { R as ResolvedSearchSocketConfig, c as SearchSocketConfig, d as Scope, V as VectorHit, P as PageHit, e as ScopeInfo, f as PageRecord, I as IndexOptions, g as IndexStats, S as SearchRequest, a as SearchResponse } from './types-Dk43uz25.cjs';
2
- export { C as Chunk } from './types-Dk43uz25.cjs';
3
- import { Search } from '@upstash/search';
4
- export { s as searchsocketHandle, b as searchsocketVitePlugin } from './plugin-B_npJSux.cjs';
1
+ import { R as ResolvedSearchSocketConfig, c as SearchSocketConfig, d as Scope, V as VectorHit, P as PageHit, e as ScopeInfo, f as PageRecord, I as IndexingHooks, g as IndexOptions, h as IndexStats, S as SearchRequest, a as SearchResponse, i as SiteStructureResult, j as RelatedPagesResult } from './types-029hl6P2.cjs';
2
+ export { A as Awaitable, C as Chunk, k as CustomRecord } from './types-029hl6P2.cjs';
3
+ import { Index } from '@upstash/vector';
4
+ export { s as searchsocketHandle, b as searchsocketVitePlugin } from './plugin-DoBW1gkK.cjs';
5
5
  export { createSearchClient } from './client.cjs';
6
6
 
7
7
  interface LoadConfigOptions {
@@ -29,63 +29,108 @@ declare function isServerless(): boolean;
29
29
 
30
30
  declare function resolveScope(config: ResolvedSearchSocketConfig, override?: string): Scope;
31
31
 
32
- /** Content fields stored in Upstash Search (indexed and searchable) */
33
- interface ChunkContent {
34
- title: string;
35
- sectionTitle: string;
36
- text: string;
37
- url: string;
38
- tags: string;
39
- headingPath: string;
40
- [key: string]: unknown;
41
- }
42
- /** Metadata fields stored in Upstash Search (returned but not searchable) */
43
- interface ChunkMetadata {
32
+ /** Flat metadata stored alongside each page vector in Upstash Vector */
33
+ interface PageVectorMetadata {
44
34
  projectId: string;
45
35
  scopeName: string;
46
- path: string;
47
- snippet: string;
48
- ordinal: number;
49
- contentHash: string;
50
- depth: number;
51
- incomingLinks: number;
52
- routeFile: string;
36
+ type: string;
37
+ title: string;
38
+ url: string;
53
39
  description: string;
54
- keywords: string;
40
+ keywords: string[];
41
+ summary: string;
42
+ tags: string[];
43
+ markdown: string;
44
+ routeFile: string;
45
+ routeResolution: string;
46
+ incomingLinks: number;
47
+ outgoingLinks: number;
48
+ outgoingLinkUrls?: string[];
49
+ depth: number;
50
+ indexedAt: string;
51
+ contentHash: string;
52
+ publishedAt?: number | null;
55
53
  [key: string]: unknown;
56
54
  }
57
55
  interface UpstashSearchStoreOptions {
58
- client: Search;
56
+ index: Index;
57
+ pagesNamespace: string;
58
+ chunksNamespace: string;
59
59
  }
60
60
  declare class UpstashSearchStore {
61
- private readonly client;
61
+ private readonly index;
62
+ private readonly pagesNs;
63
+ private readonly chunksNs;
62
64
  constructor(opts: UpstashSearchStoreOptions);
63
- private chunkIndex;
64
- private pageIndex;
65
65
  upsertChunks(chunks: Array<{
66
66
  id: string;
67
- content: ChunkContent;
68
- metadata: ChunkMetadata;
67
+ data: string;
68
+ metadata: Record<string, unknown>;
69
69
  }>, scope: Scope): Promise<void>;
70
- search(query: string, opts: {
70
+ search(data: string, opts: {
71
+ limit: number;
72
+ filter?: string;
73
+ }, scope: Scope): Promise<VectorHit[]>;
74
+ searchChunksByUrl(data: string, url: string, opts: {
71
75
  limit: number;
72
- semanticWeight?: number;
73
- inputEnrichment?: boolean;
74
- reranking?: boolean;
75
76
  filter?: string;
76
77
  }, scope: Scope): Promise<VectorHit[]>;
77
- searchPages(query: string, opts: {
78
+ searchPagesByText(data: string, opts: {
79
+ limit: number;
80
+ filter?: string;
81
+ }, scope: Scope): Promise<PageHit[]>;
82
+ searchPagesByVector(vector: number[], opts: {
78
83
  limit: number;
79
- semanticWeight?: number;
80
- inputEnrichment?: boolean;
81
84
  filter?: string;
82
85
  }, scope: Scope): Promise<PageHit[]>;
83
- deleteByIds(ids: string[], scope: Scope): Promise<void>;
86
+ private queryPages;
87
+ deleteByIds(ids: string[], _scope: Scope): Promise<void>;
84
88
  deleteScope(scope: Scope): Promise<void>;
85
89
  listScopes(projectId: string): Promise<ScopeInfo[]>;
86
90
  getContentHashes(scope: Scope): Promise<Map<string, string>>;
87
- upsertPages(pages: PageRecord[], scope: Scope): Promise<void>;
91
+ /**
92
+ * Fetch content hashes for a specific set of chunk keys using direct fetch()
93
+ * instead of range(). This avoids potential issues with range() returning
94
+ * vectors from the wrong namespace on hybrid indexes.
95
+ */
96
+ fetchContentHashesForKeys(keys: string[], scope: Scope): Promise<Map<string, string>>;
97
+ /**
98
+ * Scan all IDs in the chunks namespace for this scope.
99
+ * Used for deletion detection (finding stale chunk keys).
100
+ */
101
+ scanChunkIds(scope: Scope): Promise<Set<string>>;
102
+ private scanHashes;
103
+ listPages(scope: Scope, opts?: {
104
+ cursor?: string;
105
+ limit?: number;
106
+ pathPrefix?: string;
107
+ }): Promise<{
108
+ pages: Array<{
109
+ url: string;
110
+ title: string;
111
+ description: string;
112
+ routeFile: string;
113
+ }>;
114
+ nextCursor?: string;
115
+ }>;
116
+ getPageHashes(scope: Scope): Promise<Map<string, string>>;
117
+ deletePagesByIds(ids: string[], _scope: Scope): Promise<void>;
118
+ upsertPages(pages: Array<{
119
+ id: string;
120
+ data: string;
121
+ metadata: Record<string, unknown>;
122
+ }>, scope: Scope): Promise<void>;
88
123
  getPage(url: string, scope: Scope): Promise<PageRecord | null>;
124
+ fetchPageWithVector(url: string, scope: Scope): Promise<{
125
+ metadata: PageVectorMetadata;
126
+ vector: number[];
127
+ } | null>;
128
+ fetchPagesBatch(urls: string[], scope: Scope): Promise<Array<{
129
+ url: string;
130
+ title: string;
131
+ routeFile: string;
132
+ outgoingLinkUrls: string[];
133
+ }>>;
89
134
  deletePages(scope: Scope): Promise<void>;
90
135
  health(): Promise<{
91
136
  ok: boolean;
@@ -122,12 +167,14 @@ interface IndexPipelineOptions {
122
167
  config?: ResolvedSearchSocketConfig;
123
168
  store?: UpstashSearchStore;
124
169
  logger?: Logger;
170
+ hooks?: IndexingHooks;
125
171
  }
126
172
  declare class IndexPipeline {
127
173
  private readonly cwd;
128
174
  private readonly config;
129
175
  private readonly store;
130
176
  private readonly logger;
177
+ private readonly hooks;
131
178
  private constructor();
132
179
  static create(options?: IndexPipelineOptions): Promise<IndexPipeline>;
133
180
  getConfig(): ResolvedSearchSocketConfig;
@@ -148,6 +195,7 @@ declare class SearchEngine {
148
195
  static create(options?: SearchEngineOptions): Promise<SearchEngine>;
149
196
  getConfig(): ResolvedSearchSocketConfig;
150
197
  search(request: SearchRequest): Promise<SearchResponse>;
198
+ private buildPageFirstResults;
151
199
  private ensureSnippet;
152
200
  private buildResults;
153
201
  getPage(pathOrUrl: string, scope?: string): Promise<{
@@ -155,6 +203,29 @@ declare class SearchEngine {
155
203
  frontmatter: Record<string, unknown>;
156
204
  markdown: string;
157
205
  }>;
206
+ listPages(opts?: {
207
+ pathPrefix?: string;
208
+ cursor?: string;
209
+ limit?: number;
210
+ scope?: string;
211
+ }): Promise<{
212
+ pages: Array<{
213
+ url: string;
214
+ title: string;
215
+ description: string;
216
+ routeFile: string;
217
+ }>;
218
+ nextCursor?: string;
219
+ }>;
220
+ getSiteStructure(opts?: {
221
+ pathPrefix?: string;
222
+ scope?: string;
223
+ maxPages?: number;
224
+ }): Promise<SiteStructureResult>;
225
+ getRelatedPages(pathOrUrl: string, opts?: {
226
+ topK?: number;
227
+ scope?: string;
228
+ }): Promise<RelatedPagesResult>;
158
229
  health(): Promise<{
159
230
  ok: boolean;
160
231
  details?: string;
@@ -170,7 +241,9 @@ interface McpServerOptions {
170
241
  transport?: "stdio" | "http";
171
242
  httpPort?: number;
172
243
  httpPath?: string;
244
+ access?: "public" | "private";
245
+ apiKey?: string;
173
246
  }
174
247
  declare function runMcpServer(options?: McpServerOptions): Promise<void>;
175
248
 
176
- export { IndexOptions, IndexPipeline, IndexStats, ResolvedSearchSocketConfig, Scope, SearchEngine, SearchRequest, SearchResponse, SearchSocketConfig, UpstashSearchStore, VectorHit, createUpstashStore, isServerless, loadConfig, mergeConfig, mergeConfigServerless, resolveScope, runMcpServer };
249
+ export { IndexOptions, IndexPipeline, IndexStats, IndexingHooks, ResolvedSearchSocketConfig, Scope, SearchEngine, SearchRequest, SearchResponse, SearchSocketConfig, UpstashSearchStore, VectorHit, createUpstashStore, isServerless, loadConfig, mergeConfig, mergeConfigServerless, resolveScope, runMcpServer };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { R as ResolvedSearchSocketConfig, c as SearchSocketConfig, d as Scope, V as VectorHit, P as PageHit, e as ScopeInfo, f as PageRecord, I as IndexOptions, g as IndexStats, S as SearchRequest, a as SearchResponse } from './types-Dk43uz25.js';
2
- export { C as Chunk } from './types-Dk43uz25.js';
3
- import { Search } from '@upstash/search';
4
- export { s as searchsocketHandle, b as searchsocketVitePlugin } from './plugin-M-aW0ev6.js';
1
+ import { R as ResolvedSearchSocketConfig, c as SearchSocketConfig, d as Scope, V as VectorHit, P as PageHit, e as ScopeInfo, f as PageRecord, I as IndexingHooks, g as IndexOptions, h as IndexStats, S as SearchRequest, a as SearchResponse, i as SiteStructureResult, j as RelatedPagesResult } from './types-029hl6P2.js';
2
+ export { A as Awaitable, C as Chunk, k as CustomRecord } from './types-029hl6P2.js';
3
+ import { Index } from '@upstash/vector';
4
+ export { s as searchsocketHandle, b as searchsocketVitePlugin } from './plugin-C61L-ykY.js';
5
5
  export { createSearchClient } from './client.js';
6
6
 
7
7
  interface LoadConfigOptions {
@@ -29,63 +29,108 @@ declare function isServerless(): boolean;
29
29
 
30
30
  declare function resolveScope(config: ResolvedSearchSocketConfig, override?: string): Scope;
31
31
 
32
- /** Content fields stored in Upstash Search (indexed and searchable) */
33
- interface ChunkContent {
34
- title: string;
35
- sectionTitle: string;
36
- text: string;
37
- url: string;
38
- tags: string;
39
- headingPath: string;
40
- [key: string]: unknown;
41
- }
42
- /** Metadata fields stored in Upstash Search (returned but not searchable) */
43
- interface ChunkMetadata {
32
+ /** Flat metadata stored alongside each page vector in Upstash Vector */
33
+ interface PageVectorMetadata {
44
34
  projectId: string;
45
35
  scopeName: string;
46
- path: string;
47
- snippet: string;
48
- ordinal: number;
49
- contentHash: string;
50
- depth: number;
51
- incomingLinks: number;
52
- routeFile: string;
36
+ type: string;
37
+ title: string;
38
+ url: string;
53
39
  description: string;
54
- keywords: string;
40
+ keywords: string[];
41
+ summary: string;
42
+ tags: string[];
43
+ markdown: string;
44
+ routeFile: string;
45
+ routeResolution: string;
46
+ incomingLinks: number;
47
+ outgoingLinks: number;
48
+ outgoingLinkUrls?: string[];
49
+ depth: number;
50
+ indexedAt: string;
51
+ contentHash: string;
52
+ publishedAt?: number | null;
55
53
  [key: string]: unknown;
56
54
  }
57
55
  interface UpstashSearchStoreOptions {
58
- client: Search;
56
+ index: Index;
57
+ pagesNamespace: string;
58
+ chunksNamespace: string;
59
59
  }
60
60
  declare class UpstashSearchStore {
61
- private readonly client;
61
+ private readonly index;
62
+ private readonly pagesNs;
63
+ private readonly chunksNs;
62
64
  constructor(opts: UpstashSearchStoreOptions);
63
- private chunkIndex;
64
- private pageIndex;
65
65
  upsertChunks(chunks: Array<{
66
66
  id: string;
67
- content: ChunkContent;
68
- metadata: ChunkMetadata;
67
+ data: string;
68
+ metadata: Record<string, unknown>;
69
69
  }>, scope: Scope): Promise<void>;
70
- search(query: string, opts: {
70
+ search(data: string, opts: {
71
+ limit: number;
72
+ filter?: string;
73
+ }, scope: Scope): Promise<VectorHit[]>;
74
+ searchChunksByUrl(data: string, url: string, opts: {
71
75
  limit: number;
72
- semanticWeight?: number;
73
- inputEnrichment?: boolean;
74
- reranking?: boolean;
75
76
  filter?: string;
76
77
  }, scope: Scope): Promise<VectorHit[]>;
77
- searchPages(query: string, opts: {
78
+ searchPagesByText(data: string, opts: {
79
+ limit: number;
80
+ filter?: string;
81
+ }, scope: Scope): Promise<PageHit[]>;
82
+ searchPagesByVector(vector: number[], opts: {
78
83
  limit: number;
79
- semanticWeight?: number;
80
- inputEnrichment?: boolean;
81
84
  filter?: string;
82
85
  }, scope: Scope): Promise<PageHit[]>;
83
- deleteByIds(ids: string[], scope: Scope): Promise<void>;
86
+ private queryPages;
87
+ deleteByIds(ids: string[], _scope: Scope): Promise<void>;
84
88
  deleteScope(scope: Scope): Promise<void>;
85
89
  listScopes(projectId: string): Promise<ScopeInfo[]>;
86
90
  getContentHashes(scope: Scope): Promise<Map<string, string>>;
87
- upsertPages(pages: PageRecord[], scope: Scope): Promise<void>;
91
+ /**
92
+ * Fetch content hashes for a specific set of chunk keys using direct fetch()
93
+ * instead of range(). This avoids potential issues with range() returning
94
+ * vectors from the wrong namespace on hybrid indexes.
95
+ */
96
+ fetchContentHashesForKeys(keys: string[], scope: Scope): Promise<Map<string, string>>;
97
+ /**
98
+ * Scan all IDs in the chunks namespace for this scope.
99
+ * Used for deletion detection (finding stale chunk keys).
100
+ */
101
+ scanChunkIds(scope: Scope): Promise<Set<string>>;
102
+ private scanHashes;
103
+ listPages(scope: Scope, opts?: {
104
+ cursor?: string;
105
+ limit?: number;
106
+ pathPrefix?: string;
107
+ }): Promise<{
108
+ pages: Array<{
109
+ url: string;
110
+ title: string;
111
+ description: string;
112
+ routeFile: string;
113
+ }>;
114
+ nextCursor?: string;
115
+ }>;
116
+ getPageHashes(scope: Scope): Promise<Map<string, string>>;
117
+ deletePagesByIds(ids: string[], _scope: Scope): Promise<void>;
118
+ upsertPages(pages: Array<{
119
+ id: string;
120
+ data: string;
121
+ metadata: Record<string, unknown>;
122
+ }>, scope: Scope): Promise<void>;
88
123
  getPage(url: string, scope: Scope): Promise<PageRecord | null>;
124
+ fetchPageWithVector(url: string, scope: Scope): Promise<{
125
+ metadata: PageVectorMetadata;
126
+ vector: number[];
127
+ } | null>;
128
+ fetchPagesBatch(urls: string[], scope: Scope): Promise<Array<{
129
+ url: string;
130
+ title: string;
131
+ routeFile: string;
132
+ outgoingLinkUrls: string[];
133
+ }>>;
89
134
  deletePages(scope: Scope): Promise<void>;
90
135
  health(): Promise<{
91
136
  ok: boolean;
@@ -122,12 +167,14 @@ interface IndexPipelineOptions {
122
167
  config?: ResolvedSearchSocketConfig;
123
168
  store?: UpstashSearchStore;
124
169
  logger?: Logger;
170
+ hooks?: IndexingHooks;
125
171
  }
126
172
  declare class IndexPipeline {
127
173
  private readonly cwd;
128
174
  private readonly config;
129
175
  private readonly store;
130
176
  private readonly logger;
177
+ private readonly hooks;
131
178
  private constructor();
132
179
  static create(options?: IndexPipelineOptions): Promise<IndexPipeline>;
133
180
  getConfig(): ResolvedSearchSocketConfig;
@@ -148,6 +195,7 @@ declare class SearchEngine {
148
195
  static create(options?: SearchEngineOptions): Promise<SearchEngine>;
149
196
  getConfig(): ResolvedSearchSocketConfig;
150
197
  search(request: SearchRequest): Promise<SearchResponse>;
198
+ private buildPageFirstResults;
151
199
  private ensureSnippet;
152
200
  private buildResults;
153
201
  getPage(pathOrUrl: string, scope?: string): Promise<{
@@ -155,6 +203,29 @@ declare class SearchEngine {
155
203
  frontmatter: Record<string, unknown>;
156
204
  markdown: string;
157
205
  }>;
206
+ listPages(opts?: {
207
+ pathPrefix?: string;
208
+ cursor?: string;
209
+ limit?: number;
210
+ scope?: string;
211
+ }): Promise<{
212
+ pages: Array<{
213
+ url: string;
214
+ title: string;
215
+ description: string;
216
+ routeFile: string;
217
+ }>;
218
+ nextCursor?: string;
219
+ }>;
220
+ getSiteStructure(opts?: {
221
+ pathPrefix?: string;
222
+ scope?: string;
223
+ maxPages?: number;
224
+ }): Promise<SiteStructureResult>;
225
+ getRelatedPages(pathOrUrl: string, opts?: {
226
+ topK?: number;
227
+ scope?: string;
228
+ }): Promise<RelatedPagesResult>;
158
229
  health(): Promise<{
159
230
  ok: boolean;
160
231
  details?: string;
@@ -170,7 +241,9 @@ interface McpServerOptions {
170
241
  transport?: "stdio" | "http";
171
242
  httpPort?: number;
172
243
  httpPath?: string;
244
+ access?: "public" | "private";
245
+ apiKey?: string;
173
246
  }
174
247
  declare function runMcpServer(options?: McpServerOptions): Promise<void>;
175
248
 
176
- export { IndexOptions, IndexPipeline, IndexStats, ResolvedSearchSocketConfig, Scope, SearchEngine, SearchRequest, SearchResponse, SearchSocketConfig, UpstashSearchStore, VectorHit, createUpstashStore, isServerless, loadConfig, mergeConfig, mergeConfigServerless, resolveScope, runMcpServer };
249
+ export { IndexOptions, IndexPipeline, IndexStats, IndexingHooks, ResolvedSearchSocketConfig, Scope, SearchEngine, SearchRequest, SearchResponse, SearchSocketConfig, UpstashSearchStore, VectorHit, createUpstashStore, isServerless, loadConfig, mergeConfig, mergeConfigServerless, resolveScope, runMcpServer };