@mastra/astra 0.2.16-alpha.0 → 0.10.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.16-alpha.0 build /home/runner/work/mastra/mastra/stores/astra
2
+ > @mastra/astra@0.10.0-alpha.1 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 4802ms
9
+ TSC ⚡️ Build success in 7932ms
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 8269ms
16
+ DTS ⚡️ Build success in 10150ms
17
17
  CLI Cleaning output folder
18
18
  ESM Build start
19
19
  CJS Build start
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
20
+ CJS dist/index.cjs 11.63 KB
21
+ CJS ⚡️ Build success in 611ms
22
+ ESM dist/index.js 11.57 KB
23
+ ESM ⚡️ Build success in 612ms
package/CHANGELOG.md CHANGED
@@ -1,5 +1,55 @@
1
1
  # @mastra/astra
2
2
 
3
+ ## 0.10.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 83da932: Move @mastra/core to peerdeps
8
+
9
+ ### Patch Changes
10
+
11
+ - d0ee3c6: Change all public functions and constructors in vector stores to use named args and prepare to phase out positional args
12
+ - a7292b0: BREAKING(@mastra/core, all vector stores): Vector store breaking changes (remove deprecated functions and positional arguments)
13
+ - Updated dependencies [b3a3d63]
14
+ - Updated dependencies [344f453]
15
+ - Updated dependencies [0a3ae6d]
16
+ - Updated dependencies [95911be]
17
+ - Updated dependencies [f53a6ac]
18
+ - Updated dependencies [5eb5a99]
19
+ - Updated dependencies [7e632c5]
20
+ - Updated dependencies [1e9fbfa]
21
+ - Updated dependencies [eabdcd9]
22
+ - Updated dependencies [90be034]
23
+ - Updated dependencies [99f050a]
24
+ - Updated dependencies [d0ee3c6]
25
+ - Updated dependencies [b2ae5aa]
26
+ - Updated dependencies [23f258c]
27
+ - Updated dependencies [a7292b0]
28
+ - Updated dependencies [0dcb9f0]
29
+ - Updated dependencies [2672a05]
30
+ - @mastra/core@0.10.0
31
+
32
+ ## 0.3.0-alpha.1
33
+
34
+ ### Minor Changes
35
+
36
+ - 83da932: Move @mastra/core to peerdeps
37
+
38
+ ### Patch Changes
39
+
40
+ - a7292b0: BREAKING(@mastra/core, all vector stores): Vector store breaking changes (remove deprecated functions and positional arguments)
41
+ - Updated dependencies [b3a3d63]
42
+ - Updated dependencies [344f453]
43
+ - Updated dependencies [0a3ae6d]
44
+ - Updated dependencies [95911be]
45
+ - Updated dependencies [5eb5a99]
46
+ - Updated dependencies [7e632c5]
47
+ - Updated dependencies [1e9fbfa]
48
+ - Updated dependencies [b2ae5aa]
49
+ - Updated dependencies [a7292b0]
50
+ - Updated dependencies [0dcb9f0]
51
+ - @mastra/core@0.10.0-alpha.1
52
+
3
53
  ## 0.2.16-alpha.0
4
54
 
5
55
  ### Patch Changes
@@ -6,7 +6,6 @@ import type { DescribeIndexParams } from '@mastra/core/vector';
6
6
  import type { IndexStats } from '@mastra/core/vector';
7
7
  import { MastraVector } from '@mastra/core/vector';
8
8
  import type { OperatorSupport } from '@mastra/core/vector/filter';
9
- import type { ParamsToArgs } from '@mastra/core/vector';
10
9
  import type { QueryResult } from '@mastra/core/vector';
11
10
  import type { QueryVectorParams } from '@mastra/core/vector';
12
11
  import type { UpdateVectorParams } from '@mastra/core/vector';
