@mastra/pg 0.3.4 → 0.4.0-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.
- package/.turbo/turbo-build.log +7 -7
- package/CHANGELOG.md +37 -0
- package/dist/_tsup-dts-rollup.d.cts +21 -83
- package/dist/_tsup-dts-rollup.d.ts +21 -83
- package/dist/index.cjs +169 -185
- package/dist/index.js +169 -185
- package/docker-compose.perf.yaml +9 -9
- package/package.json +7 -4
- package/src/storage/index.test.ts +32 -51
- package/src/storage/index.ts +13 -17
- package/src/vector/index.test.ts +52 -179
- package/src/vector/index.ts +64 -152
- package/src/vector/sql-builder.ts +110 -77
- package/src/vector/vector.performance.test.ts +2 -2
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
|
|
2
|
-
> @mastra/pg@0.
|
|
2
|
+
> @mastra/pg@0.4.0-alpha.1 build /home/runner/work/mastra/mastra/stores/pg
|
|
3
3
|
> tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.ts
|
|
6
6
|
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
7
7
|
[34mCLI[39m tsup v8.4.0
|
|
8
8
|
[34mTSC[39m Build start
|
|
9
|
-
[32mTSC[39m ⚡️ Build success in
|
|
9
|
+
[32mTSC[39m ⚡️ Build success in 9665ms
|
|
10
10
|
[34mDTS[39m Build start
|
|
11
11
|
[34mCLI[39m Target: es2022
|
|
12
12
|
Analysis will use the bundled TypeScript version 5.8.3
|
|
13
13
|
[36mWriting package typings: /home/runner/work/mastra/mastra/stores/pg/dist/_tsup-dts-rollup.d.ts[39m
|
|
14
14
|
Analysis will use the bundled TypeScript version 5.8.3
|
|
15
15
|
[36mWriting package typings: /home/runner/work/mastra/mastra/stores/pg/dist/_tsup-dts-rollup.d.cts[39m
|
|
16
|
-
[32mDTS[39m ⚡️ Build success in
|
|
16
|
+
[32mDTS[39m ⚡️ Build success in 11950ms
|
|
17
17
|
[34mCLI[39m Cleaning output folder
|
|
18
18
|
[34mESM[39m Build start
|
|
19
19
|
[34mCJS[39m Build start
|
|
20
|
-
[32mESM[39m [1mdist/index.js [22m[
|
|
21
|
-
[32mESM[39m ⚡️ Build success in
|
|
22
|
-
[32mCJS[39m [1mdist/index.cjs [22m[
|
|
23
|
-
[32mCJS[39m ⚡️ Build success in
|
|
20
|
+
[32mESM[39m [1mdist/index.js [22m[32m57.30 KB[39m
|
|
21
|
+
[32mESM[39m ⚡️ Build success in 1505ms
|
|
22
|
+
[32mCJS[39m [1mdist/index.cjs [22m[32m57.80 KB[39m
|
|
23
|
+
[32mCJS[39m ⚡️ Build success in 1505ms
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,42 @@
|
|
|
1
1
|
# @mastra/pg
|
|
2
2
|
|
|
3
|
+
## 0.4.0-alpha.1
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 83da932: Move @mastra/core to peerdeps
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- b3a3d63: BREAKING: Make vnext workflow the default worklow, and old workflow legacy_workflow
|
|
12
|
+
- a7292b0: BREAKING(@mastra/core, all vector stores): Vector store breaking changes (remove deprecated functions and positional arguments)
|
|
13
|
+
- Updated dependencies [b3a3d63]
|
|
14
|
+
- Updated dependencies [344f453]
|
|
15
|
+
- Updated dependencies [0a3ae6d]
|
|
16
|
+
- Updated dependencies [95911be]
|
|
17
|
+
- Updated dependencies [5eb5a99]
|
|
18
|
+
- Updated dependencies [7e632c5]
|
|
19
|
+
- Updated dependencies [1e9fbfa]
|
|
20
|
+
- Updated dependencies [b2ae5aa]
|
|
21
|
+
- Updated dependencies [a7292b0]
|
|
22
|
+
- Updated dependencies [0dcb9f0]
|
|
23
|
+
- @mastra/core@0.10.0-alpha.1
|
|
24
|
+
|
|
25
|
+
## 0.3.5-alpha.0
|
|
26
|
+
|
|
27
|
+
### Patch Changes
|
|
28
|
+
|
|
29
|
+
- eabdcd9: [MASTRA-3451] SQL Injection Protection
|
|
30
|
+
- d0ee3c6: Change all public functions and constructors in vector stores to use named args and prepare to phase out positional args
|
|
31
|
+
- Updated dependencies [f53a6ac]
|
|
32
|
+
- Updated dependencies [eabdcd9]
|
|
33
|
+
- Updated dependencies [90be034]
|
|
34
|
+
- Updated dependencies [99f050a]
|
|
35
|
+
- Updated dependencies [d0ee3c6]
|
|
36
|
+
- Updated dependencies [23f258c]
|
|
37
|
+
- Updated dependencies [2672a05]
|
|
38
|
+
- @mastra/core@0.9.5-alpha.0
|
|
39
|
+
|
|
3
40
|
## 0.3.4
|
|
4
41
|
|
|
5
42
|
### Patch Changes
|
|
@@ -1,28 +1,23 @@
|
|
|
1
|
-
import type { ArrayOperator } from '@mastra/core/vector/filter';
|
|
2
1
|
import { BaseFilterTranslator } from '@mastra/core/vector/filter';
|
|
3
|
-
import type { BasicOperator } from '@mastra/core/vector/filter';
|
|
4
|
-
import type { CreateIndexArgs } from '@mastra/core/vector';
|
|
5
2
|
import type { CreateIndexParams } from '@mastra/core/vector';
|
|
6
|
-
import type {
|
|
3
|
+
import type { DeleteIndexParams } from '@mastra/core/vector';
|
|
4
|
+
import type { DeleteVectorParams } from '@mastra/core/vector';
|
|
5
|
+
import type { DescribeIndexParams } from '@mastra/core/vector';
|
|
7
6
|
import type { EvalRow } from '@mastra/core/storage';
|
|
8
7
|
import type { IndexStats } from '@mastra/core/vector';
|
|
9
8
|
import type { ISSLConfig } from 'pg-promise/typescript/pg-subset';
|
|
10
|
-
import type { LogicalOperator } from '@mastra/core/vector/filter';
|
|
11
9
|
import { MastraStorage } from '@mastra/core/storage';
|
|
12
10
|
import { MastraVector } from '@mastra/core/vector';
|
|
13
11
|
import type { MessageType } from '@mastra/core/memory';
|
|
14
|
-
import type { NumericOperator } from '@mastra/core/vector/filter';
|
|
15
12
|
import type { OperatorSupport } from '@mastra/core/vector/filter';
|
|
16
|
-
import type { ParamsToArgs } from '@mastra/core/vector';
|
|
17
13
|
import pg from 'pg';
|
|
18
14
|
import type { QueryResult } from '@mastra/core/vector';
|
|
19
|
-
import type { QueryVectorArgs } from '@mastra/core/vector';
|
|
20
15
|
import type { QueryVectorParams } from '@mastra/core/vector';
|
|
21
|
-
import type { RegexOperator } from '@mastra/core/vector/filter';
|
|
22
16
|
import type { StorageColumn } from '@mastra/core/storage';
|
|
23
17
|
import type { StorageGetMessagesArg } from '@mastra/core/storage';
|
|
24
18
|
import type { StorageThreadType } from '@mastra/core/memory';
|
|
25
19
|
import type { TABLE_NAMES } from '@mastra/core/storage';
|
|
20
|
+
import type { UpdateVectorParams } from '@mastra/core/vector';
|
|
26
21
|
import type { UpsertVectorParams } from '@mastra/core/vector';
|
|
27
22
|
import type { VectorFilter } from '@mastra/core/vector/filter';
|
|
28
23
|
import type { WorkflowRun } from '@mastra/core/storage';
|
|
@@ -62,7 +57,7 @@ export declare const baseTestConfigs: {
|
|
|
62
57
|
}[];
|
|
63
58
|
};
|
|
64
59
|
|
|
65
|
-
export declare function buildFilterQuery(filter: VectorFilter, minScore: number): FilterResult;
|
|
60
|
+
export declare function buildFilterQuery(filter: VectorFilter, minScore: number, topK: number): FilterResult;
|
|
66
61
|
|
|
67
62
|
export declare const calculateRecall: (actual: number[], expected: number[], k: number) => number;
|
|
68
63
|
|
|
@@ -70,15 +65,7 @@ export declare const calculateTimeout: (dimension: number, size: number, k: numb
|
|
|
70
65
|
|
|
71
66
|
export declare function cosineSimilarity(a: number[], b: number[]): number;
|
|
72
67
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
declare type FilterOperator = {
|
|
76
|
-
sql: string;
|
|
77
|
-
needsValue: boolean;
|
|
78
|
-
transformValue?: () => any;
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
export declare interface FilterResult {
|
|
68
|
+
declare interface FilterResult {
|
|
82
69
|
sql: string;
|
|
83
70
|
values: any[];
|
|
84
71
|
}
|
|
@@ -116,8 +103,6 @@ export declare function getSearchEf(k: number, m: number): {
|
|
|
116
103
|
|
|
117
104
|
export declare const groupBy: <T, K extends keyof T>(array: T[], key: K | ((item: T) => string), reducer?: (group: T[]) => any) => Record<string, any>;
|
|
118
105
|
|
|
119
|
-
export declare const handleKey: (key: string) => string;
|
|
120
|
-
|
|
121
106
|
declare interface HNSWConfig {
|
|
122
107
|
m?: number;
|
|
123
108
|
efConstruction?: number;
|
|
@@ -137,19 +122,11 @@ declare interface IVFConfig {
|
|
|
137
122
|
|
|
138
123
|
export declare function measureLatency<T>(fn: () => Promise<T>): Promise<[number, T]>;
|
|
139
124
|
|
|
140
|
-
declare type OperatorFn = (key: string, paramIndex: number, value?: any) => FilterOperator;
|
|
141
|
-
|
|
142
|
-
export declare type OperatorType = BasicOperator | NumericOperator | ArrayOperator | ElementOperator | LogicalOperator | '$contains' | Exclude<RegexOperator, '$options'>;
|
|
143
|
-
|
|
144
|
-
declare type PgCreateIndexArgs = [...CreateIndexArgs, IndexConfig?, boolean?];
|
|
145
|
-
|
|
146
125
|
declare interface PgCreateIndexParams extends CreateIndexParams {
|
|
147
126
|
indexConfig?: IndexConfig;
|
|
148
127
|
buildIndex?: boolean;
|
|
149
128
|
}
|
|
150
129
|
|
|
151
|
-
declare type PgDefineIndexArgs = [string, 'cosine' | 'euclidean' | 'dotproduct', IndexConfig];
|
|
152
|
-
|
|
153
130
|
declare interface PgDefineIndexParams {
|
|
154
131
|
indexName: string;
|
|
155
132
|
metric: 'cosine' | 'euclidean' | 'dotproduct';
|
|
@@ -185,8 +162,6 @@ declare interface PGIndexStats extends IndexStats {
|
|
|
185
162
|
export { PGIndexStats }
|
|
186
163
|
export { PGIndexStats as PGIndexStats_alias_1 }
|
|
187
164
|
|
|
188
|
-
declare type PgQueryVectorArgs = [...QueryVectorArgs, number?, number?, number?];
|
|
189
|
-
|
|
190
165
|
declare interface PgQueryVectorParams extends QueryVectorParams {
|
|
191
166
|
minScore?: number;
|
|
192
167
|
/**
|
|
@@ -211,12 +186,7 @@ declare class PgVector extends MastraVector {
|
|
|
211
186
|
private installVectorExtensionPromise;
|
|
212
187
|
private vectorExtensionInstalled;
|
|
213
188
|
private schemaSetupComplete;
|
|
214
|
-
|
|
215
|
-
* @deprecated Passing connectionString as a string is deprecated.
|
|
216
|
-
* Use the object parameter instead. This signature will be removed on May 20th, 2025.
|
|
217
|
-
*/
|
|
218
|
-
constructor(connectionString: string);
|
|
219
|
-
constructor(config: {
|
|
189
|
+
constructor({ connectionString, schemaName, pgPoolOptions, }: {
|
|
220
190
|
connectionString: string;
|
|
221
191
|
schemaName?: string;
|
|
222
192
|
pgPoolOptions?: Omit<pg.PoolConfig, 'connectionString'>;
|
|
@@ -224,43 +194,28 @@ declare class PgVector extends MastraVector {
|
|
|
224
194
|
private getMutexByName;
|
|
225
195
|
private getTableName;
|
|
226
196
|
transformFilter(filter?: VectorFilter): VectorFilter;
|
|
227
|
-
getIndexInfo(indexName:
|
|
228
|
-
query(
|
|
229
|
-
upsert(
|
|
197
|
+
getIndexInfo({ indexName }: DescribeIndexParams): Promise<PGIndexStats>;
|
|
198
|
+
query({ indexName, queryVector, topK, filter, includeVector, minScore, ef, probes, }: PgQueryVectorParams): Promise<QueryResult[]>;
|
|
199
|
+
upsert({ indexName, vectors, metadata, ids }: UpsertVectorParams): Promise<string[]>;
|
|
230
200
|
private hasher;
|
|
231
201
|
private getIndexCacheKey;
|
|
232
202
|
private cachedIndexExists;
|
|
233
203
|
private setupSchema;
|
|
234
|
-
createIndex(
|
|
235
|
-
|
|
236
|
-
* @deprecated This function is deprecated. Use buildIndex instead
|
|
237
|
-
* This function will be removed on May 20th, 2025
|
|
238
|
-
*/
|
|
239
|
-
defineIndex(indexName: string, metric: "cosine" | "euclidean" | "dotproduct" | undefined, indexConfig: IndexConfig): Promise<void>;
|
|
240
|
-
buildIndex(...args: ParamsToArgs<PgDefineIndexParams> | PgDefineIndexArgs): Promise<void>;
|
|
204
|
+
createIndex({ indexName, dimension, metric, indexConfig, buildIndex, }: PgCreateIndexParams): Promise<void>;
|
|
205
|
+
buildIndex({ indexName, metric, indexConfig }: PgDefineIndexParams): Promise<void>;
|
|
241
206
|
private setupIndex;
|
|
242
207
|
private installVectorExtension;
|
|
243
208
|
listIndexes(): Promise<string[]>;
|
|
244
|
-
describeIndex(indexName: string): Promise<PGIndexStats>;
|
|
245
|
-
deleteIndex(indexName: string): Promise<void>;
|
|
246
|
-
truncateIndex(indexName: string): Promise<void>;
|
|
247
|
-
disconnect(): Promise<void>;
|
|
248
209
|
/**
|
|
249
|
-
*
|
|
210
|
+
* Retrieves statistics about a vector index.
|
|
250
211
|
*
|
|
251
|
-
*
|
|
252
|
-
* @
|
|
253
|
-
* @param id - The ID of the vector to update.
|
|
254
|
-
* @param update - An object containing the vector and/or metadata to update.
|
|
255
|
-
* @param update.vector - An optional array of numbers representing the new vector.
|
|
256
|
-
* @param update.metadata - An optional record containing the new metadata.
|
|
257
|
-
* @returns A promise that resolves when the update is complete.
|
|
258
|
-
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
212
|
+
* @param {string} indexName - The name of the index to describe
|
|
213
|
+
* @returns A promise that resolves to the index statistics including dimension, count and metric
|
|
259
214
|
*/
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
215
|
+
describeIndex({ indexName }: DescribeIndexParams): Promise<PGIndexStats>;
|
|
216
|
+
deleteIndex({ indexName }: DeleteIndexParams): Promise<void>;
|
|
217
|
+
truncateIndex({ indexName }: DeleteIndexParams): Promise<void>;
|
|
218
|
+
disconnect(): Promise<void>;
|
|
264
219
|
/**
|
|
265
220
|
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
266
221
|
* @param indexName - The name of the index containing the vector.
|
|
@@ -271,20 +226,7 @@ declare class PgVector extends MastraVector {
|
|
|
271
226
|
* @returns A promise that resolves when the update is complete.
|
|
272
227
|
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
273
228
|
*/
|
|
274
|
-
updateVector(indexName
|
|
275
|
-
vector?: number[];
|
|
276
|
-
metadata?: Record<string, any>;
|
|
277
|
-
}): Promise<void>;
|
|
278
|
-
/**
|
|
279
|
-
* @deprecated Use {@link deleteVector} instead. This method will be removed on May 20th, 2025.
|
|
280
|
-
*
|
|
281
|
-
* Deletes a vector by its ID.
|
|
282
|
-
* @param indexName - The name of the index containing the vector.
|
|
283
|
-
* @param id - The ID of the vector to delete.
|
|
284
|
-
* @returns A promise that resolves when the deletion is complete.
|
|
285
|
-
* @throws Will throw an error if the deletion operation fails.
|
|
286
|
-
*/
|
|
287
|
-
deleteIndexById(indexName: string, id: string): Promise<void>;
|
|
229
|
+
updateVector({ indexName, id, update }: UpdateVectorParams): Promise<void>;
|
|
288
230
|
/**
|
|
289
231
|
* Deletes a vector by its ID.
|
|
290
232
|
* @param indexName - The name of the index containing the vector.
|
|
@@ -292,7 +234,7 @@ declare class PgVector extends MastraVector {
|
|
|
292
234
|
* @returns A promise that resolves when the deletion is complete.
|
|
293
235
|
* @throws Will throw an error if the deletion operation fails.
|
|
294
236
|
*/
|
|
295
|
-
deleteVector(indexName
|
|
237
|
+
deleteVector({ indexName, id }: DeleteVectorParams): Promise<void>;
|
|
296
238
|
}
|
|
297
239
|
export { PgVector }
|
|
298
240
|
export { PgVector as PgVector_alias_1 }
|
|
@@ -307,10 +249,6 @@ export { PGVECTOR_PROMPT as PGVECTOR_PROMPT_alias_1 }
|
|
|
307
249
|
|
|
308
250
|
declare type PostgresConfig = {
|
|
309
251
|
schemaName?: string;
|
|
310
|
-
/**
|
|
311
|
-
* @deprecated Use `schemaName` instead. Support for `schema` will be removed on May 20th, 2025.
|
|
312
|
-
*/
|
|
313
|
-
schema?: string;
|
|
314
252
|
} & ({
|
|
315
253
|
host: string;
|
|
316
254
|
port: number;
|
|
@@ -1,28 +1,23 @@
|
|
|
1
|
-
import type { ArrayOperator } from '@mastra/core/vector/filter';
|
|
2
1
|
import { BaseFilterTranslator } from '@mastra/core/vector/filter';
|
|
3
|
-
import type { BasicOperator } from '@mastra/core/vector/filter';
|
|
4
|
-
import type { CreateIndexArgs } from '@mastra/core/vector';
|
|
5
2
|
import type { CreateIndexParams } from '@mastra/core/vector';
|
|
6
|
-
import type {
|
|
3
|
+
import type { DeleteIndexParams } from '@mastra/core/vector';
|
|
4
|
+
import type { DeleteVectorParams } from '@mastra/core/vector';
|
|
5
|
+
import type { DescribeIndexParams } from '@mastra/core/vector';
|
|
7
6
|
import type { EvalRow } from '@mastra/core/storage';
|
|
8
7
|
import type { IndexStats } from '@mastra/core/vector';
|
|
9
8
|
import type { ISSLConfig } from 'pg-promise/typescript/pg-subset';
|
|
10
|
-
import type { LogicalOperator } from '@mastra/core/vector/filter';
|
|
11
9
|
import { MastraStorage } from '@mastra/core/storage';
|
|
12
10
|
import { MastraVector } from '@mastra/core/vector';
|
|
13
11
|
import type { MessageType } from '@mastra/core/memory';
|
|
14
|
-
import type { NumericOperator } from '@mastra/core/vector/filter';
|
|
15
12
|
import type { OperatorSupport } from '@mastra/core/vector/filter';
|
|
16
|
-
import type { ParamsToArgs } from '@mastra/core/vector';
|
|
17
13
|
import pg from 'pg';
|
|
18
14
|
import type { QueryResult } from '@mastra/core/vector';
|
|
19
|
-
import type { QueryVectorArgs } from '@mastra/core/vector';
|
|
20
15
|
import type { QueryVectorParams } from '@mastra/core/vector';
|
|
21
|
-
import type { RegexOperator } from '@mastra/core/vector/filter';
|
|
22
16
|
import type { StorageColumn } from '@mastra/core/storage';
|
|
23
17
|
import type { StorageGetMessagesArg } from '@mastra/core/storage';
|
|
24
18
|
import type { StorageThreadType } from '@mastra/core/memory';
|
|
25
19
|
import type { TABLE_NAMES } from '@mastra/core/storage';
|
|
20
|
+
import type { UpdateVectorParams } from '@mastra/core/vector';
|
|
26
21
|
import type { UpsertVectorParams } from '@mastra/core/vector';
|
|
27
22
|
import type { VectorFilter } from '@mastra/core/vector/filter';
|
|
28
23
|
import type { WorkflowRun } from '@mastra/core/storage';
|
|
@@ -62,7 +57,7 @@ export declare const baseTestConfigs: {
|
|
|
62
57
|
}[];
|
|
63
58
|
};
|
|
64
59
|
|
|
65
|
-
export declare function buildFilterQuery(filter: VectorFilter, minScore: number): FilterResult;
|
|
60
|
+
export declare function buildFilterQuery(filter: VectorFilter, minScore: number, topK: number): FilterResult;
|
|
66
61
|
|
|
67
62
|
export declare const calculateRecall: (actual: number[], expected: number[], k: number) => number;
|
|
68
63
|
|
|
@@ -70,15 +65,7 @@ export declare const calculateTimeout: (dimension: number, size: number, k: numb
|
|
|
70
65
|
|
|
71
66
|
export declare function cosineSimilarity(a: number[], b: number[]): number;
|
|
72
67
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
declare type FilterOperator = {
|
|
76
|
-
sql: string;
|
|
77
|
-
needsValue: boolean;
|
|
78
|
-
transformValue?: () => any;
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
export declare interface FilterResult {
|
|
68
|
+
declare interface FilterResult {
|
|
82
69
|
sql: string;
|
|
83
70
|
values: any[];
|
|
84
71
|
}
|
|
@@ -116,8 +103,6 @@ export declare function getSearchEf(k: number, m: number): {
|
|
|
116
103
|
|
|
117
104
|
export declare const groupBy: <T, K extends keyof T>(array: T[], key: K | ((item: T) => string), reducer?: (group: T[]) => any) => Record<string, any>;
|
|
118
105
|
|
|
119
|
-
export declare const handleKey: (key: string) => string;
|
|
120
|
-
|
|
121
106
|
declare interface HNSWConfig {
|
|
122
107
|
m?: number;
|
|
123
108
|
efConstruction?: number;
|
|
@@ -137,19 +122,11 @@ declare interface IVFConfig {
|
|
|
137
122
|
|
|
138
123
|
export declare function measureLatency<T>(fn: () => Promise<T>): Promise<[number, T]>;
|
|
139
124
|
|
|
140
|
-
declare type OperatorFn = (key: string, paramIndex: number, value?: any) => FilterOperator;
|
|
141
|
-
|
|
142
|
-
export declare type OperatorType = BasicOperator | NumericOperator | ArrayOperator | ElementOperator | LogicalOperator | '$contains' | Exclude<RegexOperator, '$options'>;
|
|
143
|
-
|
|
144
|
-
declare type PgCreateIndexArgs = [...CreateIndexArgs, IndexConfig?, boolean?];
|
|
145
|
-
|
|
146
125
|
declare interface PgCreateIndexParams extends CreateIndexParams {
|
|
147
126
|
indexConfig?: IndexConfig;
|
|
148
127
|
buildIndex?: boolean;
|
|
149
128
|
}
|
|
150
129
|
|
|
151
|
-
declare type PgDefineIndexArgs = [string, 'cosine' | 'euclidean' | 'dotproduct', IndexConfig];
|
|
152
|
-
|
|
153
130
|
declare interface PgDefineIndexParams {
|
|
154
131
|
indexName: string;
|
|
155
132
|
metric: 'cosine' | 'euclidean' | 'dotproduct';
|
|
@@ -185,8 +162,6 @@ declare interface PGIndexStats extends IndexStats {
|
|
|
185
162
|
export { PGIndexStats }
|
|
186
163
|
export { PGIndexStats as PGIndexStats_alias_1 }
|
|
187
164
|
|
|
188
|
-
declare type PgQueryVectorArgs = [...QueryVectorArgs, number?, number?, number?];
|
|
189
|
-
|
|
190
165
|
declare interface PgQueryVectorParams extends QueryVectorParams {
|
|
191
166
|
minScore?: number;
|
|
192
167
|
/**
|
|
@@ -211,12 +186,7 @@ declare class PgVector extends MastraVector {
|
|
|
211
186
|
private installVectorExtensionPromise;
|
|
212
187
|
private vectorExtensionInstalled;
|
|
213
188
|
private schemaSetupComplete;
|
|
214
|
-
|
|
215
|
-
* @deprecated Passing connectionString as a string is deprecated.
|
|
216
|
-
* Use the object parameter instead. This signature will be removed on May 20th, 2025.
|
|
217
|
-
*/
|
|
218
|
-
constructor(connectionString: string);
|
|
219
|
-
constructor(config: {
|
|
189
|
+
constructor({ connectionString, schemaName, pgPoolOptions, }: {
|
|
220
190
|
connectionString: string;
|
|
221
191
|
schemaName?: string;
|
|
222
192
|
pgPoolOptions?: Omit<pg.PoolConfig, 'connectionString'>;
|
|
@@ -224,43 +194,28 @@ declare class PgVector extends MastraVector {
|
|
|
224
194
|
private getMutexByName;
|
|
225
195
|
private getTableName;
|
|
226
196
|
transformFilter(filter?: VectorFilter): VectorFilter;
|
|
227
|
-
getIndexInfo(indexName:
|
|
228
|
-
query(
|
|
229
|
-
upsert(
|
|
197
|
+
getIndexInfo({ indexName }: DescribeIndexParams): Promise<PGIndexStats>;
|
|
198
|
+
query({ indexName, queryVector, topK, filter, includeVector, minScore, ef, probes, }: PgQueryVectorParams): Promise<QueryResult[]>;
|
|
199
|
+
upsert({ indexName, vectors, metadata, ids }: UpsertVectorParams): Promise<string[]>;
|
|
230
200
|
private hasher;
|
|
231
201
|
private getIndexCacheKey;
|
|
232
202
|
private cachedIndexExists;
|
|
233
203
|
private setupSchema;
|
|
234
|
-
createIndex(
|
|
235
|
-
|
|
236
|
-
* @deprecated This function is deprecated. Use buildIndex instead
|
|
237
|
-
* This function will be removed on May 20th, 2025
|
|
238
|
-
*/
|
|
239
|
-
defineIndex(indexName: string, metric: "cosine" | "euclidean" | "dotproduct" | undefined, indexConfig: IndexConfig): Promise<void>;
|
|
240
|
-
buildIndex(...args: ParamsToArgs<PgDefineIndexParams> | PgDefineIndexArgs): Promise<void>;
|
|
204
|
+
createIndex({ indexName, dimension, metric, indexConfig, buildIndex, }: PgCreateIndexParams): Promise<void>;
|
|
205
|
+
buildIndex({ indexName, metric, indexConfig }: PgDefineIndexParams): Promise<void>;
|
|
241
206
|
private setupIndex;
|
|
242
207
|
private installVectorExtension;
|
|
243
208
|
listIndexes(): Promise<string[]>;
|
|
244
|
-
describeIndex(indexName: string): Promise<PGIndexStats>;
|
|
245
|
-
deleteIndex(indexName: string): Promise<void>;
|
|
246
|
-
truncateIndex(indexName: string): Promise<void>;
|
|
247
|
-
disconnect(): Promise<void>;
|
|
248
209
|
/**
|
|
249
|
-
*
|
|
210
|
+
* Retrieves statistics about a vector index.
|
|
250
211
|
*
|
|
251
|
-
*
|
|
252
|
-
* @
|
|
253
|
-
* @param id - The ID of the vector to update.
|
|
254
|
-
* @param update - An object containing the vector and/or metadata to update.
|
|
255
|
-
* @param update.vector - An optional array of numbers representing the new vector.
|
|
256
|
-
* @param update.metadata - An optional record containing the new metadata.
|
|
257
|
-
* @returns A promise that resolves when the update is complete.
|
|
258
|
-
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
212
|
+
* @param {string} indexName - The name of the index to describe
|
|
213
|
+
* @returns A promise that resolves to the index statistics including dimension, count and metric
|
|
259
214
|
*/
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
215
|
+
describeIndex({ indexName }: DescribeIndexParams): Promise<PGIndexStats>;
|
|
216
|
+
deleteIndex({ indexName }: DeleteIndexParams): Promise<void>;
|
|
217
|
+
truncateIndex({ indexName }: DeleteIndexParams): Promise<void>;
|
|
218
|
+
disconnect(): Promise<void>;
|
|
264
219
|
/**
|
|
265
220
|
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
266
221
|
* @param indexName - The name of the index containing the vector.
|
|
@@ -271,20 +226,7 @@ declare class PgVector extends MastraVector {
|
|
|
271
226
|
* @returns A promise that resolves when the update is complete.
|
|
272
227
|
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
273
228
|
*/
|
|
274
|
-
updateVector(indexName
|
|
275
|
-
vector?: number[];
|
|
276
|
-
metadata?: Record<string, any>;
|
|
277
|
-
}): Promise<void>;
|
|
278
|
-
/**
|
|
279
|
-
* @deprecated Use {@link deleteVector} instead. This method will be removed on May 20th, 2025.
|
|
280
|
-
*
|
|
281
|
-
* Deletes a vector by its ID.
|
|
282
|
-
* @param indexName - The name of the index containing the vector.
|
|
283
|
-
* @param id - The ID of the vector to delete.
|
|
284
|
-
* @returns A promise that resolves when the deletion is complete.
|
|
285
|
-
* @throws Will throw an error if the deletion operation fails.
|
|
286
|
-
*/
|
|
287
|
-
deleteIndexById(indexName: string, id: string): Promise<void>;
|
|
229
|
+
updateVector({ indexName, id, update }: UpdateVectorParams): Promise<void>;
|
|
288
230
|
/**
|
|
289
231
|
* Deletes a vector by its ID.
|
|
290
232
|
* @param indexName - The name of the index containing the vector.
|
|
@@ -292,7 +234,7 @@ declare class PgVector extends MastraVector {
|
|
|
292
234
|
* @returns A promise that resolves when the deletion is complete.
|
|
293
235
|
* @throws Will throw an error if the deletion operation fails.
|
|
294
236
|
*/
|
|
295
|
-
deleteVector(indexName
|
|
237
|
+
deleteVector({ indexName, id }: DeleteVectorParams): Promise<void>;
|
|
296
238
|
}
|
|
297
239
|
export { PgVector }
|
|
298
240
|
export { PgVector as PgVector_alias_1 }
|
|
@@ -307,10 +249,6 @@ export { PGVECTOR_PROMPT as PGVECTOR_PROMPT_alias_1 }
|
|
|
307
249
|
|
|
308
250
|
declare type PostgresConfig = {
|
|
309
251
|
schemaName?: string;
|
|
310
|
-
/**
|
|
311
|
-
* @deprecated Use `schemaName` instead. Support for `schema` will be removed on May 20th, 2025.
|
|
312
|
-
*/
|
|
313
|
-
schema?: string;
|
|
314
252
|
} & ({
|
|
315
253
|
host: string;
|
|
316
254
|
port: number;
|