Skip to content

Commit 589a0ab

Browse files
committed
Merge branch 'feat/web-client' of https://github.com/weaviate/typescript-client into web/split-nice-grpc-connection
2 parents 1fc0d78 + cc8574b commit 589a0ab

File tree

15 files changed

+323
-251
lines changed

15 files changed

+323
-251
lines changed

.github/workflows/main.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ env:
1010
WEAVIATE_124: 1.24.26
1111
WEAVIATE_125: 1.25.34
1212
WEAVIATE_126: 1.26.17
13-
WEAVIATE_127: 1.27.15
14-
WEAVIATE_128: 1.28.11
15-
WEAVIATE_129: 1.29.1
16-
WEAVIATE_130: 1.30.1
13+
WEAVIATE_127: 1.27.27
14+
WEAVIATE_128: 1.28.16
15+
WEAVIATE_129: 1.29.8
16+
WEAVIATE_130: 1.30.7
1717
WEAVIATE_131: 1.31.0
1818

1919
concurrency:

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2020-2023, Weaviate B.V.
1+
Copyright (c) 2020-2025, Weaviate B.V.
22
All rights reserved.
33

44
Redistribution and use in source and binary forms, with or without

package-lock.json

Lines changed: 199 additions & 196 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "weaviate-client",
3-
"version": "3.6.0",
3+
"version": "3.6.2",
44
"description": "JS/TS client for Weaviate",
55
"main": "dist/node/cjs/index.js",
66
"type": "module",
@@ -45,7 +45,7 @@
4545
"weaviate"
4646
],
4747
"author": "Weaviate",
48-
"license": "SEE LICENSE IN LICENSE",
48+
"license": "BSD 3-Clause",
4949
"bugs": {
5050
"url": "https://github.com/weaviate/typescript-client/issues"
5151
},

