@arke-institute/sdk 0.1.3 → 2.0.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.
Files changed (64) hide show
  1. package/README.md +126 -184
  2. package/dist/generated/index.cjs +19 -0
  3. package/dist/generated/index.cjs.map +1 -0
  4. package/dist/generated/index.d.cts +6192 -0
  5. package/dist/generated/index.d.ts +6192 -0
  6. package/dist/generated/index.js +1 -0
  7. package/dist/generated/index.js.map +1 -0
  8. package/dist/index-BrXke2kI.d.ts +302 -0
  9. package/dist/index-FHcLPBSV.d.cts +302 -0
  10. package/dist/index.cjs +188 -4254
  11. package/dist/index.cjs.map +1 -1
  12. package/dist/index.d.cts +62 -7
  13. package/dist/index.d.ts +62 -7
  14. package/dist/index.js +168 -4226
  15. package/dist/index.js.map +1 -1
  16. package/dist/operations/index.cjs +113 -0
  17. package/dist/operations/index.cjs.map +1 -0
  18. package/dist/operations/index.d.cts +3 -0
  19. package/dist/operations/index.d.ts +3 -0
  20. package/dist/operations/index.js +84 -0
  21. package/dist/operations/index.js.map +1 -0
  22. package/package.json +44 -53
  23. package/dist/client-dAk3E64p.d.cts +0 -183
  24. package/dist/client-dAk3E64p.d.ts +0 -183
  25. package/dist/collections/index.cjs +0 -233
  26. package/dist/collections/index.cjs.map +0 -1
  27. package/dist/collections/index.d.cts +0 -9
  28. package/dist/collections/index.d.ts +0 -9
  29. package/dist/collections/index.js +0 -205
  30. package/dist/collections/index.js.map +0 -1
  31. package/dist/content/index.cjs +0 -591
  32. package/dist/content/index.cjs.map +0 -1
  33. package/dist/content/index.d.cts +0 -516
  34. package/dist/content/index.d.ts +0 -516
  35. package/dist/content/index.js +0 -558
  36. package/dist/content/index.js.map +0 -1
  37. package/dist/edit/index.cjs +0 -1503
  38. package/dist/edit/index.cjs.map +0 -1
  39. package/dist/edit/index.d.cts +0 -78
  40. package/dist/edit/index.d.ts +0 -78
  41. package/dist/edit/index.js +0 -1447
  42. package/dist/edit/index.js.map +0 -1
  43. package/dist/errors-3L7IiHcr.d.cts +0 -480
  44. package/dist/errors-BTe8GKRQ.d.ts +0 -480
  45. package/dist/errors-CT7yzKkU.d.cts +0 -874
  46. package/dist/errors-CT7yzKkU.d.ts +0 -874
  47. package/dist/graph/index.cjs +0 -427
  48. package/dist/graph/index.cjs.map +0 -1
  49. package/dist/graph/index.d.cts +0 -485
  50. package/dist/graph/index.d.ts +0 -485
  51. package/dist/graph/index.js +0 -396
  52. package/dist/graph/index.js.map +0 -1
  53. package/dist/query/index.cjs +0 -356
  54. package/dist/query/index.cjs.map +0 -1
  55. package/dist/query/index.d.cts +0 -636
  56. package/dist/query/index.d.ts +0 -636
  57. package/dist/query/index.js +0 -328
  58. package/dist/query/index.js.map +0 -1
  59. package/dist/upload/index.cjs +0 -1634
  60. package/dist/upload/index.cjs.map +0 -1
  61. package/dist/upload/index.d.cts +0 -150
  62. package/dist/upload/index.d.ts +0 -150
  63. package/dist/upload/index.js +0 -1597
  64. package/dist/upload/index.js.map +0 -1
