@mastra/vectorize 0.1.5 → 0.1.6-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.
- package/.turbo/turbo-build.log +7 -7
- package/CHANGELOG.md +8 -0
- package/dist/index.js +17 -9
- package/package.json +2 -2
- package/src/vector/index.test.ts +5 -5
- package/src/vector/index.ts +18 -10
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
|
|
2
|
-
> @mastra/vectorize@0.1.
|
|
2
|
+
> @mastra/vectorize@0.1.6-alpha.0 build /home/runner/work/mastra/mastra/stores/vectorize
|
|
3
3
|
> tsup src/index.ts --format esm --experimental-dts --clean --treeshake
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.ts
|
|
6
6
|
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
7
7
|
[34mCLI[39m tsup v8.3.6
|
|
8
8
|
[34mTSC[39m Build start
|
|
9
|
-
[32mTSC[39m ⚡️ Build success in
|
|
9
|
+
[32mTSC[39m ⚡️ Build success in 12685ms
|
|
10
10
|
[34mDTS[39m Build start
|
|
11
11
|
[34mCLI[39m Target: es2022
|
|
12
|
-
[34mCLI[39m Cleaning output folder
|
|
13
|
-
[34mESM[39m Build start
|
|
14
12
|
Analysis will use the bundled TypeScript version 5.7.3
|
|
15
13
|
[36mWriting package typings: /home/runner/work/mastra/mastra/stores/vectorize/dist/_tsup-dts-rollup.d.ts[39m
|
|
16
|
-
[32mDTS[39m ⚡️ Build success in
|
|
17
|
-
[
|
|
18
|
-
[
|
|
14
|
+
[32mDTS[39m ⚡️ Build success in 9765ms
|
|
15
|
+
[34mCLI[39m Cleaning output folder
|
|
16
|
+
[34mESM[39m Build start
|
|
17
|
+
[32mESM[39m [1mdist/index.js [22m[32m5.26 KB[39m
|
|
18
|
+
[32mESM[39m ⚡️ Build success in 465ms
|
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -70,15 +70,23 @@ var CloudflareVector = class extends MastraVector {
|
|
|
70
70
|
}
|
|
71
71
|
async upsert(indexName, vectors, metadata, ids) {
|
|
72
72
|
const generatedIds = ids || vectors.map(() => crypto.randomUUID());
|
|
73
|
-
const ndjson = vectors.map(
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
73
|
+
const ndjson = vectors.map(
|
|
74
|
+
(vector, index) => JSON.stringify({
|
|
75
|
+
id: generatedIds[index],
|
|
76
|
+
values: vector,
|
|
77
|
+
metadata: metadata?.[index]
|
|
78
|
+
})
|
|
79
|
+
).join("\n");
|
|
80
|
+
await this.client.vectorize.indexes.upsert(
|
|
81
|
+
indexName,
|
|
82
|
+
{
|
|
83
|
+
account_id: this.accountId,
|
|
84
|
+
body: ndjson
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
__binaryRequest: true
|
|
88
|
+
}
|
|
89
|
+
);
|
|
82
90
|
return generatedIds;
|
|
83
91
|
}
|
|
84
92
|
transformFilter(filter) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/vectorize",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6-alpha.0",
|
|
4
4
|
"description": "Cloudflare Vectorize store provider for Mastra",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"cloudflare": "^4.0.0",
|
|
19
|
-
"@mastra/core": "^0.4.
|
|
19
|
+
"@mastra/core": "^0.4.3-alpha.0"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"@microsoft/api-extractor": "^7.49.2",
|
package/src/vector/index.test.ts
CHANGED
|
@@ -167,7 +167,7 @@ describe('CloudflareVector', () => {
|
|
|
167
167
|
expect(result.vector).toHaveLength(VECTOR_DIMENSION);
|
|
168
168
|
}
|
|
169
169
|
});
|
|
170
|
-
},
|
|
170
|
+
}, 60000);
|
|
171
171
|
|
|
172
172
|
describe('Error Handling', () => {
|
|
173
173
|
it('should handle invalid dimension vectors', async () => {
|
|
@@ -480,7 +480,7 @@ describe('CloudflareVector', () => {
|
|
|
480
480
|
results.forEach(result => {
|
|
481
481
|
expect(result.metadata?.nested?.string).toBe('premium');
|
|
482
482
|
});
|
|
483
|
-
},
|
|
483
|
+
}, 10000);
|
|
484
484
|
|
|
485
485
|
it('combines nested numeric and boolean conditions', async () => {
|
|
486
486
|
const results = await vectorDB.query(testIndexName2, createVector(0, 1.0), 10, {
|
|
@@ -490,7 +490,7 @@ describe('CloudflareVector', () => {
|
|
|
490
490
|
expect(results.length).toBe(1);
|
|
491
491
|
expect(results[0]?.metadata?.nested?.number).toBeGreaterThan(100);
|
|
492
492
|
expect(results[0]?.metadata?.nested?.boolean).toBe(true);
|
|
493
|
-
},
|
|
493
|
+
}, 10000);
|
|
494
494
|
|
|
495
495
|
it('handles multiple nested field comparisons', async () => {
|
|
496
496
|
const results = await vectorDB.query(testIndexName2, createVector(0, 1.0), 10, {
|
|
@@ -503,7 +503,7 @@ describe('CloudflareVector', () => {
|
|
|
503
503
|
expect(result?.string).toBe('premium');
|
|
504
504
|
expect(result?.number).toBeLessThan(200);
|
|
505
505
|
expect(result?.boolean).toBe(true);
|
|
506
|
-
},
|
|
506
|
+
}, 10000);
|
|
507
507
|
|
|
508
508
|
it('handles $in with nested string values', async () => {
|
|
509
509
|
const results = await vectorDB.query(testIndexName2, createVector(0, 1.0), 10, {
|
|
@@ -513,7 +513,7 @@ describe('CloudflareVector', () => {
|
|
|
513
513
|
results.forEach(result => {
|
|
514
514
|
expect(['premium', 'basic']).toContain(result.metadata?.nested?.string);
|
|
515
515
|
});
|
|
516
|
-
},
|
|
516
|
+
}, 10000);
|
|
517
517
|
});
|
|
518
518
|
|
|
519
519
|
describe('String Operations', () => {
|
package/src/vector/index.ts
CHANGED
|
@@ -27,18 +27,26 @@ export class CloudflareVector extends MastraVector {
|
|
|
27
27
|
|
|
28
28
|
// Create NDJSON string - each line is a JSON object
|
|
29
29
|
const ndjson = vectors
|
|
30
|
-
.map((vector, index) =>
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
30
|
+
.map((vector, index) =>
|
|
31
|
+
JSON.stringify({
|
|
32
|
+
id: generatedIds[index]!,
|
|
33
|
+
values: vector,
|
|
34
|
+
metadata: metadata?.[index],
|
|
35
|
+
}),
|
|
36
|
+
)
|
|
36
37
|
.join('\n');
|
|
37
38
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
// Note: __binaryRequest is required for proper NDJSON handling
|
|
40
|
+
await this.client.vectorize.indexes.upsert(
|
|
41
|
+
indexName,
|
|
42
|
+
{
|
|
43
|
+
account_id: this.accountId,
|
|
44
|
+
body: ndjson,
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
__binaryRequest: true,
|
|
48
|
+
},
|
|
49
|
+
);
|
|
42
50
|
|
|
43
51
|
return generatedIds;
|
|
44
52
|
}
|