src/collections/config/classes.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {
2323
GenerativeConfig,
2424
GenerativeSearch,
2525
ModuleConfig,
26+
PropertyDescriptionsUpdate,
2627
Reranker,
2728
RerankerConfig,
2829
VectorIndexType,
@@ -32,10 +33,12 @@ export class MergeWithExisting {
3233
static schema(
3334
current: WeaviateClass,
3435
supportsNamedVectors: boolean,
35-
update?: CollectionConfigUpdate
36+
update?: CollectionConfigUpdate<any>
3637
): WeaviateClass {
3738
if (update === undefined) return current;
3839
if (update.description !== undefined) current.description = update.description;
40+
if (update.propertyDescriptions !== undefined)
41+
current.properties = MergeWithExisting.properties(current.properties, update.propertyDescriptions);
3942
if (update.generative !== undefined)
4043
current.moduleConfig = MergeWithExisting.generative(current.moduleConfig, update.generative);
4144
if (update.invertedIndex !== undefined)
@@ -74,6 +77,18 @@ export class MergeWithExisting {
7477
return current;
7578
}
7679

80+
static properties(
81+
current: WeaviateClass['properties'],
82+
update: PropertyDescriptionsUpdate<any>
83+
): WeaviateClass['properties'] {
84+
if (current === undefined) throw Error('Properties are missing from the class schema.');
85+
if (current.length === 0) return current;
86+
return current.map((property) => ({
87+
...property,
88+
description: update[property.name!] ?? property.description,
89+
}));
90+
}
91+
7792
static generative(
7893
current: WeaviateModuleConfig,
7994
update: ModuleConfig<GenerativeSearch, GenerativeConfig>

src/collections/config/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ const config = <T>(
8787
)
8888
).then(() => this.getShards());
8989
},
90-
update: (config?: CollectionConfigUpdate) => {
90+
update: (config?: CollectionConfigUpdate<T>) => {
9191
return getRaw()
9292
.then(async (current) =>
9393
MergeWithExisting.schema(
@@ -164,10 +164,10 @@ export interface Config<T> {
164164
*
165165
* Use the `weaviate.classes.Reconfigure` class to generate the necessary configuration objects for this method.
166166
*
167-
* @param {CollectionConfigUpdate} [config] The configuration to update. Only a subset of the actual collection configuration can be updated.
167+
* @param {CollectionConfigUpdate<T>} [config] The configuration to update. Only a subset of the actual collection configuration can be updated.
168168
* @returns {Promise<void>} A promise that resolves when the collection has been updated.
169169
*/
170-
update: (config?: CollectionConfigUpdate) => Promise<void>;
170+
update: (config?: CollectionConfigUpdate<T>) => Promise<void>;
171171
}
172172

173173
export class VectorIndex {

src/collections/config/integration.test.ts

Lines changed: 62 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ describe('Testing of the collection.config namespace', () => {
186186
expect(config.vectorizers.title.vectorizer.name).toEqual('text2vec-contextionary');
187187
});
188188

189-
it('should be able to get the config of a collection with HNSW+PQ', async () => {
189+
it('should be able to get the config of a collection with hnsw-pq', async () => {
190190
const collectionName = 'TestCollectionConfigGetHNSWPlusPQ';
191191
const collection = await client.collections.create({
192192
name: collectionName,
@@ -204,12 +204,13 @@ describe('Testing of the collection.config namespace', () => {
204204
expect(config.reranker).toBeUndefined();
205205
expect(vectorIndexConfig).toBeDefined();
206206
expect(vectorIndexConfig.quantizer).toBeDefined();
207+
expect(vectorIndexConfig.quantizer?.type).toEqual('pq');
207208
expect(config.vectorizers.default.indexType).toEqual('hnsw');
208209
expect(config.vectorizers.default.properties).toBeUndefined();
209210
expect(config.vectorizers.default.vectorizer.name).toEqual('none');
210211
});
211212

212-
it('should be able to get the config of a collection with HNSW+BQ', async () => {
213+
it('should be able to get the config of a collection with hnsw-bq', async () => {
213214
const collectionName = 'TestCollectionConfigGetHNSWPlusBQ';
214215
const query = () =>
215216
client.collections.create({
@@ -232,12 +233,37 @@ describe('Testing of the collection.config namespace', () => {
232233
expect(config.reranker).toBeUndefined();
233234
expect(vectorIndexConfig).toBeDefined();
234235
expect(vectorIndexConfig.quantizer).toBeDefined();
236+
expect(vectorIndexConfig.quantizer?.type).toEqual('bq');
235237
expect(config.vectorizers.default.indexType).toEqual('hnsw');
236238
expect(config.vectorizers.default.properties).toBeUndefined();
237239
expect(config.vectorizers.default.vectorizer.name).toEqual('none');
238240
});
239241

240-
it('should be able to get the config of a collection with flat+BQ', async () => {
242+
requireAtLeast(1, 26, 0).it('should be able to get the config of a collection with hnsw-sq', async () => {
243+
const collectionName = 'TestCollectionConfigGetHNSWPlusSQ';
244+
const collection = await client.collections.create({
245+
name: collectionName,
246+
vectorizers: weaviate.configure.vectorizer.none({
247+
vectorIndexConfig: weaviate.configure.vectorIndex.hnsw({
248+
quantizer: weaviate.configure.vectorIndex.quantizer.sq(),
249+
}),
250+
}),
251+
});
252+
const config = await collection.config.get();
253+
254+
const vectorIndexConfig = config.vectorizers.default.indexConfig as VectorIndexConfigHNSW;
255+
expect(config.name).toEqual(collectionName);
256+
expect(config.generative).toBeUndefined();
257+
expect(config.reranker).toBeUndefined();
258+
expect(vectorIndexConfig).toBeDefined();
259+
expect(vectorIndexConfig.quantizer).toBeDefined();
260+
expect(vectorIndexConfig.quantizer?.type).toEqual('sq');
261+
expect(config.vectorizers.default.indexType).toEqual('hnsw');
262+
expect(config.vectorizers.default.properties).toBeUndefined();
263+
expect(config.vectorizers.default.vectorizer.name).toEqual('none');
264+
});
265+
266+
it('should be able to get the config of a collection with flat-bq', async () => {
241267
const collectionName = 'TestCollectionConfigGetFlatPlusBQ';
242268
const collection = await client.collections.create({
243269
name: collectionName,
@@ -255,12 +281,13 @@ describe('Testing of the collection.config namespace', () => {
255281
expect(config.reranker).toBeUndefined();
256282
expect(vectorIndexConfig).toBeDefined();
257283
expect(vectorIndexConfig.quantizer).toBeDefined();
284+
expect(vectorIndexConfig.quantizer?.type).toEqual('bq');
258285
expect(config.vectorizers.default.indexType).toEqual('flat');
259286
expect(config.vectorizers.default.properties).toBeUndefined();
260287
expect(config.vectorizers.default.vectorizer.name).toEqual('none');
261288
});
262289

263-
it('should be able to get the config of a single-vector collection with dynamic+BQ', async () => {
290+
it('should be able to get the config of a single-vector collection with dynamic hnsw-pq & flat-bq', async () => {
264291
const asyncIndexing = await weaviate.connectToLocal({ port: 8078, grpcPort: 50049 }); // need async indexing for dynamic vectorizer
265292
const collectionName = 'TestSVCollectionConfigGetDynamicPlusBQ';
266293
await asyncIndexing.collections.delete(collectionName);
@@ -292,14 +319,16 @@ describe('Testing of the collection.config namespace', () => {
292319
expect((vectorIndexConfig as any).quantizer).toBeUndefined();
293320
expect(vectorIndexConfig.hnsw).toBeDefined();
294321
expect(vectorIndexConfig.hnsw.quantizer).toBeDefined();
322+
expect(vectorIndexConfig.hnsw.quantizer?.type).toEqual('pq');
295323
expect(vectorIndexConfig.flat).toBeDefined();
296324
expect(vectorIndexConfig.flat.quantizer).toBeDefined();
325+
expect(vectorIndexConfig.flat.quantizer?.type).toEqual('bq');
297326
expect(config.vectorizers.default.indexType).toEqual('dynamic');
298327
expect(config.vectorizers.default.properties).toBeUndefined();
299328
expect(config.vectorizers.default.vectorizer.name).toEqual('none');
300329
});
301330

302-
it('should be able to get the config of a multi-vector collection with dynamic+BQ', async () => {
331+
it('should be able to get the config of a multi-vector collection with dynamic hnsw-pq & flat-bq', async () => {
303332
const asyncIndexing = await weaviate.connectToLocal({ port: 8078, grpcPort: 50049 }); // need async indexing for dynamic vectorizer
304333
const collectionName = 'TestMVCollectionConfigGetDynamicPlusBQ';
305334
await asyncIndexing.collections.delete(collectionName);
@@ -331,8 +360,10 @@ describe('Testing of the collection.config namespace', () => {
331360
expect((vectorIndexConfig as any).quantizer).toBeUndefined();
332361
expect(vectorIndexConfig.hnsw).toBeDefined();
333362
expect(vectorIndexConfig.hnsw.quantizer).toBeDefined();
363+
expect(vectorIndexConfig.hnsw.quantizer?.type).toEqual('pq');
334364
expect(vectorIndexConfig.flat).toBeDefined();
335365
expect(vectorIndexConfig.flat.quantizer).toBeDefined();
366+
expect(vectorIndexConfig.flat.quantizer?.type).toEqual('bq');
336367
expect(config.vectorizers.default.indexType).toEqual('dynamic');
337368
expect(config.vectorizers.default.properties).toBeUndefined();
338369
expect(config.vectorizers.default.vectorizer.name).toEqual('none');
@@ -387,11 +418,7 @@ describe('Testing of the collection.config namespace', () => {
387418
]);
388419
});
389420

390-
requireAtLeast(
391-
1,
392-
31,
393-
0
394-
)('Mutable named vectors', () => {
421+
requireAtLeast(1, 31, 0).describe('Mutable named vectors', () => {
395422
it('should be able to add named vectors to a collection', async () => {
396423
const collectionName = 'TestCollectionConfigAddVector' as const;
397424
const collection = await client.collections.create({
@@ -484,7 +511,7 @@ describe('Testing of the collection.config namespace', () => {
484511
expect(notUpdated?.status).toEqual('READY');
485512
});
486513

487-
it('should be able update the config of a collection', async () => {
514+
it.only('should be able update the config of a collection', async () => {
488515
const collectionName = 'TestCollectionConfigUpdate';
489516
const collection = await client.collections.create({
490517
name: collectionName,
@@ -493,11 +520,23 @@ describe('Testing of the collection.config namespace', () => {
493520
name: 'testProp',
494521
dataType: 'text',
495522
},
523+
{
524+
name: 'testProp2',
525+
dataType: 'text',
526+
},
496527
],
497528
vectorizers: weaviate.configure.vectorizer.none(),
498529
});
530+
const supportsUpdatingPropertyDescriptions = await client
531+
.getWeaviateVersion()
532+
.then((ver) => ver.isAtLeast(1, 27, 0));
499533
const config = await collection.config
500534
.update({
535+
propertyDescriptions: supportsUpdatingPropertyDescriptions
536+
? {
537+
testProp: 'This is a test property',
538+
}
539+
: undefined,
501540
vectorizers: weaviate.reconfigure.vectorizer.update({
502541
vectorIndexConfig: weaviate.reconfigure.vectorIndex.hnsw({
503542
quantizer: weaviate.reconfigure.vectorIndex.quantizer.pq(),
@@ -512,6 +551,18 @@ describe('Testing of the collection.config namespace', () => {
512551
{
513552
name: 'testProp',
514553
dataType: 'text',
554+
description: supportsUpdatingPropertyDescriptions ? 'This is a test property' : undefined,
555+
indexRangeFilters: false,
556+
indexSearchable: true,
557+
indexFilterable: true,
558+
indexInverted: false,
559+
vectorizerConfig: undefined,
560+
nestedProperties: undefined,
561+
tokenization: 'word',
562+
},
563+
{
564+
name: 'testProp2',
565+
dataType: 'text',
515566
description: undefined,
516567
indexRangeFilters: false,
517568
indexSearchable: true,

src/collections/config/types/index.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,15 @@ export type CollectionConfig = {
104104
vectorizers: VectorConfig;
105105
};
106106

107-
export type CollectionConfigUpdate = {
107+
export type PropertyDescriptionsUpdate<T> = T extends undefined
108+
? Record<string, string>
109+
: {
110+
[Property in keyof T]: string;
111+
};
112+
113+
export type CollectionConfigUpdate<T> = {
108114
description?: string;
115+
propertyDescriptions?: PropertyDescriptionsUpdate<T>;
109116
generative?: ModuleConfig<GenerativeSearch, GenerativeConfig>;
110117
invertedIndex?: InvertedIndexConfigUpdate;
111118
multiTenancy?: MultiTenancyConfigUpdate;

src/collections/config/utils.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,16 @@ export const parseVectorIndex = (module: ModuleConfig<VectorIndexType, VectorInd
172172
},
173173
};
174174
}
175+
if (QuantizerGuards.isSQCreate(quantizer)) {
176+
const { type, ...quant } = quantizer;
177+
return {
178+
...conf,
179+
sq: {
180+
...quant,
181+
enabled: true,
182+
},
183+
};
184+
}
175185
};
176186

177187
export const parseVectorizerConfig = (config?: VectorizerConfig): any => {

src/collections/filters/integration.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ describe('Testing of the filter class with a simple collection', () => {
112112

113113
it('should filter a fetch objects query with a single filter and non-generic collection', async () => {
114114
const res = await client.collections.use(collectionName).query.fetchObjects({
115-
filters: client.collections.use(collectionName).filter.byProperty('text').equal('two'),
115+
filters: weaviate.filter.byProperty('text').equal('two'),
116116
});
117117
expect(res.objects.length).toEqual(1);
118118
const obj = res.objects[0];

0 commit comments

Comments
 (0)