@mastra/astra 0.2.15-alpha.4 → 0.2.16-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/astra@0.2.15-alpha.4 build /home/runner/work/mastra/mastra/stores/astra
2
+ > @mastra/astra@0.2.16-alpha.0 build /home/runner/work/mastra/mastra/stores/astra
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 6098ms
9
+ TSC ⚡️ Build success in 4802ms
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/astra/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/astra/dist/_tsup-dts-rollup.d.cts
16
- DTS ⚡️ Build success in 7222ms
16
+ DTS ⚡️ Build success in 8269ms
17
17
  CLI Cleaning output folder
18
18
  ESM Build start
19
19
  CJS Build start
20
- ESM dist/index.js 13.23 KB
21
- ESM ⚡️ Build success in 319ms
22
- CJS dist/index.cjs 13.28 KB
23
- CJS ⚡️ Build success in 396ms
20
+ CJS dist/index.cjs 13.91 KB
21
+ CJS ⚡️ Build success in 681ms
22
+ ESM dist/index.js 13.85 KB
23
+ ESM ⚡️ Build success in 681ms
package/CHANGELOG.md CHANGED
@@ -1,5 +1,40 @@
1
1
  # @mastra/astra
2
2
 
3
+ ## 0.2.16-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
+
17
+ ## 0.2.15
18
+
19
+ ### Patch Changes
20
+
21
+ - c3bd795: [MASTRA-3358] Deprecate updateIndexById and deleteIndexById
22
+ - Updated dependencies [396be50]
23
+ - Updated dependencies [ab80e7e]
24
+ - Updated dependencies [c3bd795]
25
+ - Updated dependencies [da082f8]
26
+ - Updated dependencies [a5810ce]
27
+ - Updated dependencies [3e9c131]
28
+ - Updated dependencies [3171b5b]
29
+ - Updated dependencies [973e5ac]
30
+ - Updated dependencies [daf942f]
31
+ - Updated dependencies [0b8b868]
32
+ - Updated dependencies [9e1eff5]
33
+ - Updated dependencies [6fa1ad1]
34
+ - Updated dependencies [c28d7a0]
35
+ - Updated dependencies [edf1e88]
36
+ - @mastra/core@0.9.4
37
+
3
38
  ## 0.2.15-alpha.4
4
39
 
5
40
  ### Patch Changes
@@ -1,11 +1,15 @@
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 { MastraVector } from '@mastra/core/vector';
5
8
  import type { OperatorSupport } from '@mastra/core/vector/filter';
6
9
  import type { ParamsToArgs } from '@mastra/core/vector';
7
10
  import type { QueryResult } from '@mastra/core/vector';
8
11
  import type { QueryVectorParams } from '@mastra/core/vector';
12
+ import type { UpdateVectorParams } from '@mastra/core/vector';
9
13
  import type { UpsertVectorParams } from '@mastra/core/vector';
10
14
  import type { VectorFilter } from '@mastra/core/vector/filter';
11
15
 