@@ -52,7 +51,7 @@ declare class AstraVector extends MastraVector {
52
51
  * @param {'cosine' | 'euclidean' | 'dotproduct'} [metric=cosine] - The metric to use to sort vectors in the collection.
53
52
  * @returns {Promise<void>} A promise that resolves when the collection is created.
54
53
  */
55
- createIndex(...args: ParamsToArgs<CreateIndexParams>): Promise<void>;
54
+ createIndex({ indexName, dimension, metric }: CreateIndexParams): Promise<void>;
56
55
  /**
57
56
  * Inserts or updates vectors in the specified collection.
58
57
  *
@@ -62,7 +61,7 @@ declare class AstraVector extends MastraVector {
62
61
  * @param {string[]} [ids] - An optional array of IDs corresponding to each vector. If not provided, new IDs will be generated.
63
62
  * @returns {Promise<string[]>} A promise that resolves to an array of IDs of the upserted vectors.
64
63
  */
65
- upsert(...args: ParamsToArgs<UpsertVectorParams>): Promise<string[]>;
64
+ upsert({ indexName, vectors, metadata, ids }: UpsertVectorParams): Promise<string[]>;
66
65
  transformFilter(filter?: VectorFilter): VectorFilter;
67
66
  /**
68
67
  * Queries the specified collection using a vector and optional filter.
@@ -74,7 +73,7 @@ declare class AstraVector extends MastraVector {
74
73
  * @param {boolean} [includeVectors=false] - Whether to include the vectors in the response.
75
74
  * @returns {Promise<QueryResult[]>} A promise that resolves to an array of query results.
76
75
  */
77
- query(...args: ParamsToArgs<QueryVectorParams>): Promise<QueryResult[]>;
76
+ query({ indexName, queryVector, topK, filter, includeVector, }: QueryVectorParams): Promise<QueryResult[]>;
78
77
  /**
79
78
  * Lists all collections in the database.
80
79
  *
@@ -84,21 +83,18 @@ declare class AstraVector extends MastraVector {
84
83
  /**
85
84
  * Retrieves statistics about a vector index.
86
85
  *
87
- * @param params - The parameters for describing an index
88
- * @param params.indexName - The name of the index to describe
86
+ * @param {string} indexName - The name of the index to describe
89
87
  * @returns A promise that resolves to the index statistics including dimension, count and metric
90
88
  */
91
- describeIndex(...args: ParamsToArgs<DescribeIndexParams>): Promise<IndexStats>;
89
+ describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats>;
92
90
  /**
93
91
  * Deletes the specified collection.
94
92
  *
95
93
  * @param {string} indexName - The name of the collection to delete.
96
94
  * @returns {Promise<void>} A promise that resolves when the collection is deleted.
97
95
  */
98
- deleteIndex(...args: ParamsToArgs<DeleteIndexParams>): Promise<void>;
96
+ deleteIndex({ indexName }: DeleteIndexParams): Promise<void>;
99
97
  /**
100
- * @deprecated Use {@link updateVector} instead. This method will be removed on May 20th, 2025.
101
- *
102
98
  * Updates a vector by its ID with the provided vector and/or metadata.
103
99
  * @param indexName - The name of the index containing the vector.
104
100
  * @param id - The ID of the vector to update.
@@ -108,31 +104,7 @@ declare class AstraVector extends MastraVector {
108
104
  * @returns A promise that resolves when the update is complete.
109
105
  * @throws Will throw an error if no updates are provided or if the update operation fails.
110
106
  */
111
- updateIndexById(indexName: string, id: string, update: {
112
- vector?: number[];
113
- metadata?: Record<string, any>;
114
- }): Promise<void>;
115
- /**
116
- * Updates a vector by its ID with the provided vector and/or metadata.
117
- * @param indexName - The name of the index containing the vector.
118
- * @param id - The ID of the vector to update.
119
- * @param update - An object containing the vector and/or metadata to update.
120
- * @param update.vector - An optional array of numbers representing the new vector.
121
- * @param update.metadata - An optional record containing the new metadata.
122
- * @returns A promise that resolves when the update is complete.
123
- * @throws Will throw an error if no updates are provided or if the update operation fails.
124
- */
125
- updateVector(...args: ParamsToArgs<UpdateVectorParams>): Promise<void>;
126
- /**
127
- * @deprecated Use {@link deleteVector} instead. This method will be removed on May 20th, 2025.
128
- *
129
- * Deletes a vector by its ID.
130
- * @param indexName - The name of the index containing the vector.
131
- * @param id - The ID of the vector to delete.
132
- * @returns A promise that resolves when the deletion is complete.
133
- * @throws Will throw an error if the deletion operation fails.
134
- */
135
- deleteIndexById(indexName: string, id: string): Promise<void>;
107
+ updateVector({ indexName, id, update }: UpdateVectorParams): Promise<void>;
136
108
  /**
137
109
  * Deletes a vector by its ID.
138
110
  * @param indexName - The name of the index containing the vector.
@@ -140,7 +112,7 @@ declare class AstraVector extends MastraVector {
140
112
  * @returns A promise that resolves when the deletion is complete.
141
113
  * @throws Will throw an error if the deletion operation fails.
142
114
  */
143
- deleteVector(...args: ParamsToArgs<DeleteVectorParams>): Promise<void>;
115
+ deleteVector({ indexName, id }: DeleteVectorParams): Promise<void>;
144
116
  }
145
117
  export { AstraVector }
146
118
  export { AstraVector as AstraVector_alias_1 }
@@ -6,7 +6,6 @@ import type { DescribeIndexParams } from '@mastra/core/vector';
6
6
  import type { IndexStats } from '@mastra/core/vector';
7
7
  import { MastraVector } from '@mastra/core/vector';
8
8
  import type { OperatorSupport } from '@mastra/core/vector/filter';
9
- import type { ParamsToArgs } from '@mastra/core/vector';
10
9
  import type { QueryResult } from '@mastra/core/vector';
11
10
  import type { QueryVectorParams } from '@mastra/core/vector';
12
11
  import type { UpdateVectorParams } from '@mastra/core/vector';
