@mastra/astra 0.2.6 → 0.2.7-alpha.1

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.6-alpha.3 build /home/runner/work/mastra/mastra/stores/astra
2
+ > @mastra/astra@0.2.7-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 6577ms
9
+ TSC ⚡️ Build success in 6306ms
10
10
  DTS Build start
11
11
  CLI Target: es2022
12
12
  Analysis will use the bundled TypeScript version 5.8.2
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.2
15
15
  Writing package typings: /home/runner/work/mastra/mastra/stores/astra/dist/_tsup-dts-rollup.d.cts
16
- DTS ⚡️ Build success in 8257ms
16
+ DTS ⚡️ Build success in 8743ms
17
17
  CLI Cleaning output folder
18
18
  ESM Build start
19
19
  CJS Build start
20
20
  ESM dist/index.js 7.06 KB
21
- ESM ⚡️ Build success in 571ms
21
+ ESM ⚡️ Build success in 638ms
22
22
  CJS dist/index.cjs 7.09 KB
23
- CJS ⚡️ Build success in 571ms
23
+ CJS ⚡️ Build success in 639ms
package/CHANGELOG.md CHANGED
@@ -1,5 +1,30 @@
1
1
  # @mastra/astra
2
2
 
3
+ ## 0.2.7-alpha.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 866da3c: Update astra tests to check collection is empty
8
+ - Updated dependencies [619c39d]
9
+ - Updated dependencies [fe56be0]
10
+ - Updated dependencies [a0967a0]
11
+ - Updated dependencies [fca3b21]
12
+ - Updated dependencies [0118361]
13
+ - Updated dependencies [619c39d]
14
+ - @mastra/core@0.8.0-alpha.1
15
+
16
+ ## 0.2.7-alpha.0
17
+
18
+ ### Patch Changes
19
+
20
+ - Updated dependencies [107bcfe]
21
+ - Updated dependencies [5b4e19f]
22
+ - Updated dependencies [7599d77]
23
+ - Updated dependencies [cafae83]
24
+ - Updated dependencies [8076ecf]
25
+ - Updated dependencies [304397c]
26
+ - @mastra/core@0.7.1-alpha.0
27
+
3
28
  ## 0.2.6
4
29
 
5
30
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/astra",
3
- "version": "0.2.6",
3
+ "version": "0.2.7-alpha.1",
4
4
  "description": "Astra DB provider for Mastra - includes vector store capabilities",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -20,7 +20,7 @@
20
20
  },
21
21
  "dependencies": {
22
22
  "@datastax/astra-db-ts": "^1.5.0",
23
- "@mastra/core": "^0.7.0"
23
+ "@mastra/core": "^0.8.0-alpha.1"
24
24
  },
