@synapcores/sdk 0.2.1 → 0.4.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/CHANGELOG.md ADDED
@@ -0,0 +1,108 @@
1
+ # Changelog
2
+
3
+ All notable changes to `@synapcores/sdk` are documented here.
4
+ This project follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
5
+
6
+ ## 0.4.0 — 2026-05-18 — vector-subsystem + auth alignment with v1.6.5.2-ce gateway
7
+
8
+ Closes three wire-format gaps surfaced during the OpenClaw v0.1.0 integration.
9
+ Validation against `validate-nodejs-sdk-v04.ts` goes from **8/9** under 0.3.0
10
+ to **11/12** under 0.4.0 (#5 — Cypher `$param` — remains the documented
11
+ gateway-side blocker).
12
+
13
+ ### Fixed
14
+
15
+ - **Auth: `apiKey` now sends `Authorization: Bearer <key>` instead of
16
+ `X-API-Key`.** Gateway v1.6.5.2-ce only honours the `Authorization`
17
+ header for both JWTs and AIDB-issued API keys (`aidb_*` / `ak_*`);
18
+ the legacy `X-API-Key` shim was rejected with HTTP 401
19
+ `missing_authorization`, forcing callers to manually promote API keys
20
+ into `jwtToken`. The SDK now sends `Bearer` for every credential
21
+ type — `apiKey: 'aidb_...'` Just Works.
22
+ - **`Collection.vectorSearch` no longer crosses subsystems** (regression
23
+ guard for callers that relied on the 0.3.0 `client.collection(name)`
24
+ accessor with a vector collection: the search still hits the right
25
+ endpoint regardless of which accessor produced the handle).
26
+
27
+ ### Added
28
+
29
+ - **`client.createVectorCollection({name, dimensions, distance_metric})`** —
30
+ posts to `POST /v1/vectors/collections` with the gateway's expected
31
+ body shape. The legacy `createCollection({name, vector_size, ...})`
32
+ silently dropped `vector_size` and posted to the document-store
33
+ subsystem, leaving the collection invisible to vector search.
34
+ - **`client.vectorCollection(name)`** — synchronous typed handle for an
35
+ existing vector collection. Returns a `VectorCollection` wired to
36
+ `/v1/vectors/collections/{name}/...`, distinct from the document-store
37
+ `client.collection(name)` accessor.
38
+ - **`VectorCollection` class** (`src/vector_collection.ts`) — explicit
39
+ vector-subsystem API surface: `insert(records)`, `search({vector, k,
40
+ filter?, includeMetadata?})`, `get(id)`, `delete(id|ids)`, `count()`,
41
+ `info()`. Wire paths target `/v1/vectors/collections/{name}/vectors`
42
+ and `/search`; envelope unwrapping matches the rest of the 0.3.0 SDK.
43
+ - **`client.listVectorCollections()`** and
44
+ **`client.deleteVectorCollection(name)`** — sibling helpers for the
45
+ vector subsystem.
46
+ - **`tests/live-smoke-v04.test.ts`** — gated on `AIDB_LIVE_TEST=1`,
47
+ runs the 12-test v0.4.0 validation suite against a live gateway.
48
+
49
+ ### Documentation
50
+
51
+ - README now lists v1.6.5.2-ce as the verified-against gateway version.
52
+
53
+ ## 0.3.0 — 2026-05-18
54
+
55
+ Wire-alignment release for the v1.6.5.1-ce gateway. Brings the SDK back into sync
56
+ with the gateway response shapes and route prefixes that shipped in v1.6.x.
57
+
58
+ ### Fixed
59
+
60
+ - `client.listCollections()` / `listCollectionsDetailed()` now correctly parse the
61
+ v1.6.x envelope `{ data: { items, total, page, page_size }, meta }`. Previously
62
+ the SDK looked for `data.collections` and threw
63
+ `Cannot read properties of undefined (reading 'map')`.
64
+ - `client.graph.graphs.{list,create,get,delete}()` now hit `/v1/graph/graphs`
65
+ (the actual mount point); the old `/v1/graphs` paths 404'd against the v1.6.x
66
+ gateway.
67
+ - `client.automl.listModels()` now tolerates the v1.6.x `{ data: [...], meta }`
68
+ envelope (was throwing `(data.models ?? data ?? []).map is not a function`
69
+ because `data` is an object, not an array).
70
+ - `client.automl.getModel(id)` no longer hard-fails when the gateway's model
71
+ registry returns 404 for an id whose `/predict` endpoint still works (the
72
+ registry and the predict path can be out of sync after a recipe-loaded model
73
+ is hot-swapped). It now returns a stub `AutoMLModel` so `.predict()` /
74
+ `.evaluate()` still flow through.
75
+ - `collection(name).vectorSearch({ vector, topK, filter? })` now posts to
76
+ `POST /v1/vectors/collections/{name}/search` with the gateway's `k` field
77
+ (was using the removed `/collections/{name}/vector_search` route with
78
+ `top_k`).
79
+
80
+ ### Added
81
+
82
+ - `client.collection(name)` — synchronous accessor returning a `Collection`
83
+ handle without round-tripping to the gateway. Enables one-liner
84
+ `client.collection('docs').vectorSearch({...})`.
85
+ - `tests/live-smoke.test.ts` — gated on `AIDB_LIVE_TEST=1`, runs the 9-test
86
+ validation suite against a live gateway so regressions in wire shapes are
87
+ caught in CI rather than at customer-install time.
88
+
89
+ ### Process
90
+
91
+ - This is the first release where the public `SynapCores/nodejs-sdk` repository
92
+ reflects the code actually shipped to npm. Releases 0.1.0 / 0.2.0 / 0.2.1
93
+ were published directly from an internal workspace and the public repo
94
+ diverged by months. Going forward, all releases must be cut from this repo.
95
+
96
+ ## 0.2.1 — 2026-05-13
97
+
98
+ - Internal release published from the workspace (not from this repo).
99
+
100
+ ## 0.2.0 — 2026-05-07
101
+
102
+ - Internal release published from the workspace (not from this repo).
103
+ - Migrated `/ai/*` routes to `/automl/*`, added Graph / NL2SQL / Filesystem /
104
+ Chat / Multimodal / System / Transactions / MCP sub-clients.
105
+
106
+ ## 0.1.0 — 2025-10-31
107
+
108
+ - Initial release.
package/README.md CHANGED
@@ -2,6 +2,16 @@
2
2
 
