searchsocket 0.5.0 → 0.6.0

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,96 @@ 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
+ listPages(scope: Scope, opts?: {
92
+ cursor?: string;
93
+ limit?: number;
94
+ pathPrefix?: string;
95
+ }): Promise<{
96
+ pages: Array<{
97
+ url: string;
98
+ title: string;
99
+ description: string;
100
+ routeFile: string;
101
+ }>;
102
+ nextCursor?: string;
103
+ }>;
104
+ getPageHashes(scope: Scope): Promise<Map<string, string>>;
105
+ deletePagesByIds(ids: string[], _scope: Scope): Promise<void>;
106
+ upsertPages(pages: Array<{
107
+ id: string;
108
+ data: string;
109
+ metadata: Record<string, unknown>;
110
+ }>, scope: Scope): Promise<void>;
88
111
  getPage(url: string, scope: Scope): Promise<PageRecord | null>;
112
+ fetchPageWithVector(url: string, scope: Scope): Promise<{
113
+ metadata: PageVectorMetadata;
114
+ vector: number[];
115
+ } | null>;
116
+ fetchPagesBatch(urls: string[], scope: Scope): Promise<Array<{
117
+ url: string;
118
+ title: string;
119
+ routeFile: string;
120
+ outgoingLinkUrls: string[];
121
+ }>>;
89
122
  deletePages(scope: Scope): Promise<void>;
