@mastra/qdrant 0.2.14 → 0.2.15-alpha.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.
@@ -1,23 +1,23 @@
1
1
 
2
- > @mastra/qdrant@0.2.14-alpha.4 build /home/runner/work/mastra/mastra/stores/qdrant
2
+ > @mastra/qdrant@0.2.15-alpha.0 build /home/runner/work/mastra/mastra/stores/qdrant
3
3
  > tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting
4
4
 
5
5
  CLI Building entry: src/index.ts
6
6
  CLI Using tsconfig: tsconfig.json
7
7
  CLI tsup v8.4.0
8
8
  TSC Build start
9
- TSC ⚡️ Build success in 6845ms
9
+ TSC ⚡️ Build success in 9736ms
10
10
  DTS Build start
11
11
  CLI Target: es2022
12
12
  Analysis will use the bundled TypeScript version 5.8.3
13
13
  Writing package typings: /home/runner/work/mastra/mastra/stores/qdrant/dist/_tsup-dts-rollup.d.ts
14
14
  Analysis will use the bundled TypeScript version 5.8.3
15
15
  Writing package typings: /home/runner/work/mastra/mastra/stores/qdrant/dist/_tsup-dts-rollup.d.cts
16
- DTS ⚡️ Build success in 8721ms
16
+ DTS ⚡️ Build success in 10156ms
17
17
  CLI Cleaning output folder
18
18
  ESM Build start
19
19
  CJS Build start
20
- ESM dist/index.js 19.69 KB
21
- ESM ⚡️ Build success in 839ms
22
- CJS dist/index.cjs 19.75 KB
23
- CJS ⚡️ Build success in 842ms
20
+ ESM dist/index.js 20.98 KB
21
+ ESM ⚡️ Build success in 858ms
22
+ CJS dist/index.cjs 21.04 KB
23
+ CJS ⚡️ Build success in 858ms
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @mastra/qdrant
2
2
 
3
+ ## 0.2.15-alpha.0
4
+
5
+ ### Patch Changes
6
+
7
+ - d0ee3c6: Change all public functions and constructors in vector stores to use named args and prepare to phase out positional args
8
+ - Updated dependencies [f53a6ac]
9
+ - Updated dependencies [eabdcd9]
10
+ - Updated dependencies [90be034]
11
+ - Updated dependencies [99f050a]
12
+ - Updated dependencies [d0ee3c6]
13
+ - Updated dependencies [23f258c]
14
+ - Updated dependencies [2672a05]
15
+ - @mastra/core@0.9.5-alpha.0
16
+
3
17
  ## 0.2.14
4
18
 
5
19
  ### Patch Changes
@@ -1,5 +1,8 @@
1
1
  import { BaseFilterTranslator } from '@mastra/core/vector/filter';
2
2
  import type { CreateIndexParams } from '@mastra/core/vector';
3
+ import type { DeleteIndexParams } from '@mastra/core/vector';
4
+ import type { DeleteVectorParams } from '@mastra/core/vector';
5
+ import type { DescribeIndexParams } from '@mastra/core/vector';
3
6
  import type { IndexStats } from '@mastra/core/vector';
4
7
  import type { LogicalOperator } from '@mastra/core/vector/filter';
5
8
  import { MastraVector } from '@mastra/core/vector';
@@ -7,6 +10,7 @@ import type { OperatorSupport } from '@mastra/core/vector/filter';
7
10
  import type { ParamsToArgs } from '@mastra/core/vector';
8
11
  import type { QueryResult } from '@mastra/core/vector';
9
12
  import type { QueryVectorParams } from '@mastra/core/vector';
13
+ import type { UpdateVectorParams } from '@mastra/core/vector';
10
14
  import type { UpsertVectorParams } from '@mastra/core/vector';
11
15
  import type { VectorFilter } from '@mastra/core/vector/filter';
12
16
 