3
3
  Official Node.js/TypeScript SDK for SynapCores AI-Native Database Management System - A SQL 2026-compliant database with native tenant isolation, AI/ML functions, and multimedia support.
4
4
 
5
+ > **0.4.0 — vector-subsystem + auth alignment with gateway v1.6.5.2-ce.**
6
+ > Closes three wire-format gaps the OpenClaw v0.1.0 integration hit:
7
+ > (a) `apiKey: 'aidb_...'` now sends `Authorization: Bearer` instead of the
8
+ > rejected `X-API-Key` header; (b) `client.createVectorCollection({name,
9
+ > dimensions, distance_metric})` provisions on the **vector subsystem**
10
+ > (not the document-store one); (c) the new
11
+ > `client.vectorCollection(name).insert(...)` / `.search(...)` round-trip
12
+ > hits `/v1/vectors/collections/{name}/...` end-to-end. See CHANGELOG.md.
13
+ > Verified against gateway v1.6.5.2-ce. Validation: 11/12 PASS.
14
+
5
15
  > **0.2.0 — gateway v1.5.0-ce alignment.** This release rewires every
6
16
  > module against the v1.5.0-ce route surface: AutoML moved from `/ai/*`
7
17
  > to `/automl/*`, vector ops collapsed onto `/vector-algebra/operation`,
package/dist/index.d.mts CHANGED
@@ -151,6 +151,124 @@ declare class Collection {
151
151
  subscribe(options?: SubscriptionOptions): Promise<Subscription>;
152
152
  }
153
153
 
154
+ /**
155
+ * VectorCollection — thin wrapper around the gateway's
156
+ * `/v1/vectors/collections/{name}/...` API.
157
+ *
158
+ * v0.4.0: introduced so users have an explicit, typed handle for the
159
+ * **vector subsystem** (separate from `/v1/collections/{name}`, the
160
+ * document-store world that `Collection` wraps). Mirror of the Python
161
+ * SDK's `synapcores.vector_collection.VectorCollection`.
162
+ *
163
+ * Get one via `client.vectorCollection(name)` for an existing collection,
164
+ * or `client.createVectorCollection({name, dimensions, distance_metric})`
165
+ * to provision a new one.
166
+ */
167
+
168
+ type VectorDistanceMetric = 'cosine' | 'l2' | 'dot' | 'euclidean' | 'dot_product';
169
+ /** Wire shape of a single vector going into the gateway. */
170
+ interface VectorRecord {
171
+ id: string;
172
+ /** Embedding values. Length must match the collection's `dimensions`. */
173
+ values: number[];
174
+ /** Optional per-vector metadata returned on search hits. */
175
+ metadata?: Record<string, any>;
176
+ }
177
+ /** Options for `VectorCollection.search()`. */
178
+ interface VectorCollectionSearchOptions {
179
+ vector: number[];
180
+ /** Number of nearest neighbours. */
181
+ k?: number;
182
+ /** Alias for `k` (parity with the document-store API). */
183
+ topK?: number;
184
+ /** Optional metadata filter forwarded as `filter` on the wire. */
185
+ filter?: Record<string, any>;
186
+ /** Whether the gateway should include metadata in each hit (default: true). */
187
+ includeMetadata?: boolean;
188
+ }
189
+ /** One match returned from `VectorCollection.search()`. */
190
+ interface VectorHit {
191
+ id: string;
192
+ /** Cosine distance (lower = closer) for cosine metric; raw distance otherwise. */
193
+ score?: number;
194
+ distance?: number;
195
+ values?: number[];
196
+ metadata?: Record<string, any>;
197
+ [key: string]: any;
198
+ }
199
+ /** Shape returned by `VectorCollection.info()`. */
200
+ interface VectorCollectionInfo {
201
+ name: string;
202
+ dimensions: number;
203
+ vector_count?: number;
204
+ distance_metric?: string;
205
+ index_type?: string;
206
+ [key: string]: any;
207
+ }
208
+ /** Shape returned by `client.createVectorCollection()`. */
209
+ interface CreateVectorCollectionOptions {
210
+ name: string;
211
+ dimensions: number;
212
+ /** Distance metric. `cosine` is the gateway default. */
213
+ distance_metric?: VectorDistanceMetric;
214
+ }
215
+ declare class VectorCollection {
216
+ private readonly client;
217
+ readonly name: string;
218
+ constructor(client: SynapCores, name: string);
219
+ private get basePath();
220
+ /**
221
+ * Insert one or more vectors.
222
+ *
223
+ * Wire: `POST /v1/vectors/collections/{name}/vectors` with
224
+ * `{ vectors: [{ id, values, metadata }] }`.
225
+ *
226
+ * Accepts either a single record or an array — the SDK always sends
227
+ * the wrapped `{ vectors: [...] }` envelope the gateway expects.
228
+ */
229
+ insert(records: VectorRecord | VectorRecord[]): Promise<any>;
230
+ /**
231
+ * k-NN search over the vector collection.
232
+ *
233
+ * Wire: `POST /v1/vectors/collections/{name}/search` with
234
+ * `{ vector, k, include_metadata, filter? }`.
235
+ *
236
+ * Returns the bare array of hits — gateway envelope (`{data: [...]}`) is
237
+ * unwrapped automatically for parity with `Collection.vectorSearch`.
238
+ */
239
+ search(options: VectorCollectionSearchOptions): Promise<VectorHit[]>;
240
+ /**
241
+ * Fetch a single vector by id.
242
+ *
243
+ * Wire: `GET /v1/vectors/collections/{name}/vectors/{id}`. Returns the
244
+ * gateway payload `{ id, values, metadata }` (envelope unwrapped) or
245
+ * `null` on 404.
246
+ */
247
+ get(id: string): Promise<VectorHit | null>;
248
+ /**
249
+ * Delete one or more vectors by id.
250
+ *
251
+ * Single-id wire: `DELETE /v1/vectors/collections/{name}/vectors/{id}`.
252
+ * Bulk wire: `DELETE /v1/vectors/collections/{name}/vectors` with
253
+ * `{ ids: [...] }` body.
254
+ */
255
+ delete(ids: string | string[]): Promise<any>;
256
+ /**
257
+ * Vector count.
258
+ *
259
+ * Wire: `GET /v1/vectors/collections/{name}/count` if the gateway
260
+ * exposes it, otherwise falls back to `info().vector_count`.
261
+ */
262
+ count(): Promise<number>;
263
+ /**
264
+ * Collection metadata.
265
+ *
266
+ * Wire: `GET /v1/vectors/collections/{name}` returning
267
+ * `{ name, dimensions, vector_count, distance_metric, index_type }`.
268
+ */
269
+ info(): Promise<VectorCollectionInfo>;
270
+ }
271
+
154
272
  /**
155
273
  * Type definitions for AutoML
156
274
  */
