@mastra/lance 0.0.0-add-libsql-changeset-20250910154739

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.
@@ -0,0 +1,41 @@
1
+ import { BaseFilterTranslator } from '@mastra/core/vector/filter';
2
+ import type { VectorFilter, OperatorValueMap, LogicalOperatorValueMap, BlacklistedRootOperators } from '@mastra/core/vector/filter';
3
+ type LanceOperatorValueMap = OperatorValueMap & {
4
+ $like: string;
5
+ $notLike: string;
6
+ $contains: string;
7
+ };
8
+ type LanceBlacklisted = BlacklistedRootOperators | '$like' | '$notLike' | '$contains';
9
+ export type LanceVectorFilter = VectorFilter<keyof LanceOperatorValueMap, LanceOperatorValueMap, LogicalOperatorValueMap, LanceBlacklisted>;
10
+ export declare class LanceFilterTranslator extends BaseFilterTranslator<LanceVectorFilter, string> {
11
+ translate(filter: LanceVectorFilter): string;
12
+ private processFilter;
13
+ private processLogicalOperator;
14
+ private processNestedObject;
15
+ private processField;
16
+ private processOperators;
17
+ private formatValue;
18
+ private formatArrayValues;
19
+ normalizeArrayValues(array: unknown[]): unknown[];
20
+ normalizeComparisonValue(value: unknown): unknown;
21
+ private isOperatorObject;
22
+ private isNestedObject;
23
+ private isNormalNestedField;
24
+ private escapeFieldName;
25
+ private isSqlKeyword;
26
+ private isDateObject;
27
+ /**
28
+ * Override getSupportedOperators to add custom operators for LanceDB
29
+ */
30
+ protected getSupportedOperators(): {
31
+ custom: string[];
32
+ logical: import("@mastra/core/vector/filter").LogicalOperator[];
33
+ basic: import("@mastra/core/vector/filter").BasicOperator[];
34
+ numeric: import("@mastra/core/vector/filter").NumericOperator[];
35
+ array: import("@mastra/core/vector/filter").ArrayOperator[];
36
+ element: "$exists"[];
37
+ regex: import("@mastra/core/vector/filter").RegexOperator[];
38
+ };
39
+ }
40
+ export {};
41
+ //# sourceMappingURL=filter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filter.d.ts","sourceRoot":"","sources":["../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+ import type { CreateIndexParams, DeleteIndexParams, DeleteVectorParams, DescribeIndexParams, IndexStats, QueryResult, QueryVectorParams, UpdateVectorParams, UpsertVectorParams } from '@mastra/core/vector';
3
+ import { MastraVector } from '@mastra/core/vector';
4
+ import type { LanceVectorFilter } from './filter.js';
5
+ import type { IndexConfig } from './types.js';
6
+ interface LanceCreateIndexParams extends CreateIndexParams {
7
+ indexConfig?: LanceIndexConfig;
8
+ tableName?: string;
9
+ }
10
+ interface LanceIndexConfig extends IndexConfig {
11
+ numPartitions?: number;
12
+ numSubVectors?: number;
13
+ }
14
+ interface LanceUpsertVectorParams extends UpsertVectorParams {
15
+ tableName: string;
16
+ }
17
+ interface LanceQueryVectorParams extends QueryVectorParams<LanceVectorFilter> {
18
+ tableName: string;
19
+ columns?: string[];
20
+ includeAllColumns?: boolean;
21
+ }
22
+ export declare class LanceVectorStore extends MastraVector<LanceVectorFilter> {
23
+ private lanceClient;
24
+ /**
25
+ * Creates a new instance of LanceVectorStore
26
+ * @param uri The URI to connect to LanceDB
27
+ * @param options connection options
28
+ *
29
+ * Usage:
30
+ *
31
+ * Connect to a local database
32
+ * ```ts
33
+ * const store = await LanceVectorStore.create('/path/to/db');
34
+ * ```
35
+ *
36
+ * Connect to a LanceDB cloud database
37
+ * ```ts
38
+ * const store = await LanceVectorStore.create('db://host:port');
39
+ * ```
40
+ *
41
+ * Connect to a cloud database
42
+ * ```ts
43
+ * const store = await LanceVectorStore.create('s3://bucket/db', { storageOptions: { timeout: '60s' } });
44
+ * ```
45
+ */
46
+ static create(uri: string, options?: ConnectionOptions): Promise<LanceVectorStore>;
47
+ /**
48
+ * @internal
49
+ * Private constructor to enforce using the create factory method
50
+ */
51
+ private constructor();
52
+ close(): void;
53
+ query({ tableName, queryVector, filter, includeVector, topK, columns, includeAllColumns, }: LanceQueryVectorParams): Promise<QueryResult[]>;
54
+ private filterTranslator;
55
+ upsert({ tableName, vectors, metadata, ids }: LanceUpsertVectorParams): Promise<string[]>;
56
+ /**
57
+ * Flattens a nested object, creating new keys with underscores for nested properties.
58
+ * Example: { metadata: { text: 'test' } } → { metadata_text: 'test' }
59
+ */
60
+ private flattenObject;
61
+ createTable(tableName: string, data: Record<string, unknown>[] | TableLike, options?: Partial<CreateTableOptions>): Promise<Table>;
62
+ listTables(): Promise<string[]>;
63
+ getTableSchema(tableName: string): Promise<any>;
64
+ /**
65
+ * indexName is actually a column name in a table in lanceDB
66
+ */
67
+ createIndex({ tableName, indexName, dimension, metric, indexConfig, }: LanceCreateIndexParams): Promise<void>;
68
+ listIndexes(): Promise<string[]>;
69
+ describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats>;
70
+ deleteIndex({ indexName }: DeleteIndexParams): Promise<void>;
71
+ /**
72
+ * Deletes all tables in the database
73
+ */
74
+ deleteAllTables(): Promise<void>;
75
+ deleteTable(tableName: string): Promise<void>;
76
+ updateVector({ indexName, id, update }: UpdateVectorParams): Promise<void>;
77
+ deleteVector({ indexName, id }: DeleteVectorParams): Promise<void>;
78
+ /**
79
+ * Converts a flattened object with keys using underscore notation back to a nested object.
80
+ * Example: { name: 'test', details_text: 'test' } → { name: 'test', details: { text: 'test' } }
81
+ */
82
+ private unflattenObject;
83
+ }
84
+ export {};
85
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +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;AAG5G,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,UAAU,EACV,WAAW,EACX,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EACnB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,KAAK,EAAE,iBAAiB,EAAE,M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AM,EAAE,OAAO,CAAC,EAAE,GAAG,SAAS,EAC3C,OAAO,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,GACpC,OAAO,CAAC,KAAK,CAAC;IA+BX,UAAU,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAwB/B,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IA2BrD;;OAEG;IACG,WAAW,CAAC,EAChB,SAAS,EACT,SAAS,EACT,SAAS,EACT,MAAiB,EACjB,WAAgB,GACjB,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC;IAkFnC,WAAW,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAkChC,aAAa,CAAC,EAAE,SAAS,EAAE,EAAE,mBAAmB,GAAG,OAAO,CAAC,UAAU,CAAC;IAkEtE,WAAW,CAAC,EAAE,SAAS,EAAE,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAgDlE;;OAEG;IACG,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC;IAyBhC,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA2B7C,YAAY,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;IAuH1E,YAAY,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;IAiExE;;;OAGG;IACH,OAAO,CAAC,eAAe;CAgCxB"}
@@ -0,0 +1,15 @@
1
+ export type IndexType = 'ivfflat' | 'hnsw';
2
+ interface IVFConfig {
3
+ lists?: number;
4
+ }
5
+ interface HNSWConfig {
6
+ m?: number;
7
+ efConstruction?: number;
8
+ }
9
+ export interface IndexConfig {
10
+ type?: IndexType;
11
+ ivf?: IVFConfig;
12
+ hnsw?: HNSWConfig;
13
+ }
14
+ export {};
15
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/vector/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG,MAAM,CAAC;AAE3C,UAAU,SAAS;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,UAAU,UAAU;IAClB,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,GAAG,CAAC,EAAE,SAAS,CAAC;IAChB,IAAI,CAAC,EAAE,UAAU,CAAC;CACnB"}
package/package.json ADDED
@@ -0,0 +1,60 @@
1
+ {
2
+ "name": "@mastra/lance",
3
+ "version": "0.0.0-add-libsql-changeset-20250910154739",
4
+ "description": "Lance provider for Mastra - includes both vector and db storage capabilities",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": {
11
+ "types": "./dist/index.d.ts",
12
+ "default": "./dist/index.js"
13
+ },
14
+ "require": {
15
+ "types": "./dist/index.d.ts",
16
+ "default": "./dist/index.cjs"
17
+ }
18
+ },
19
+ "./package.json": "./package.json"
20
+ },
21
+ "dependencies": {
22
+ "@lancedb/lancedb": "^0.21.2",
23
+ "apache-arrow": "^18.1.0"
24
+ },
25
+ "devDependencies": {
26
+ "@microsoft/api-extractor": "^7.52.8",
27
+ "@types/node": "^20.19.0",
28
+ "eslint": "^9.30.1",
29
+ "tsup": "^8.5.0",
30
+ "typescript": "^5.8.3",
31
+ "vitest": "^3.2.4",
32
+ "@internal/lint": "0.0.0-add-libsql-changeset-20250910154739",
33
+ "@internal/storage-test-utils": "0.0.34",
34
+ "@mastra/core": "0.0.0-add-libsql-changeset-20250910154739",
35
+ "@internal/types-builder": "0.0.0-add-libsql-changeset-20250910154739"
36
+ },
37
+ "peerDependencies": {
38
+ "@mastra/core": "0.0.0-add-libsql-changeset-20250910154739"
39
+ },
40
+ "files": [
41
+ "dist",
42
+ "CHANGELOG.md"
43
+ ],
44
+ "homepage": "https://mastra.ai",
45
+ "repository": {
46
+ "type": "git",
47
+ "url": "git+https://github.com/mastra-ai/mastra.git",
48
+ "directory": "stores/lance"
49
+ },
50
+ "bugs": {
51
+ "url": "https://github.com/mastra-ai/mastra/issues"
52
+ },
53
+ "scripts": {
54
+ "build": "tsup --silent --config tsup.config.ts",
55
+ "build:watch": "tsup --watch --silent --config tsup.config.ts",
56
+ "test": "vitest run",
57
+ "test:watch": "vitest watch",
58
+ "lint": "eslint ."
59
+ }
60
+ }