@mastra/vectorize 0.1.5 → 0.1.6-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,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.1 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 13586ms
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 10111ms
15
+ CLI Cleaning output folder
16
+ ESM Build start
17
+ ESM dist/index.js 5.26 KB
18
+ ESM ⚡️ Build success in 497ms
package/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # @mastra/vectorize
2
2
 
3
+ ## 0.1.6-alpha.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [0d185b1]
8
+ - Updated dependencies [ed55f1d]
9
+ - Updated dependencies [8d13b14]
10
+ - Updated dependencies [3ee4831]
11
+ - Updated dependencies [108793c]
12
+ - Updated dependencies [5f28f44]
13
+ - @mastra/core@0.4.3-alpha.1
14
+
15
+ ## 0.1.6-alpha.0
16
+
17
+ ### Patch Changes
18
+
19
+ - 0f7bd01: Fixed upsert for vectorize by adding \_\_binaryRequest
20
+ - Updated dependencies [06aa827]
21
+ - @mastra/core@0.4.3-alpha.0
22
+
3
23
  ## 0.1.5
4
24
 
5
25
  ### Patch Changes
@@ -1,9 +1,9 @@
1
1
  import { BaseFilterTranslator } from '@mastra/core/filter';
2
2
  import Cloudflare from 'cloudflare';
3
- import { Filter } from '@mastra/core/filter';
3
+ import type { Filter } from '@mastra/core/filter';
4
4
  import { MastraVector } from '@mastra/core/vector';
5
- import { OperatorSupport } from '@mastra/core/filter';
6
- import { QueryResult } from '@mastra/core/vector';
5
+ import type { OperatorSupport } from '@mastra/core/filter';
6
+ import type { QueryResult } from '@mastra/core/vector';
7
7
 
8
8
  declare class CloudflareVector extends MastraVector {
9
9
  client: Cloudflare;
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
- import { BaseFilterTranslator } from '@mastra/core/filter';
2
1
  import { MastraVector } from '@mastra/core/vector';
3
2
  import Cloudflare from 'cloudflare';
3
+ import { BaseFilterTranslator } from '@mastra/core/filter';
4
4
 
5
5
  // src/vector/index.ts
6
6
  var VectorizeFilterTranslator = class extends BaseFilterTranslator {
@@ -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) {
@@ -0,0 +1,6 @@
1
+ import { createConfig } from '@internal/lint/eslint';
2
+
3
+ const config = await createConfig();
4
+
5
+ /** @type {import("eslint").Linter.Config[]} */
6
+ export default [...config];
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.1",
4
4
  "description": "Cloudflare Vectorize store provider for Mastra",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -16,18 +16,21 @@
16
16
  },
17
17
  "dependencies": {
18
18
  "cloudflare": "^4.0.0",
19
- "@mastra/core": "^0.4.2"
19
+ "@mastra/core": "^0.4.3-alpha.1"
20
20
  },
21
21
  "devDependencies": {
22
22
  "@microsoft/api-extractor": "^7.49.2",
23
23
  "@types/node": "^22.13.1",
24
24
  "tsup": "^8.0.1",
25
25
  "typescript": "^5.7.3",
26
- "vitest": "^3.0.5"
26
+ "vitest": "^3.0.5",
27
+ "eslint": "^9.20.1",
28
+ "@internal/lint": "0.0.0"
27
29
  },
28
30
  "scripts": {
29
31
  "build": "tsup src/index.ts --format esm --experimental-dts --clean --treeshake",
30
32
  "build:watch": "pnpm build --watch",
31
- "test": "vitest run"
33
+ "test": "vitest run",
34
+ "lint": "eslint ."
32
35
  }
33
36
  }
@@ -1,4 +1,5 @@
1
- import { BaseFilterTranslator, type Filter, type FieldCondition, type OperatorSupport } from '@mastra/core/filter';
1
+ import { BaseFilterTranslator } from '@mastra/core/filter';
2
+ import type { Filter, FieldCondition, OperatorSupport } from '@mastra/core/filter';
2
3
 
3
4
  export class VectorizeFilterTranslator extends BaseFilterTranslator {
4
5
  protected override getSupportedOperators(): OperatorSupport {
@@ -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', () => {
@@ -1,5 +1,6 @@
1
- import { type Filter } from '@mastra/core/filter';
2
- import { MastraVector, type QueryResult } from '@mastra/core/vector';
1
+ import type { Filter } from '@mastra/core/filter';
2
+ import { MastraVector } from '@mastra/core/vector';
3
+ import type { QueryResult } from '@mastra/core/vector';
3
4
  import Cloudflare from 'cloudflare';
4
5
 
5
6
  import { VectorizeFilterTranslator } from './filter';
@@ -27,18 +28,26 @@ export class CloudflareVector extends MastraVector {
27
28
 
28
29
  // Create NDJSON string - each line is a JSON object
29
30
  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))
31
+ .map((vector, index) =>
32
+ JSON.stringify({
33
+ id: generatedIds[index]!,
34
+ values: vector,
35
+ metadata: metadata?.[index],
36
+ }),
37
+ )
36
38
  .join('\n');
37
39
 
38
- await this.client.vectorize.indexes.upsert(indexName, {
39
- account_id: this.accountId,
40
- body: ndjson as any,
41
- });
40
+ // Note: __binaryRequest is required for proper NDJSON handling
41
+ await this.client.vectorize.indexes.upsert(
42
+ indexName,
43
+ {
44
+ account_id: this.accountId,
45
+ body: ndjson,
46
+ },
47
+ {
48
+ __binaryRequest: true,
49
+ },
50
+ );
42
51
 
43
52
  return generatedIds;
44
53
  }