@@ -52,7 +51,7 @@ declare class AstraVector extends MastraVector {
52
51
  * @param {'cosine' | 'euclidean' | 'dotproduct'} [metric=cosine] - The metric to use to sort vectors in the collection.
53
52
  * @returns {Promise<void>} A promise that resolves when the collection is created.
54
53
  */
55
- createIndex(...args: ParamsToArgs<CreateIndexParams>): Promise<void>;
54
+ createIndex({ indexName, dimension, metric }: CreateIndexParams): Promise<void>;
56
55
  /**
57
56
  * Inserts or updates vectors in the specified collection.
58
57
  *
@@ -62,7 +61,7 @@ declare class AstraVector extends MastraVector {
62
61
  * @param {string[]} [ids] - An optional array of IDs corresponding to each vector. If not provided, new IDs will be generated.
63
62
  * @returns {Promise<string[]>} A promise that resolves to an array of IDs of the upserted vectors.
64
63
  */
65
- upsert(...args: ParamsToArgs<UpsertVectorParams>): Promise<string[]>;
64
+ upsert({ indexName, vectors, metadata, ids }: UpsertVectorParams): Promise<string[]>;
66
65
  transformFilter(filter?: VectorFilter): VectorFilter;
67
66
  /**
68
67
  * Queries the specified collection using a vector and optional filter.
@@ -74,7 +73,7 @@ declare class AstraVector extends MastraVector {
74
73
  * @param {boolean} [includeVectors=false] - Whether to include the vectors in the response.
75
74
  * @returns {Promise<QueryResult[]>} A promise that resolves to an array of query results.
76
75
  */
77
- query(...args: ParamsToArgs<QueryVectorParams>): Promise<QueryResult[]>;
76
+ query({ indexName, queryVector, topK, filter, includeVector, }: QueryVectorParams): Promise<QueryResult[]>;
78
77
  /**
79
78
  * Lists all collections in the database.
80
79
  *
@@ -84,21 +83,18 @@ declare class AstraVector extends MastraVector {
84
83
  /**
85
84
  * Retrieves statistics about a vector index.
86
85
  *
87
- * @param params - The parameters for describing an index
88
- * @param params.indexName - The name of the index to describe
86
+ * @param {string} indexName - The name of the index to describe
89
87
  * @returns A promise that resolves to the index statistics including dimension, count and metric
90
88
  */
91
- describeIndex(...args: ParamsToArgs<DescribeIndexParams>): Promise<IndexStats>;
89
+ describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats>;
92
90
  /**
93
91
  * Deletes the specified collection.
94
92
  *
95
93
  * @param {string} indexName - The name of the collection to delete.
96
94
  * @returns {Promise<void>} A promise that resolves when the collection is deleted.
97
95
  */
98
- deleteIndex(...args: ParamsToArgs<DeleteIndexParams>): Promise<void>;
96
+ deleteIndex({ indexName }: DeleteIndexParams): Promise<void>;
99
97
  /**
100
- * @deprecated Use {@link updateVector} instead. This method will be removed on May 20th, 2025.
101
- *
102
98
  * Updates a vector by its ID with the provided vector and/or metadata.
103
99
  * @param indexName - The name of the index containing the vector.
104
100
  * @param id - The ID of the vector to update.
@@ -108,31 +104,7 @@ declare class AstraVector extends MastraVector {
108
104
  * @returns A promise that resolves when the update is complete.
109
105
  * @throws Will throw an error if no updates are provided or if the update operation fails.
110
106
  */
111
- updateIndexById(indexName: string, id: string, update: {
112
- vector?: number[];
113
- metadata?: Record<string, any>;
114
- }): Promise<void>;
115
- /**
116
- * Updates a vector by its ID with the provided vector and/or metadata.
117
- * @param indexName - The name of the index containing the vector.
118
- * @param id - The ID of the vector to update.
119
- * @param update - An object containing the vector and/or metadata to update.
120
- * @param update.vector - An optional array of numbers representing the new vector.
121
- * @param update.metadata - An optional record containing the new metadata.
122
- * @returns A promise that resolves when the update is complete.
123
- * @throws Will throw an error if no updates are provided or if the update operation fails.
124
- */
125
- updateVector(...args: ParamsToArgs<UpdateVectorParams>): Promise<void>;
126
- /**
127
- * @deprecated Use {@link deleteVector} instead. This method will be removed on May 20th, 2025.
128
- *
129
- * Deletes a vector by its ID.
130
- * @param indexName - The name of the index containing the vector.
131
- * @param id - The ID of the vector to delete.
132
- * @returns A promise that resolves when the deletion is complete.
133
- * @throws Will throw an error if the deletion operation fails.
134
- */
135
- deleteIndexById(indexName: string, id: string): Promise<void>;
107
+ updateVector({ indexName, id, update }: UpdateVectorParams): Promise<void>;
136
108
  /**
137
109
  * Deletes a vector by its ID.
138
110
  * @param indexName - The name of the index containing the vector.
@@ -140,7 +112,7 @@ declare class AstraVector extends MastraVector {
140
112
  * @returns A promise that resolves when the deletion is complete.
141
113
  * @throws Will throw an error if the deletion operation fails.
142
114
  */
143
- deleteVector(...args: ParamsToArgs<DeleteVectorParams>): Promise<void>;
115
+ deleteVector({ indexName, id }: DeleteVectorParams): Promise<void>;
144
116
  }
145
117
  export { AstraVector }
146
118
  export { AstraVector as AstraVector_alias_1 }