@@ -1,356 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/query/index.ts
21
- var query_exports = {};
22
- __export(query_exports, {
23
- QueryClient: () => QueryClient,
24
- QueryError: () => QueryError
25
- });
26
- module.exports = __toCommonJS(query_exports);
27
-
28
- // src/query/errors.ts
29
- var QueryError = class extends Error {
30
- constructor(message, code = "UNKNOWN_ERROR", details) {
31
- super(message);
32
- this.code = code;
33
- this.details = details;
34
- this.name = "QueryError";
35
- }
36
- };
37
-
38
- // src/query/client.ts
39
- var QueryClient = class {
40
- constructor(config) {
41
- this.baseUrl = config.gatewayUrl.replace(/\/$/, "");
42
- this.fetchImpl = config.fetchImpl ?? fetch;
43
- }
44
- // ---------------------------------------------------------------------------
45
- // Request helpers
46
- // ---------------------------------------------------------------------------
47
- buildUrl(path, query) {
48
- const url = new URL(`${this.baseUrl}${path}`);
49
- if (query) {
50
- Object.entries(query).forEach(([key, value]) => {
51
- if (value !== void 0 && value !== null) {
52
- url.searchParams.set(key, String(value));
53
- }
54
- });
55
- }
56
- return url.toString();
57
- }
58
- async request(path, options = {}) {
59
- const url = this.buildUrl(path, options.query);
60
- const headers = new Headers({ "Content-Type": "application/json" });
61
- if (options.headers) {
62
- Object.entries(options.headers).forEach(([k, v]) => {
63
- if (v !== void 0) headers.set(k, v);
64
- });
65
- }
66
- const response = await this.fetchImpl(url, { ...options, headers });
67
- if (response.ok) {
68
- const contentType = response.headers.get("content-type") || "";
69
- if (contentType.includes("application/json")) {
70
- return await response.json();
71
- }
72
- return await response.text();
73
- }
74
- let body;
75
- const text = await response.text();
76
- try {
77
- body = JSON.parse(text);
78
- } catch {
79
- body = text;
80
- }
81
- const message = body?.error && typeof body.error === "string" ? body.error : body?.message && typeof body.message === "string" ? body.message : `Request failed with status ${response.status}`;
82
- throw new QueryError(message, "HTTP_ERROR", {
83
- status: response.status,
84
- body
85
- });
86
- }
87
- // ---------------------------------------------------------------------------
88
- // Query methods
89
- // ---------------------------------------------------------------------------
90
- /**
91
- * Execute a path query against the knowledge graph.
92
- *
93
- * @param pathQuery - The path query string (e.g., '"alice austen" -[*]{,4}-> type:person')
94
- * @param options - Query options (k, k_explore, lineage, enrich, etc.)
95
- * @returns Query results with entities, paths, and metadata
96
- *
97
- * @example
98
- * ```typescript
99
- * // Simple semantic search
100
- * const results = await query.path('"Washington" type:person');
101
- *
102
- * // Multi-hop traversal
103
- * const results = await query.path('"alice austen" -[*]{,4}-> type:person ~ "photographer"');
104
- *
105
- * // With lineage filtering (collection scope)
106
- * const results = await query.path('"letters" type:document', {
107
- * lineage: { sourcePi: 'arke:my_collection', direction: 'descendants' },
108
- * k: 10,
109
- * });
110
- * ```
111
- */
112
- async path(pathQuery, options = {}) {
113
- return this.request("/query/path", {
114
- method: "POST",
115
- body: JSON.stringify({
116
- path: pathQuery,
117
- ...options
118
- })
119
- });
120
- }
121
- /**
122
- * Execute a natural language query.
123
- *
124
- * The query is translated to a path query using an LLM, then executed.
125
- *
126
- * @param question - Natural language question
127
- * @param options - Query options including custom_instructions for the LLM
128
- * @returns Query results with translation info
129
- *
130
- * @example
131
- * ```typescript
132
- * const results = await query.natural('Find photographers connected to Alice Austen');
133
- * console.log('Generated query:', results.translation.path);
134
- * console.log('Explanation:', results.translation.explanation);
135
- * ```
136
- */
137
- async natural(question, options = {}) {
138
- const { custom_instructions, ...queryOptions } = options;
139
- return this.request("/query/natural", {
140
- method: "POST",
141
- body: JSON.stringify({
142
- query: question,
143
- custom_instructions,
144
- ...queryOptions
145
- })
146
- });
147
- }
148
- /**
149
- * Translate a natural language question to a path query without executing it.
150
- *
151
- * Useful for understanding how questions are translated or for manual execution later.
152
- *
153
- * @param question - Natural language question
154
- * @param customInstructions - Optional additional instructions for the LLM
155
- * @returns Translation result with path query and explanation
156
- *
157
- * @example
158
- * ```typescript
159
- * const result = await query.translate('Who wrote letters from Philadelphia?');
160
- * console.log('Path query:', result.path);
161
- * // '"letters" <-[authored, wrote]- type:person -[located]-> "Philadelphia"'
162
- * ```
163
- */
164
- async translate(question, customInstructions) {
165
- return this.request("/query/translate", {
166
- method: "POST",
167
- body: JSON.stringify({
168
- query: question,
169
- custom_instructions: customInstructions
170
- })
171
- });
172
- }
173
- /**
174
- * Parse and validate a path query without executing it.
175
- *
176
- * Returns the AST (Abstract Syntax Tree) if valid, or throws an error.
177
- *
178
- * @param pathQuery - The path query to parse
179
- * @returns Parsed AST
180
- * @throws QueryError if the query has syntax errors
181
- *
182
- * @example
183
- * ```typescript
184
- * try {
185
- * const result = await query.parse('"test" -[*]-> type:person');
186
- * console.log('Valid query, AST:', result.ast);
187
- * } catch (err) {
188
- * console.error('Invalid query:', err.message);
189
- * }
190
- * ```
191
- */
192
- async parse(pathQuery) {
193
- const url = this.buildUrl("/query/parse", { path: pathQuery });
194
- const response = await this.fetchImpl(url, {
195
- method: "GET",
196
- headers: { "Content-Type": "application/json" }
197
- });
198
- const body = await response.json();
199
- if ("error" in body && body.error === "Parse error") {
200
- throw new QueryError(
201
- body.message,
202
- "PARSE_ERROR",
203
- { position: body.position }
204
- );
205
- }
206
- if (!response.ok) {
207
- throw new QueryError(
208
- body.error || `Request failed with status ${response.status}`,
209
- "HTTP_ERROR",
210
- { status: response.status, body }
211
- );
212
- }
213
- return body;
214
- }
215
- /**
216
- * Get the path query syntax documentation.
217
- *
218
- * Returns comprehensive documentation including entry points, edge traversal,
219
- * filters, examples, and constraints.
220
- *
221
- * @returns Syntax documentation
222
- *
223
- * @example
224
- * ```typescript
225
- * const syntax = await query.syntax();
226
- *
227
- * // List all entry point types
228
- * syntax.entryPoints.types.forEach(ep => {
229
- * console.log(`${ep.syntax} - ${ep.description}`);
230
- * });
231
- *
232
- * // Show examples
233
- * syntax.examples.forEach(ex => {
234
- * console.log(`${ex.description}: ${ex.query}`);
235
- * });
236
- * ```
237
- */
238
- async syntax() {
239
- return this.request("/query/syntax", {
240
- method: "GET"
241
- });
242
- }
243
- /**
244
- * Check the health of the query service.
245
- *
246
- * @returns Health status
247
- */
248
- async health() {
249
- return this.request("/query/health", { method: "GET" });
250
- }
251
- /**
252
- * Direct semantic search against the vector index.
253
- *
254
- * This bypasses the path query syntax and directly queries Pinecone for
255
- * semantically similar entities. Useful for:
256
- * - Simple semantic searches without graph traversal
257
- * - Scoped searches filtered by source_pi (collection scope)
258
- * - Type-filtered semantic searches
259
- *
260
- * For graph traversal and path-based queries, use `path()` instead.
261
- *
262
- * @param text - Search query text
263
- * @param options - Search options (namespace, filters, top_k)
264
- * @returns Matching entities with similarity scores
265
- *
266
- * @example
267
- * ```typescript
268
- * // Simple semantic search
269
- * const results = await query.semanticSearch('photographers from New York');
270
- *
271
- * // Scoped to a specific PI (collection)
272
- * const scoped = await query.semanticSearch('portraits', {
273
- * filter: { source_pi: '01K75HQQXNTDG7BBP7PS9AWYAN' },
274
- * top_k: 20,
275
- * });
276
- *
277
- * // Filter by type
278
- * const people = await query.semanticSearch('artists', {
279
- * filter: { type: 'person' },
280
- * });
281
- *
282
- * // Search across merged entities from multiple source PIs
283
- * const merged = await query.semanticSearch('historical documents', {
284
- * filter: { merged_entities_source_pis: ['pi-1', 'pi-2'] },
285
- * });
286
- * ```
287
- */
288
- async semanticSearch(text, options = {}) {
289
- let pineconeFilter;
290
- if (options.filter) {
291
- pineconeFilter = {};
292
- if (options.filter.type) {
293
- const types = Array.isArray(options.filter.type) ? options.filter.type : [options.filter.type];
294
- pineconeFilter.type = types.length === 1 ? { $eq: types[0] } : { $in: types };
295
- }
296
- if (options.filter.source_pi) {
297
- const pis = Array.isArray(options.filter.source_pi) ? options.filter.source_pi : [options.filter.source_pi];
298
- pineconeFilter.source_pi = pis.length === 1 ? { $eq: pis[0] } : { $in: pis };
299
- }
300
- if (options.filter.merged_entities_source_pis) {
301
- const pis = Array.isArray(options.filter.merged_entities_source_pis) ? options.filter.merged_entities_source_pis : [options.filter.merged_entities_source_pis];
302
- pineconeFilter.merged_entities_source_pis = { $in: pis };
303
- }
304
- if (Object.keys(pineconeFilter).length === 0) {
305
- pineconeFilter = void 0;
306
- }
307
- }
308
- return this.request("/query/search/semantic", {
309
- method: "POST",
310
- body: JSON.stringify({
311
- text,
312
- namespace: options.namespace,
313
- filter: pineconeFilter,
314
- top_k: options.top_k
315
- })
316
- });
317
- }
318
- /**
319
- * Search for collections by semantic similarity.
320
- *
321
- * Searches the dedicated collections index for fast semantic matching.
322
- *
323
- * @param query - Search query text
324
- * @param options - Search options (limit, visibility filter)
325
- * @returns Matching collections with similarity scores
326
- *
327
- * @example
328
- * ```typescript
329
- * // Search for photography-related collections
330
- * const results = await query.searchCollections('photography');
331
- * console.log(results.collections[0].title);
332
- *
333
- * // Search only public collections
334
- * const publicResults = await query.searchCollections('history', {
335
- * visibility: 'public',
336
- * limit: 20,
337
- * });
338
- * ```
339
- */
340
- async searchCollections(query, options = {}) {
341
- return this.request("/query/search/collections", {
342
- method: "GET",
343
- query: {
344
- q: query,
345
- limit: options.limit?.toString(),
346
- visibility: options.visibility
347
- }
348
- });
349
- }
350
- };
351
- // Annotate the CommonJS export names for ESM import in node:
352
- 0 && (module.exports = {
353
- QueryClient,
354
- QueryError
355
- });
356
- //# sourceMappingURL=index.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/query/index.ts","../../src/query/errors.ts","../../src/query/client.ts"],"sourcesContent":["export { QueryClient, type QueryClientConfig } from './client';\nexport { QueryError } from './errors';\nexport type {\n // Request types\n LineageFilter,\n PathQueryOptions,\n NaturalQueryOptions,\n // Response types\n EnrichedContent,\n Entity,\n PathStep,\n QueryResultItem,\n LineageMetadata,\n QueryMetadata,\n QueryResult,\n TranslationInfo,\n NaturalQueryResult,\n TranslateResult,\n // Parse types\n ASTNodeType,\n EntryAST,\n FilterAST,\n HopAST,\n PathAST,\n ParseResult,\n ParseError,\n // Syntax documentation types\n EntryPointDoc,\n EdgeTypeDoc,\n VariableDepthDoc,\n FilterTypeDoc,\n ParameterDoc,\n ExampleDoc,\n SyntaxDocumentation,\n // Semantic search types\n SemanticSearchFilter,\n SemanticSearchOptions,\n SemanticSearchMetadata,\n SemanticSearchMatch,\n SemanticSearchResponse,\n // Collection search types\n CollectionSearchOptions,\n CollectionSearchResult,\n CollectionSearchResponse,\n} from './types';\n","/**\n * Error class for query operations\n */\nexport class QueryError extends Error {\n constructor(\n message: string,\n public code: string = 'UNKNOWN_ERROR',\n public details?: unknown\n ) {\n super(message);\n this.name = 'QueryError';\n }\n}\n","import { QueryError } from './errors';\nimport type {\n PathQueryOptions,\n NaturalQueryOptions,\n QueryResult,\n NaturalQueryResult,\n TranslateResult,\n ParseResult,\n ParseError,\n SyntaxDocumentation,\n SemanticSearchOptions,\n SemanticSearchResponse,\n CollectionSearchOptions,\n CollectionSearchResponse,\n} from './types';\n\n/**\n * Configuration for QueryClient\n */\nexport interface QueryClientConfig {\n /**\n * Gateway base URL (e.g., https://gateway.arke.institute).\n * The client will call /query/* endpoints.\n */\n gatewayUrl: string;\n /**\n * Optional custom fetch implementation (useful for testing).\n */\n fetchImpl?: typeof fetch;\n}\n\ntype JsonBody = Record<string, unknown>;\n\n/**\n * Client for querying the Arke knowledge graph.\n *\n * All query endpoints are public and do not require authentication.\n *\n * @example\n * ```typescript\n * const query = new QueryClient({\n * gatewayUrl: 'https://gateway.arke.institute',\n * });\n *\n * // Direct path query\n * const results = await query.path('\"alice austen\" -[*]{,4}-> type:person');\n *\n * // Natural language query\n * const nlResults = await query.natural('Find photographers connected to Alice Austen');\n *\n * // Get syntax documentation\n * const syntax = await query.syntax();\n * ```\n */\nexport class QueryClient {\n private baseUrl: string;\n private fetchImpl: typeof fetch;\n\n constructor(config: QueryClientConfig) {\n this.baseUrl = config.gatewayUrl.replace(/\\/$/, '');\n this.fetchImpl = config.fetchImpl ?? fetch;\n }\n\n // ---------------------------------------------------------------------------\n // Request helpers\n // ---------------------------------------------------------------------------\n\n private buildUrl(path: string, query?: Record<string, string | undefined>) {\n const url = new URL(`${this.baseUrl}${path}`);\n if (query) {\n Object.entries(query).forEach(([key, value]) => {\n if (value !== undefined && value !== null) {\n url.searchParams.set(key, String(value));\n }\n });\n }\n return url.toString();\n }\n\n private async request<T>(\n path: string,\n options: RequestInit & {\n query?: Record<string, string | undefined>;\n } = {}\n ): Promise<T> {\n const url = this.buildUrl(path, options.query);\n const headers = new Headers({ 'Content-Type': 'application/json' });\n if (options.headers) {\n Object.entries(options.headers).forEach(([k, v]) => {\n if (v !== undefined) headers.set(k, v as string);\n });\n }\n\n const response = await this.fetchImpl(url, { ...options, headers });\n\n if (response.ok) {\n const contentType = response.headers.get('content-type') || '';\n if (contentType.includes('application/json')) {\n return (await response.json()) as T;\n }\n return (await response.text()) as unknown as T;\n }\n\n let body: unknown;\n const text = await response.text();\n try {\n body = JSON.parse(text);\n } catch {\n body = text;\n }\n\n const message =\n (body as JsonBody)?.error && typeof (body as JsonBody).error === 'string'\n ? ((body as JsonBody).error as string)\n : (body as JsonBody)?.message && typeof (body as JsonBody).message === 'string'\n ? ((body as JsonBody).message as string)\n : `Request failed with status ${response.status}`;\n\n throw new QueryError(message, 'HTTP_ERROR', {\n status: response.status,\n body,\n });\n }\n\n // ---------------------------------------------------------------------------\n // Query methods\n // ---------------------------------------------------------------------------\n\n /**\n * Execute a path query against the knowledge graph.\n *\n * @param pathQuery - The path query string (e.g., '\"alice austen\" -[*]{,4}-> type:person')\n * @param options - Query options (k, k_explore, lineage, enrich, etc.)\n * @returns Query results with entities, paths, and metadata\n *\n * @example\n * ```typescript\n * // Simple semantic search\n * const results = await query.path('\"Washington\" type:person');\n *\n * // Multi-hop traversal\n * const results = await query.path('\"alice austen\" -[*]{,4}-> type:person ~ \"photographer\"');\n *\n * // With lineage filtering (collection scope)\n * const results = await query.path('\"letters\" type:document', {\n * lineage: { sourcePi: 'arke:my_collection', direction: 'descendants' },\n * k: 10,\n * });\n * ```\n */\n async path(pathQuery: string, options: PathQueryOptions = {}): Promise<QueryResult> {\n return this.request<QueryResult>('/query/path', {\n method: 'POST',\n body: JSON.stringify({\n path: pathQuery,\n ...options,\n }),\n });\n }\n\n /**\n * Execute a natural language query.\n *\n * The query is translated to a path query using an LLM, then executed.\n *\n * @param question - Natural language question\n * @param options - Query options including custom_instructions for the LLM\n * @returns Query results with translation info\n *\n * @example\n * ```typescript\n * const results = await query.natural('Find photographers connected to Alice Austen');\n * console.log('Generated query:', results.translation.path);\n * console.log('Explanation:', results.translation.explanation);\n * ```\n */\n async natural(question: string, options: NaturalQueryOptions = {}): Promise<NaturalQueryResult> {\n const { custom_instructions, ...queryOptions } = options;\n return this.request<NaturalQueryResult>('/query/natural', {\n method: 'POST',\n body: JSON.stringify({\n query: question,\n custom_instructions,\n ...queryOptions,\n }),\n });\n }\n\n /**\n * Translate a natural language question to a path query without executing it.\n *\n * Useful for understanding how questions are translated or for manual execution later.\n *\n * @param question - Natural language question\n * @param customInstructions - Optional additional instructions for the LLM\n * @returns Translation result with path query and explanation\n *\n * @example\n * ```typescript\n * const result = await query.translate('Who wrote letters from Philadelphia?');\n * console.log('Path query:', result.path);\n * // '\"letters\" <-[authored, wrote]- type:person -[located]-> \"Philadelphia\"'\n * ```\n */\n async translate(question: string, customInstructions?: string): Promise<TranslateResult> {\n return this.request<TranslateResult>('/query/translate', {\n method: 'POST',\n body: JSON.stringify({\n query: question,\n custom_instructions: customInstructions,\n }),\n });\n }\n\n /**\n * Parse and validate a path query without executing it.\n *\n * Returns the AST (Abstract Syntax Tree) if valid, or throws an error.\n *\n * @param pathQuery - The path query to parse\n * @returns Parsed AST\n * @throws QueryError if the query has syntax errors\n *\n * @example\n * ```typescript\n * try {\n * const result = await query.parse('\"test\" -[*]-> type:person');\n * console.log('Valid query, AST:', result.ast);\n * } catch (err) {\n * console.error('Invalid query:', err.message);\n * }\n * ```\n */\n async parse(pathQuery: string): Promise<ParseResult> {\n const url = this.buildUrl('/query/parse', { path: pathQuery });\n const response = await this.fetchImpl(url, {\n method: 'GET',\n headers: { 'Content-Type': 'application/json' },\n });\n\n const body = await response.json() as ParseResult | ParseError;\n\n // Check if it's an error response (parse errors return 400)\n if ('error' in body && body.error === 'Parse error') {\n throw new QueryError(\n (body as ParseError).message,\n 'PARSE_ERROR',\n { position: (body as ParseError).position }\n );\n }\n\n if (!response.ok) {\n throw new QueryError(\n (body as any).error || `Request failed with status ${response.status}`,\n 'HTTP_ERROR',\n { status: response.status, body }\n );\n }\n\n return body as ParseResult;\n }\n\n /**\n * Get the path query syntax documentation.\n *\n * Returns comprehensive documentation including entry points, edge traversal,\n * filters, examples, and constraints.\n *\n * @returns Syntax documentation\n *\n * @example\n * ```typescript\n * const syntax = await query.syntax();\n *\n * // List all entry point types\n * syntax.entryPoints.types.forEach(ep => {\n * console.log(`${ep.syntax} - ${ep.description}`);\n * });\n *\n * // Show examples\n * syntax.examples.forEach(ex => {\n * console.log(`${ex.description}: ${ex.query}`);\n * });\n * ```\n */\n async syntax(): Promise<SyntaxDocumentation> {\n return this.request<SyntaxDocumentation>('/query/syntax', {\n method: 'GET',\n });\n }\n\n /**\n * Check the health of the query service.\n *\n * @returns Health status\n */\n async health(): Promise<{ status: string; service: string; version: string }> {\n return this.request('/query/health', { method: 'GET' });\n }\n\n /**\n * Direct semantic search against the vector index.\n *\n * This bypasses the path query syntax and directly queries Pinecone for\n * semantically similar entities. Useful for:\n * - Simple semantic searches without graph traversal\n * - Scoped searches filtered by source_pi (collection scope)\n * - Type-filtered semantic searches\n *\n * For graph traversal and path-based queries, use `path()` instead.\n *\n * @param text - Search query text\n * @param options - Search options (namespace, filters, top_k)\n * @returns Matching entities with similarity scores\n *\n * @example\n * ```typescript\n * // Simple semantic search\n * const results = await query.semanticSearch('photographers from New York');\n *\n * // Scoped to a specific PI (collection)\n * const scoped = await query.semanticSearch('portraits', {\n * filter: { source_pi: '01K75HQQXNTDG7BBP7PS9AWYAN' },\n * top_k: 20,\n * });\n *\n * // Filter by type\n * const people = await query.semanticSearch('artists', {\n * filter: { type: 'person' },\n * });\n *\n * // Search across merged entities from multiple source PIs\n * const merged = await query.semanticSearch('historical documents', {\n * filter: { merged_entities_source_pis: ['pi-1', 'pi-2'] },\n * });\n * ```\n */\n async semanticSearch(\n text: string,\n options: SemanticSearchOptions = {}\n ): Promise<SemanticSearchResponse> {\n // Build Pinecone-compatible filter from our typed filter\n let pineconeFilter: Record<string, unknown> | undefined;\n\n if (options.filter) {\n pineconeFilter = {};\n\n if (options.filter.type) {\n const types = Array.isArray(options.filter.type)\n ? options.filter.type\n : [options.filter.type];\n pineconeFilter.type = types.length === 1\n ? { $eq: types[0] }\n : { $in: types };\n }\n\n if (options.filter.source_pi) {\n const pis = Array.isArray(options.filter.source_pi)\n ? options.filter.source_pi\n : [options.filter.source_pi];\n pineconeFilter.source_pi = pis.length === 1\n ? { $eq: pis[0] }\n : { $in: pis };\n }\n\n if (options.filter.merged_entities_source_pis) {\n const pis = Array.isArray(options.filter.merged_entities_source_pis)\n ? options.filter.merged_entities_source_pis\n : [options.filter.merged_entities_source_pis];\n // Use $in for array field matching (any of the provided PIs)\n pineconeFilter.merged_entities_source_pis = { $in: pis };\n }\n\n // If no filters were actually set, clear the object\n if (Object.keys(pineconeFilter).length === 0) {\n pineconeFilter = undefined;\n }\n }\n\n return this.request<SemanticSearchResponse>('/query/search/semantic', {\n method: 'POST',\n body: JSON.stringify({\n text,\n namespace: options.namespace,\n filter: pineconeFilter,\n top_k: options.top_k,\n }),\n });\n }\n\n /**\n * Search for collections by semantic similarity.\n *\n * Searches the dedicated collections index for fast semantic matching.\n *\n * @param query - Search query text\n * @param options - Search options (limit, visibility filter)\n * @returns Matching collections with similarity scores\n *\n * @example\n * ```typescript\n * // Search for photography-related collections\n * const results = await query.searchCollections('photography');\n * console.log(results.collections[0].title);\n *\n * // Search only public collections\n * const publicResults = await query.searchCollections('history', {\n * visibility: 'public',\n * limit: 20,\n * });\n * ```\n */\n async searchCollections(\n query: string,\n options: CollectionSearchOptions = {}\n ): Promise<CollectionSearchResponse> {\n return this.request<CollectionSearchResponse>('/query/search/collections', {\n method: 'GET',\n query: {\n q: query,\n limit: options.limit?.toString(),\n visibility: options.visibility,\n },\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACGO,IAAM,aAAN,cAAyB,MAAM;AAAA,EACpC,YACE,SACO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