@mastra/lance 1.0.0 → 1.0.1-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.
@@ -88,10 +88,15 @@ export declare class LanceVectorStore extends MastraVector<LanceVectorFilter> {
88
88
  updateVector(params: UpdateVectorParams<LanceVectorFilter>): Promise<void>;
89
89
  deleteVector({ indexName, id }: DeleteVectorParams): Promise<void>;
90
90
  /**
91
- * Converts a flattened object with keys using underscore notation back to a nested object.
92
- * Example: { name: 'test', details_text: 'test' } → { name: 'test', details: { text: 'test' } }
91
+ * Extracts column names referenced in a SQL WHERE clause.
92
+ * Identifies metadata_* prefixed identifiers used in filter conditions.
93
93
  */
94
- private unflattenObject;
94
+ private extractFilterColumns;
95
+ /**
96
+ * Extracts metadata from flattened column names (legacy data without _metadata_json).
97
+ * Returns keys as-is after stripping the 'metadata_' prefix, without any unflattening.
98
+ */
99
+ private extractFlatMetadata;
95
100
  deleteVectors({ indexName, filter, ids }: DeleteVectorsParams<LanceVectorFilter>): Promise<void>;
96
101
  }
97
102
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vector/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAc,iBAAiB,EAAE,kBAAkB,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAI5G,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,UAAU,EACV,WAAW,EACX,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAElD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C,UAAU,sBAAuB,SAAQ,iB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EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;IAuExE;;;OAGG;IACH,OAAO,CAAC,oBAAoB;IAM5B;;;OAGG;IACH,OAAO,CAAC,mBAAmB;IAYrB,aAAa,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE,mBAAmB,CAAC,iBAAiB,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;CA6HvG"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/lance",
3
- "version": "1.0.0",
3
+ "version": "1.0.1-alpha.0",
4
4
  "description": "Lance provider for Mastra - includes both vector and db storage capabilities",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -23,17 +23,17 @@
23
23
  "apache-arrow": "^18.1.0"
24
24
  },
25
25
  "devDependencies": {
26
- "@types/node": "22.13.17",
26
+ "@types/node": "22.19.7",
27
27
  "@vitest/coverage-v8": "4.0.12",
28
28
  "@vitest/ui": "4.0.12",
29
29
  "eslint": "^9.37.0",
30
- "tsup": "^8.5.0",
30
+ "tsup": "^8.5.1",
31
31
  "typescript": "^5.9.3",
32
32
  "vitest": "4.0.16",
33
- "@internal/lint": "0.0.54",
34
- "@internal/storage-test-utils": "0.0.50",
35
- "@internal/types-builder": "0.0.29",
36
- "@mastra/core": "^1.0.0"
33
+ "@internal/lint": "0.0.57",
34
+ "@internal/storage-test-utils": "0.0.53",
35
+ "@internal/types-builder": "0.0.32",
36
+ "@mastra/core": "^1.3.0-alpha.1"
37
37
  },
38
38
  "peerDependencies": {
39
39
  "@mastra/core": ">=1.0.0-0 <2.0.0-0"
@@ -56,7 +56,6 @@
56
56
  },
