@anvailabs/proximadb-client 0.3.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/README.md +160 -0
- package/dist/client.d.ts +319 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +681 -0
- package/dist/client.js.map +1 -0
- package/dist/collection.d.ts +227 -0
- package/dist/collection.d.ts.map +1 -0
- package/dist/collection.js +436 -0
- package/dist/collection.js.map +1 -0
- package/dist/esm/client.js +674 -0
- package/dist/esm/client.js.map +1 -0
- package/dist/esm/collection.js +428 -0
- package/dist/esm/collection.js.map +1 -0
- package/dist/esm/filter.js +228 -0
- package/dist/esm/filter.js.map +1 -0
- package/dist/esm/generated/schema.js +6 -0
- package/dist/esm/generated/schema.js.map +1 -0
- package/dist/esm/graph.js +678 -0
- package/dist/esm/graph.js.map +1 -0
- package/dist/esm/index.js +86 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/search.js +317 -0
- package/dist/esm/search.js.map +1 -0
- package/dist/esm/transport.js +33 -0
- package/dist/esm/transport.js.map +1 -0
- package/dist/esm/types.js +181 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/filter.d.ts +51 -0
- package/dist/filter.d.ts.map +1 -0
- package/dist/filter.js +241 -0
- package/dist/filter.js.map +1 -0
- package/dist/generated/schema.d.ts +4271 -0
- package/dist/generated/schema.d.ts.map +1 -0
- package/dist/generated/schema.js +7 -0
- package/dist/generated/schema.js.map +1 -0
- package/dist/graph.d.ts +350 -0
- package/dist/graph.d.ts.map +1 -0
- package/dist/graph.js +690 -0
- package/dist/graph.js.map +1 -0
- package/dist/index.d.ts +58 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +126 -0
- package/dist/index.js.map +1 -0
- package/dist/search.d.ts +160 -0
- package/dist/search.d.ts.map +1 -0
- package/dist/search.js +322 -0
- package/dist/search.js.map +1 -0
- package/dist/transport.d.ts +40 -0
- package/dist/transport.d.ts.map +1 -0
- package/dist/transport.js +39 -0
- package/dist/transport.js.map +1 -0
- package/dist/types.d.ts +632 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +185 -0
- package/dist/types.js.map +1 -0
- package/package.json +72 -0
- package/src/client.ts +856 -0
- package/src/collection.ts +578 -0
- package/src/filter.ts +280 -0
- package/src/generated/schema.ts +4271 -0
- package/src/graph.ts +811 -0
- package/src/index.ts +184 -0
- package/src/search.ts +401 -0
- package/src/transport.ts +52 -0
- package/src/types.ts +726 -0
package/src/types.ts
ADDED
|
@@ -0,0 +1,726 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ProximaDB TypeScript SDK - Type Definitions
|
|
3
|
+
*
|
|
4
|
+
* Copyright 2025 ProximaDB Contributors
|
|
5
|
+
* Licensed under the Apache License, Version 2.0
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
// ============================================================================
|
|
9
|
+
// ENUMS
|
|
10
|
+
// ============================================================================
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Distance metrics for vector similarity search
|
|
14
|
+
*/
|
|
15
|
+
export enum DistanceMetric {
|
|
16
|
+
/** Cosine similarity (normalized dot product) */
|
|
17
|
+
Cosine = "cosine",
|
|
18
|
+
/** Euclidean (L2) distance */
|
|
19
|
+
Euclidean = "euclidean",
|
|
20
|
+
/** Dot product similarity */
|
|
21
|
+
DotProduct = "dot_product",
|
|
22
|
+
/** Manhattan (L1) distance */
|
|
23
|
+
Manhattan = "manhattan",
|
|
24
|
+
/** Hamming distance for binary vectors */
|
|
25
|
+
Hamming = "hamming",
|
|
26
|
+
/** Jaccard similarity for set-like vectors */
|
|
27
|
+
Jaccard = "jaccard",
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Storage engines available in ProximaDB
|
|
32
|
+
*/
|
|
33
|
+
export enum StorageEngine {
|
|
34
|
+
/** Write-optimized, real-time workloads */
|
|
35
|
+
Sst = "sst",
|
|
36
|
+
/** Locality-optimized with Hilbert curves */
|
|
37
|
+
Helix = "helix",
|
|
38
|
+
/** Columnar Parquet for analytics */
|
|
39
|
+
Viper = "viper",
|
|
40
|
+
/** Ultra-low latency for small datasets */
|
|
41
|
+
Swift = "swift",
|
|
42
|
+
/** Progressive columnar for mixed workloads */
|
|
43
|
+
Nova = "nova",
|
|
44
|
+
/** Adaptive row-group for dynamic workloads */
|
|
45
|
+
Raptor = "raptor",
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Index types for vector search
|
|
50
|
+
*/
|
|
51
|
+
export enum IndexType {
|
|
52
|
+
/** Hierarchical Navigable Small World */
|
|
53
|
+
Hnsw = "hnsw",
|
|
54
|
+
/** Inverted File Index */
|
|
55
|
+
Ivf = "ivf",
|
|
56
|
+
/** Locality Sensitive Hashing */
|
|
57
|
+
Lsh = "lsh",
|
|
58
|
+
/** Brute force (no index) */
|
|
59
|
+
Flat = "flat",
|
|
60
|
+
/** Product Quantization */
|
|
61
|
+
Pq = "pq",
|
|
62
|
+
/** Approximate Nearest Neighbors Oh Yeah */
|
|
63
|
+
Annoy = "annoy",
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Filter operations for metadata filtering
|
|
68
|
+
*/
|
|
69
|
+
export enum FilterOp {
|
|
70
|
+
/** Equal to */
|
|
71
|
+
Eq = "equals",
|
|
72
|
+
/** Not equal to */
|
|
73
|
+
Ne = "not_equals",
|
|
74
|
+
/** Greater than */
|
|
75
|
+
Gt = "gt",
|
|
76
|
+
/** Greater than or equal */
|
|
77
|
+
Gte = "gte",
|
|
78
|
+
/** Less than */
|
|
79
|
+
Lt = "lt",
|
|
80
|
+
/** Less than or equal */
|
|
81
|
+
Lte = "lte",
|
|
82
|
+
/** In list of values */
|
|
83
|
+
In = "in",
|
|
84
|
+
/** Not in list of values */
|
|
85
|
+
NotIn = "not_in",
|
|
86
|
+
/** Contains (for strings/arrays) */
|
|
87
|
+
Contains = "contains",
|
|
88
|
+
/** Starts with (for strings) */
|
|
89
|
+
StartsWith = "starts_with",
|
|
90
|
+
/** Ends with (for strings) */
|
|
91
|
+
EndsWith = "ends_with",
|
|
92
|
+
/** Field exists */
|
|
93
|
+
Exists = "exists",
|
|
94
|
+
/** Field is null */
|
|
95
|
+
IsNull = "is_null",
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Logical operators for combining filter conditions
|
|
100
|
+
*/
|
|
101
|
+
export enum LogicalOp {
|
|
102
|
+
/** All conditions must match */
|
|
103
|
+
And = "and",
|
|
104
|
+
/** Any condition must match */
|
|
105
|
+
Or = "or",
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Search mode for controlling recall vs performance tradeoff
|
|
110
|
+
*/
|
|
111
|
+
export enum SearchMode {
|
|
112
|
+
/** Exact search - 100% recall, searches all partitions */
|
|
113
|
+
Exact = "exact",
|
|
114
|
+
/** Approximate search - faster with ~95% recall */
|
|
115
|
+
Approximate = "approximate",
|
|
116
|
+
/** Adaptive search - auto-selects based on dataset size */
|
|
117
|
+
Adaptive = "adaptive",
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Traversal direction for graph queries
|
|
122
|
+
*/
|
|
123
|
+
export enum TraversalDirection {
|
|
124
|
+
/** Traverse outgoing edges */
|
|
125
|
+
Outgoing = "outgoing",
|
|
126
|
+
/** Traverse incoming edges */
|
|
127
|
+
Incoming = "incoming",
|
|
128
|
+
/** Traverse both directions */
|
|
129
|
+
Both = "both",
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// ============================================================================
|
|
133
|
+
// CORE INTERFACES
|
|
134
|
+
// ============================================================================
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Metadata value types supported by ProximaDB
|
|
138
|
+
*/
|
|
139
|
+
export type MetadataValue = string | number | boolean | string[] | number[];
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Metadata dictionary type
|
|
143
|
+
*/
|
|
144
|
+
export type Metadata = Record<string, MetadataValue>;
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* JSON-compatible value type for filters
|
|
148
|
+
*/
|
|
149
|
+
export type JsonValue =
|
|
150
|
+
| string
|
|
151
|
+
| number
|
|
152
|
+
| boolean
|
|
153
|
+
| null
|
|
154
|
+
| JsonValue[]
|
|
155
|
+
| { [key: string]: JsonValue };
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Canonical ProximaRecord payload for storing records with optional vectors.
|
|
159
|
+
*/
|
|
160
|
+
export interface ProximaRecord {
|
|
161
|
+
/** Unique record identifier */
|
|
162
|
+
id: string;
|
|
163
|
+
/** Dense vector embedding */
|
|
164
|
+
vector: number[];
|
|
165
|
+
/** Rich record properties */
|
|
166
|
+
props?: Record<string, JsonValue>;
|
|
167
|
+
/** @deprecated Use props. */
|
|
168
|
+
metadata?: Metadata;
|
|
169
|
+
/** Creation timestamp in milliseconds */
|
|
170
|
+
timestampMs?: number;
|
|
171
|
+
/** Last update timestamp in milliseconds */
|
|
172
|
+
updatedAtMs?: number;
|
|
173
|
+
/** Expiration timestamp in milliseconds (TTL support) */
|
|
174
|
+
expiresAtMs?: number;
|
|
175
|
+
/** Version number for optimistic concurrency */
|
|
176
|
+
version?: number;
|
|
177
|
+
/** Original content that generated this vector (e.g., chunk text for RAG) */
|
|
178
|
+
source?: string;
|
|
179
|
+
/** Text fields for dedicated text storage */
|
|
180
|
+
textFields?: Array<{ name: string; content: string }>;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* @deprecated Use ProximaRecord. VectorRecord remains a compatibility alias.
|
|
185
|
+
*/
|
|
186
|
+
export type VectorRecord = ProximaRecord;
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Search result with score and optional metadata
|
|
190
|
+
*/
|
|
191
|
+
export interface SearchResult {
|
|
192
|
+
/** Vector ID */
|
|
193
|
+
id: string;
|
|
194
|
+
/** Similarity score */
|
|
195
|
+
score: number;
|
|
196
|
+
/** Associated metadata (if requested) */
|
|
197
|
+
metadata?: Metadata;
|
|
198
|
+
/** Vector data (if requested) */
|
|
199
|
+
vector?: number[];
|
|
200
|
+
/** Result rank in the result set */
|
|
201
|
+
rank?: number;
|
|
202
|
+
/** Version number */
|
|
203
|
+
version?: number;
|
|
204
|
+
/** Original source content */
|
|
205
|
+
source?: string;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Collection configuration
|
|
210
|
+
*/
|
|
211
|
+
export interface CollectionConfig {
|
|
212
|
+
/** Collection name (min 8 characters) */
|
|
213
|
+
name: string;
|
|
214
|
+
/** Vector dimension */
|
|
215
|
+
dimension: number;
|
|
216
|
+
/** Distance metric for similarity */
|
|
217
|
+
distanceMetric?: DistanceMetric;
|
|
218
|
+
/** Storage engine */
|
|
219
|
+
storageEngine?: StorageEngine;
|
|
220
|
+
/** Index type */
|
|
221
|
+
indexType?: IndexType;
|
|
222
|
+
/** Collection description */
|
|
223
|
+
description?: string;
|
|
224
|
+
/** Collection tags */
|
|
225
|
+
tags?: string[];
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Collection statistics
|
|
230
|
+
*/
|
|
231
|
+
export interface CollectionStats {
|
|
232
|
+
/** Number of vectors in the collection */
|
|
233
|
+
vectorCount: number;
|
|
234
|
+
/** Index size in bytes */
|
|
235
|
+
indexSizeBytes: number;
|
|
236
|
+
/** Data size in bytes */
|
|
237
|
+
dataSizeBytes: number;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Collection information
|
|
242
|
+
*/
|
|
243
|
+
export interface CollectionInfo {
|
|
244
|
+
/** Collection ID */
|
|
245
|
+
id: string;
|
|
246
|
+
/** Collection name */
|
|
247
|
+
name: string;
|
|
248
|
+
/** Vector dimension */
|
|
249
|
+
dimension: number;
|
|
250
|
+
/** Distance metric */
|
|
251
|
+
metric: string;
|
|
252
|
+
/** Creation timestamp in milliseconds */
|
|
253
|
+
createdAtMs: number;
|
|
254
|
+
/** Last update timestamp in milliseconds */
|
|
255
|
+
updatedAtMs: number;
|
|
256
|
+
/** Number of vectors */
|
|
257
|
+
vectorCount?: number;
|
|
258
|
+
/** Whether the collection is indexed */
|
|
259
|
+
indexed?: boolean;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Health status response
|
|
264
|
+
*/
|
|
265
|
+
export interface HealthStatus {
|
|
266
|
+
/** Server status */
|
|
267
|
+
status: string;
|
|
268
|
+
/** Server version */
|
|
269
|
+
version: string;
|
|
270
|
+
/** Uptime in seconds */
|
|
271
|
+
uptimeSeconds: number;
|
|
272
|
+
/** Service statuses */
|
|
273
|
+
services: Record<string, string>;
|
|
274
|
+
/** Timestamp in milliseconds */
|
|
275
|
+
timestampMs: number;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
// ============================================================================
|
|
279
|
+
// PROBE / SCHEMA / QUERY INTERFACES (v2 wire types — snake_case)
|
|
280
|
+
// ============================================================================
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Kubernetes-style liveness/readiness probe response.
|
|
284
|
+
*
|
|
285
|
+
* Matches the `ProbeResponse` schema in docs/openapi/proximadb-openapi.yaml.
|
|
286
|
+
*/
|
|
287
|
+
export interface ProbeResponse {
|
|
288
|
+
/** Probe status (e.g. "ok", "ready") */
|
|
289
|
+
status: string;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* Column definition for a typed schema.
|
|
294
|
+
*
|
|
295
|
+
* Field names are snake_case to wire-match the OpenAPI spec / Python SDK.
|
|
296
|
+
*/
|
|
297
|
+
export interface ColumnDefinition {
|
|
298
|
+
/** Column name */
|
|
299
|
+
name: string;
|
|
300
|
+
/** Column data type (see OpenAPI enum: text, integer, float, ...) */
|
|
301
|
+
data_type: string;
|
|
302
|
+
/** Whether the column is nullable */
|
|
303
|
+
nullable?: boolean;
|
|
304
|
+
/** Whether the column is indexed */
|
|
305
|
+
indexed?: boolean;
|
|
306
|
+
/** Whether the column is filterable */
|
|
307
|
+
filterable?: boolean;
|
|
308
|
+
/** Maximum length (for text types) */
|
|
309
|
+
max_length?: number;
|
|
310
|
+
/** Decimal precision */
|
|
311
|
+
precision?: number;
|
|
312
|
+
/** Decimal scale */
|
|
313
|
+
scale?: number;
|
|
314
|
+
/** Vector dimension (for `vector` columns) */
|
|
315
|
+
vector_dimension?: number;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* Typed schema definition for a collection.
|
|
320
|
+
*/
|
|
321
|
+
export interface SchemaDefinition {
|
|
322
|
+
/** Column definitions */
|
|
323
|
+
columns: ColumnDefinition[];
|
|
324
|
+
/** Schema enforcement strategy */
|
|
325
|
+
enforcement?: "strict" | "flexible" | "hybrid";
|
|
326
|
+
/** Whether records may include fields beyond the declared columns */
|
|
327
|
+
allow_additional_fields?: boolean;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* Response from GET /api/v2/collections/{id}/schema.
|
|
332
|
+
*/
|
|
333
|
+
export interface SchemaResponse {
|
|
334
|
+
schema_id: string;
|
|
335
|
+
schema_version: string;
|
|
336
|
+
collection_id: string;
|
|
337
|
+
schema: SchemaDefinition;
|
|
338
|
+
created_at: string;
|
|
339
|
+
updated_at?: string | null;
|
|
340
|
+
parent_schema_id?: string | null;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* Request body for PUT /api/v2/collections/{id}/schema.
|
|
345
|
+
*
|
|
346
|
+
* Wire-encodes as a `SchemaDefinition` plus optional `force` flag.
|
|
347
|
+
*/
|
|
348
|
+
export interface UpdateSchemaRequest extends SchemaDefinition {
|
|
349
|
+
/** Allow incompatible schema changes */
|
|
350
|
+
force?: boolean;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* Response from PUT /api/v2/collections/{id}/schema.
|
|
355
|
+
*/
|
|
356
|
+
export interface UpdateSchemaResponse {
|
|
357
|
+
schema_id: string;
|
|
358
|
+
schema_version: string;
|
|
359
|
+
previous_schema_id: string;
|
|
360
|
+
changes: unknown[];
|
|
361
|
+
warnings: unknown[];
|
|
362
|
+
updated_at: string;
|
|
363
|
+
[key: string]: unknown;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* Supported query languages for the shared query facade.
|
|
368
|
+
*/
|
|
369
|
+
export type QueryLanguage = "uql" | "aql" | "federated";
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* Request body for POST /api/v2/query.
|
|
373
|
+
*/
|
|
374
|
+
export interface QueryRequest {
|
|
375
|
+
/** Query language */
|
|
376
|
+
language: QueryLanguage;
|
|
377
|
+
/** Query text (AQL / UQL) */
|
|
378
|
+
query: string;
|
|
379
|
+
/** Optional bound parameters (ProximaValue-encoded) */
|
|
380
|
+
parameters?: JsonValue[];
|
|
381
|
+
/** Optional default collection */
|
|
382
|
+
collection?: string | null;
|
|
383
|
+
/** Optional row-limit cap */
|
|
384
|
+
limit?: number | null;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
/**
|
|
388
|
+
* Request body for POST /api/v2/query/explain.
|
|
389
|
+
*/
|
|
390
|
+
export interface ExplainQueryRequest {
|
|
391
|
+
/** Query language */
|
|
392
|
+
language: QueryLanguage;
|
|
393
|
+
/** Query text (AQL / UQL) */
|
|
394
|
+
query: string;
|
|
395
|
+
/** Optional default collection */
|
|
396
|
+
collection?: string | null;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
/**
|
|
400
|
+
* Response from POST /api/v2/query and POST /api/v2/query/explain.
|
|
401
|
+
*
|
|
402
|
+
* Open shape per the OpenAPI contract — implementations typically return
|
|
403
|
+
* records / total_count / metrics / plan / diagnostics depending on the
|
|
404
|
+
* language and endpoint.
|
|
405
|
+
*/
|
|
406
|
+
export interface QueryResponse {
|
|
407
|
+
[key: string]: unknown;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
// ============================================================================
|
|
411
|
+
// FILTER INTERFACES
|
|
412
|
+
// ============================================================================
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* A single filter condition
|
|
416
|
+
*/
|
|
417
|
+
export interface FilterCondition {
|
|
418
|
+
/** Field name */
|
|
419
|
+
field: string;
|
|
420
|
+
/** Operation */
|
|
421
|
+
operation: string;
|
|
422
|
+
/** Value to compare (optional for exists/is_null) */
|
|
423
|
+
value?: JsonValue;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
/**
|
|
427
|
+
* A filter group containing conditions and nested groups
|
|
428
|
+
*/
|
|
429
|
+
export interface FilterGroup {
|
|
430
|
+
/** Logical operator for combining conditions */
|
|
431
|
+
operator: string;
|
|
432
|
+
/** List of conditions */
|
|
433
|
+
conditions: FilterNode[];
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* A node in the filter tree
|
|
438
|
+
*/
|
|
439
|
+
export type FilterNode = FilterCondition | FilterGroup;
|
|
440
|
+
|
|
441
|
+
/**
|
|
442
|
+
* Compiled filter expression
|
|
443
|
+
*/
|
|
444
|
+
export interface Filter {
|
|
445
|
+
/** Root filter group */
|
|
446
|
+
operator: string;
|
|
447
|
+
conditions: FilterNode[];
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
// ============================================================================
|
|
451
|
+
// GRAPH INTERFACES
|
|
452
|
+
// ============================================================================
|
|
453
|
+
|
|
454
|
+
/**
|
|
455
|
+
* A graph node
|
|
456
|
+
*/
|
|
457
|
+
export interface GraphNode {
|
|
458
|
+
/** Unique node identifier */
|
|
459
|
+
id: string;
|
|
460
|
+
/** Node label (type) */
|
|
461
|
+
label?: string;
|
|
462
|
+
/** Node properties */
|
|
463
|
+
properties: Record<string, JsonValue>;
|
|
464
|
+
/** Optional embedding vector for semantic operations */
|
|
465
|
+
vector?: number[];
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
/**
|
|
469
|
+
* A graph edge
|
|
470
|
+
*/
|
|
471
|
+
export interface GraphEdge {
|
|
472
|
+
/** Source node ID */
|
|
473
|
+
source: string;
|
|
474
|
+
/** Target node ID */
|
|
475
|
+
target: string;
|
|
476
|
+
/** Relationship type */
|
|
477
|
+
relationship: string;
|
|
478
|
+
/** Edge properties */
|
|
479
|
+
properties: Record<string, JsonValue>;
|
|
480
|
+
/** Optional weight */
|
|
481
|
+
weight?: number;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
/**
|
|
485
|
+
* Graph traversal result
|
|
486
|
+
*/
|
|
487
|
+
export interface TraversalResult {
|
|
488
|
+
/** Nodes in the traversal path */
|
|
489
|
+
nodes: GraphNode[];
|
|
490
|
+
/** Edges in the traversal path */
|
|
491
|
+
edges: GraphEdge[];
|
|
492
|
+
/** Paths from start to each node */
|
|
493
|
+
paths: string[][];
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
/**
|
|
497
|
+
* Graph information
|
|
498
|
+
*/
|
|
499
|
+
export interface GraphInfo {
|
|
500
|
+
/** Graph name */
|
|
501
|
+
name: string;
|
|
502
|
+
/** Number of nodes */
|
|
503
|
+
nodeCount: number;
|
|
504
|
+
/** Number of edges */
|
|
505
|
+
edgeCount: number;
|
|
506
|
+
/** Graph description */
|
|
507
|
+
description?: string;
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
// ----------------------------------------------------------------------------
|
|
511
|
+
// Server-true graph payload shapes (OpenAPI: docs/openapi/proximadb-openapi.yaml)
|
|
512
|
+
//
|
|
513
|
+
// These mirror the wire-level types the server actually accepts. The legacy
|
|
514
|
+
// `GraphNode` / `GraphEdge` interfaces above remain as ergonomic SDK-facing
|
|
515
|
+
// types; the SDK builders now lower them into the spec types below.
|
|
516
|
+
// ----------------------------------------------------------------------------
|
|
517
|
+
|
|
518
|
+
/**
|
|
519
|
+
* Embedding payload nested inside `NodeInput.embedding`.
|
|
520
|
+
*
|
|
521
|
+
* OpenAPI: `EmbeddingInput` — `{ vector, model_id?, modality? }`.
|
|
522
|
+
*/
|
|
523
|
+
export interface EmbeddingInput {
|
|
524
|
+
vector: number[];
|
|
525
|
+
model_id?: string;
|
|
526
|
+
modality?: string;
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
/**
|
|
530
|
+
* Node payload nested inside `CreateNodeRequest.node` and
|
|
531
|
+
* `BatchCreateNodesRequest.nodes[]`.
|
|
532
|
+
*
|
|
533
|
+
* OpenAPI: `NodeInput` — `{ id, labels?, properties?, embedding? }`.
|
|
534
|
+
*/
|
|
535
|
+
export interface NodeInput {
|
|
536
|
+
id: string;
|
|
537
|
+
labels?: string[];
|
|
538
|
+
properties?: Record<string, JsonValue>;
|
|
539
|
+
embedding?: EmbeddingInput;
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
/**
|
|
543
|
+
* Edge payload nested inside `CreateEdgeRequest.edge` and
|
|
544
|
+
* `BatchCreateEdgesRequest.edges[]`.
|
|
545
|
+
*
|
|
546
|
+
* OpenAPI: `EdgeInput` — `{ id, from_node_id, to_node_id, edge_type,
|
|
547
|
+
* properties?, weight? }`.
|
|
548
|
+
*/
|
|
549
|
+
export interface EdgeInput {
|
|
550
|
+
id: string;
|
|
551
|
+
from_node_id: string;
|
|
552
|
+
to_node_id: string;
|
|
553
|
+
edge_type: string;
|
|
554
|
+
properties?: Record<string, JsonValue>;
|
|
555
|
+
weight?: number;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
// ============================================================================
|
|
559
|
+
// CLIENT CONFIGURATION
|
|
560
|
+
// ============================================================================
|
|
561
|
+
|
|
562
|
+
/**
|
|
563
|
+
* Client configuration options
|
|
564
|
+
*/
|
|
565
|
+
export interface ClientConfig {
|
|
566
|
+
/** Server URL */
|
|
567
|
+
url: string;
|
|
568
|
+
/** Request timeout in milliseconds */
|
|
569
|
+
timeoutMs?: number;
|
|
570
|
+
/** Number of retries for failed requests */
|
|
571
|
+
maxRetries?: number;
|
|
572
|
+
/** API key for authentication */
|
|
573
|
+
apiKey?: string;
|
|
574
|
+
/** Enable connection pooling */
|
|
575
|
+
poolConnections?: boolean;
|
|
576
|
+
/** Maximum idle connections in pool */
|
|
577
|
+
maxIdleConnections?: number;
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
/**
|
|
581
|
+
* Search request options
|
|
582
|
+
*/
|
|
583
|
+
export interface SearchOptions {
|
|
584
|
+
/** Number of results to return */
|
|
585
|
+
topK?: number;
|
|
586
|
+
/** Filter expression string */
|
|
587
|
+
filter?: string;
|
|
588
|
+
/** Search mode */
|
|
589
|
+
mode?: SearchMode;
|
|
590
|
+
/** Number of partitions to probe (for approximate search) */
|
|
591
|
+
nprobe?: number;
|
|
592
|
+
/** Include vectors in results */
|
|
593
|
+
includeVectors?: boolean;
|
|
594
|
+
/** Include metadata in results */
|
|
595
|
+
includeMetadata?: boolean;
|
|
596
|
+
/** Minimum score threshold */
|
|
597
|
+
minScore?: number;
|
|
598
|
+
/** Request timeout in milliseconds */
|
|
599
|
+
timeoutMs?: number;
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
/**
|
|
603
|
+
* Insert operation options
|
|
604
|
+
*/
|
|
605
|
+
export interface InsertOptions {
|
|
606
|
+
/** Timeout in milliseconds */
|
|
607
|
+
timeoutMs?: number;
|
|
608
|
+
/** Skip validation */
|
|
609
|
+
skipValidation?: boolean;
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
/**
|
|
613
|
+
* Update operation options
|
|
614
|
+
*/
|
|
615
|
+
export interface UpdateOptions {
|
|
616
|
+
/** Replace all metadata instead of merging */
|
|
617
|
+
replaceMetadata?: boolean;
|
|
618
|
+
/** Timeout in milliseconds */
|
|
619
|
+
timeoutMs?: number;
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
/**
|
|
623
|
+
* Delete operation result
|
|
624
|
+
*/
|
|
625
|
+
export interface DeleteResult {
|
|
626
|
+
/** Number of items deleted */
|
|
627
|
+
deletedCount: number;
|
|
628
|
+
/** Whether the operation succeeded */
|
|
629
|
+
success: boolean;
|
|
630
|
+
/** Optional message */
|
|
631
|
+
message?: string;
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
/**
|
|
635
|
+
* Operation metrics
|
|
636
|
+
*/
|
|
637
|
+
export interface OperationMetrics {
|
|
638
|
+
/** Total items processed */
|
|
639
|
+
totalProcessed: number;
|
|
640
|
+
/** Successful count */
|
|
641
|
+
successfulCount: number;
|
|
642
|
+
/** Failed count */
|
|
643
|
+
failedCount: number;
|
|
644
|
+
/** Processing time in microseconds */
|
|
645
|
+
processingTimeUs: number;
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
// ============================================================================
|
|
649
|
+
// ERROR TYPES
|
|
650
|
+
// ============================================================================
|
|
651
|
+
|
|
652
|
+
/**
|
|
653
|
+
* ProximaDB error codes
|
|
654
|
+
*/
|
|
655
|
+
export enum ErrorCode {
|
|
656
|
+
/** Unknown error */
|
|
657
|
+
Unknown = "UNKNOWN",
|
|
658
|
+
/** Network error */
|
|
659
|
+
Network = "NETWORK_ERROR",
|
|
660
|
+
/** Authentication failed */
|
|
661
|
+
AuthenticationFailed = "AUTHENTICATION_FAILED",
|
|
662
|
+
/** Authorization denied */
|
|
663
|
+
AuthorizationDenied = "AUTHORIZATION_DENIED",
|
|
664
|
+
/** Rate limited */
|
|
665
|
+
RateLimited = "RATE_LIMITED",
|
|
666
|
+
/** Collection not found */
|
|
667
|
+
CollectionNotFound = "COLLECTION_NOT_FOUND",
|
|
668
|
+
/** Collection already exists */
|
|
669
|
+
CollectionExists = "COLLECTION_EXISTS",
|
|
670
|
+
/** Vector not found */
|
|
671
|
+
VectorNotFound = "VECTOR_NOT_FOUND",
|
|
672
|
+
/** Invalid vector dimension */
|
|
673
|
+
InvalidDimension = "INVALID_DIMENSION",
|
|
674
|
+
/** Invalid configuration */
|
|
675
|
+
InvalidConfig = "INVALID_CONFIG",
|
|
676
|
+
/** Invalid filter */
|
|
677
|
+
InvalidFilter = "INVALID_FILTER",
|
|
678
|
+
/** Timeout */
|
|
679
|
+
Timeout = "TIMEOUT",
|
|
680
|
+
/** Server error */
|
|
681
|
+
ServerError = "SERVER_ERROR",
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
/**
|
|
685
|
+
* ProximaDB error
|
|
686
|
+
*/
|
|
687
|
+
export class ProximaDBError extends Error {
|
|
688
|
+
constructor(
|
|
689
|
+
message: string,
|
|
690
|
+
public readonly code: ErrorCode = ErrorCode.Unknown,
|
|
691
|
+
public readonly statusCode?: number,
|
|
692
|
+
public readonly details?: Record<string, unknown>
|
|
693
|
+
) {
|
|
694
|
+
super(message);
|
|
695
|
+
this.name = "ProximaDBError";
|
|
696
|
+
Object.setPrototypeOf(this, ProximaDBError.prototype);
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
// ============================================================================
|
|
701
|
+
// STREAMING INTERFACES
|
|
702
|
+
// ============================================================================
|
|
703
|
+
|
|
704
|
+
/**
|
|
705
|
+
* Streaming search result batch
|
|
706
|
+
*/
|
|
707
|
+
export interface SearchResultBatch {
|
|
708
|
+
/** Results in this batch */
|
|
709
|
+
results: SearchResult[];
|
|
710
|
+
/** Whether there are more results */
|
|
711
|
+
hasMore: boolean;
|
|
712
|
+
/** Cursor for pagination */
|
|
713
|
+
cursor?: string;
|
|
714
|
+
/** Total count (if known) */
|
|
715
|
+
total?: number;
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
/**
|
|
719
|
+
* Async iterator for streaming search results
|
|
720
|
+
*/
|
|
721
|
+
export interface SearchResultIterator extends AsyncIterableIterator<SearchResult> {
|
|
722
|
+
/** Get total count if available */
|
|
723
|
+
getTotal(): number | undefined;
|
|
724
|
+
/** Check if iteration is complete */
|
|
725
|
+
isComplete(): boolean;
|
|
726
|
+
}
|