90
123
  health(): Promise<{
91
124
  ok: boolean;
@@ -122,12 +155,14 @@ interface IndexPipelineOptions {
122
155
  config?: ResolvedSearchSocketConfig;
123
156
  store?: UpstashSearchStore;
124
157
  logger?: Logger;
158
+ hooks?: IndexingHooks;
125
159
  }
126
160
  declare class IndexPipeline {
127
161
  private readonly cwd;
128
162
  private readonly config;
129
163
  private readonly store;
130
164
  private readonly logger;
165
+ private readonly hooks;
131
166
  private constructor();
132
167
  static create(options?: IndexPipelineOptions): Promise<IndexPipeline>;
133
168
  getConfig(): ResolvedSearchSocketConfig;
@@ -148,6 +183,7 @@ declare class SearchEngine {
148
183
  static create(options?: SearchEngineOptions): Promise<SearchEngine>;
149
184
  getConfig(): ResolvedSearchSocketConfig;
150
185
  search(request: SearchRequest): Promise<SearchResponse>;
186
+ private buildPageFirstResults;
151
187
  private ensureSnippet;
152
188
  private buildResults;
153
189
  getPage(pathOrUrl: string, scope?: string): Promise<{
@@ -155,6 +191,29 @@ declare class SearchEngine {
155
191
  frontmatter: Record<string, unknown>;
156
192
  markdown: string;
157
193
  }>;
194
+ listPages(opts?: {
195
+ pathPrefix?: string;
196
+ cursor?: string;
197
+ limit?: number;
198
+ scope?: string;
199
+ }): Promise<{
200
+ pages: Array<{
201
+ url: string;
202
+ title: string;
203
+ description: string;
204
+ routeFile: string;
205
+ }>;
206
+ nextCursor?: string;
207
+ }>;
208
+ getSiteStructure(opts?: {
209
+ pathPrefix?: string;
210
+ scope?: string;
211
+ maxPages?: number;
212
+ }): Promise<SiteStructureResult>;
213
+ getRelatedPages(pathOrUrl: string, opts?: {
214
+ topK?: number;
215
+ scope?: string;
216
+ }): Promise<RelatedPagesResult>;
158
217
  health(): Promise<{
159
218
  ok: boolean;
160
219
  details?: string;
@@ -170,7 +229,9 @@ interface McpServerOptions {
170
229
  transport?: "stdio" | "http";
171
230
  httpPort?: number;
172
231
  httpPath?: string;
232
+ access?: "public" | "private";
233
+ apiKey?: string;
173
234
  }
174
235
  declare function runMcpServer(options?: McpServerOptions): Promise<void>;
175
236
 
176
- export { IndexOptions, IndexPipeline, IndexStats, ResolvedSearchSocketConfig, Scope, SearchEngine, SearchRequest, SearchResponse, SearchSocketConfig, UpstashSearchStore, VectorHit, createUpstashStore, isServerless, loadConfig, mergeConfig, mergeConfigServerless, resolveScope, runMcpServer };
237
+ 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,96 @@ 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
+ listPages(scope: Scope, opts?: {
92
+ cursor?: string;
93
+ limit?: number;
94
+ pathPrefix?: string;
95
+ }): Promise<{
96
+ pages: Array<{
97
+ url: string;
98
+ title: string;
99
+ description: string;
100
+ routeFile: string;
101
+ }>;
102
+ nextCursor?: string;
103
+ }>;
104
+ getPageHashes(scope: Scope): Promise<Map<string, string>>;
105
+ deletePagesByIds(ids: string[], _scope: Scope): Promise<void>;
106
+ upsertPages(pages: Array<{
107
+ id: string;
108
+ data: string;
109
+ metadata: Record<string, unknown>;
110
+ }>, scope: Scope): Promise<void>;
88
111
  getPage(url: string, scope: Scope): Promise<PageRecord | null>;
112
+ fetchPageWithVector(url: string, scope: Scope): Promise<{
113
+ metadata: PageVectorMetadata;
114
+ vector: number[];
115
+ } | null>;
116
+ fetchPagesBatch(urls: string[], scope: Scope): Promise<Array<{
117
+ url: string;
118
+ title: string;
119
+ routeFile: string;
120
+ outgoingLinkUrls: string[];
121
+ }>>;
89
122
  deletePages(scope: Scope): Promise<void>;
90
123
  health(): Promise<{
91
124
  ok: boolean;
@@ -122,12 +155,14 @@ interface IndexPipelineOptions {
122
155
  config?: ResolvedSearchSocketConfig;
123
156
  store?: UpstashSearchStore;
124
157
  logger?: Logger;
158
+ hooks?: IndexingHooks;
125
159
  }
126
160
  declare class IndexPipeline {
127
161
  private readonly cwd;
128
162
  private readonly config;
129
163
  private readonly store;
130
164
  private readonly logger;
165
+ private readonly hooks;
131
166
  private constructor();
132
167
  static create(options?: IndexPipelineOptions): Promise<IndexPipeline>;
133
168
  getConfig(): ResolvedSearchSocketConfig;
@@ -148,6 +183,7 @@ declare class SearchEngine {
148
183
  static create(options?: SearchEngineOptions): Promise<SearchEngine>;
149
184
  getConfig(): ResolvedSearchSocketConfig;
150
185
  search(request: SearchRequest): Promise<SearchResponse>;
186
+ private buildPageFirstResults;
151
187
  private ensureSnippet;
152
188
  private buildResults;
153
189
  getPage(pathOrUrl: string, scope?: string): Promise<{
@@ -155,6 +191,29 @@ declare class SearchEngine {
155
191
  frontmatter: Record<string, unknown>;
156
192
  markdown: string;
157
193
  }>;
194
+ listPages(opts?: {
195
+ pathPrefix?: string;
196
+ cursor?: string;
197
+ limit?: number;
198
+ scope?: string;
199
+ }): Promise<{
200
+ pages: Array<{
201
+ url: string;
202
+ title: string;
203
+ description: string;
204
+ routeFile: string;
205
+ }>;
206
+ nextCursor?: string;
207
+ }>;
208
+ getSiteStructure(opts?: {
209
+ pathPrefix?: string;
210
+ scope?: string;
211
+ maxPages?: number;
212
+ }): Promise<SiteStructureResult>;
213
+ getRelatedPages(pathOrUrl: string, opts?: {
214
+ topK?: number;
215
+ scope?: string;
216
+ }): Promise<RelatedPagesResult>;
158
217
  health(): Promise<{
159
218
  ok: boolean;
160
219
  details?: string;
@@ -170,7 +229,9 @@ interface McpServerOptions {
170
229
  transport?: "stdio" | "http";
171
230
  httpPort?: number;
172
231
  httpPath?: string;
232
+ access?: "public" | "private";
233
+ apiKey?: string;
173
234
  }
174
235
  declare function runMcpServer(options?: McpServerOptions): Promise<void>;
175
236
 
176
- export { IndexOptions, IndexPipeline, IndexStats, ResolvedSearchSocketConfig, Scope, SearchEngine, SearchRequest, SearchResponse, SearchSocketConfig, UpstashSearchStore, VectorHit, createUpstashStore, isServerless, loadConfig, mergeConfig, mergeConfigServerless, resolveScope, runMcpServer };
237
+ export { IndexOptions, IndexPipeline, IndexStats, IndexingHooks, ResolvedSearchSocketConfig, Scope, SearchEngine, SearchRequest, SearchResponse, SearchSocketConfig, UpstashSearchStore, VectorHit, createUpstashStore, isServerless, loadConfig, mergeConfig, mergeConfigServerless, resolveScope, runMcpServer };