@@ -77,14 +81,21 @@ declare class AstraVector extends MastraVector {
77
81
  * @returns {Promise<string[]>} A promise that resolves to an array of collection names.
78
82
  */
79
83
  listIndexes(): Promise<string[]>;
80
- describeIndex(indexName: string): Promise<IndexStats>;
84
+ /**
85
+ * Retrieves statistics about a vector index.
86
+ *
87
+ * @param params - The parameters for describing an index
88
+ * @param params.indexName - The name of the index to describe
89
+ * @returns A promise that resolves to the index statistics including dimension, count and metric
90
+ */
91
+ describeIndex(...args: ParamsToArgs<DescribeIndexParams>): Promise<IndexStats>;
81
92
  /**
82
93
  * Deletes the specified collection.
83
94
  *
84
95
  * @param {string} indexName - The name of the collection to delete.
85
96
  * @returns {Promise<void>} A promise that resolves when the collection is deleted.
86
97
  */
87
- deleteIndex(indexName: string): Promise<void>;
98
+ deleteIndex(...args: ParamsToArgs<DeleteIndexParams>): Promise<void>;
88
99
  /**
89
100
  * @deprecated Use {@link updateVector} instead. This method will be removed on May 20th, 2025.
90
101
  *
@@ -111,10 +122,7 @@ declare class AstraVector extends MastraVector {
111
122
  * @returns A promise that resolves when the update is complete.
112
123
  * @throws Will throw an error if no updates are provided or if the update operation fails.
113
124
  */
114
- updateVector(indexName: string, id: string, update: {
115
- vector?: number[];
116
- metadata?: Record<string, any>;
117
- }): Promise<void>;
125
+ updateVector(...args: ParamsToArgs<UpdateVectorParams>): Promise<void>;
118
126
  /**
119
127
  * @deprecated Use {@link deleteVector} instead. This method will be removed on May 20th, 2025.
120
128
  *
@@ -132,7 +140,7 @@ declare class AstraVector extends MastraVector {
132
140
  * @returns A promise that resolves when the deletion is complete.
133
141
  * @throws Will throw an error if the deletion operation fails.
134
142
  */
135
- deleteVector(indexName: string, id: string): Promise<void>;
143
+ deleteVector(...args: ParamsToArgs<DeleteVectorParams>): Promise<void>;
136
144
  }
137
145
  export { AstraVector }
138
146
  export { AstraVector as AstraVector_alias_1 }
@@ -1,11 +1,15 @@
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 { MastraVector } from '@mastra/core/vector';
5
8
  import type { OperatorSupport } from '@mastra/core/vector/filter';
6
9
  import type { ParamsToArgs } from '@mastra/core/vector';
7
10
  import type { QueryResult } from '@mastra/core/vector';
8
11
  import type { QueryVectorParams } from '@mastra/core/vector';
12
+ import type { UpdateVectorParams } from '@mastra/core/vector';
9
13
  import type { UpsertVectorParams } from '@mastra/core/vector';
10
14
  import type { VectorFilter } from '@mastra/core/vector/filter';
11
15
 
@@ -77,14 +81,21 @@ declare class AstraVector extends MastraVector {
77
81
  * @returns {Promise<string[]>} A promise that resolves to an array of collection names.
78
82
  */
79
83
  listIndexes(): Promise<string[]>;
80
- describeIndex(indexName: string): Promise<IndexStats>;
84
+ /**
85
+ * Retrieves statistics about a vector index.
86
+ *
87
+ * @param params - The parameters for describing an index
88
+ * @param params.indexName - The name of the index to describe
89
+ * @returns A promise that resolves to the index statistics including dimension, count and metric
90
+ */
91
+ describeIndex(...args: ParamsToArgs<DescribeIndexParams>): Promise<IndexStats>;
81
92
  /**
82
93
  * Deletes the specified collection.
83
94
  *
84
95
  * @param {string} indexName - The name of the collection to delete.
85
96
  * @returns {Promise<void>} A promise that resolves when the collection is deleted.
86
97
  */
87
- deleteIndex(indexName: string): Promise<void>;
98
+ deleteIndex(...args: ParamsToArgs<DeleteIndexParams>): Promise<void>;
88
99
  /**
89
100
  * @deprecated Use {@link updateVector} instead. This method will be removed on May 20th, 2025.
90
101
  *
@@ -111,10 +122,7 @@ declare class AstraVector extends MastraVector {
111
122
  * @returns A promise that resolves when the update is complete.
112
123
  * @throws Will throw an error if no updates are provided or if the update operation fails.
113
124
  */
114
- updateVector(indexName: string, id: string, update: {
115
- vector?: number[];
116
- metadata?: Record<string, any>;
117
- }): Promise<void>;
125
+ updateVector(...args: ParamsToArgs<UpdateVectorParams>): Promise<void>;
118
126
  /**
119
127
  * @deprecated Use {@link deleteVector} instead. This method will be removed on May 20th, 2025.
120
128
  *
@@ -132,7 +140,7 @@ declare class AstraVector extends MastraVector {
132
140
  * @returns A promise that resolves when the deletion is complete.
133
141
  * @throws Will throw an error if the deletion operation fails.
134
142
  */
135
- deleteVector(indexName: string, id: string): Promise<void>;
143
+ deleteVector(...args: ParamsToArgs<DeleteVectorParams>): Promise<void>;
136
144
  }