@@ -55,14 +59,34 @@ export declare class QdrantFilterTranslator extends BaseFilterTranslator {
55
59
 
56
60
  declare class QdrantVector extends MastraVector {
57
61
  private client;
62
+ /**
63
+ * @deprecated Passing url, apiKey, https as positional arguments is deprecated.
64
+ * Use the object parameter instead. This signature will be removed on May 20th, 2025.
65
+ */
58
66
  constructor(url: string, apiKey?: string, https?: boolean);
67
+ /**
68
+ * Creates a new QdrantVector client.
69
+ * @param params - An object with url, optional apiKey, and optional https.
70
+ */
71
+ constructor(params: {
72
+ url: string;
73
+ apiKey?: string;
74
+ https?: boolean;
75
+ });
59
76
  upsert(...args: ParamsToArgs<UpsertVectorParams>): Promise<string[]>;
60
77
  createIndex(...args: ParamsToArgs<CreateIndexParams>): Promise<void>;
61
78
  transformFilter(filter?: VectorFilter): VectorFilter;
62
79
  query(...args: ParamsToArgs<QueryVectorParams>): Promise<QueryResult[]>;
63
80
  listIndexes(): Promise<string[]>;
64
- describeIndex(indexName: string): Promise<IndexStats>;
65
- deleteIndex(indexName: string): Promise<void>;
81
+ /**
82
+ * Retrieves statistics about a vector index.
83
+ *
84
+ * @param params - The parameters for describing an index
85
+ * @param params.indexName - The name of the index to describe
86
+ * @returns A promise that resolves to the index statistics including dimension, count and metric
87
+ */
88
+ describeIndex(...args: ParamsToArgs<DescribeIndexParams>): Promise<IndexStats>;
89
+ deleteIndex(...args: ParamsToArgs<DeleteIndexParams>): Promise<void>;
66
90
  /**
67
91
  * @deprecated Use {@link updateVector} instead. This method will be removed on May 20th, 2025.
68
92
  *
@@ -89,10 +113,7 @@ declare class QdrantVector extends MastraVector {
89
113
  * @returns A promise that resolves when the update is complete.
90
114
  * @throws Will throw an error if no updates are provided or if the update operation fails.
91
115
  */
92
- updateVector(indexName: string, id: string, update: {
93
- vector?: number[];
94
- metadata?: Record<string, any>;
95
- }): Promise<void>;
116
+ updateVector(...args: ParamsToArgs<UpdateVectorParams>): Promise<void>;
96
117
  /**
97
118
  * @deprecated Use {@link deleteVector} instead. This method will be removed on May 20th, 2025.
98
119
  *
@@ -110,7 +131,7 @@ declare class QdrantVector extends MastraVector {
110
131
  * @returns A promise that resolves when the deletion is complete.
111
132
  * @throws Will throw an error if the deletion operation fails.
112
133
  */
113
- deleteVector(indexName: string, id: string): Promise<void>;
134
+ deleteVector(...args: ParamsToArgs<DeleteVectorParams>): Promise<void>;
114
135
  /**
115
136
  * Parses and converts a string ID to the appropriate type (string or number) for Qdrant point operations.
116
137
  *
@@ -1,5 +1,8 @@
1
1
  import { BaseFilterTranslator } from '@mastra/core/vector/filter';
2
2
  import type { CreateIndexParams } from '@mastra/core/vector';
3
+ import type { DeleteIndexParams } from '@mastra/core/vector';
4
+ import type { DeleteVectorParams } from '@mastra/core/vector';
5
+ import type { DescribeIndexParams } from '@mastra/core/vector';
3
6
  import type { IndexStats } from '@mastra/core/vector';
4
7
  import type { LogicalOperator } from '@mastra/core/vector/filter';
5
8
  import { MastraVector } from '@mastra/core/vector';
@@ -7,6 +10,7 @@ import type { OperatorSupport } from '@mastra/core/vector/filter';
7
10
  import type { ParamsToArgs } from '@mastra/core/vector';
8
11
  import type { QueryResult } from '@mastra/core/vector';
9
12
  import type { QueryVectorParams } from '@mastra/core/vector';
13
+ import type { UpdateVectorParams } from '@mastra/core/vector';
10
14
  import type { UpsertVectorParams } from '@mastra/core/vector';
11
15
  import type { VectorFilter } from '@mastra/core/vector/filter';
12
16
 
@@ -55,14 +59,34 @@ export declare class QdrantFilterTranslator extends BaseFilterTranslator {
55
59
 
56
60
  declare class QdrantVector extends MastraVector {
57
61
  private client;
62
+ /**
63
+ * @deprecated Passing url, apiKey, https as positional arguments is deprecated.
64
+ * Use the object parameter instead. This signature will be removed on May 20th, 2025.
65
+ */
58
66
  constructor(url: string, apiKey?: string, https?: boolean);
67
+ /**
68
+ * Creates a new QdrantVector client.
69
+ * @param params - An object with url, optional apiKey, and optional https.
70
+ */
71
+ constructor(params: {
72
+ url: string;
73
+ apiKey?: string;
74
+ https?: boolean;
75
+ });
59
76
  upsert(...args: ParamsToArgs<UpsertVectorParams>): Promise<string[]>;
60
77
  createIndex(...args: ParamsToArgs<CreateIndexParams>): Promise<void>;
61
78
  transformFilter(filter?: VectorFilter): VectorFilter;
62
79
  query(...args: ParamsToArgs<QueryVectorParams>): Promise<QueryResult[]>;
63
80
  listIndexes(): Promise<string[]>;
64
- describeIndex(indexName: string): Promise<IndexStats>;
65
- deleteIndex(indexName: string): Promise<void>;
81
+ /**
82
+ * Retrieves statistics about a vector index.
83
+ *
84
+ * @param params - The parameters for describing an index
85
+ * @param params.indexName - The name of the index to describe
86
+ * @returns A promise that resolves to the index statistics including dimension, count and metric
87
+ */
88
+ describeIndex(...args: ParamsToArgs<DescribeIndexParams>): Promise<IndexStats>;
89
+ deleteIndex(...args: ParamsToArgs<DeleteIndexParams>): Promise<void>;
66
90
  /**
67
91
  * @deprecated Use {@link updateVector} instead. This method will be removed on May 20th, 2025.
68
92
  *
@@ -89,10 +113,7 @@ declare class QdrantVector extends MastraVector {
89
113
  * @returns A promise that resolves when the update is complete.
90
114
  * @throws Will throw an error if no updates are provided or if the update operation fails.
91
115
  */
92
- updateVector(indexName: string, id: string, update: {
93
- vector?: number[];
94
- metadata?: Record<string, any>;
95
- }): Promise<void>;
116
+ updateVector(...args: ParamsToArgs<UpdateVectorParams>): Promise<void>;
96
117
  /**
97
118
  * @deprecated Use {@link deleteVector} instead. This method will be removed on May 20th, 2025.
98
119
  *
@@ -110,7 +131,7 @@ declare class QdrantVector extends MastraVector {
110
131
  * @returns A promise that resolves when the deletion is complete.
111
132
  * @throws Will throw an error if the deletion operation fails.
112
133
  */
113
- deleteVector(indexName: string, id: string): Promise<void>;
134
+ deleteVector(...args: ParamsToArgs<DeleteVectorParams>): Promise<void>;
114
135
  /**
115
136
  * Parses and converts a string ID to the appropriate type (string or number) for Qdrant point operations.
116
137
  *
package/dist/index.cjs CHANGED
@@ -239,12 +239,32 @@ var DISTANCE_MAPPING = {
239
239
  };
240
240
  var QdrantVector = class extends vector.MastraVector {
241
241
  client;
242
- constructor(url, apiKey, https) {
242
+ constructor(paramsOrUrl, apiKey, https) {
243
243
  super();
244
+ let url;
245
+ let key;
246
+ let secure;
247
+ if (typeof paramsOrUrl === "string") {
248
+ if (typeof console !== "undefined" && console.warn) {
249
+ console.warn(
250
+ `Deprecation Warning: Passing url, apiKey, https as positional arguments to QdrantVector constructor is deprecated.
251
+ Please use an object parameter instead:
252
+ new QdrantVector({ url, apiKey, https })
253
+ This signature will be removed on May 20th, 2025.`
254
+ );
255
+ }
256
+ url = paramsOrUrl;
257
+ key = apiKey;
258
+ secure = https;
259
+ } else {
260
+ url = paramsOrUrl.url;
261
+ key = paramsOrUrl.apiKey;
262
+ secure = paramsOrUrl.https;
263
+ }
244
264
  const baseClient = new jsClientRest.QdrantClient({
245
265
  url,
246
- apiKey,
247
- https
266
+ apiKey: key,
267
+ https: secure
248
268
  });
249
269
  const telemetry = this.__getTelemetry();
250
270
  this.client = telemetry?.traceClass(baseClient, {
@@ -333,7 +353,16 @@ var QdrantVector = class extends vector.MastraVector {
333
353
  const response = await this.client.getCollections();
334
354
  return response.collections.map((collection) => collection.name) || [];
335
355
  }
336
- async describeIndex(indexName) {
356
+ /**
357
+ * Retrieves statistics about a vector index.
358
+ *
359
+ * @param params - The parameters for describing an index
360
+ * @param params.indexName - The name of the index to describe
361
+ * @returns A promise that resolves to the index statistics including dimension, count and metric
362
+ */
363
+ async describeIndex(...args) {
364
+ const params = this.normalizeArgs("describeIndex", args);
365
+ const { indexName } = params;
337
366
  const { config, points_count } = await this.client.getCollection(indexName);
338
367
  const distance = config.params.vectors?.distance;
339
368
  return {
@@ -343,7 +372,9 @@ var QdrantVector = class extends vector.MastraVector {
343
372
  metric: Object.keys(DISTANCE_MAPPING).find((key) => DISTANCE_MAPPING[key] === distance)
344
373
  };
345
374
  }
346
- async deleteIndex(indexName) {
375
+ async deleteIndex(...args) {
376
+ const params = this.normalizeArgs("deleteIndex", args);
377
+ const { indexName } = params;
347
378
  await this.client.deleteCollection(indexName);
348
379
  }
349
380
  /**
@@ -364,7 +395,7 @@ var QdrantVector = class extends vector.MastraVector {
364
395
  Please use updateVector() instead.
365
396
  updateIndexById() will be removed on May 20th, 2025.`
366
397
  );
367
- await this.updateVector(indexName, id, update);
398
+ await this.updateVector({ indexName, id, update });
368
399
  }
369
400
  /**
370
401
  * Updates a vector by its ID with the provided vector and/or metadata.
@@ -376,7 +407,9 @@ var QdrantVector = class extends vector.MastraVector {
376
407
  * @returns A promise that resolves when the update is complete.
377
408
  * @throws Will throw an error if no updates are provided or if the update operation fails.
378
409
  */
379
- async updateVector(indexName, id, update) {
410
+ async updateVector(...args) {
411
+ const params = this.normalizeArgs("updateVector", args);
412
+ const { indexName, id, update } = params;
380
413
  if (!update.vector && !update.metadata) {
381
414
  throw new Error("No updates provided");
382
415
  }
@@ -428,7 +461,7 @@ var QdrantVector = class extends vector.MastraVector {
428
461
  Please use deleteVector() instead.
429
462
  deleteIndexById() will be removed on May 20th, 2025.`
430
463
  );
431
- await this.deleteVector(indexName, id);
464
+ await this.deleteVector({ indexName, id });
432
465
  }
433
466
  /**
434
467
  * Deletes a vector by its ID.
@@ -437,7 +470,9 @@ var QdrantVector = class extends vector.MastraVector {
437
470
  * @returns A promise that resolves when the deletion is complete.
438
471
  * @throws Will throw an error if the deletion operation fails.
439
472
  */
440
- async deleteVector(indexName, id) {
473
+ async deleteVector(...args) {
474
+ const params = this.normalizeArgs("deleteVector", args);
475
+ const { indexName, id } = params;
441
476
  try {
442
477
  const pointId = this.parsePointId(id);
443
478
  await this.client.delete(indexName, {
package/dist/index.js CHANGED
@@ -237,12 +237,32 @@ var DISTANCE_MAPPING = {
237
237
  };
238
238
  var QdrantVector = class extends MastraVector {
239
239
  client;
240
- constructor(url, apiKey, https) {
240
+ constructor(paramsOrUrl, apiKey, https) {
241
241
  super();
242
+ let url;
243
+ let key;
244
+ let secure;
245
+ if (typeof paramsOrUrl === "string") {
246
+ if (typeof console !== "undefined" && console.warn) {
247
+ console.warn(
248
+ `Deprecation Warning: Passing url, apiKey, https as positional arguments to QdrantVector constructor is deprecated.
249
+ Please use an object parameter instead:
250
+ new QdrantVector({ url, apiKey, https })
251
+ This signature will be removed on May 20th, 2025.`
252
+ );
253
+ }
254
+ url = paramsOrUrl;
255
+ key = apiKey;
256
+ secure = https;
257
+ } else {
258
+ url = paramsOrUrl.url;
259
+ key = paramsOrUrl.apiKey;
260
+ secure = paramsOrUrl.https;
261
+ }
242
262
  const baseClient = new QdrantClient({
243
263
  url,
244
- apiKey,
245
- https
264
+ apiKey: key,
265
+ https: secure
246
266
  });
247
267
  const telemetry = this.__getTelemetry();
248
268
  this.client = telemetry?.traceClass(baseClient, {
@@ -331,7 +351,16 @@ var QdrantVector = class extends MastraVector {
331
351
  const response = await this.client.getCollections();
332
352
  return response.collections.map((collection) => collection.name) || [];
333
353
  }
334
- async describeIndex(indexName) {
354
+ /**
355
+ * Retrieves statistics about a vector index.
356
+ *
357
+ * @param params - The parameters for describing an index
358
+ * @param params.indexName - The name of the index to describe
359
+ * @returns A promise that resolves to the index statistics including dimension, count and metric
360
+ */
361
+ async describeIndex(...args) {
362
+ const params = this.normalizeArgs("describeIndex", args);
363
+ const { indexName } = params;
335
364
  const { config, points_count } = await this.client.getCollection(indexName);
336
365
  const distance = config.params.vectors?.distance;
337
366
  return {
@@ -341,7 +370,9 @@ var QdrantVector = class extends MastraVector {
341
370
  metric: Object.keys(DISTANCE_MAPPING).find((key) => DISTANCE_MAPPING[key] === distance)
342
371
  };
343
372
  }
344
- async deleteIndex(indexName) {
373
+ async deleteIndex(...args) {
374
+ const params = this.normalizeArgs("deleteIndex", args);
375
+ const { indexName } = params;
345
376
  await this.client.deleteCollection(indexName);
346
377
  }
347
378
  /**
@@ -362,7 +393,7 @@ var QdrantVector = class extends MastraVector {
362
393
  Please use updateVector() instead.
363
394
  updateIndexById() will be removed on May 20th, 2025.`
364
395
  );
365
- await this.updateVector(indexName, id, update);
396
+ await this.updateVector({ indexName, id, update });
366
397
  }
367
398
  /**
368
399
  * Updates a vector by its ID with the provided vector and/or metadata.
@@ -374,7 +405,9 @@ var QdrantVector = class extends MastraVector {
374
405
  * @returns A promise that resolves when the update is complete.
375
406
  * @throws Will throw an error if no updates are provided or if the update operation fails.
376
407
  */
377
- async updateVector(indexName, id, update) {
408
+ async updateVector(...args) {
409
+ const params = this.normalizeArgs("updateVector", args);
410
+ const { indexName, id, update } = params;
378
411
  if (!update.vector && !update.metadata) {
379
412
  throw new Error("No updates provided");
380
413
  }
@@ -426,7 +459,7 @@ var QdrantVector = class extends MastraVector {
426
459
  Please use deleteVector() instead.
427
460
  deleteIndexById() will be removed on May 20th, 2025.`
428
461
  );
429
- await this.deleteVector(indexName, id);
462
+ await this.deleteVector({ indexName, id });
430
463
  }
431
464
  /**
432
465
  * Deletes a vector by its ID.
@@ -435,7 +468,9 @@ var QdrantVector = class extends MastraVector {
435
468
  * @returns A promise that resolves when the deletion is complete.
436
469
  * @throws Will throw an error if the deletion operation fails.
437
470
  */
438
- async deleteVector(indexName, id) {
471
+ async deleteVector(...args) {
472
+ const params = this.normalizeArgs("deleteVector", args);
473
+ const { indexName, id } = params;
439
474
  try {
440
475
  const pointId = this.parsePointId(id);
441
476
  await this.client.delete(indexName, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/qdrant",
3
- "version": "0.2.14",
3
+ "version": "0.2.15-alpha.0",
4
4
  "description": "Qdrant vector store provider for Mastra",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -21,7 +21,7 @@
21
21
  "license": "MIT",
22
22
  "dependencies": {
23
23
  "@qdrant/js-client-rest": "^1.13.0",
24
- "@mastra/core": "^0.9.4"
24
+ "@mastra/core": "^0.9.5-alpha.0"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@microsoft/api-extractor": "^7.52.5",
@@ -13,12 +13,12 @@ describe('QdrantVector', () => {
13
13
 
14
14
  describe('Index Operations', () => {
15
15
  beforeAll(async () => {
16
- qdrant = new QdrantVector('http://localhost:6333/');
16
+ qdrant = new QdrantVector({ url: 'http://localhost:6333/' });
17
17
  await qdrant.createIndex({ indexName: testCollectionName, dimension });
18
18
  });
19
19
 
20
20
  afterAll(async () => {
21
- await qdrant.deleteIndex(testCollectionName);
21
+ await qdrant.deleteIndex({ indexName: testCollectionName });
22
22
  }, 50000);
23
23
 
24
24
  it('should list collections including ours', async () => {
@@ -27,7 +27,7 @@ describe('QdrantVector', () => {
27
27
  }, 50000);
28
28
 
29
29
  it('should describe index with correct properties', async () => {
30
- const stats = await qdrant.describeIndex(testCollectionName);
30
+ const stats = await qdrant.describeIndex({ indexName: testCollectionName });
31
31
  expect(stats.dimension).toBe(dimension);
32
32
  expect(stats.metric).toBe('cosine');
33
33
  expect(typeof stats.count).toBe('number');
@@ -36,12 +36,12 @@ describe('QdrantVector', () => {
36
36
 
37
37
  describe('Vector Operations', () => {
38
38
  beforeAll(async () => {
39
- qdrant = new QdrantVector('http://localhost:6333/');
39
+ qdrant = new QdrantVector({ url: 'http://localhost:6333/' });
40
40
  await qdrant.createIndex({ indexName: testCollectionName, dimension });
41
41
  });
42
42
 
43
43
  afterAll(async () => {
44
- await qdrant.deleteIndex(testCollectionName);
44
+ await qdrant.deleteIndex({ indexName: testCollectionName });
45
45
  }, 50000);
46
46
 
47
47
  const testVectors = [
@@ -100,7 +100,7 @@ describe('QdrantVector', () => {
100
100
  });
101
101
 
102
102
  afterEach(async () => {
103
- await qdrant.deleteIndex(testCollectionName);
103
+ await qdrant.deleteIndex({ indexName: testCollectionName });
104
104
  });
105
105
 
106
106
  it('should update the vector by id', async () => {
@@ -118,7 +118,7 @@ describe('QdrantVector', () => {
118
118
  metadata: newMetaData,
119
119
  };
120
120
 
121
- await qdrant.updateVector(testCollectionName, idToBeUpdated, update);
121
+ await qdrant.updateVector({ indexName: testCollectionName, id: idToBeUpdated, update });
122
122
 
123
123
  const results: QueryResult[] = await qdrant.query({
124
124
  indexName: testCollectionName,
@@ -146,7 +146,7 @@ describe('QdrantVector', () => {
146
146
  metadata: newMetaData,
147
147
  };
148
148
 
149
- await qdrant.updateVector(testCollectionName, idToBeUpdated, update);
149
+ await qdrant.updateVector({ indexName: testCollectionName, id: idToBeUpdated, update });
150
150
 
151
151
  const results: QueryResult[] = await qdrant.query({
152
152
  indexName: testCollectionName,
@@ -171,7 +171,7 @@ describe('QdrantVector', () => {
171
171
  vector: newVector,
172
172
  };
173
173
 
174
- await qdrant.updateVector(testCollectionName, idToBeUpdated, update);
174
+ await qdrant.updateVector({ indexName: testCollectionName, id: idToBeUpdated, update });
175
175
 
176
176
  const results: QueryResult[] = await qdrant.query({
177
177
  indexName: testCollectionName,
@@ -185,12 +185,16 @@ describe('QdrantVector', () => {
185
185
  });
186
186
 
187
187
  it('should throw exception when no updates are given', async () => {
188
- await expect(qdrant.updateVector(testCollectionName, 'id', {})).rejects.toThrow('No updates provided');
188
+ await expect(qdrant.updateVector({ indexName: testCollectionName, id: 'id', update: {} })).rejects.toThrow(
189
+ 'No updates provided',
190
+ );
189
191
  });
190
192
 
191
193
  it('should throw error for non-existent index', async () => {
192
194
  const nonExistentIndex = 'non-existent-index';
193
- await expect(qdrant.updateVector(nonExistentIndex, 'test-id', { vector: [1, 2, 3] })).rejects.toThrow();
195
+ await expect(
196
+ qdrant.updateVector({ indexName: nonExistentIndex, id: 'test-id', update: { vector: [1, 2, 3] } }),
197
+ ).rejects.toThrow();
194
198
  });
195
199
 
196
200
  it('should throw error for invalid vector dimension', async () => {
@@ -201,7 +205,7 @@ describe('QdrantVector', () => {
201
205
  });
202
206
 
203
207
  await expect(
204
- qdrant.updateVector(testCollectionName, id, { vector: [1, 2] }), // Wrong dimension
208
+ qdrant.updateVector({ indexName: testCollectionName, id, update: { vector: [1, 2] } }), // Wrong dimension
205
209
  ).rejects.toThrow();
206
210
  });
207
211
  });
@@ -218,7 +222,7 @@ describe('QdrantVector', () => {
218
222
  });
219
223
 
220
224
  afterEach(async () => {
221
- await qdrant.deleteIndex(testCollectionName);
225
+ await qdrant.deleteIndex({ indexName: testCollectionName });
222
226
  });
223
227
 
224
228
  it('should delete the vector by id', async () => {
@@ -226,7 +230,7 @@ describe('QdrantVector', () => {
226
230
  expect(ids).toHaveLength(3);
227
231
  const idToBeDeleted = ids[0];
228
232
 
229
- await qdrant.deleteVector(testCollectionName, idToBeDeleted);
233
+ await qdrant.deleteVector({ indexName: testCollectionName, id: idToBeDeleted });
230
234
 
231
235
  const results: QueryResult[] = await qdrant.query({
232
236
  indexName: testCollectionName,
@@ -335,13 +339,13 @@ describe('QdrantVector', () => {
335
339
  ];
336
340
 
337
341
  beforeAll(async () => {
338
- qdrant = new QdrantVector('http://localhost:6333/');
342
+ qdrant = new QdrantVector({ url: 'http://localhost:6333/' });
339
343
  await qdrant.createIndex({ indexName: testCollectionName, dimension });
340
344
  await qdrant.upsert({ indexName: testCollectionName, vectors: filterTestVectors, metadata: filterTestMetadata });
341
345
  });
342
346
 
343
347
  afterAll(async () => {
344
- await qdrant.deleteIndex(testCollectionName);
348
+ await qdrant.deleteIndex({ indexName: testCollectionName });
345
349
  }, 50000);
346
350
 
347
351
  describe('Basic Operators', () => {
@@ -761,7 +765,7 @@ describe('QdrantVector', () => {
761
765
  });
762
766
 
763
767
  afterAll(async () => {
764
- await qdrant.deleteIndex(testIndexName);
768
+ await qdrant.deleteIndex({ indexName: testIndexName });
765
769
  });
766
770
 
767
771
  it('should handle non-existent index query gracefully', async () => {
@@ -829,7 +833,7 @@ describe('QdrantVector', () => {
829
833
  infoSpy.mockRestore();
830
834
  warnSpy.mockRestore();
831
835
  // Cleanup
832
- await qdrant.deleteIndex(duplicateIndexName);
836
+ await qdrant.deleteIndex({ indexName: duplicateIndexName });
833
837
  }
834
838
  });
835
839
  });
@@ -870,13 +874,13 @@ describe('QdrantVector', () => {
870
874
  ];
871
875
 
872
876
  beforeAll(async () => {
873
- qdrant = new QdrantVector('http://localhost:6333/');
877
+ qdrant = new QdrantVector({ url: 'http://localhost:6333/' });
874
878
  await qdrant.createIndex({ indexName: testCollectionName, dimension });
875
879
  await qdrant.upsert({ indexName: testCollectionName, vectors: filterTestVectors, metadata: filterTestMetadata });
876
880
  });
877
881
 
878
882
  afterAll(async () => {
879
- await qdrant.deleteIndex(testCollectionName);
883
+ await qdrant.deleteIndex({ indexName: testCollectionName });
880
884
  }, 50000);
881
885
  it('should handle undefined filter', async () => {
882
886
  const results1 = await qdrant.query({ indexName: testCollectionName, queryVector: [1, 0, 0], filter: undefined });
@@ -902,12 +906,12 @@ describe('QdrantVector', () => {
902
906
 
903
907
  describe('Performance Tests', () => {
904
908
  beforeAll(async () => {
905
- qdrant = new QdrantVector('http://localhost:6333/');
909
+ qdrant = new QdrantVector({ url: 'http://localhost:6333/' });
906
910
  await qdrant.createIndex({ indexName: testCollectionName, dimension });
907
911
  });
908
912
 
909
913
  afterAll(async () => {
910
- await qdrant.deleteIndex(testCollectionName);
914
+ await qdrant.deleteIndex({ indexName: testCollectionName });
911
915
  }, 50000);
912
916
 
913
917
  it('should handle batch upsert of 1000 vectors', async () => {
@@ -953,12 +957,12 @@ describe('QdrantVector', () => {
953
957
  let warnSpy;
954
958
 
955
959
  beforeAll(async () => {
956
- await qdrant.createIndex({ indexName: indexName, dimension: 3 });
960
+ await qdrant.createIndex({ indexName, dimension: 3 });
957
961
  });
958
962
 
959
963
  afterAll(async () => {
960
- await qdrant.deleteIndex(indexName);
961
- await qdrant.deleteIndex(indexName2);
964
+ await qdrant.deleteIndex({ indexName });
965
+ await qdrant.deleteIndex({ indexName: indexName2 });
962
966
  });
963
967
 
964
968
  beforeEach(async () => {
@@ -967,7 +971,7 @@ describe('QdrantVector', () => {
967
971
 
968
972
  afterEach(async () => {
969
973
  warnSpy.mockRestore();
970
- await qdrant.deleteIndex(indexName2);
974
+ await qdrant.deleteIndex({ indexName: indexName2 });
971
975
  });
972
976
 
973
977
  it('should show deprecation warning when using individual args for createIndex', async () => {
@@ -6,6 +6,10 @@ import type {
6
6
  UpsertVectorParams,
7
7
  QueryVectorParams,
8
8
  ParamsToArgs,
9
+ DescribeIndexParams,
10
+ DeleteIndexParams,
11
+ DeleteVectorParams,
12
+ UpdateVectorParams,
9
13
  } from '@mastra/core/vector';
10
14
  import type { VectorFilter } from '@mastra/core/vector/filter';
11
15
  import { QdrantClient } from '@qdrant/js-client-rest';
@@ -23,15 +27,45 @@ const DISTANCE_MAPPING: Record<string, Schemas['Distance']> = {
23
27
  export class QdrantVector extends MastraVector {
24
28
  private client: QdrantClient;
25
29
 
26
- constructor(url: string, apiKey?: string, https?: boolean) {
30
+ /**
31
+ * @deprecated Passing url, apiKey, https as positional arguments is deprecated.
32
+ * Use the object parameter instead. This signature will be removed on May 20th, 2025.
33
+ */
34
+ constructor(url: string, apiKey?: string, https?: boolean);
35
+ /**
36
+ * Creates a new QdrantVector client.
37
+ * @param params - An object with url, optional apiKey, and optional https.
38
+ */
39
+ constructor(params: { url: string; apiKey?: string; https?: boolean });
40
+ constructor(
41
+ paramsOrUrl: { url: string; apiKey?: string; https?: boolean } | string,
42
+ apiKey?: string,
43
+ https?: boolean,
44
+ ) {
27
45
  super();
28
-
46
+ let url: string;
47
+ let key: string | undefined;
48
+ let secure: boolean | undefined;
49
+ if (typeof paramsOrUrl === 'string') {
50
+ // DEPRECATION WARNING
51
+ if (typeof console !== 'undefined' && console.warn) {
52
+ console.warn(
53
+ `Deprecation Warning: Passing url, apiKey, https as positional arguments to QdrantVector constructor is deprecated.\nPlease use an object parameter instead:\n new QdrantVector({ url, apiKey, https })\nThis signature will be removed on May 20th, 2025.`,
54
+ );
55
+ }
56
+ url = paramsOrUrl;
57
+ key = apiKey;
58
+ secure = https;
59
+ } else {
60
+ url = paramsOrUrl.url;
61
+ key = paramsOrUrl.apiKey;
62
+ secure = paramsOrUrl.https;
63
+ }
29
64
  const baseClient = new QdrantClient({
30
65
  url,
31
- apiKey,
32
- https,
66
+ apiKey: key,
67
+ https: secure,
33
68
  });
34
-
35
69
  const telemetry = this.__getTelemetry();
36
70
  this.client =
37
71
  telemetry?.traceClass(baseClient, {
@@ -144,7 +178,16 @@ export class QdrantVector extends MastraVector {
144
178
  return response.collections.map(collection => collection.name) || [];
145
179
  }
146
180
 
147
- async describeIndex(indexName: string): Promise<IndexStats> {
181
+ /**
182
+ * Retrieves statistics about a vector index.
183
+ *
184
+ * @param params - The parameters for describing an index
185
+ * @param params.indexName - The name of the index to describe
186
+ * @returns A promise that resolves to the index statistics including dimension, count and metric
187
+ */
188
+ async describeIndex(...args: ParamsToArgs<DescribeIndexParams>): Promise<IndexStats> {
189
+ const params = this.normalizeArgs<DescribeIndexParams>('describeIndex', args);
190
+ const { indexName } = params;
148
191
  const { config, points_count } = await this.client.getCollection(indexName);
149
192
 
150
193
  const distance = config.params.vectors?.distance as Schemas['Distance'];
@@ -156,7 +199,9 @@ export class QdrantVector extends MastraVector {
156
199
  };
157
200
  }
158
201
 
159
- async deleteIndex(indexName: string): Promise<void> {
202
+ async deleteIndex(...args: ParamsToArgs<DeleteIndexParams>): Promise<void> {
203
+ const params = this.normalizeArgs<DeleteIndexParams>('deleteIndex', args);
204
+ const { indexName } = params;
160
205
  await this.client.deleteCollection(indexName);
161
206
  }
162
207
 
@@ -182,7 +227,7 @@ export class QdrantVector extends MastraVector {
182
227
  Please use updateVector() instead.
183
228
  updateIndexById() will be removed on May 20th, 2025.`,
184
229
  );
185
- await this.updateVector(indexName, id, update);
230
+ await this.updateVector({ indexName, id, update });
186
231
  }
187
232
 
188
233
  /**
@@ -195,14 +240,9 @@ export class QdrantVector extends MastraVector {
195
240
  * @returns A promise that resolves when the update is complete.
196
241
  * @throws Will throw an error if no updates are provided or if the update operation fails.
197
242
  */
198
- async updateVector(
199
- indexName: string,
200
- id: string,
201
- update: {
202
- vector?: number[];
203
- metadata?: Record<string, any>;
204
- },
205
- ): Promise<void> {
243
+ async updateVector(...args: ParamsToArgs<UpdateVectorParams>): Promise<void> {
244
+ const params = this.normalizeArgs<UpdateVectorParams>('updateVector', args);
245
+ const { indexName, id, update } = params;
206
246
  if (!update.vector && !update.metadata) {
207
247
  throw new Error('No updates provided');
208
248
  }
@@ -264,7 +304,7 @@ export class QdrantVector extends MastraVector {
264
304
  Please use deleteVector() instead.
265
305
  deleteIndexById() will be removed on May 20th, 2025.`,
266
306
  );
267
- await this.deleteVector(indexName, id);
307
+ await this.deleteVector({ indexName, id });
268
308
  }
269
309
 
270
310
  /**
@@ -274,7 +314,9 @@ export class QdrantVector extends MastraVector {
274
314
  * @returns A promise that resolves when the deletion is complete.
275
315
  * @throws Will throw an error if the deletion operation fails.
276
316
  */
277
- async deleteVector(indexName: string, id: string): Promise<void> {
317
+ async deleteVector(...args: ParamsToArgs<DeleteVectorParams>): Promise<void> {
318
+ const params = this.normalizeArgs<DeleteVectorParams>('deleteVector', args);
319
+ const { indexName, id } = params;
278
320
  try {
279
321
  // Parse the ID - Qdrant supports both string and numeric IDs
280
322
  const pointId = this.parsePointId(id);