@mastra/turbopuffer 0.0.0-pg-pool-options-20250428183821 → 0.0.0-pgvector-index-fix-20250905222058
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/CHANGELOG.md +1214 -0
- package/LICENSE.md +12 -4
- package/dist/index.cjs +215 -46
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +210 -41
- package/dist/index.js.map +1 -0
- package/dist/vector/filter.d.ts +50 -0
- package/dist/vector/filter.d.ts.map +1 -0
- package/dist/vector/index.d.ts +87 -0
- package/dist/vector/index.d.ts.map +1 -0
- package/package.json +30 -16
- package/dist/_tsup-dts-rollup.d.cts +0 -116
- package/dist/_tsup-dts-rollup.d.ts +0 -116
- package/dist/index.d.cts +0 -2
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import { BaseFilterTranslator } from '@mastra/core/vector/filter';
|
|
2
|
-
import type { CreateIndexParams } from '@mastra/core/vector';
|
|
3
|
-
import type { Filters } from '@turbopuffer/turbopuffer';
|
|
4
|
-
import type { IndexStats } from '@mastra/core/vector';
|
|
5
|
-
import { MastraVector } from '@mastra/core/vector';
|
|
6
|
-
import type { OperatorSupport } from '@mastra/core/vector/filter';
|
|
7
|
-
import type { QueryResult } from '@mastra/core/vector';
|
|
8
|
-
import type { QueryVectorParams } from '@mastra/core/vector';
|
|
9
|
-
import type { Schema } from '@turbopuffer/turbopuffer';
|
|
10
|
-
import type { UpsertVectorParams } from '@mastra/core/vector';
|
|
11
|
-
import type { VectorFilter } from '@mastra/core/vector/filter';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Translator for converting Mastra filters to Turbopuffer format
|
|
15
|
-
*
|
|
16
|
-
* Mastra filters: { field: { $gt: 10 } }
|
|
17
|
-
* Turbopuffer filters: ["And", [["field", "Gt", 10]]]
|
|
18
|
-
*/
|
|
19
|
-
export declare class TurbopufferFilterTranslator extends BaseFilterTranslator {
|
|
20
|
-
protected getSupportedOperators(): OperatorSupport;
|
|
21
|
-
/**
|
|
22
|
-
* Map Mastra operators to Turbopuffer operators
|
|
23
|
-
*/
|
|
24
|
-
private operatorMap;
|
|
25
|
-
/**
|
|
26
|
-
* Convert the Mastra filter to Turbopuffer format
|
|
27
|
-
*/
|
|
28
|
-
translate(filter?: VectorFilter): Filters | undefined;
|
|
29
|
-
/**
|
|
30
|
-
* Recursively translate a filter node
|
|
31
|
-
*/
|
|
32
|
-
private translateNode;
|
|
33
|
-
/**
|
|
34
|
-
* Translate a field condition
|
|
35
|
-
*/
|
|
36
|
-
private translateFieldCondition;
|
|
37
|
-
/**
|
|
38
|
-
* Translate a logical operator
|
|
39
|
-
*/
|
|
40
|
-
private translateLogical;
|
|
41
|
-
/**
|
|
42
|
-
* Translate a specific operator
|
|
43
|
-
*/
|
|
44
|
-
private translateOperator;
|
|
45
|
-
/**
|
|
46
|
-
* Normalize a value for comparison operations
|
|
47
|
-
*/
|
|
48
|
-
protected normalizeValue(value: any): any;
|
|
49
|
-
/**
|
|
50
|
-
* Normalize array values
|
|
51
|
-
*/
|
|
52
|
-
protected normalizeArrayValues(values: any[]): any[];
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
declare class TurbopufferVector extends MastraVector {
|
|
56
|
-
private client;
|
|
57
|
-
private filterTranslator;
|
|
58
|
-
private createIndexCache;
|
|
59
|
-
private opts;
|
|
60
|
-
constructor(opts: TurbopufferVectorOptions);
|
|
61
|
-
createIndex({ indexName, dimension, metric }: CreateIndexParams): Promise<void>;
|
|
62
|
-
upsert({ indexName, vectors, metadata, ids }: UpsertVectorParams): Promise<string[]>;
|
|
63
|
-
query({ indexName, queryVector, topK, filter, includeVector }: QueryVectorParams): Promise<QueryResult[]>;
|
|
64
|
-
listIndexes(): Promise<string[]>;
|
|
65
|
-
describeIndex(indexName: string): Promise<IndexStats>;
|
|
66
|
-
deleteIndex(indexName: string): Promise<void>;
|
|
67
|
-
}
|
|
68
|
-
export { TurbopufferVector }
|
|
69
|
-
export { TurbopufferVector as TurbopufferVector_alias_1 }
|
|
70
|
-
|
|
71
|
-
declare interface TurbopufferVectorOptions {
|
|
72
|
-
/** The API key to authenticate with. */
|
|
73
|
-
apiKey: string;
|
|
74
|
-
/** The base URL. Default is https://api.turbopuffer.com. */
|
|
75
|
-
baseUrl?: string;
|
|
76
|
-
/** The timeout to establish a connection, in ms. Default is 10_000. Only applicable in Node and Deno.*/
|
|
77
|
-
connectTimeout?: number;
|
|
78
|
-
/** The socket idle timeout, in ms. Default is 60_000. Only applicable in Node and Deno.*/
|
|
79
|
-
connectionIdleTimeout?: number;
|
|
80
|
-
/** The number of connections to open initially when creating a new client. Default is 0. */
|
|
81
|
-
warmConnections?: number;
|
|
82
|
-
/** Whether to compress requests and accept compressed responses. Default is true. */
|
|
83
|
-
compression?: boolean;
|
|
84
|
-
/**
|
|
85
|
-
* A callback function that takes an index name and returns a config object for that index.
|
|
86
|
-
* This allows you to define explicit schemas per index.
|
|
87
|
-
*
|
|
88
|
-
* Example:
|
|
89
|
-
* ```typescript
|
|
90
|
-
* schemaConfigForIndex: (indexName: string) => {
|
|
91
|
-
* // Mastra's default embedding model and index for memory messages:
|
|
92
|
-
* if (indexName === "memory_messages_384") {
|
|
93
|
-
* return {
|
|
94
|
-
* dimensions: 384,
|
|
95
|
-
* schema: {
|
|
96
|
-
* thread_id: {
|
|
97
|
-
* type: "string",
|
|
98
|
-
* filterable: true,
|
|
99
|
-
* },
|
|
100
|
-
* },
|
|
101
|
-
* };
|
|
102
|
-
* } else {
|
|
103
|
-
* throw new Error(`TODO: add schema for index: ${indexName}`);
|
|
104
|
-
* }
|
|
105
|
-
* },
|
|
106
|
-
* ```
|
|
107
|
-
*/
|
|
108
|
-
schemaConfigForIndex?: (indexName: string) => {
|
|
109
|
-
dimensions: number;
|
|
110
|
-
schema: Schema;
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
export { TurbopufferVectorOptions }
|
|
114
|
-
export { TurbopufferVectorOptions as TurbopufferVectorOptions_alias_1 }
|
|
115
|
-
|
|
116
|
-
export { }
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import { BaseFilterTranslator } from '@mastra/core/vector/filter';
|
|
2
|
-
import type { CreateIndexParams } from '@mastra/core/vector';
|
|
3
|
-
import type { Filters } from '@turbopuffer/turbopuffer';
|
|
4
|
-
import type { IndexStats } from '@mastra/core/vector';
|
|
5
|
-
import { MastraVector } from '@mastra/core/vector';
|
|
6
|
-
import type { OperatorSupport } from '@mastra/core/vector/filter';
|
|
7
|
-
import type { QueryResult } from '@mastra/core/vector';
|
|
8
|
-
import type { QueryVectorParams } from '@mastra/core/vector';
|
|
9
|
-
import type { Schema } from '@turbopuffer/turbopuffer';
|
|
10
|
-
import type { UpsertVectorParams } from '@mastra/core/vector';
|
|
11
|
-
import type { VectorFilter } from '@mastra/core/vector/filter';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Translator for converting Mastra filters to Turbopuffer format
|
|
15
|
-
*
|
|
16
|
-
* Mastra filters: { field: { $gt: 10 } }
|
|
17
|
-
* Turbopuffer filters: ["And", [["field", "Gt", 10]]]
|
|
18
|
-
*/
|
|
19
|
-
export declare class TurbopufferFilterTranslator extends BaseFilterTranslator {
|
|
20
|
-
protected getSupportedOperators(): OperatorSupport;
|
|
21
|
-
/**
|
|
22
|
-
* Map Mastra operators to Turbopuffer operators
|
|
23
|
-
*/
|
|
24
|
-
private operatorMap;
|
|
25
|
-
/**
|
|
26
|
-
* Convert the Mastra filter to Turbopuffer format
|
|
27
|
-
*/
|
|
28
|
-
translate(filter?: VectorFilter): Filters | undefined;
|
|
29
|
-
/**
|
|
30
|
-
* Recursively translate a filter node
|
|
31
|
-
*/
|
|
32
|
-
private translateNode;
|
|
33
|
-
/**
|
|
34
|
-
* Translate a field condition
|
|
35
|
-
*/
|
|
36
|
-
private translateFieldCondition;
|
|
37
|
-
/**
|
|
38
|
-
* Translate a logical operator
|
|
39
|
-
*/
|
|
40
|
-
private translateLogical;
|
|
41
|
-
/**
|
|
42
|
-
* Translate a specific operator
|
|
43
|
-
*/
|
|
44
|
-
private translateOperator;
|
|
45
|
-
/**
|
|
46
|
-
* Normalize a value for comparison operations
|
|
47
|
-
*/
|
|
48
|
-
protected normalizeValue(value: any): any;
|
|
49
|
-
/**
|
|
50
|
-
* Normalize array values
|
|
51
|
-
*/
|
|
52
|
-
protected normalizeArrayValues(values: any[]): any[];
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
declare class TurbopufferVector extends MastraVector {
|
|
56
|
-
private client;
|
|
57
|
-
private filterTranslator;
|
|
58
|
-
private createIndexCache;
|
|
59
|
-
private opts;
|
|
60
|
-
constructor(opts: TurbopufferVectorOptions);
|
|
61
|
-
createIndex({ indexName, dimension, metric }: CreateIndexParams): Promise<void>;
|
|
62
|
-
upsert({ indexName, vectors, metadata, ids }: UpsertVectorParams): Promise<string[]>;
|
|
63
|
-
query({ indexName, queryVector, topK, filter, includeVector }: QueryVectorParams): Promise<QueryResult[]>;
|
|
64
|
-
listIndexes(): Promise<string[]>;
|
|
65
|
-
describeIndex(indexName: string): Promise<IndexStats>;
|
|
66
|
-
deleteIndex(indexName: string): Promise<void>;
|
|
67
|
-
}
|
|
68
|
-
export { TurbopufferVector }
|
|
69
|
-
export { TurbopufferVector as TurbopufferVector_alias_1 }
|
|
70
|
-
|
|
71
|
-
declare interface TurbopufferVectorOptions {
|
|
72
|
-
/** The API key to authenticate with. */
|
|
73
|
-
apiKey: string;
|
|
74
|
-
/** The base URL. Default is https://api.turbopuffer.com. */
|
|
75
|
-
baseUrl?: string;
|
|
76
|
-
/** The timeout to establish a connection, in ms. Default is 10_000. Only applicable in Node and Deno.*/
|
|
77
|
-
connectTimeout?: number;
|
|
78
|
-
/** The socket idle timeout, in ms. Default is 60_000. Only applicable in Node and Deno.*/
|
|
79
|
-
connectionIdleTimeout?: number;
|
|
80
|
-
/** The number of connections to open initially when creating a new client. Default is 0. */
|
|
81
|
-
warmConnections?: number;
|
|
82
|
-
/** Whether to compress requests and accept compressed responses. Default is true. */
|
|
83
|
-
compression?: boolean;
|
|
84
|
-
/**
|
|
85
|
-
* A callback function that takes an index name and returns a config object for that index.
|
|
86
|
-
* This allows you to define explicit schemas per index.
|
|
87
|
-
*
|
|
88
|
-
* Example:
|
|
89
|
-
* ```typescript
|
|
90
|
-
* schemaConfigForIndex: (indexName: string) => {
|
|
91
|
-
* // Mastra's default embedding model and index for memory messages:
|
|
92
|
-
* if (indexName === "memory_messages_384") {
|
|
93
|
-
* return {
|
|
94
|
-
* dimensions: 384,
|
|
95
|
-
* schema: {
|
|
96
|
-
* thread_id: {
|
|
97
|
-
* type: "string",
|
|
98
|
-
* filterable: true,
|
|
99
|
-
* },
|
|
100
|
-
* },
|
|
101
|
-
* };
|
|
102
|
-
* } else {
|
|
103
|
-
* throw new Error(`TODO: add schema for index: ${indexName}`);
|
|
104
|
-
* }
|
|
105
|
-
* },
|
|
106
|
-
* ```
|
|
107
|
-
*/
|
|
108
|
-
schemaConfigForIndex?: (indexName: string) => {
|
|
109
|
-
dimensions: number;
|
|
110
|
-
schema: Schema;
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
export { TurbopufferVectorOptions }
|
|
114
|
-
export { TurbopufferVectorOptions as TurbopufferVectorOptions_alias_1 }
|
|
115
|
-
|
|
116
|
-
export { }
|
package/dist/index.d.cts
DELETED