@@ -2925,12 +3043,25 @@ declare class SynapCores {
2925
3043
  */
2926
3044
  createCollectionWithSchema(request: CreateCollectionRequest): Promise<Collection>;
2927
3045
  getCollection(name: string): Promise<Collection>;
3046
+ /**
3047
+ * Synchronous accessor that returns a Collection handle without round-tripping
3048
+ * to the gateway. Use this when you already know the collection exists and just
3049
+ * want to issue a vectorSearch / search / insert against it.
3050
+ *
3051
+ * v0.3.0: added so `client.collection(name).vectorSearch(...)` works without
3052
+ * a preceding await on getCollection().
3053
+ */
3054
+ collection(name: string): Collection;
2928
3055
  /**
2929
3056
  * List collections (legacy method for backward compatibility)
2930
3057
  */
2931
3058
  listCollections(): Promise<string[]>;
2932
3059
  /**
2933
3060
  * List collections with detailed information matching the database integration guide format
3061
+ *
3062
+ * v0.3.0: gateway returns an envelope { data: { items, total, page, page_size, ... }, meta }.
3063
+ * We normalise that into the SDK's { collections, total, page, pageSize } shape and also
3064
+ * accept legacy { collections: [...] } / bare arrays for forward-compat.
2934
3065
  */
2935
3066
  listCollectionsDetailed(options?: {
2936
3067
  page?: number;
@@ -2941,6 +3072,45 @@ declare class SynapCores {
2941
3072
  }): Promise<ListCollectionsResponse>;
2942
3073
  getDocuments(collectionName: string, page: number, pageSize: number): Promise<Document[]>;
2943
3074
  deleteCollection(name: string): Promise<void>;
3075
+ private readonly vectorCollectionsCache;
3076
+ /**
3077
+ * Create a vector collection.
3078
+ *
3079
+ * Wire: `POST /v1/vectors/collections` with
3080
+ * `{ name, dimensions, distance_metric }`. Distinct from
3081
+ * `createCollection`, which targets the document-store subsystem.
3082
+ *
3083
+ * @example
3084
+ * const coll = await client.createVectorCollection({
3085
+ * name: 'memory_v1', dimensions: 1536, distance_metric: 'cosine',
3086
+ * });
3087
+ * await coll.insert({ id: 'v1', values: [...], metadata: { ... } });
3088
+ */
3089
+ createVectorCollection(options: CreateVectorCollectionOptions): Promise<VectorCollection>;
3090
+ /**
3091
+ * Synchronous accessor for an existing vector collection. Does not
3092
+ * round-trip to the gateway — use `createVectorCollection` if you
3093
+ * need to provision the collection first, or `listVectorCollections`
3094
+ * to confirm existence.
3095
+ *
3096
+ * v0.4.0 split: this targets the **vector subsystem**
3097
+ * (`/v1/vectors/collections/{name}`). `client.collection(name)` still
3098
+ * returns a document-store `Collection` for the legacy subsystem.
3099
+ */
3100
+ vectorCollection(name: string): VectorCollection;
3101
+ /**
3102
+ * List vector collections.
3103
+ *
3104
+ * Wire: `GET /v1/vectors/collections`. Returns the bare array of
3105
+ * collection-info objects (envelope unwrapped).
3106
+ */
3107
+ listVectorCollections(): Promise<VectorCollectionInfo[]>;
3108
+ /**
3109
+ * Delete a vector collection.
3110
+ *
3111
+ * Wire: `DELETE /v1/vectors/collections/{name}`.
3112
+ */
3113
+ deleteVectorCollection(name: string): Promise<void>;
2944
3114
  /**
2945
3115
  * Execute SQL query (legacy method for backward compatibility)
2946
3116
  * @deprecated Use executeQuery for new code
@@ -3304,6 +3474,6 @@ declare class BatchOperationError extends SynapCoresError {
3304
3474
  * Official SDK for SynapCores AI-Native Database Management System.
3305
3475
  */
3306
3476
 
3307
- declare const VERSION = "0.2.0";
3477
+ declare const VERSION = "0.4.0";
3308
3478
 
3309
- export { type APIKeyInfo, type APIKeyStats, type AlterTableOptions, type AnalyzeOptions, type AsyncTrainOptions, type AuthConfig, AuthenticationError, AutoMLClient, AutoMLModel, type Backup, BackupClient, type BackupMetrics, type BackupOptions, type BackupSchedule, type BackupStatus, type BackupVerificationResult, type BatchDeleteOptions, type BatchInsertOptions, BatchOperationError, type BatchQueryRequest, type BatchQueryResponse, type BatchQueryResult, type BatchResult, type BatchUpdateOptions, type BeginTransactionOptions, type BulkImportOptions, type BulkImportResult, type CTEDefinition, type ChangeOperation, type ChatCacheStats, ChatClient, type ChatMessage, type ChatModelInfo, type ChatSession, type ChatStreamChunk, type ChatSuggestion, type ChatSuggestionsOptions, type ChatSystemPrompt, type ChatTool, Collection, type CollectionFieldDefinition, type CollectionIndexDefinition, type CollectionInfo, type CollectionSchema, type CollectionSchemaDefinition, type CollectionStats, type ColumnConstraint, type ColumnDefinition, type ColumnInfo, ConnectionError, type ConnectionPool, type ConstraintInfo, type CreateAPIKeyRequest, type CreateAPIKeyResponse, type CreateChatSessionOptions, type CreateCollectionRequest, type CreateCollectionResponse, type CreateFsCollectionOptions, type CreateIntegrationOptions, type CreateRecipeOptions, type CreateScheduleOptions, type CreateTableOptions, type CreateWebhookOptions, type CypherProfileResult, type CypherResult, type DataValidationOptions, type DataValidationResult, type Document, type EmbedOptions, type Entity, type EvaluationResult, type ExecuteIntegrationOptions, type ExecuteQueryRequest, type ExecuteRecipeOptions, type ExportJobStatus, type ExportOptions, type ExportResult, FilesystemCollectionsClient, type ForeignKeyReference, type FsCollection, type FsDocument, type FsProgressEvent, type GenerateRecipeOptions, type GeneratedRecipe, type GraphAlgorithmName, type GraphAlgorithmRequest, type GraphAlgorithmResult, GraphClient, type GraphEdge, type GraphExtractRequest, type GraphExtractResult, type GraphNode, type GraphSummary, type HybridSearchOptions, type ImportError, ImportExportClient, type ImportJobStatus, type ImportOptions, type ImportResult, type ValidationError$1 as ImportValidationError, type ValidationWarning as ImportValidationWarning, type IndexDefinition, type IndexInfo, type InsertResult, type Integration, IntegrationClient, type IntegrationConfig, type IntegrationEvent, type IntegrationExecutionResult, type IntegrationLog, type IntegrationStats, type IntegrationWebhook, type KNNSearchOptions, type ListAPIKeysResponse, type ListBackupsOptions, type ListCollectionsResponse, type ListIntegrationsOptions, type ListMultimediaResponse, type ListRecipesOptions, type ListTrainingJobsOptions, type LoginRequest, type LoginResponse, McpClient, type McpInfo, type McpRequest, type McpResponse, type ModelInfo, type MultimediaInfo, MultimodalClient, type MultimodalEmbedResult, type MultimodalInput, type MultimodalJoinOptions, type MultimodalJoinResult, type MultimodalSearchHit, type MultimodalSearchOptions, type MultimodalSimilarityOptions, type MultimodalSimilarityResult, NL2SqlClient, type NLPAnalysis, NLPClient, type Nl2SqlAskOptions, type Nl2SqlAskResult, type Nl2SqlHistoryEntry, type Nl2SqlSchemaContext, type Nl2SqlValidateResult, NotFoundError, type OAuth2Config, type PredictResult, type PreparedStatement, type PreparedStatementOptions, type QueryColumn, type QueryOptions, type QueryPerformance, type QueryResult, type RangeSearchOptions, RateLimitError, type Recipe, RecipeClient, type RecipeExecutionResult, type RecipeInfo, type RecipeParameter, type RefreshResponse, type RegisterRequest, type RegisterResponse, type RelationshipInfo, type RestoreOptions, type RestoreResult, type RestoreStatus, type RetryConfig, SQLError, SchemaClient, type SchemaStatistics, type ValidationError$2 as SchemaValidationError, type SearchOptions, type SearchResult, type SendChatOptions, type SendChatResult, type Sentiment, ServerError, type StorageConfig, Subscription, type SubscriptionEvent, type SubscriptionOptions, type SummarizeOptions, SynapCores, type SynapCoresConfig, SynapCoresError, SystemClient, type TableConstraint, type TableInfo, type TableSchema, type TestIntegrationOptions, type TestIntegrationResult, TimeoutError, type TrainOptions, type TrainingJob, type TrainingMetrics, type TransactionContext, TransactionError, type TransactionOptions, TransactionsClient, Tx, type TxHistoryEntry, type TxQueryResult, type UpdateOptions, type UploadMultimediaRequest, VERSION, ValidationError, type ValidationResult, type ValidationWarning$1 as ValidationWarning, type Vector, type VectorArithmeticResult, VectorError, type VectorSearchOptions, type VectorSearchResult, type VectorSimilarityResult, type VisionConfig, type VisionTestResult, type WindowFunctionOptions };
3479
+ export { type APIKeyInfo, type APIKeyStats, type AlterTableOptions, type AnalyzeOptions, type AsyncTrainOptions, type AuthConfig, AuthenticationError, AutoMLClient, AutoMLModel, type Backup, BackupClient, type BackupMetrics, type BackupOptions, type BackupSchedule, type BackupStatus, type BackupVerificationResult, type BatchDeleteOptions, type BatchInsertOptions, BatchOperationError, type BatchQueryRequest, type BatchQueryResponse, type BatchQueryResult, type BatchResult, type BatchUpdateOptions, type BeginTransactionOptions, type BulkImportOptions, type BulkImportResult, type CTEDefinition, type ChangeOperation, type ChatCacheStats, ChatClient, type ChatMessage, type ChatModelInfo, type ChatSession, type ChatStreamChunk, type ChatSuggestion, type ChatSuggestionsOptions, type ChatSystemPrompt, type ChatTool, Collection, type CollectionFieldDefinition, type CollectionIndexDefinition, type CollectionInfo, type CollectionSchema, type CollectionSchemaDefinition, type CollectionStats, type ColumnConstraint, type ColumnDefinition, type ColumnInfo, ConnectionError, type ConnectionPool, type ConstraintInfo, type CreateAPIKeyRequest, type CreateAPIKeyResponse, type CreateChatSessionOptions, type CreateCollectionRequest, type CreateCollectionResponse, type CreateFsCollectionOptions, type CreateIntegrationOptions, type CreateRecipeOptions, type CreateScheduleOptions, type CreateTableOptions, type CreateVectorCollectionOptions, type CreateWebhookOptions, type CypherProfileResult, type CypherResult, type DataValidationOptions, type DataValidationResult, type Document, type EmbedOptions, type Entity, type EvaluationResult, type ExecuteIntegrationOptions, type ExecuteQueryRequest, type ExecuteRecipeOptions, type ExportJobStatus, type ExportOptions, type ExportResult, FilesystemCollectionsClient, type ForeignKeyReference, type FsCollection, type FsDocument, type FsProgressEvent, type GenerateRecipeOptions, type GeneratedRecipe, type GraphAlgorithmName, type GraphAlgorithmRequest, type GraphAlgorithmResult, GraphClient, type GraphEdge, type GraphExtractRequest, type GraphExtractResult, type GraphNode, type GraphSummary, type HybridSearchOptions, type ImportError, ImportExportClient, type ImportJobStatus, type ImportOptions, type ImportResult, type ValidationError$1 as ImportValidationError, type ValidationWarning as ImportValidationWarning, type IndexDefinition, type IndexInfo, type InsertResult, type Integration, IntegrationClient, type IntegrationConfig, type IntegrationEvent, type IntegrationExecutionResult, type IntegrationLog, type IntegrationStats, type IntegrationWebhook, type KNNSearchOptions, type ListAPIKeysResponse, type ListBackupsOptions, type ListCollectionsResponse, type ListIntegrationsOptions, type ListMultimediaResponse, type ListRecipesOptions, type ListTrainingJobsOptions, type LoginRequest, type LoginResponse, McpClient, type McpInfo, type McpRequest, type McpResponse, type ModelInfo, type MultimediaInfo, MultimodalClient, type MultimodalEmbedResult, type MultimodalInput, type MultimodalJoinOptions, type MultimodalJoinResult, type MultimodalSearchHit, type MultimodalSearchOptions, type MultimodalSimilarityOptions, type MultimodalSimilarityResult, NL2SqlClient, type NLPAnalysis, NLPClient, type Nl2SqlAskOptions, type Nl2SqlAskResult, type Nl2SqlHistoryEntry, type Nl2SqlSchemaContext, type Nl2SqlValidateResult, NotFoundError, type OAuth2Config, type PredictResult, type PreparedStatement, type PreparedStatementOptions, type QueryColumn, type QueryOptions, type QueryPerformance, type QueryResult, type RangeSearchOptions, RateLimitError, type Recipe, RecipeClient, type RecipeExecutionResult, type RecipeInfo, type RecipeParameter, type RefreshResponse, type RegisterRequest, type RegisterResponse, type RelationshipInfo, type RestoreOptions, type RestoreResult, type RestoreStatus, type RetryConfig, SQLError, SchemaClient, type SchemaStatistics, type ValidationError$2 as SchemaValidationError, type SearchOptions, type SearchResult, type SendChatOptions, type SendChatResult, type Sentiment, ServerError, type StorageConfig, Subscription, type SubscriptionEvent, type SubscriptionOptions, type SummarizeOptions, SynapCores, type SynapCoresConfig, SynapCoresError, SystemClient, type TableConstraint, type TableInfo, type TableSchema, type TestIntegrationOptions, type TestIntegrationResult, TimeoutError, type TrainOptions, type TrainingJob, type TrainingMetrics, type TransactionContext, TransactionError, type TransactionOptions, TransactionsClient, Tx, type TxHistoryEntry, type TxQueryResult, type UpdateOptions, type UploadMultimediaRequest, VERSION, ValidationError, type ValidationResult, type ValidationWarning$1 as ValidationWarning, type Vector, type VectorArithmeticResult, VectorCollection, type VectorCollectionInfo, type VectorCollectionSearchOptions, type VectorDistanceMetric, VectorError, type VectorHit, type VectorRecord, type VectorSearchOptions, type VectorSearchResult, type VectorSimilarityResult, type VisionConfig, type VisionTestResult, type WindowFunctionOptions };
package/dist/index.d.ts CHANGED
@@ -151,6 +151,124 @@ declare class Collection {
151
151
  subscribe(options?: SubscriptionOptions): Promise<Subscription>;
152
152
  }
153
153
 
154
+ /**
155
+ * VectorCollection — thin wrapper around the gateway's
156
+ * `/v1/vectors/collections/{name}/...` API.
157
+ *
158
+ * v0.4.0: introduced so users have an explicit, typed handle for the
159
+ * **vector subsystem** (separate from `/v1/collections/{name}`, the
160
+ * document-store world that `Collection` wraps). Mirror of the Python
161
+ * SDK's `synapcores.vector_collection.VectorCollection`.
162
+ *
163
+ * Get one via `client.vectorCollection(name)` for an existing collection,
164
+ * or `client.createVectorCollection({name, dimensions, distance_metric})`
165
+ * to provision a new one.
166
+ */
167
+
168
+ type VectorDistanceMetric = 'cosine' | 'l2' | 'dot' | 'euclidean' | 'dot_product';
169
+ /** Wire shape of a single vector going into the gateway. */
170
+ interface VectorRecord {
171
+ id: string;
172
+ /** Embedding values. Length must match the collection's `dimensions`. */
173
+ values: number[];
174
+ /** Optional per-vector metadata returned on search hits. */
175
+ metadata?: Record<string, any>;
176
+ }
177
+ /** Options for `VectorCollection.search()`. */
178
+ interface VectorCollectionSearchOptions {
179
+ vector: number[];
180
+ /** Number of nearest neighbours. */
181
+ k?: number;
182
+ /** Alias for `k` (parity with the document-store API). */
183
+ topK?: number;
184
+ /** Optional metadata filter forwarded as `filter` on the wire. */
185
+ filter?: Record<string, any>;
186
+ /** Whether the gateway should include metadata in each hit (default: true). */
187
+ includeMetadata?: boolean;
188
+ }
189
+ /** One match returned from `VectorCollection.search()`. */
190
+ interface VectorHit {
191
+ id: string;
192
+ /** Cosine distance (lower = closer) for cosine metric; raw distance otherwise. */
193
+ score?: number;
194
+ distance?: number;
195
+ values?: number[];
196
+ metadata?: Record<string, any>;
197
+ [key: string]: any;
198
+ }
199
+ /** Shape returned by `VectorCollection.info()`. */
200
+ interface VectorCollectionInfo {
201
+ name: string;
202
+ dimensions: number;
203
+ vector_count?: number;
204
+ distance_metric?: string;
205
+ index_type?: string;
206
+ [key: string]: any;
207
+ }
208
+ /** Shape returned by `client.createVectorCollection()`. */
209
+ interface CreateVectorCollectionOptions {
210
+ name: string;
211
+ dimensions: number;
212
+ /** Distance metric. `cosine` is the gateway default. */
213
+ distance_metric?: VectorDistanceMetric;
214
+ }
215
+ declare class VectorCollection {
216
+ private readonly client;
217
+ readonly name: string;
218
+ constructor(client: SynapCores, name: string);
219
+ private get basePath();
220
+ /**
221
+ * Insert one or more vectors.
222
+ *
223
+ * Wire: `POST /v1/vectors/collections/{name}/vectors` with
224
+ * `{ vectors: [{ id, values, metadata }] }`.
225
+ *
226
+ * Accepts either a single record or an array — the SDK always sends
227
+ * the wrapped `{ vectors: [...] }` envelope the gateway expects.
228
+ */
229
+ insert(records: VectorRecord | VectorRecord[]): Promise<any>;
230
+ /**
231
+ * k-NN search over the vector collection.
232
+ *
233
+ * Wire: `POST /v1/vectors/collections/{name}/search` with
234
+ * `{ vector, k, include_metadata, filter? }`.
235
+ *
236
+ * Returns the bare array of hits — gateway envelope (`{data: [...]}`) is
237
+ * unwrapped automatically for parity with `Collection.vectorSearch`.
238
+ */
239
+ search(options: VectorCollectionSearchOptions): Promise<VectorHit[]>;
240
+ /**
241
+ * Fetch a single vector by id.
242
+ *
243
+ * Wire: `GET /v1/vectors/collections/{name}/vectors/{id}`. Returns the
244
+ * gateway payload `{ id, values, metadata }` (envelope unwrapped) or
245
+ * `null` on 404.
246
+ */
247
+ get(id: string): Promise<VectorHit | null>;
248
+ /**
249
+ * Delete one or more vectors by id.
250
+ *
251
+ * Single-id wire: `DELETE /v1/vectors/collections/{name}/vectors/{id}`.
252
+ * Bulk wire: `DELETE /v1/vectors/collections/{name}/vectors` with
253
+ * `{ ids: [...] }` body.
254
+ */
255
+ delete(ids: string | string[]): Promise<any>;
256
+ /**
257
+ * Vector count.
258
+ *
259
+ * Wire: `GET /v1/vectors/collections/{name}/count` if the gateway
260
+ * exposes it, otherwise falls back to `info().vector_count`.
261
+ */
262
+ count(): Promise<number>;
263
+ /**
264
+ * Collection metadata.
265
+ *
266
+ * Wire: `GET /v1/vectors/collections/{name}` returning
267
+ * `{ name, dimensions, vector_count, distance_metric, index_type }`.
268
+ */
269
+ info(): Promise<VectorCollectionInfo>;
270
+ }
271
+
154
272
  /**
155
273
  * Type definitions for AutoML
156
274
  */
@@ -2925,12 +3043,25 @@ declare class SynapCores {
2925
3043
  */
2926
3044
  createCollectionWithSchema(request: CreateCollectionRequest): Promise<Collection>;
2927
3045
  getCollection(name: string): Promise<Collection>;
3046
+ /**
3047
+ * Synchronous accessor that returns a Collection handle without round-tripping
3048
+ * to the gateway. Use this when you already know the collection exists and just
3049
+ * want to issue a vectorSearch / search / insert against it.
3050
+ *
3051
+ * v0.3.0: added so `client.collection(name).vectorSearch(...)` works without
3052
+ * a preceding await on getCollection().
3053
+ */
3054
+ collection(name: string): Collection;
2928
3055
  /**
2929
3056
  * List collections (legacy method for backward compatibility)
2930
3057
  */
2931
3058
  listCollections(): Promise<string[]>;
2932
3059
  /**
2933
3060
  * List collections with detailed information matching the database integration guide format
3061
+ *
3062
+ * v0.3.0: gateway returns an envelope { data: { items, total, page, page_size, ... }, meta }.
3063
+ * We normalise that into the SDK's { collections, total, page, pageSize } shape and also
3064
+ * accept legacy { collections: [...] } / bare arrays for forward-compat.
2934
3065
  */
2935
3066
  listCollectionsDetailed(options?: {
2936
3067
  page?: number;
@@ -2941,6 +3072,45 @@ declare class SynapCores {
2941
3072
  }): Promise<ListCollectionsResponse>;
2942
3073
  getDocuments(collectionName: string, page: number, pageSize: number): Promise<Document[]>;
2943
3074
  deleteCollection(name: string): Promise<void>;
3075
+ private readonly vectorCollectionsCache;
3076
+ /**
3077
+ * Create a vector collection.
3078
+ *
3079
+ * Wire: `POST /v1/vectors/collections` with
3080
+ * `{ name, dimensions, distance_metric }`. Distinct from
3081
+ * `createCollection`, which targets the document-store subsystem.
3082
+ *
3083
+ * @example
3084
+ * const coll = await client.createVectorCollection({
3085
+ * name: 'memory_v1', dimensions: 1536, distance_metric: 'cosine',
3086
+ * });
3087
+ * await coll.insert({ id: 'v1', values: [...], metadata: { ... } });
3088
+ */
3089
+ createVectorCollection(options: CreateVectorCollectionOptions): Promise<VectorCollection>;
3090
+ /**
3091
+ * Synchronous accessor for an existing vector collection. Does not
3092
+ * round-trip to the gateway — use `createVectorCollection` if you
3093
+ * need to provision the collection first, or `listVectorCollections`
3094
+ * to confirm existence.
3095
+ *
3096
+ * v0.4.0 split: this targets the **vector subsystem**
3097
+ * (`/v1/vectors/collections/{name}`). `client.collection(name)` still
3098
+ * returns a document-store `Collection` for the legacy subsystem.
3099
+ */
3100
+ vectorCollection(name: string): VectorCollection;
3101
+ /**
3102
+ * List vector collections.
3103
+ *
3104
+ * Wire: `GET /v1/vectors/collections`. Returns the bare array of
3105
+ * collection-info objects (envelope unwrapped).
3106
+ */
3107
+ listVectorCollections(): Promise<VectorCollectionInfo[]>;
3108
+ /**
3109
+ * Delete a vector collection.
3110
+ *
3111
+ * Wire: `DELETE /v1/vectors/collections/{name}`.
3112
+ */
3113
+ deleteVectorCollection(name: string): Promise<void>;
2944
3114
  /**
2945
3115
  * Execute SQL query (legacy method for backward compatibility)
2946
3116
  * @deprecated Use executeQuery for new code
@@ -3304,6 +3474,6 @@ declare class BatchOperationError extends SynapCoresError {
3304
3474
  * Official SDK for SynapCores AI-Native Database Management System.
3305
3475
  */
3306
3476
 
3307
- declare const VERSION = "0.2.0";
3477
+ declare const VERSION = "0.4.0";
3308
3478
 
3309
- export { type APIKeyInfo, type APIKeyStats, type AlterTableOptions, type AnalyzeOptions, type AsyncTrainOptions, type AuthConfig, AuthenticationError, AutoMLClient, AutoMLModel, type Backup, BackupClient, type BackupMetrics, type BackupOptions, type BackupSchedule, type BackupStatus, type BackupVerificationResult, type BatchDeleteOptions, type BatchInsertOptions, BatchOperationError, type BatchQueryRequest, type BatchQueryResponse, type BatchQueryResult, type BatchResult, type BatchUpdateOptions, type BeginTransactionOptions, type BulkImportOptions, type BulkImportResult, type CTEDefinition, type ChangeOperation, type ChatCacheStats, ChatClient, type ChatMessage, type ChatModelInfo, type ChatSession, type ChatStreamChunk, type ChatSuggestion, type ChatSuggestionsOptions, type ChatSystemPrompt, type ChatTool, Collection, type CollectionFieldDefinition, type CollectionIndexDefinition, type CollectionInfo, type CollectionSchema, type CollectionSchemaDefinition, type CollectionStats, type ColumnConstraint, type ColumnDefinition, type ColumnInfo, ConnectionError, type ConnectionPool, type ConstraintInfo, type CreateAPIKeyRequest, type CreateAPIKeyResponse, type CreateChatSessionOptions, type CreateCollectionRequest, type CreateCollectionResponse, type CreateFsCollectionOptions, type CreateIntegrationOptions, type CreateRecipeOptions, type CreateScheduleOptions, type CreateTableOptions, type CreateWebhookOptions, type CypherProfileResult, type CypherResult, type DataValidationOptions, type DataValidationResult, type Document, type EmbedOptions, type Entity, type EvaluationResult, type ExecuteIntegrationOptions, type ExecuteQueryRequest, type ExecuteRecipeOptions, type ExportJobStatus, type ExportOptions, type ExportResult, FilesystemCollectionsClient, type ForeignKeyReference, type FsCollection, type FsDocument, type FsProgressEvent, type GenerateRecipeOptions, type GeneratedRecipe, type GraphAlgorithmName, type GraphAlgorithmRequest, type GraphAlgorithmResult, GraphClient, type GraphEdge, type GraphExtractRequest, type GraphExtractResult, type GraphNode, type GraphSummary, type HybridSearchOptions, type ImportError, ImportExportClient, type ImportJobStatus, type ImportOptions, type ImportResult, type ValidationError$1 as ImportValidationError, type ValidationWarning as ImportValidationWarning, type IndexDefinition, type IndexInfo, type InsertResult, type Integration, IntegrationClient, type IntegrationConfig, type IntegrationEvent, type IntegrationExecutionResult, type IntegrationLog, type IntegrationStats, type IntegrationWebhook, type KNNSearchOptions, type ListAPIKeysResponse, type ListBackupsOptions, type ListCollectionsResponse, type ListIntegrationsOptions, type ListMultimediaResponse, type ListRecipesOptions, type ListTrainingJobsOptions, type LoginRequest, type LoginResponse, McpClient, type McpInfo, type McpRequest, type McpResponse, type ModelInfo, type MultimediaInfo, MultimodalClient, type MultimodalEmbedResult, type MultimodalInput, type MultimodalJoinOptions, type MultimodalJoinResult, type MultimodalSearchHit, type MultimodalSearchOptions, type MultimodalSimilarityOptions, type MultimodalSimilarityResult, NL2SqlClient, type NLPAnalysis, NLPClient, type Nl2SqlAskOptions, type Nl2SqlAskResult, type Nl2SqlHistoryEntry, type Nl2SqlSchemaContext, type Nl2SqlValidateResult, NotFoundError, type OAuth2Config, type PredictResult, type PreparedStatement, type PreparedStatementOptions, type QueryColumn, type QueryOptions, type QueryPerformance, type QueryResult, type RangeSearchOptions, RateLimitError, type Recipe, RecipeClient, type RecipeExecutionResult, type RecipeInfo, type RecipeParameter, type RefreshResponse, type RegisterRequest, type RegisterResponse, type RelationshipInfo, type RestoreOptions, type RestoreResult, type RestoreStatus, type RetryConfig, SQLError, SchemaClient, type SchemaStatistics, type ValidationError$2 as SchemaValidationError, type SearchOptions, type SearchResult, type SendChatOptions, type SendChatResult, type Sentiment, ServerError, type StorageConfig, Subscription, type SubscriptionEvent, type SubscriptionOptions, type SummarizeOptions, SynapCores, type SynapCoresConfig, SynapCoresError, SystemClient, type TableConstraint, type TableInfo, type TableSchema, type TestIntegrationOptions, type TestIntegrationResult, TimeoutError, type TrainOptions, type TrainingJob, type TrainingMetrics, type TransactionContext, TransactionError, type TransactionOptions, TransactionsClient, Tx, type TxHistoryEntry, type TxQueryResult, type UpdateOptions, type UploadMultimediaRequest, VERSION, ValidationError, type ValidationResult, type ValidationWarning$1 as ValidationWarning, type Vector, type VectorArithmeticResult, VectorError, type VectorSearchOptions, type VectorSearchResult, type VectorSimilarityResult, type VisionConfig, type VisionTestResult, type WindowFunctionOptions };
3479
+ export { type APIKeyInfo, type APIKeyStats, type AlterTableOptions, type AnalyzeOptions, type AsyncTrainOptions, type AuthConfig, AuthenticationError, AutoMLClient, AutoMLModel, type Backup, BackupClient, type BackupMetrics, type BackupOptions, type BackupSchedule, type BackupStatus, type BackupVerificationResult, type BatchDeleteOptions, type BatchInsertOptions, BatchOperationError, type BatchQueryRequest, type BatchQueryResponse, type BatchQueryResult, type BatchResult, type BatchUpdateOptions, type BeginTransactionOptions, type BulkImportOptions, type BulkImportResult, type CTEDefinition, type ChangeOperation, type ChatCacheStats, ChatClient, type ChatMessage, type ChatModelInfo, type ChatSession, type ChatStreamChunk, type ChatSuggestion, type ChatSuggestionsOptions, type ChatSystemPrompt, type ChatTool, Collection, type CollectionFieldDefinition, type CollectionIndexDefinition, type CollectionInfo, type CollectionSchema, type CollectionSchemaDefinition, type CollectionStats, type ColumnConstraint, type ColumnDefinition, type ColumnInfo, ConnectionError, type ConnectionPool, type ConstraintInfo, type CreateAPIKeyRequest, type CreateAPIKeyResponse, type CreateChatSessionOptions, type CreateCollectionRequest, type CreateCollectionResponse, type CreateFsCollectionOptions, type CreateIntegrationOptions, type CreateRecipeOptions, type CreateScheduleOptions, type CreateTableOptions, type CreateVectorCollectionOptions, type CreateWebhookOptions, type CypherProfileResult, type CypherResult, type DataValidationOptions, type DataValidationResult, type Document, type EmbedOptions, type Entity, type EvaluationResult, type ExecuteIntegrationOptions, type ExecuteQueryRequest, type ExecuteRecipeOptions, type ExportJobStatus, type ExportOptions, type ExportResult, FilesystemCollectionsClient, type ForeignKeyReference, type FsCollection, type FsDocument, type FsProgressEvent, type GenerateRecipeOptions, type GeneratedRecipe, type GraphAlgorithmName, type GraphAlgorithmRequest, type GraphAlgorithmResult, GraphClient, type GraphEdge, type GraphExtractRequest, type GraphExtractResult, type GraphNode, type GraphSummary, type HybridSearchOptions, type ImportError, ImportExportClient, type ImportJobStatus, type ImportOptions, type ImportResult, type ValidationError$1 as ImportValidationError, type ValidationWarning as ImportValidationWarning, type IndexDefinition, type IndexInfo, type InsertResult, type Integration, IntegrationClient, type IntegrationConfig, type IntegrationEvent, type IntegrationExecutionResult, type IntegrationLog, type IntegrationStats, type IntegrationWebhook, type KNNSearchOptions, type ListAPIKeysResponse, type ListBackupsOptions, type ListCollectionsResponse, type ListIntegrationsOptions, type ListMultimediaResponse, type ListRecipesOptions, type ListTrainingJobsOptions, type LoginRequest, type LoginResponse, McpClient, type McpInfo, type McpRequest, type McpResponse, type ModelInfo, type MultimediaInfo, MultimodalClient, type MultimodalEmbedResult, type MultimodalInput, type MultimodalJoinOptions, type MultimodalJoinResult, type MultimodalSearchHit, type MultimodalSearchOptions, type MultimodalSimilarityOptions, type MultimodalSimilarityResult, NL2SqlClient, type NLPAnalysis, NLPClient, type Nl2SqlAskOptions, type Nl2SqlAskResult, type Nl2SqlHistoryEntry, type Nl2SqlSchemaContext, type Nl2SqlValidateResult, NotFoundError, type OAuth2Config, type PredictResult, type PreparedStatement, type PreparedStatementOptions, type QueryColumn, type QueryOptions, type QueryPerformance, type QueryResult, type RangeSearchOptions, RateLimitError, type Recipe, RecipeClient, type RecipeExecutionResult, type RecipeInfo, type RecipeParameter, type RefreshResponse, type RegisterRequest, type RegisterResponse, type RelationshipInfo, type RestoreOptions, type RestoreResult, type RestoreStatus, type RetryConfig, SQLError, SchemaClient, type SchemaStatistics, type ValidationError$2 as SchemaValidationError, type SearchOptions, type SearchResult, type SendChatOptions, type SendChatResult, type Sentiment, ServerError, type StorageConfig, Subscription, type SubscriptionEvent, type SubscriptionOptions, type SummarizeOptions, SynapCores, type SynapCoresConfig, SynapCoresError, SystemClient, type TableConstraint, type TableInfo, type TableSchema, type TestIntegrationOptions, type TestIntegrationResult, TimeoutError, type TrainOptions, type TrainingJob, type TrainingMetrics, type TransactionContext, TransactionError, type TransactionOptions, TransactionsClient, Tx, type TxHistoryEntry, type TxQueryResult, type UpdateOptions, type UploadMultimediaRequest, VERSION, ValidationError, type ValidationResult, type ValidationWarning$1 as ValidationWarning, type Vector, type VectorArithmeticResult, VectorCollection, type VectorCollectionInfo, type VectorCollectionSearchOptions, type VectorDistanceMetric, VectorError, type VectorHit, type VectorRecord, type VectorSearchOptions, type VectorSearchResult, type VectorSimilarityResult, type VisionConfig, type VisionTestResult, type WindowFunctionOptions };