57
57
  "scripts": {
58
58
  "build:lib": "tsup --silent --config tsup.config.ts",
59
- "build:docs": "pnpx tsx ../../scripts/generate-package-docs.ts stores/lance",
60
59
  "build:watch": "tsup --watch --silent --config tsup.config.ts",
61
60
  "test": "vitest run",
62
61
  "test:watch": "vitest watch",
@@ -1,33 +0,0 @@
1
- # @mastra/lance Documentation
2
-
3
- > Embedded documentation for coding agents
4
-
5
- ## Quick Start
6
-
7
- ```bash
8
- # Read the skill overview
9
- cat docs/SKILL.md
10
-
11
- # Get the source map
12
- cat docs/SOURCE_MAP.json
13
-
14
- # Read topic documentation
15
- cat docs/<topic>/01-overview.md
16
- ```
17
-
18
- ## Structure
19
-
20
- ```
21
- docs/
22
- ├── SKILL.md # Entry point
23
- ├── README.md # This file
24
- ├── SOURCE_MAP.json # Export index
25
- ├── rag/ (1 files)
26
- ├── storage/ (1 files)
27
- ├── vectors/ (1 files)
28
- ```
29
-
30
- ## Version
31
-
32
- Package: @mastra/lance
33
- Version: 1.0.0
@@ -1,149 +0,0 @@
1
- # Vectors API Reference
2
-
3
- > API reference for vectors - 1 entries
4
-
5
-
6
- ---
7
-
8
- ## Reference: Lance Vector Store
9
-
10
- > Documentation for the LanceVectorStore class in Mastra, which provides vector search using LanceDB, an embedded vector database based on the Lance columnar format.
11
-
12
- The LanceVectorStore class provides vector search using [LanceDB](https://lancedb.github.io/lancedb/), an embedded vector database built on the Lance columnar format. It offers efficient storage and fast similarity search for both local development and production deployments.
13
-
14
- ## Factory Method
15
-
16
- The LanceVectorStore uses a factory pattern for creation. You should use the static `create()` method rather than the constructor directly.
17
-
18
- ## Constructor Examples
19
-
20
- You can create a `LanceVectorStore` instance using the static create method:
21
-
22
- ```ts
23
- import { LanceVectorStore } from "@mastra/lance";
24
-
25
- // Connect to a local database
26
- const vectorStore = await LanceVectorStore.create("/path/to/db");
27
-
28
- // Connect to a LanceDB cloud database
29
- const cloudStore = await LanceVectorStore.create("db://host:port");
30
-
31
- // Connect to a cloud database with options
32
- const s3Store = await LanceVectorStore.create("s3://bucket/db", {
33
- storageOptions: { timeout: "60s" },
34
- });
35
- ```
36
-
37
- ## Methods
38
-
39
- ### createIndex()
40
-
41
- #### LanceIndexConfig
42
-
43
- ### createTable()
44
-
45
- ### upsert()
46
-
47
- ### query()
48
-
49
- ### listTables()
50
-
51
- Returns an array of table names as strings.
52
-
53
- ```typescript
54
- const tables = await vectorStore.listTables();
55
- // ['my_vectors', 'embeddings', 'documents']
56
- ```
57
-
58
- ### getTableSchema()
59
-
60
- Returns the schema of the specified table.
61
-
62
- ### deleteTable()
63
-
64
- ### deleteAllTables()
65
-
66
- Deletes all tables in the database.
67
-
68
- ### listIndexes()
69
-
70
- Returns an array of index names as strings.
71
-
72
- ### describeIndex()
73
-
74
- Returns information about the index:
75
-
76
- ```typescript
77
- interface IndexStats {
78
- dimension: number;
79
- count: number;
80
- metric: "cosine" | "euclidean" | "dotproduct";
81
- type: "ivfflat" | "hnsw";
82
- config: {
83
- m?: number;
84
- efConstruction?: number;
85
- numPartitions?: number;
86
- numSubVectors?: number;
87
- };
88
- }
89
- ```
90
-
91
- ### deleteIndex()
92
-
93
- ### updateVector()
94
-
95
- Update a single vector by ID or by metadata filter. Either `id` or `filter` must be provided, but not both.
96
-
97
- ### deleteVector()
98
-
99
- ### deleteVectors()
100
-
101
- Delete multiple vectors by IDs or by metadata filter. Either `ids` or `filter` must be provided, but not both.
102
-
103
- ### close()
104
-
105
- Closes the database connection.
106
-
107
- ## Response Types
108
-
109
- Query results are returned in this format:
110
-
111
- ```typescript
112
- interface QueryResult {
113
- id: string;
114
- score: number;
115
- metadata: Record<string, any>;
116
- vector?: number[]; // Only included if includeVector is true
117
- document?: string; // Document text if available
118
- }
119
- ```
120
-
121
- ## Error Handling
122
-
123
- The store throws typed errors that can be caught:
124
-
125
- ```typescript
126
- try {
127
- await store.query({
128
- tableName: "my_vectors",
129
- queryVector: queryVector,
130
- });
131
- } catch (error) {
132
- if (error instanceof Error) {
133
- console.log(error.message);
134
- }
135
- }
136
- ```
137
-
138
- ## Best Practices
139
-
140
- - Use the appropriate index type for your use case:
141
- - HNSW for better recall and performance when memory isn't constrained
142
- - IVF for better memory efficiency with large datasets
143
- - For optimal performance with large datasets, consider adjusting `numPartitions` and `numSubVectors` values
144
- - Use `close()` method to properly close connections when done with the database
145
- - Store metadata with a consistent schema to simplify filtering operations
146
-
147
- ## Related
148
-
149
- - [Metadata Filters](../rag/metadata-filters)