@anvailabs/proximadb-client 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client.d.ts +4 -4
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +92 -5
- package/dist/client.js.map +1 -1
- package/dist/collection.d.ts +12 -1
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +33 -3
- package/dist/collection.js.map +1 -1
- package/dist/generated/schema.d.ts +7508 -2185
- package/dist/generated/schema.d.ts.map +1 -1
- package/dist/graph.d.ts +3 -3
- package/dist/graph.d.ts.map +1 -1
- package/dist/graph.js +15 -8
- package/dist/graph.js.map +1 -1
- package/dist/index.d.mts +3 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4 -0
- package/package.json +14 -9
- package/src/client.ts +195 -32
- package/src/collection.ts +38 -3
- package/src/generated/schema.ts +7508 -2185
- package/src/graph.ts +37 -13
- package/src/index.ts +4 -1
- package/dist/esm/client.js +0 -674
- package/dist/esm/client.js.map +0 -1
- package/dist/esm/collection.js +0 -428
- package/dist/esm/collection.js.map +0 -1
- package/dist/esm/filter.js +0 -228
- package/dist/esm/filter.js.map +0 -1
- package/dist/esm/generated/schema.js +0 -6
- package/dist/esm/generated/schema.js.map +0 -1
- package/dist/esm/graph.js +0 -678
- package/dist/esm/graph.js.map +0 -1
- package/dist/esm/index.js +0 -86
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/search.js +0 -317
- package/dist/esm/search.js.map +0 -1
- package/dist/esm/transport.js +0 -33
- package/dist/esm/transport.js.map +0 -1
- package/dist/esm/types.js +0 -181
- package/dist/esm/types.js.map +0 -1
package/src/collection.ts
CHANGED
|
@@ -77,6 +77,24 @@ export interface CollectionHttpClient extends SearchHttpClient {
|
|
|
77
77
|
// COLLECTION BUILDER
|
|
78
78
|
// ============================================================================
|
|
79
79
|
|
|
80
|
+
const INDEX_TYPES: readonly string[] = Object.values(IndexType);
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Normalize an index type the way the server reads algorithm names (trimmed,
|
|
84
|
+
* case-insensitive), failing fast on anything that is not an `IndexType`: a
|
|
85
|
+
* plain-JS caller's `"HNSW"` used to be sent as a declared index instead of
|
|
86
|
+
* the default route, and a typo only failed as a server 400.
|
|
87
|
+
*/
|
|
88
|
+
export function normalizeIndexType(idx: IndexType | string): IndexType {
|
|
89
|
+
const value = String(idx).trim().toLowerCase();
|
|
90
|
+
if (!INDEX_TYPES.includes(value)) {
|
|
91
|
+
throw new TypeError(
|
|
92
|
+
`unknown index type "${String(idx)}"; expected one of ${INDEX_TYPES.join(", ")}`,
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
return value as IndexType;
|
|
96
|
+
}
|
|
97
|
+
|
|
80
98
|
/**
|
|
81
99
|
* Builder for creating collections
|
|
82
100
|
*/
|
|
@@ -120,10 +138,14 @@ export class CollectionBuilder {
|
|
|
120
138
|
}
|
|
121
139
|
|
|
122
140
|
/**
|
|
123
|
-
* Set the index type
|
|
141
|
+
* Set the index type.
|
|
142
|
+
*
|
|
143
|
+
* Case-insensitive and whitespace-tolerant, like the server's algorithm
|
|
144
|
+
* names (`"HNSW"` is `IndexType.Hnsw`). An unknown value throws a
|
|
145
|
+
* `TypeError` here, at the call that is wrong, before any request is sent.
|
|
124
146
|
*/
|
|
125
147
|
index(idx: IndexType): CollectionBuilder {
|
|
126
|
-
this.indexValue = idx;
|
|
148
|
+
this.indexValue = normalizeIndexType(idx);
|
|
127
149
|
return this;
|
|
128
150
|
}
|
|
129
151
|
|
|
@@ -159,11 +181,24 @@ export class CollectionBuilder {
|
|
|
159
181
|
throw new Error("Dimension is required for collection creation");
|
|
160
182
|
}
|
|
161
183
|
|
|
184
|
+
// TD-RESTGET-1: the server ignores `index_type` "hnsw" (index selection
|
|
185
|
+
// is cost-derived) and rejects any other value, which it never honoured.
|
|
186
|
+
// Send what each choice means: Hnsw keeps the default payload; Flat forces
|
|
187
|
+
// brute force through the routing policy; the others declare that index.
|
|
188
|
+
// `index()` already normalized the value, so these comparisons are exact.
|
|
189
|
+
const index = this.indexValue;
|
|
190
|
+
const indexFields =
|
|
191
|
+
index === IndexType.Hnsw
|
|
192
|
+
? { index_type: index }
|
|
193
|
+
: index === IndexType.Flat
|
|
194
|
+
? { index_policy: { mode: "exact" } }
|
|
195
|
+
: { index_configs: [{ algorithm: index, is_primary: true }] };
|
|
196
|
+
|
|
162
197
|
const request = {
|
|
163
198
|
name: this.collectionName,
|
|
164
199
|
dimension: this.dimensionValue,
|
|
165
200
|
engine: this.engineValue,
|
|
166
|
-
|
|
201
|
+
...indexFields,
|
|
167
202
|
distance_metric: this.metricValue,
|
|
168
203
|
description: this.descriptionValue ?? undefined,
|
|
169
204
|
tags: this.tagsValue.length > 0 ? this.tagsValue : undefined,
|