137
145
  export { AstraVector }
138
146
  export { AstraVector as AstraVector_alias_1 }
package/dist/index.cjs CHANGED
@@ -147,12 +147,20 @@ var AstraVector = class extends vector.MastraVector {
147
147
  listIndexes() {
148
148
  return this.#db.listCollections({ nameOnly: true });
149
149
  }
150
- async describeIndex(indexName) {
150
+ /**
151
+ * Retrieves statistics about a vector index.
152
+ *
153
+ * @param params - The parameters for describing an index
154
+ * @param params.indexName - The name of the index to describe
155
+ * @returns A promise that resolves to the index statistics including dimension, count and metric
156
+ */
157
+ async describeIndex(...args) {
158
+ const params = this.normalizeArgs("describeIndex", args);
159
+ const { indexName } = params;
151
160
  const collection = this.#db.collection(indexName);
152
161
  const optionsPromise = collection.options();
153
162
  const countPromise = collection.countDocuments({}, 100);
154
163
  const [options, count] = await Promise.all([optionsPromise, countPromise]);
155
- console.log(options, count);
156
164
  const keys = Object.keys(metricMap);
157
165
  const metric = keys.find((key) => metricMap[key] === options.vector?.metric);
158
166
  return {
@@ -167,7 +175,9 @@ var AstraVector = class extends vector.MastraVector {
167
175
  * @param {string} indexName - The name of the collection to delete.
168
176
  * @returns {Promise<void>} A promise that resolves when the collection is deleted.
169
177
  */
170
- async deleteIndex(indexName) {
178
+ async deleteIndex(...args) {
179
+ const params = this.normalizeArgs("deleteIndex", args);
180
+ const { indexName } = params;
171
181
  const collection = this.#db.collection(indexName);
172
182
  await collection.drop();
173
183
  }
@@ -187,7 +197,7 @@ var AstraVector = class extends vector.MastraVector {
187
197
  this.logger.warn(
188
198
  `Deprecation Warning: updateIndexById() is deprecated. Please use updateVector() instead. updateIndexById() will be removed on May 20th, 2025.`
189
199
  );
190
- await this.updateVector(indexName, id, update);
200
+ await this.updateVector({ indexName, id, update });
191
201
  }
192
202
  /**
193
203
  * Updates a vector by its ID with the provided vector and/or metadata.
@@ -199,7 +209,9 @@ var AstraVector = class extends vector.MastraVector {
199
209
  * @returns A promise that resolves when the update is complete.
200
210
  * @throws Will throw an error if no updates are provided or if the update operation fails.
201
211
  */
202
- async updateVector(indexName, id, update) {
212
+ async updateVector(...args) {
213
+ const params = this.normalizeArgs("updateVector", args);
214
+ const { indexName, id, update } = params;
203
215
  try {
204
216
  if (!update.vector && !update.metadata) {
205
217
  throw new Error("No updates provided");
@@ -232,7 +244,7 @@ var AstraVector = class extends vector.MastraVector {
232
244
  Please use deleteVector() instead.
233
245
  deleteIndexById() will be removed on May 20th, 2025.`
234
246
  );
235
- await this.deleteVector(indexName, id);
247
+ await this.deleteVector({ indexName, id });
236
248
  }
237
249
  /**
238
250
  * Deletes a vector by its ID.
@@ -241,7 +253,9 @@ var AstraVector = class extends vector.MastraVector {
241
253
  * @returns A promise that resolves when the deletion is complete.
242
254
  * @throws Will throw an error if the deletion operation fails.
243
255
  */
244
- async deleteVector(indexName, id) {
256
+ async deleteVector(...args) {
257
+ const params = this.normalizeArgs("deleteVector", args);
258
+ const { indexName, id } = params;
245
259
  try {
246
260
  const collection = this.#db.collection(indexName);
247
261
  await collection.deleteOne({ id });
package/dist/index.js CHANGED
@@ -145,12 +145,20 @@ var AstraVector = class extends MastraVector {
145
145
  listIndexes() {
146
146
  return this.#db.listCollections({ nameOnly: true });
147
147
  }
148
- async describeIndex(indexName) {
148
+ /**
149
+ * Retrieves statistics about a vector index.
150
+ *
151
+ * @param params - The parameters for describing an index
152
+ * @param params.indexName - The name of the index to describe
153
+ * @returns A promise that resolves to the index statistics including dimension, count and metric
154
+ */
155
+ async describeIndex(...args) {
156
+ const params = this.normalizeArgs("describeIndex", args);
157
+ const { indexName } = params;
149
158
  const collection = this.#db.collection(indexName);
150
159
  const optionsPromise = collection.options();
151
160
  const countPromise = collection.countDocuments({}, 100);
152
161
  const [options, count] = await Promise.all([optionsPromise, countPromise]);
153
- console.log(options, count);
154
162
  const keys = Object.keys(metricMap);
155
163
  const metric = keys.find((key) => metricMap[key] === options.vector?.metric);
156
164
  return {
@@ -165,7 +173,9 @@ var AstraVector = class extends MastraVector {
165
173
  * @param {string} indexName - The name of the collection to delete.
166
174
  * @returns {Promise<void>} A promise that resolves when the collection is deleted.
167
175
  */
168
- async deleteIndex(indexName) {
176
+ async deleteIndex(...args) {
177
+ const params = this.normalizeArgs("deleteIndex", args);
178
+ const { indexName } = params;
169
179
  const collection = this.#db.collection(indexName);
170
180
  await collection.drop();
171
181
  }
@@ -185,7 +195,7 @@ var AstraVector = class extends MastraVector {
185
195
  this.logger.warn(
186
196
  `Deprecation Warning: updateIndexById() is deprecated. Please use updateVector() instead. updateIndexById() will be removed on May 20th, 2025.`
187
197
  );
188
- await this.updateVector(indexName, id, update);
198
+ await this.updateVector({ indexName, id, update });
189
199
  }
190
200
  /**
191
201
  * Updates a vector by its ID with the provided vector and/or metadata.
@@ -197,7 +207,9 @@ var AstraVector = class extends MastraVector {
197
207
  * @returns A promise that resolves when the update is complete.
198
208
  * @throws Will throw an error if no updates are provided or if the update operation fails.
199
209
  */
200
- async updateVector(indexName, id, update) {
210
+ async updateVector(...args) {
211
+ const params = this.normalizeArgs("updateVector", args);
212
+ const { indexName, id, update } = params;
201
213
  try {
202
214
  if (!update.vector && !update.metadata) {
203
215
  throw new Error("No updates provided");
@@ -230,7 +242,7 @@ var AstraVector = class extends MastraVector {
230
242
  Please use deleteVector() instead.
231
243
  deleteIndexById() will be removed on May 20th, 2025.`
232
244
  );
233
- await this.deleteVector(indexName, id);
245
+ await this.deleteVector({ indexName, id });
234
246
  }
235
247
  /**
236
248
  * Deletes a vector by its ID.
@@ -239,7 +251,9 @@ var AstraVector = class extends MastraVector {
239
251
  * @returns A promise that resolves when the deletion is complete.
240
252
  * @throws Will throw an error if the deletion operation fails.
241
253
  */
242
- async deleteVector(indexName, id) {
254
+ async deleteVector(...args) {
255
+ const params = this.normalizeArgs("deleteVector", args);
256
+ const { indexName, id } = params;
243
257
  try {
244
258
  const collection = this.#db.collection(indexName);
245
259
  await collection.deleteOne({ id });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/astra",
3
- "version": "0.2.15-alpha.4",
3
+ "version": "0.2.16-alpha.0",
4
4
  "description": "Astra DB provider for Mastra - includes vector store capabilities",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -21,7 +21,7 @@
21
21
  "license": "MIT",
22
22
  "dependencies": {
23
23
  "@datastax/astra-db-ts": "^1.5.0",
24
- "@mastra/core": "^0.9.4-alpha.4"
24
+ "@mastra/core": "^0.9.5-alpha.0"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@microsoft/api-extractor": "^7.52.5",
@@ -30,7 +30,7 @@
30
30
  "tsup": "^8.4.0",
31
31
  "typescript": "^5.8.2",
32
32
  "vitest": "^3.1.2",
33
- "@internal/lint": "0.0.4"
33
+ "@internal/lint": "0.0.5"
34
34
  },
35
35
  "scripts": {
36
36
  "build": "tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting",
@@ -44,7 +44,7 @@ async function createIndexAndWait(
44
44
  }
45
45
 
46
46
  async function deleteIndexAndWait(vectorDB: AstraVector, indexName: string) {
47
- await vectorDB.deleteIndex(indexName);
47
+ await vectorDB.deleteIndex({ indexName });
48
48
  const deleted = await waitForCondition(
49
49
  async () => {
50
50
  const newCollections = await vectorDB.listIndexes();
@@ -80,7 +80,7 @@ describe.skip('AstraVector Integration Tests', () => {
80
80
  });
81
81
  try {
82
82
  const collections = await vectorDB.listIndexes();
83
- await Promise.all(collections.map(c => vectorDB.deleteIndex(c)));
83
+ await Promise.all(collections.map(c => vectorDB.deleteIndex({ indexName: c })));
84
84
  const deleted = await waitForCondition(
85
85
  async () => {
86
86
  const remainingCollections = await vectorDB.listIndexes();
@@ -104,12 +104,12 @@ describe.skip('AstraVector Integration Tests', () => {
104
104
  afterAll(async () => {
105
105
  // Cleanup: delete test collection
106
106
  try {
107
- await vectorDB.deleteIndex(testIndexName);
107
+ await vectorDB.deleteIndex({ indexName: testIndexName });
108
108
  } catch (error) {
109
109
  console.error('Failed to delete test collection:', error);
110
110
  }
111
111
  try {
112
- await vectorDB.deleteIndex(testIndexName2);
112
+ await vectorDB.deleteIndex({ indexName: testIndexName2 });
113
113
  } catch (error) {
114
114
  console.error('Failed to delete test collection:', error);
115
115
  }
@@ -121,7 +121,7 @@ describe.skip('AstraVector Integration Tests', () => {
121
121
  expect(indexes).toContain(testIndexName);
122
122
 
123
123
  // 2. Get collection stats
124
- const initialStats = await vectorDB.describeIndex(testIndexName);
124
+ const initialStats = await vectorDB.describeIndex({ indexName: testIndexName });
125
125
  expect(initialStats).toEqual({
126
126
  dimension: 4,
127
127
  metric: 'cosine',
@@ -144,7 +144,7 @@ describe.skip('AstraVector Integration Tests', () => {
144
144
  // Wait for document count to update (with timeout)
145
145
  const countUpdated = await waitForCondition(
146
146
  async () => {
147
- const stats = await vectorDB.describeIndex(testIndexName);
147
+ const stats = await vectorDB.describeIndex({ indexName: testIndexName });
148
148
  console.log('Current count:', stats.count);
149
149
  return stats.count === 4;
150
150
  },
@@ -176,7 +176,7 @@ describe.skip('AstraVector Integration Tests', () => {
176
176
  expect(filteredResults?.[0]?.metadata).toEqual({ label: 'vector2' });
177
177
 
178
178
  // Get final stats
179
- const finalStats = await vectorDB.describeIndex(testIndexName);
179
+ const finalStats = await vectorDB.describeIndex({ indexName: testIndexName });
180
180
  console.log('Final stats:', finalStats);
181
181
 
182
182
  // More lenient assertion for document count
@@ -1224,12 +1224,12 @@ describe.skip('AstraVector Integration Tests', () => {
1224
1224
  metadata: newMetaData,
1225
1225
  };
1226
1226
 
1227
- await vectorDB.updateVector(indexName, idToBeUpdated, update);
1227
+ await vectorDB.updateVector({ indexName, id: idToBeUpdated, update });
1228
1228
 
1229
1229
  await new Promise(resolve => setTimeout(resolve, 2000));
1230
1230
 
1231
1231
  const results = await vectorDB.query({
1232
- indexName: indexName,
1232
+ indexName,
1233
1233
  queryVector: newVector,
1234
1234
  topK: 2,
1235
1235
  includeVector: true,
@@ -1256,11 +1256,11 @@ describe.skip('AstraVector Integration Tests', () => {
1256
1256
  metadata: newMetaData,
1257
1257
  };
1258
1258
 
1259
- await vectorDB.updateVector(indexName, idToBeUpdated, update);
1259
+ await vectorDB.updateVector({ indexName, id: idToBeUpdated, update });
1260
1260
  await new Promise(resolve => setTimeout(resolve, 2000));
1261
1261
 
1262
1262
  const results = await vectorDB.query({
1263
- indexName: indexName,
1263
+ indexName,
1264
1264
  queryVector: testVectors[0],
1265
1265
  topK: 2,
1266
1266
  includeVector: true,
@@ -1285,11 +1285,11 @@ describe.skip('AstraVector Integration Tests', () => {
1285
1285
  vector: newVector,
1286
1286
  };
1287
1287
 
1288
- await vectorDB.updateVector(indexName, idToBeUpdated, update);
1288
+ await vectorDB.updateVector({ indexName, id: idToBeUpdated, update });
1289
1289
  await new Promise(resolve => setTimeout(resolve, 2000));
1290
1290
 
1291
1291
  const results = await vectorDB.query({
1292
- indexName: indexName,
1292
+ indexName,
1293
1293
  queryVector: newVector,
1294
1294
  topK: 2,
1295
1295
  includeVector: true,
@@ -1303,7 +1303,7 @@ describe.skip('AstraVector Integration Tests', () => {
1303
1303
  });
1304
1304
 
1305
1305
  it('should throw exception when no updates are given', async () => {
1306
- await expect(vectorDB.updateVector(indexName, 'id', {})).rejects.toThrow('No updates provided');
1306
+ await expect(vectorDB.updateVector({ indexName, id: 'id', update: {} })).rejects.toThrow('No updates provided');
1307
1307
  });
1308
1308
 
1309
1309
  it('should delete the vector by id', async () => {
@@ -1311,7 +1311,7 @@ describe.skip('AstraVector Integration Tests', () => {
1311
1311
  expect(ids).toHaveLength(4);
1312
1312
 
1313
1313
  const idToBeDeleted = ids[0];
1314
- await vectorDB.deleteVector(indexName, idToBeDeleted);
1314
+ await vectorDB.deleteVector({ indexName, id: idToBeDeleted });
1315
1315
 
1316
1316
  const results = await vectorDB.query({
1317
1317
  indexName: indexName,
@@ -1331,7 +1331,7 @@ describe.skip('AstraVector Integration Tests', () => {
1331
1331
  });
1332
1332
 
1333
1333
  afterAll(async () => {
1334
- await vectorDB.deleteIndex(testIndexName);
1334
+ await vectorDB.deleteIndex({ indexName: testIndexName });
1335
1335
  });
1336
1336
 
1337
1337
  it('should handle non-existent index queries', async () => {
@@ -1376,7 +1376,7 @@ describe.skip('AstraVector Integration Tests', () => {
1376
1376
  );
1377
1377
  } finally {
1378
1378
  // Cleanup
1379
- await vectorDB.deleteIndex(duplicateIndexName);
1379
+ await vectorDB.deleteIndex({ indexName: duplicateIndexName });
1380
1380
  }
1381
1381
  });
1382
1382
  });
@@ -8,6 +8,10 @@ import type {
8
8
  UpsertVectorParams,
9
9
  QueryVectorParams,
10
10
  ParamsToArgs,
11
+ DescribeIndexParams,
12
+ DeleteIndexParams,
13
+ DeleteVectorParams,
14
+ UpdateVectorParams,
11
15
  } from '@mastra/core/vector';
12
16
  import type { VectorFilter } from '@mastra/core/vector/filter';
13
17
 
@@ -141,14 +145,23 @@ export class AstraVector extends MastraVector {
141
145
  return this.#db.listCollections({ nameOnly: true });
142
146
  }
143
147
 
144
- async describeIndex(indexName: string): Promise<IndexStats> {
148
+ /**
149
+ * Retrieves statistics about a vector index.
150
+ *
151
+ * @param params - The parameters for describing an index
152
+ * @param params.indexName - The name of the index to describe
153
+ * @returns A promise that resolves to the index statistics including dimension, count and metric
154
+ */
155
+ async describeIndex(...args: ParamsToArgs<DescribeIndexParams>): Promise<IndexStats> {
156
+ const params = this.normalizeArgs<DescribeIndexParams>('describeIndex', args);
157
+
158
+ const { indexName } = params;
159
+
145
160
  const collection = this.#db.collection(indexName);
146
161
  const optionsPromise = collection.options();
147
162
  const countPromise = collection.countDocuments({}, 100);
148
163
  const [options, count] = await Promise.all([optionsPromise, countPromise]);
149
164
 
150
- console.log(options, count);
151
-
152
165
  const keys = Object.keys(metricMap) as (keyof typeof metricMap)[];
153
166
  const metric = keys.find(key => metricMap[key] === options.vector?.metric);
154
167
  return {
@@ -164,7 +177,10 @@ export class AstraVector extends MastraVector {
164
177
  * @param {string} indexName - The name of the collection to delete.
165
178
  * @returns {Promise<void>} A promise that resolves when the collection is deleted.
166
179
  */
167
- async deleteIndex(indexName: string): Promise<void> {
180
+ async deleteIndex(...args: ParamsToArgs<DeleteIndexParams>): Promise<void> {
181
+ const params = this.normalizeArgs<DeleteIndexParams>('deleteIndex', args);
182
+
183
+ const { indexName } = params;
168
184
  const collection = this.#db.collection(indexName);
169
185
  await collection.drop();
170
186
  }
@@ -189,7 +205,7 @@ export class AstraVector extends MastraVector {
189
205
  this.logger.warn(
190
206
  `Deprecation Warning: updateIndexById() is deprecated. Please use updateVector() instead. updateIndexById() will be removed on May 20th, 2025.`,
191
207
  );
192
- await this.updateVector(indexName, id, update);
208
+ await this.updateVector({ indexName, id, update });
193
209
  }
194
210
 
195
211
  /**
@@ -202,11 +218,9 @@ export class AstraVector extends MastraVector {
202
218
  * @returns A promise that resolves when the update is complete.
203
219
  * @throws Will throw an error if no updates are provided or if the update operation fails.
204
220
  */
205
- async updateVector(
206
- indexName: string,
207
- id: string,
208
- update: { vector?: number[]; metadata?: Record<string, any> },
209
- ): Promise<void> {
221
+ async updateVector(...args: ParamsToArgs<UpdateVectorParams>): Promise<void> {
222
+ const params = this.normalizeArgs<UpdateVectorParams>('updateVector', args);
223
+ const { indexName, id, update } = params;
210
224
  try {
211
225
  if (!update.vector && !update.metadata) {
212
226
  throw new Error('No updates provided');
@@ -244,7 +258,7 @@ export class AstraVector extends MastraVector {
244
258
  Please use deleteVector() instead.
245
259
  deleteIndexById() will be removed on May 20th, 2025.`,
246
260
  );
247
- await this.deleteVector(indexName, id);
261
+ await this.deleteVector({ indexName, id });
248
262
  }
249
263
 
250
264
  /**
@@ -254,7 +268,10 @@ export class AstraVector extends MastraVector {
254
268
  * @returns A promise that resolves when the deletion is complete.
255
269
  * @throws Will throw an error if the deletion operation fails.
256
270
  */
257
- async deleteVector(indexName: string, id: string): Promise<void> {
271
+ async deleteVector(...args: ParamsToArgs<DeleteVectorParams>): Promise<void> {
272
+ const params = this.normalizeArgs<DeleteVectorParams>('deleteVector', args);
273
+
274
+ const { indexName, id } = params;
258
275
  try {
259
276
  const collection = this.#db.collection(indexName);
260
277
  await collection.deleteOne({ id });