25
25
  "devDependencies": {
26
26
  "@microsoft/api-extractor": "^7.52.1",
@@ -23,6 +23,41 @@ async function waitForCondition(
23
23
  return false;
24
24
  }
25
25
 
26
+ async function createIndexAndWait(
27
+ vectorDB: AstraVector,
28
+ indexName: string,
29
+ dimension: number,
30
+ metric: 'cosine' | 'euclidean' | 'dotproduct',
31
+ ) {
32
+ await vectorDB.createIndex({ indexName, dimension, metric });
33
+ const created = await waitForCondition(
34
+ async () => {
35
+ const newCollections = await vectorDB.listIndexes();
36
+ return newCollections.includes(indexName);
37
+ },
38
+ 30000,
39
+ 2000,
40
+ );
41
+ if (!created) {
42
+ throw new Error('Timed out waiting for collection to be created');
43
+ }
44
+ }
45
+
46
+ async function deleteIndexAndWait(vectorDB: AstraVector, indexName: string) {
47
+ await vectorDB.deleteIndex(indexName);
48
+ const deleted = await waitForCondition(
49
+ async () => {
50
+ const newCollections = await vectorDB.listIndexes();
51
+ return !newCollections.includes(indexName);
52
+ },
53
+ 30000,
54
+ 2000,
55
+ );
56
+ if (!deleted) {
57
+ throw new Error('Timed out waiting for collection to be deleted');
58
+ }
59
+ }
60
+
26
61
  describe('AstraVector Integration Tests', () => {
27
62
  let vectorDB: AstraVector;
28
63
  const testIndexName = 'testvectors1733728136118'; // Unique collection name
@@ -46,12 +81,24 @@ describe('AstraVector Integration Tests', () => {
46
81
  try {
47
82
  const collections = await vectorDB.listIndexes();
48
83
  await Promise.all(collections.map(c => vectorDB.deleteIndex(c)));
84
+ const deleted = await waitForCondition(
85
+ async () => {
86
+ const remainingCollections = await vectorDB.listIndexes();
87
+ return remainingCollections.length === 0;
88
+ },
89
+ 30000,
90
+ 2000,
91
+ );
92
+ if (!deleted) {
93
+ throw new Error('Timed out waiting for collections to be deleted');
94
+ }
49
95
  } catch (error) {
50
96
  console.error('Failed to delete test collections:', error);
97
+ throw error;
51
98
  }
52
99
 
53
- await vectorDB.createIndex({ indexName: testIndexName, dimension: 4, metric: 'cosine' });
54
- await vectorDB.createIndex({ indexName: testIndexName2, dimension: 4, metric: 'cosine' });
100
+ await createIndexAndWait(vectorDB, testIndexName, 4, 'cosine');
101
+ await createIndexAndWait(vectorDB, testIndexName2, 4, 'cosine');
55
102
  }, 500000);
56
103
 
57
104
  afterAll(async () => {
@@ -159,11 +206,7 @@ describe('AstraVector Integration Tests', () => {
159
206
 
160
207
  try {
161
208
  // Create index with higher dimensions
162
- await vectorDB.createIndex({
163
- indexName: highDimIndexName,
164
- dimension: 1536,
165
- metric: 'cosine',
166
- });
209
+ await createIndexAndWait(vectorDB, highDimIndexName, 1536, 'cosine');
167
210
 
168
211
  // Insert high-dimensional vectors
169
212
  const vectors = [
@@ -202,7 +245,7 @@ describe('AstraVector Integration Tests', () => {
202
245
  expect(results?.[0]?.score).toBeCloseTo(1, 4);
203
246
  } finally {
204
247
  // Cleanup
205
- await vectorDB.deleteIndex(highDimIndexName);
248
+ await deleteIndexAndWait(vectorDB, highDimIndexName);
206
249
  }
207
250
  });
208
251
 
@@ -214,11 +257,7 @@ describe('AstraVector Integration Tests', () => {
214
257
 
215
258
  try {
216
259
  // Create index with different metric
217
- await vectorDB.createIndex({
218
- indexName: metricIndexName,
219
- dimension: 4,
220
- metric,
221
- });
260
+ await createIndexAndWait(vectorDB, metricIndexName, 4, metric);
222
261
 
223
262
  // Insert same vectors
224
263
  const vectors = [
@@ -247,7 +286,7 @@ describe('AstraVector Integration Tests', () => {
247
286
  expect(results?.[0]?.score).toBeGreaterThan(results?.[1]?.score!);
248
287
  } finally {
249
288
  // Cleanup
250
- await vectorDB.deleteIndex(metricIndexName);
289
+ await deleteIndexAndWait(vectorDB, metricIndexName);
251
290
  }
252
291
  }
253
292
  }, 500000);
@@ -1062,12 +1101,12 @@ describe('AstraVector Integration Tests', () => {
1062
1101
  let warnSpy;
1063
1102
 
1064
1103
  beforeAll(async () => {
1065
- await vectorDB.createIndex({ indexName: indexName, dimension: 3 });
1104
+ await createIndexAndWait(vectorDB, indexName, 3, 'cosine');
1066
1105
  });
1067
1106
 
1068
1107
  afterAll(async () => {
1069
- await vectorDB.deleteIndex(indexName);
1070
- await vectorDB.deleteIndex(indexName2);
1108
+ await deleteIndexAndWait(vectorDB, indexName);
1109
+ await deleteIndexAndWait(vectorDB, indexName2);
1071
1110
  });
1072
1111
 
1073
1112
  beforeEach(async () => {
@@ -1076,7 +1115,7 @@ describe('AstraVector Integration Tests', () => {
1076
1115
 
1077
1116
  afterEach(async () => {
1078
1117
  warnSpy.mockRestore();
1079
- await vectorDB.deleteIndex(indexName2);
1118
+ await deleteIndexAndWait(vectorDB, indexName2);
1080
1119
  });
1081
1120
 
1082
1121
  it('should show deprecation warning when using individual args for createIndex', async () => {
@@ -1156,11 +1195,11 @@ describe('AstraVector Integration Tests', () => {
1156
1195
  const indexName = 'testbasicvectoroperations';
1157
1196
 
1158
1197
  beforeAll(async () => {
1159
- await vectorDB.createIndex({ indexName, dimension: 4 });
1198
+ await createIndexAndWait(vectorDB, indexName, 4, 'cosine');
1160
1199
  });
1161
1200
 
1162
1201
  afterAll(async () => {
1163
- await vectorDB.deleteIndex(indexName);
1202
+ await deleteIndexAndWait(vectorDB, indexName);
1164
1203
  });
1165
1204
 
1166
1205
  const testVectors = [