package/dist/index.cjs CHANGED
@@ -68,9 +68,7 @@ var AstraVector = class extends vector.MastraVector {
68
68
  * @param {'cosine' | 'euclidean' | 'dotproduct'} [metric=cosine] - The metric to use to sort vectors in the collection.
69
69
  * @returns {Promise<void>} A promise that resolves when the collection is created.
70
70
  */
71
- async createIndex(...args) {
72
- const params = this.normalizeArgs("createIndex", args);
73
- const { indexName, dimension, metric = "cosine" } = params;
71
+ async createIndex({ indexName, dimension, metric = "cosine" }) {
74
72
  if (!Number.isInteger(dimension) || dimension <= 0) {
75
73
  throw new Error("Dimension must be a positive integer");
76
74
  }
@@ -91,9 +89,7 @@ var AstraVector = class extends vector.MastraVector {
91
89
  * @param {string[]} [ids] - An optional array of IDs corresponding to each vector. If not provided, new IDs will be generated.
92
90
  * @returns {Promise<string[]>} A promise that resolves to an array of IDs of the upserted vectors.
93
91
  */
94
- async upsert(...args) {
95
- const params = this.normalizeArgs("upsert", args);
96
- const { indexName, vectors, metadata, ids } = params;
92
+ async upsert({ indexName, vectors, metadata, ids }) {
97
93
  const collection = this.#db.collection(indexName);
98
94
  const vectorIds = ids || vectors.map(() => astraDbTs.UUID.v7().toString());
99
95
  const records = vectors.map((vector, i) => ({
@@ -118,9 +114,13 @@ var AstraVector = class extends vector.MastraVector {
118
114
  * @param {boolean} [includeVectors=false] - Whether to include the vectors in the response.
119
115
  * @returns {Promise<QueryResult[]>} A promise that resolves to an array of query results.
120
116
  */
121
- async query(...args) {
122
- const params = this.normalizeArgs("query", args);
123
- const { indexName, queryVector, topK = 10, filter, includeVector = false } = params;
117
+ async query({
118
+ indexName,
119
+ queryVector,
120
+ topK = 10,
121
+ filter,
122
+ includeVector = false
123
+ }) {
124
124
  const collection = this.#db.collection(indexName);
125
125
  const translatedFilter = this.transformFilter(filter);
126
126
  const cursor = collection.find(translatedFilter ?? {}, {
@@ -150,13 +150,10 @@ var AstraVector = class extends vector.MastraVector {
150
150
  /**
151
151
  * Retrieves statistics about a vector index.
152
152
  *
153
- * @param params - The parameters for describing an index
154
- * @param params.indexName - The name of the index to describe
153
+ * @param {string} indexName - The name of the index to describe
155
154
  * @returns A promise that resolves to the index statistics including dimension, count and metric
156
155
  */
157
- async describeIndex(...args) {
158
- const params = this.normalizeArgs("describeIndex", args);
159
- const { indexName } = params;
156
+ async describeIndex({ indexName }) {
160
157
  const collection = this.#db.collection(indexName);
161
158
  const optionsPromise = collection.options();
162
159
  const countPromise = collection.countDocuments({}, 100);
@@ -175,15 +172,11 @@ var AstraVector = class extends vector.MastraVector {
175
172
  * @param {string} indexName - The name of the collection to delete.
176
173
  * @returns {Promise<void>} A promise that resolves when the collection is deleted.
177
174
  */
178
- async deleteIndex(...args) {
179
- const params = this.normalizeArgs("deleteIndex", args);
180
- const { indexName } = params;
175
+ async deleteIndex({ indexName }) {
181
176
  const collection = this.#db.collection(indexName);
182
177
  await collection.drop();
183
178
  }
184
179
  /**
185
- * @deprecated Use {@link updateVector} instead. This method will be removed on May 20th, 2025.
186
- *
187
180
  * Updates a vector by its ID with the provided vector and/or metadata.
188
181
  * @param indexName - The name of the index containing the vector.
189
182
  * @param id - The ID of the vector to update.
@@ -193,25 +186,7 @@ var AstraVector = class extends vector.MastraVector {
193
186
  * @returns A promise that resolves when the update is complete.
194
187
  * @throws Will throw an error if no updates are provided or if the update operation fails.
195
188
  */
196
- async updateIndexById(indexName, id, update) {
197
- this.logger.warn(
198
- `Deprecation Warning: updateIndexById() is deprecated. Please use updateVector() instead. updateIndexById() will be removed on May 20th, 2025.`
199
- );
200
- await this.updateVector({ indexName, id, update });
201
- }
202
- /**
203
- * Updates a vector by its ID with the provided vector and/or metadata.
204
- * @param indexName - The name of the index containing the vector.
205
- * @param id - The ID of the vector to update.
206
- * @param update - An object containing the vector and/or metadata to update.
207
- * @param update.vector - An optional array of numbers representing the new vector.
208
- * @param update.metadata - An optional record containing the new metadata.
209
- * @returns A promise that resolves when the update is complete.
210
- * @throws Will throw an error if no updates are provided or if the update operation fails.
211
- */
212
- async updateVector(...args) {
213
- const params = this.normalizeArgs("updateVector", args);
214
- const { indexName, id, update } = params;
189
+ async updateVector({ indexName, id, update }) {
215
190
  try {
216
191
  if (!update.vector && !update.metadata) {
217
192
  throw new Error("No updates provided");
@@ -229,23 +204,6 @@ var AstraVector = class extends vector.MastraVector {
229
204
  throw new Error(`Failed to update vector by id: ${id} for index name: ${indexName}: ${error.message}`);
230
205
  }
231
206
  }
232
- /**
233
- * @deprecated Use {@link deleteVector} instead. This method will be removed on May 20th, 2025.
234
- *
235
- * Deletes a vector by its ID.
236
- * @param indexName - The name of the index containing the vector.
237
- * @param id - The ID of the vector to delete.
238
- * @returns A promise that resolves when the deletion is complete.
239
- * @throws Will throw an error if the deletion operation fails.
240
- */
241
- async deleteIndexById(indexName, id) {
242
- this.logger.warn(
243
- `Deprecation Warning: deleteIndexById() is deprecated.
244
- Please use deleteVector() instead.
245
- deleteIndexById() will be removed on May 20th, 2025.`
246
- );
247
- await this.deleteVector({ indexName, id });
248
- }
249
207
  /**
250
208
  * Deletes a vector by its ID.
251
209
  * @param indexName - The name of the index containing the vector.
@@ -253,9 +211,7 @@ var AstraVector = class extends vector.MastraVector {
253
211
  * @returns A promise that resolves when the deletion is complete.
254
212
  * @throws Will throw an error if the deletion operation fails.
255
213
  */
256
- async deleteVector(...args) {
257
- const params = this.normalizeArgs("deleteVector", args);
258
- const { indexName, id } = params;
214
+ async deleteVector({ indexName, id }) {
259
215
  try {
260
216
  const collection = this.#db.collection(indexName);
261
217
  await collection.deleteOne({ id });
package/dist/index.js CHANGED
@@ -66,9 +66,7 @@ var AstraVector = class extends MastraVector {
66
66
  * @param {'cosine' | 'euclidean' | 'dotproduct'} [metric=cosine] - The metric to use to sort vectors in the collection.
67
67
  * @returns {Promise<void>} A promise that resolves when the collection is created.
68
68
  */
69
- async createIndex(...args) {
70
- const params = this.normalizeArgs("createIndex", args);
71
- const { indexName, dimension, metric = "cosine" } = params;
69
+ async createIndex({ indexName, dimension, metric = "cosine" }) {
72
70
  if (!Number.isInteger(dimension) || dimension <= 0) {
73
71
  throw new Error("Dimension must be a positive integer");
74
72
  }
@@ -89,9 +87,7 @@ var AstraVector = class extends MastraVector {
89
87
  * @param {string[]} [ids] - An optional array of IDs corresponding to each vector. If not provided, new IDs will be generated.
90
88
  * @returns {Promise<string[]>} A promise that resolves to an array of IDs of the upserted vectors.
91
89
  */
92
- async upsert(...args) {
93
- const params = this.normalizeArgs("upsert", args);
94
- const { indexName, vectors, metadata, ids } = params;
90
+ async upsert({ indexName, vectors, metadata, ids }) {
95
91
  const collection = this.#db.collection(indexName);
96
92
  const vectorIds = ids || vectors.map(() => UUID.v7().toString());
97
93
  const records = vectors.map((vector, i) => ({
@@ -116,9 +112,13 @@ var AstraVector = class extends MastraVector {
116
112
  * @param {boolean} [includeVectors=false] - Whether to include the vectors in the response.
117
113
  * @returns {Promise<QueryResult[]>} A promise that resolves to an array of query results.
118
114
  */
119
- async query(...args) {
120
- const params = this.normalizeArgs("query", args);
121
- const { indexName, queryVector, topK = 10, filter, includeVector = false } = params;
115
+ async query({
116
+ indexName,
117
+ queryVector,
118
+ topK = 10,
119
+ filter,
120
+ includeVector = false
121
+ }) {
122
122
  const collection = this.#db.collection(indexName);
123
123
  const translatedFilter = this.transformFilter(filter);
124
124
  const cursor = collection.find(translatedFilter ?? {}, {
@@ -148,13 +148,10 @@ var AstraVector = class extends MastraVector {
148
148
  /**
149
149
  * Retrieves statistics about a vector index.
150
150
  *
151
- * @param params - The parameters for describing an index
152
- * @param params.indexName - The name of the index to describe
151
+ * @param {string} indexName - The name of the index to describe
153
152
  * @returns A promise that resolves to the index statistics including dimension, count and metric
154
153
  */
155
- async describeIndex(...args) {
156
- const params = this.normalizeArgs("describeIndex", args);
157
- const { indexName } = params;
154
+ async describeIndex({ indexName }) {
158
155
  const collection = this.#db.collection(indexName);
159
156
  const optionsPromise = collection.options();
160
157
  const countPromise = collection.countDocuments({}, 100);
@@ -173,15 +170,11 @@ var AstraVector = class extends MastraVector {
173
170
  * @param {string} indexName - The name of the collection to delete.
174
171
  * @returns {Promise<void>} A promise that resolves when the collection is deleted.
175
172
  */
176
- async deleteIndex(...args) {
177
- const params = this.normalizeArgs("deleteIndex", args);
178
- const { indexName } = params;
173
+ async deleteIndex({ indexName }) {
179
174
  const collection = this.#db.collection(indexName);
180
175
  await collection.drop();
181
176
  }
182
177
  /**
183
- * @deprecated Use {@link updateVector} instead. This method will be removed on May 20th, 2025.
184
- *
185
178
  * Updates a vector by its ID with the provided vector and/or metadata.
186
179
  * @param indexName - The name of the index containing the vector.
187
180
  * @param id - The ID of the vector to update.
@@ -191,25 +184,7 @@ var AstraVector = class extends MastraVector {
191
184
  * @returns A promise that resolves when the update is complete.
192
185
  * @throws Will throw an error if no updates are provided or if the update operation fails.
193
186
  */
194
- async updateIndexById(indexName, id, update) {
195
- this.logger.warn(
196
- `Deprecation Warning: updateIndexById() is deprecated. Please use updateVector() instead. updateIndexById() will be removed on May 20th, 2025.`
197
- );
198
- await this.updateVector({ indexName, id, update });
199
- }
200
- /**
201
- * Updates a vector by its ID with the provided vector and/or metadata.
202
- * @param indexName - The name of the index containing the vector.
203
- * @param id - The ID of the vector to update.
204
- * @param update - An object containing the vector and/or metadata to update.
205
- * @param update.vector - An optional array of numbers representing the new vector.
206
- * @param update.metadata - An optional record containing the new metadata.
207
- * @returns A promise that resolves when the update is complete.
208
- * @throws Will throw an error if no updates are provided or if the update operation fails.
209
- */
210
- async updateVector(...args) {
211
- const params = this.normalizeArgs("updateVector", args);
212
- const { indexName, id, update } = params;
187
+ async updateVector({ indexName, id, update }) {
213
188
  try {
214
189
  if (!update.vector && !update.metadata) {
215
190
  throw new Error("No updates provided");
@@ -227,23 +202,6 @@ var AstraVector = class extends MastraVector {
227
202
  throw new Error(`Failed to update vector by id: ${id} for index name: ${indexName}: ${error.message}`);
228
203
  }
229
204
  }
230
- /**
231
- * @deprecated Use {@link deleteVector} instead. This method will be removed on May 20th, 2025.
232
- *
233
- * Deletes a vector by its ID.
234
- * @param indexName - The name of the index containing the vector.
235
- * @param id - The ID of the vector to delete.
236
- * @returns A promise that resolves when the deletion is complete.
237
- * @throws Will throw an error if the deletion operation fails.
238
- */
239
- async deleteIndexById(indexName, id) {
240
- this.logger.warn(
241
- `Deprecation Warning: deleteIndexById() is deprecated.
242
- Please use deleteVector() instead.
243
- deleteIndexById() will be removed on May 20th, 2025.`
244
- );
245
- await this.deleteVector({ indexName, id });
246
- }
247
205
  /**
248
206
  * Deletes a vector by its ID.
249
207
  * @param indexName - The name of the index containing the vector.
@@ -251,9 +209,7 @@ var AstraVector = class extends MastraVector {
251
209
  * @returns A promise that resolves when the deletion is complete.
252
210
  * @throws Will throw an error if the deletion operation fails.
253
211
  */
254
- async deleteVector(...args) {
255
- const params = this.normalizeArgs("deleteVector", args);
256
- const { indexName, id } = params;
212
+ async deleteVector({ indexName, id }) {
257
213
  try {
258
214
  const collection = this.#db.collection(indexName);
259
215
  await collection.deleteOne({ id });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/astra",
3
- "version": "0.2.16-alpha.0",
3
+ "version": "0.10.0",
4
4
  "description": "Astra DB provider for Mastra - includes vector store capabilities",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -20,8 +20,7 @@
20
20
  },
21
21
  "license": "MIT",
22
22
  "dependencies": {
23
- "@datastax/astra-db-ts": "^1.5.0",
24
- "@mastra/core": "^0.9.5-alpha.0"
23
+ "@datastax/astra-db-ts": "^1.5.0"
25
24
  },
26
25
  "devDependencies": {
27
26
  "@microsoft/api-extractor": "^7.52.5",
@@ -30,7 +29,11 @@
30
29
  "tsup": "^8.4.0",
31
30
  "typescript": "^5.8.2",
32
31
  "vitest": "^3.1.2",
33
- "@internal/lint": "0.0.5"
32
+ "@internal/lint": "0.0.6",
33
+ "@mastra/core": "0.10.0"
34
+ },
35
+ "peerDependencies": {
36
+ "@mastra/core": "^0.10.0"
34
37
  },
35
38
  "scripts": {
36
39
  "build": "tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting",
@@ -1,4 +1,4 @@
1
- import { vi, describe, it, expect, beforeAll, afterAll, test, beforeEach, afterEach } from 'vitest';
1
+ import { vi, describe, it, expect, beforeAll, afterAll, test } from 'vitest';
2
2
 
3
3
  import { AstraVector } from './';
4
4
 
@@ -1093,103 +1093,6 @@ describe.skip('AstraVector Integration Tests', () => {
1093
1093
  });
1094
1094
  });
1095
1095
  });
1096
- describe('Deprecation Warnings', () => {
1097
- const indexName = 'testdeprecationwarnings';
1098
-
1099
- const indexName2 = 'testdeprecationwarnings2';
1100
-
1101
- let warnSpy;
1102
-
1103
- beforeAll(async () => {
1104
- await createIndexAndWait(vectorDB, indexName, 3, 'cosine');
1105
- });
1106
-
1107
- afterAll(async () => {
1108
- await deleteIndexAndWait(vectorDB, indexName);
1109
- await deleteIndexAndWait(vectorDB, indexName2);
1110
- });
1111
-
1112
- beforeEach(async () => {
1113
- warnSpy = vi.spyOn(vectorDB['logger'], 'warn');
1114
- });
1115
-
1116
- afterEach(async () => {
1117
- warnSpy.mockRestore();
1118
- await deleteIndexAndWait(vectorDB, indexName2);
1119
- });
1120
-
1121
- it('should show deprecation warning when using individual args for createIndex', async () => {
1122
- await vectorDB.createIndex(indexName2, 3, 'cosine');
1123
-
1124
- expect(warnSpy).toHaveBeenCalledWith(
1125
- expect.stringContaining('Deprecation Warning: Passing individual arguments to createIndex() is deprecated'),
1126
- );
1127
- });
1128
-
1129
- it('should show deprecation warning when using individual args for upsert', async () => {
1130
- await vectorDB.upsert(indexName, [[1, 2, 3]], [{ test: 'data' }]);
1131
-
1132
- expect(warnSpy).toHaveBeenCalledWith(
1133
- expect.stringContaining('Deprecation Warning: Passing individual arguments to upsert() is deprecated'),
1134
- );
1135
- });
1136
-
1137
- it('should show deprecation warning when using individual args for query', async () => {
1138
- await vectorDB.query(indexName, [1, 2, 3], 5);
1139
-
1140
- expect(warnSpy).toHaveBeenCalledWith(
1141
- expect.stringContaining('Deprecation Warning: Passing individual arguments to query() is deprecated'),
1142
- );
1143
- });
1144
-
1145
- it('should not show deprecation warning when using object param for query', async () => {
1146
- await vectorDB.query({
1147
- indexName,
1148
- queryVector: [1, 2, 3],
1149
- topK: 5,
1150
- });
1151
-
1152
- expect(warnSpy).not.toHaveBeenCalled();
1153
- });
1154
-
1155
- it('should not show deprecation warning when using object param for createIndex', async () => {
1156
- await vectorDB.createIndex({
1157
- indexName: indexName2,
1158
- dimension: 3,
1159
- metric: 'cosine',
1160
- });
1161
-
1162
- expect(warnSpy).not.toHaveBeenCalled();
1163
- });
1164
-
1165
- it('should not show deprecation warning when using object param for upsert', async () => {
1166
- await vectorDB.upsert({
1167
- indexName,
1168
- vectors: [[1, 2, 3]],
1169
- metadata: [{ test: 'data' }],
1170
- });
1171
-
1172
- expect(warnSpy).not.toHaveBeenCalled();
1173
- });
1174
-
1175
- it('should maintain backward compatibility with individual args', async () => {
1176
- // Query
1177
- const queryResults = await vectorDB.query(indexName, [1, 2, 3], 5);
1178
- expect(Array.isArray(queryResults)).toBe(true);
1179
-
1180
- // CreateIndex
1181
- await expect(vectorDB.createIndex(indexName2, 3, 'cosine')).resolves.not.toThrow();
1182
-
1183
- // Upsert
1184
- const upsertResults = await vectorDB.upsert({
1185
- indexName,
1186
- vectors: [[1, 2, 3]],
1187
- metadata: [{ test: 'data' }],
1188
- });
1189
- expect(Array.isArray(upsertResults)).toBe(true);
1190
- expect(upsertResults).toHaveLength(1);
1191
- });
1192
- });
1193
1096
 
1194
1097
  describe('Basic vector operations', () => {
1195
1098
  const indexName = 'testbasicvectoroperations';
@@ -7,7 +7,6 @@ import type {
7
7
  CreateIndexParams,
8
8
  UpsertVectorParams,
9
9
  QueryVectorParams,
10
- ParamsToArgs,
11
10
  DescribeIndexParams,
12
11
  DeleteIndexParams,
13
12
  DeleteVectorParams,
@@ -47,11 +46,7 @@ export class AstraVector extends MastraVector {
47
46
  * @param {'cosine' | 'euclidean' | 'dotproduct'} [metric=cosine] - The metric to use to sort vectors in the collection.
48
47
  * @returns {Promise<void>} A promise that resolves when the collection is created.
49
48
  */
50
- async createIndex(...args: ParamsToArgs<CreateIndexParams>): Promise<void> {
51
- const params = this.normalizeArgs<CreateIndexParams>('createIndex', args);
52
-
53
- const { indexName, dimension, metric = 'cosine' } = params;
54
-
49
+ async createIndex({ indexName, dimension, metric = 'cosine' }: CreateIndexParams): Promise<void> {
55
50
  if (!Number.isInteger(dimension) || dimension <= 0) {
56
51
  throw new Error('Dimension must be a positive integer');
57
52
  }
@@ -73,11 +68,7 @@ export class AstraVector extends MastraVector {
73
68
  * @param {string[]} [ids] - An optional array of IDs corresponding to each vector. If not provided, new IDs will be generated.
74
69
  * @returns {Promise<string[]>} A promise that resolves to an array of IDs of the upserted vectors.
75
70
  */
76
- async upsert(...args: ParamsToArgs<UpsertVectorParams>): Promise<string[]> {
77
- const params = this.normalizeArgs<UpsertVectorParams>('upsert', args);
78
-
79
- const { indexName, vectors, metadata, ids } = params;
80
-
71
+ async upsert({ indexName, vectors, metadata, ids }: UpsertVectorParams): Promise<string[]> {
81
72
  const collection = this.#db.collection(indexName);
82
73
 
83
74
  // Generate IDs if not provided
@@ -108,11 +99,13 @@ export class AstraVector extends MastraVector {
108
99
  * @param {boolean} [includeVectors=false] - Whether to include the vectors in the response.
109
100
  * @returns {Promise<QueryResult[]>} A promise that resolves to an array of query results.
110
101
  */
111
- async query(...args: ParamsToArgs<QueryVectorParams>): Promise<QueryResult[]> {
112
- const params = this.normalizeArgs<QueryVectorParams>('query', args);
113
-
114
- const { indexName, queryVector, topK = 10, filter, includeVector = false } = params;
115
-
102
+ async query({
103
+ indexName,
104
+ queryVector,
105
+ topK = 10,
106
+ filter,
107
+ includeVector = false,
108
+ }: QueryVectorParams): Promise<QueryResult[]> {
116
109
  const collection = this.#db.collection(indexName);
117
110
 
118
111
  const translatedFilter = this.transformFilter(filter);
@@ -148,15 +141,10 @@ export class AstraVector extends MastraVector {
148
141
  /**
149
142
  * Retrieves statistics about a vector index.
150
143
  *
151
- * @param params - The parameters for describing an index
152
- * @param params.indexName - The name of the index to describe
144
+ * @param {string} indexName - The name of the index to describe
153
145
  * @returns A promise that resolves to the index statistics including dimension, count and metric
154
146
  */
155
- async describeIndex(...args: ParamsToArgs<DescribeIndexParams>): Promise<IndexStats> {
156
- const params = this.normalizeArgs<DescribeIndexParams>('describeIndex', args);
157
-
158
- const { indexName } = params;
159
-
147
+ async describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats> {
160
148
  const collection = this.#db.collection(indexName);
161
149
  const optionsPromise = collection.options();
162
150
  const countPromise = collection.countDocuments({}, 100);
@@ -177,17 +165,12 @@ export class AstraVector extends MastraVector {
177
165
  * @param {string} indexName - The name of the collection to delete.
178
166
  * @returns {Promise<void>} A promise that resolves when the collection is deleted.
179
167
  */
180
- async deleteIndex(...args: ParamsToArgs<DeleteIndexParams>): Promise<void> {
181
- const params = this.normalizeArgs<DeleteIndexParams>('deleteIndex', args);
182
-
183
- const { indexName } = params;
168
+ async deleteIndex({ indexName }: DeleteIndexParams): Promise<void> {
184
169
  const collection = this.#db.collection(indexName);
185
170
  await collection.drop();
186
171
  }
187
172
 
188
173
  /**
189
- * @deprecated Use {@link updateVector} instead. This method will be removed on May 20th, 2025.
190
- *
191
174
  * Updates a vector by its ID with the provided vector and/or metadata.
192
175
  * @param indexName - The name of the index containing the vector.
193
176
  * @param id - The ID of the vector to update.
@@ -197,30 +180,7 @@ export class AstraVector extends MastraVector {
197
180
  * @returns A promise that resolves when the update is complete.
198
181
  * @throws Will throw an error if no updates are provided or if the update operation fails.
199
182
  */
200
- async updateIndexById(
201
- indexName: string,
202
- id: string,
203
- update: { vector?: number[]; metadata?: Record<string, any> },
204
- ): Promise<void> {
205
- this.logger.warn(
206
- `Deprecation Warning: updateIndexById() is deprecated. Please use updateVector() instead. updateIndexById() will be removed on May 20th, 2025.`,
207
- );
208
- await this.updateVector({ indexName, id, update });
209
- }
210
-
211
- /**
212
- * Updates a vector by its ID with the provided vector and/or metadata.
213
- * @param indexName - The name of the index containing the vector.
214
- * @param id - The ID of the vector to update.
215
- * @param update - An object containing the vector and/or metadata to update.
216
- * @param update.vector - An optional array of numbers representing the new vector.
217
- * @param update.metadata - An optional record containing the new metadata.
218
- * @returns A promise that resolves when the update is complete.
219
- * @throws Will throw an error if no updates are provided or if the update operation fails.
220
- */
221
- async updateVector(...args: ParamsToArgs<UpdateVectorParams>): Promise<void> {
222
- const params = this.normalizeArgs<UpdateVectorParams>('updateVector', args);
223
- const { indexName, id, update } = params;
183
+ async updateVector({ indexName, id, update }: UpdateVectorParams): Promise<void> {
224
184
  try {
225
185
  if (!update.vector && !update.metadata) {
226
186
  throw new Error('No updates provided');
@@ -243,24 +203,6 @@ export class AstraVector extends MastraVector {
243
203
  }
244
204
  }
245
205
 
246
- /**
247
- * @deprecated Use {@link deleteVector} instead. This method will be removed on May 20th, 2025.
248
- *
249
- * Deletes a vector by its ID.
250
- * @param indexName - The name of the index containing the vector.
251
- * @param id - The ID of the vector to delete.
252
- * @returns A promise that resolves when the deletion is complete.
253
- * @throws Will throw an error if the deletion operation fails.
254
- */
255
- async deleteIndexById(indexName: string, id: string): Promise<void> {
256
- this.logger.warn(
257
- `Deprecation Warning: deleteIndexById() is deprecated.
258
- Please use deleteVector() instead.
259
- deleteIndexById() will be removed on May 20th, 2025.`,
260
- );
261
- await this.deleteVector({ indexName, id });
262
- }
263
-
264
206
  /**
265
207
  * Deletes a vector by its ID.
266
208
  * @param indexName - The name of the index containing the vector.
@@ -268,10 +210,7 @@ export class AstraVector extends MastraVector {
268
210
  * @returns A promise that resolves when the deletion is complete.
269
211
  * @throws Will throw an error if the deletion operation fails.
270
212
  */
271
- async deleteVector(...args: ParamsToArgs<DeleteVectorParams>): Promise<void> {
272
- const params = this.normalizeArgs<DeleteVectorParams>('deleteVector', args);
273
-
274
- const { indexName, id } = params;
213
+ async deleteVector({ indexName, id }: DeleteVectorParams): Promise<void> {
275
214
  try {
276
215
  const collection = this.#db.collection(indexName);
277
216
  await collection.deleteOne({ id });