@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.
@@ -1,18 +1,18 @@
1
1
 
2
- > @mastra/vectorize@0.1.5-alpha.2 build /home/runner/work/mastra/mastra/stores/vectorize
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
  CLI Building entry: src/index.ts
6
6
  CLI Using tsconfig: tsconfig.json
7
7
  CLI tsup v8.3.6
8
8
  TSC Build start
9
- TSC ⚡️ Build success in 13201ms
9
+ TSC ⚡️ Build success in 12685ms
10
10
  DTS Build start
11
11
  CLI Target: es2022
12
- CLI Cleaning output folder
13
- ESM Build start
14
12
  Analysis will use the bundled TypeScript version 5.7.3
15
13
  Writing package typings: /home/runner/work/mastra/mastra/stores/vectorize/dist/_tsup-dts-rollup.d.ts
16
- DTS ⚡️ Build success in 8907ms
17
- ESM dist/index.js 5.20 KB
18
- ESM ⚡️ Build success in 9115ms
14
+ DTS ⚡️ Build success in 9765ms
15
+ CLI Cleaning output folder
16
+ ESM Build start
17
+ ESM dist/index.js 5.26 KB
18
+ ESM ⚡️ Build success in 465ms
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @mastra/vectorize
2
2
 
3
+ ## 0.1.6-alpha.0
4
+
5
+ ### Patch Changes
6
+
7
+ - 0f7bd01: Fixed upsert for vectorize by adding \_\_binaryRequest
8
+ - Updated dependencies [06aa827]
9
+ - @mastra/core@0.4.3-alpha.0
10
+
3
11
  ## 0.1.5
4
12
 
5
13
  ### Patch Changes
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((vector, index) => ({
74
- id: generatedIds[index],
75
- values: vector,
76
- metadata: metadata?.[index]
77
- })).map((record) => JSON.stringify(record)).join("\n");
78
- await this.client.vectorize.indexes.upsert(indexName, {
79
- account_id: this.accountId,
80
- body: ndjson
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.5",
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.2"
19
+ "@mastra/core": "^0.4.3-alpha.0"
20
20
  },
21
21
  "devDependencies": {
22
22
  "@microsoft/api-extractor": "^7.49.2",
@@ -167,7 +167,7 @@ describe('CloudflareVector', () => {
167
167
  expect(result.vector).toHaveLength(VECTOR_DIMENSION);
168
168
  }
169
169
  });
170
- }, 30000);
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
- }, 5000);
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
- }, 5000);
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
- }, 5000);
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
- }, 5000);
516
+ }, 10000);
517
517
  });
518
518
 
519
519
  describe('String Operations', () => {
@@ -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
- id: generatedIds[index]!,
32
- values: vector,
33
- metadata: metadata?.[index],
34
- }))
35
- .map(record => JSON.stringify(record))
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
- await this.client.vectorize.indexes.upsert(indexName, {
39
- account_id: this.accountId,
40
- body: ndjson as any,
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
  }