@mastra/pg 0.3.4-alpha.5 → 0.3.5-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.
@@ -1,23 +1,23 @@
1
1
 
2
- > @mastra/pg@0.3.4-alpha.5 build /home/runner/work/mastra/mastra/stores/pg
2
+ > @mastra/pg@0.3.5-alpha.0 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
  CLI Building entry: src/index.ts
6
6
  CLI Using tsconfig: tsconfig.json
7
7
  CLI tsup v8.4.0
8
8
  TSC Build start
9
- TSC ⚡️ Build success in 10773ms
9
+ TSC ⚡️ Build success in 9464ms
10
10
  DTS Build start
11
11
  CLI Target: es2022
12
12
  Analysis will use the bundled TypeScript version 5.8.3
13
13
  Writing package typings: /home/runner/work/mastra/mastra/stores/pg/dist/_tsup-dts-rollup.d.ts
14
14
  Analysis will use the bundled TypeScript version 5.8.3
15
15
  Writing package typings: /home/runner/work/mastra/mastra/stores/pg/dist/_tsup-dts-rollup.d.cts
16
- DTS ⚡️ Build success in 12198ms
16
+ DTS ⚡️ Build success in 12331ms
17
17
  CLI Cleaning output folder
18
18
  ESM Build start
19
19
  CJS Build start
20
- CJS dist/index.cjs 58.86 KB
21
- CJS ⚡️ Build success in 1568ms
22
- ESM dist/index.js 58.39 KB
23
- ESM ⚡️ Build success in 1568ms
20
+ CJS dist/index.cjs 61.67 KB
21
+ CJS ⚡️ Build success in 1494ms
22
+ ESM dist/index.js 61.16 KB
23
+ ESM ⚡️ Build success in 1495ms
package/CHANGELOG.md CHANGED
@@ -1,5 +1,43 @@
1
1
  # @mastra/pg
2
2
 
3
+ ## 0.3.5-alpha.0
4
+
5
+ ### Patch Changes
6
+
7
+ - eabdcd9: [MASTRA-3451] SQL Injection Protection
8
+ - d0ee3c6: Change all public functions and constructors in vector stores to use named args and prepare to phase out positional args
9
+ - Updated dependencies [f53a6ac]
10
+ - Updated dependencies [eabdcd9]
11
+ - Updated dependencies [90be034]
12
+ - Updated dependencies [99f050a]
13
+ - Updated dependencies [d0ee3c6]
14
+ - Updated dependencies [23f258c]
15
+ - Updated dependencies [2672a05]
16
+ - @mastra/core@0.9.5-alpha.0
17
+
18
+ ## 0.3.4
19
+
20
+ ### Patch Changes
21
+
22
+ - c3bd795: [MASTRA-3358] Deprecate updateIndexById and deleteIndexById
23
+ - 2836734: [MASTRA-3391] fix describe index for custom schema
24
+ - a3fc60c: fix whereClause condition for fromDate and toDate in pg getTraces
25
+ - Updated dependencies [396be50]
26
+ - Updated dependencies [ab80e7e]
27
+ - Updated dependencies [c3bd795]
28
+ - Updated dependencies [da082f8]
29
+ - Updated dependencies [a5810ce]
30
+ - Updated dependencies [3e9c131]
31
+ - Updated dependencies [3171b5b]
32
+ - Updated dependencies [973e5ac]
33
+ - Updated dependencies [daf942f]
34
+ - Updated dependencies [0b8b868]
35
+ - Updated dependencies [9e1eff5]
36
+ - Updated dependencies [6fa1ad1]
37
+ - Updated dependencies [c28d7a0]
38
+ - Updated dependencies [edf1e88]
39
+ - @mastra/core@0.9.4
40
+
3
41
  ## 0.3.4-alpha.5
4
42
 
5
43
  ### Patch Changes
@@ -1,28 +1,26 @@
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
2
  import type { CreateIndexArgs } from '@mastra/core/vector';
5
3
  import type { CreateIndexParams } from '@mastra/core/vector';
6
- import type { ElementOperator } from '@mastra/core/vector/filter';
4
+ import type { DeleteIndexParams } from '@mastra/core/vector';
5
+ import type { DeleteVectorParams } from '@mastra/core/vector';
6
+ import type { DescribeIndexParams } from '@mastra/core/vector';
7
7
  import type { EvalRow } from '@mastra/core/storage';
8
8
  import type { IndexStats } from '@mastra/core/vector';
9
9
  import type { ISSLConfig } from 'pg-promise/typescript/pg-subset';
10
- import type { LogicalOperator } from '@mastra/core/vector/filter';
11
10
  import { MastraStorage } from '@mastra/core/storage';
12
11
  import { MastraVector } from '@mastra/core/vector';
13
12
  import type { MessageType } from '@mastra/core/memory';
14
- import type { NumericOperator } from '@mastra/core/vector/filter';
15
13
  import type { OperatorSupport } from '@mastra/core/vector/filter';
16
14
  import type { ParamsToArgs } from '@mastra/core/vector';
17
15
  import pg from 'pg';
18
16
  import type { QueryResult } from '@mastra/core/vector';
19
17
  import type { QueryVectorArgs } from '@mastra/core/vector';
20
18
  import type { QueryVectorParams } from '@mastra/core/vector';
21
- import type { RegexOperator } from '@mastra/core/vector/filter';
22
19
  import type { StorageColumn } from '@mastra/core/storage';
23
20
  import type { StorageGetMessagesArg } from '@mastra/core/storage';
24
21
  import type { StorageThreadType } from '@mastra/core/memory';
25
22
  import type { TABLE_NAMES } from '@mastra/core/storage';
23
+ import type { UpdateVectorParams } from '@mastra/core/vector';
26
24
  import type { UpsertVectorParams } from '@mastra/core/vector';
27
25
  import type { VectorFilter } from '@mastra/core/vector/filter';
28
26
  import type { WorkflowRun } from '@mastra/core/storage';
@@ -62,7 +60,7 @@ export declare const baseTestConfigs: {
62
60
  }[];
63
61
  };
64
62
 
65
- export declare function buildFilterQuery(filter: VectorFilter, minScore: number): FilterResult;
63
+ export declare function buildFilterQuery(filter: VectorFilter, minScore: number, topK: number): FilterResult;
66
64
 
67
65
  export declare const calculateRecall: (actual: number[], expected: number[], k: number) => number;
68
66
 
@@ -70,15 +68,7 @@ export declare const calculateTimeout: (dimension: number, size: number, k: numb
70
68
 
71
69
  export declare function cosineSimilarity(a: number[], b: number[]): number;
72
70
 
73
- export declare const FILTER_OPERATORS: Record<string, OperatorFn>;
74
-
75
- declare type FilterOperator = {
76
- sql: string;
77
- needsValue: boolean;
78
- transformValue?: () => any;
79
- };
80
-
81
- export declare interface FilterResult {
71
+ declare interface FilterResult {
82
72
  sql: string;
83
73
  values: any[];
84
74
  }
@@ -116,8 +106,6 @@ export declare function getSearchEf(k: number, m: number): {
116
106
 
117
107
  export declare const groupBy: <T, K extends keyof T>(array: T[], key: K | ((item: T) => string), reducer?: (group: T[]) => any) => Record<string, any>;
118
108
 
119
- export declare const handleKey: (key: string) => string;
120
-
121
109
  declare interface HNSWConfig {
122
110
  m?: number;
123
111
  efConstruction?: number;
@@ -137,10 +125,6 @@ declare interface IVFConfig {
137
125
 
138
126
  export declare function measureLatency<T>(fn: () => Promise<T>): Promise<[number, T]>;
139
127
 
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
128
  declare type PgCreateIndexArgs = [...CreateIndexArgs, IndexConfig?, boolean?];
145
129
 
146
130
  declare interface PgCreateIndexParams extends CreateIndexParams {
@@ -224,7 +208,7 @@ declare class PgVector extends MastraVector {
224
208
  private getMutexByName;
225
209
  private getTableName;
226
210
  transformFilter(filter?: VectorFilter): VectorFilter;
227
- getIndexInfo(indexName: string): Promise<PGIndexStats>;
211
+ getIndexInfo(...args: ParamsToArgs<DescribeIndexParams>): Promise<PGIndexStats>;
228
212
  query(...args: ParamsToArgs<PgQueryVectorParams> | PgQueryVectorArgs): Promise<QueryResult[]>;
229
213
  upsert(...args: ParamsToArgs<UpsertVectorParams>): Promise<string[]>;
230
214
  private hasher;
@@ -241,9 +225,16 @@ declare class PgVector extends MastraVector {
241
225
  private setupIndex;
242
226
  private installVectorExtension;
243
227
  listIndexes(): Promise<string[]>;
244
- describeIndex(indexName: string): Promise<PGIndexStats>;
245
- deleteIndex(indexName: string): Promise<void>;
246
- truncateIndex(indexName: string): Promise<void>;
228
+ /**
229
+ * Retrieves statistics about a vector index.
230
+ *
231
+ * @param params - The parameters for describing an index
232
+ * @param params.indexName - The name of the index to describe
233
+ * @returns A promise that resolves to the index statistics including dimension, count and metric
234
+ */
235
+ describeIndex(...args: ParamsToArgs<DescribeIndexParams>): Promise<PGIndexStats>;
236
+ deleteIndex(...args: ParamsToArgs<DeleteIndexParams>): Promise<void>;
237
+ truncateIndex(...args: ParamsToArgs<DeleteIndexParams>): Promise<void>;
247
238
  disconnect(): Promise<void>;
248
239
  /**
249
240
  * @deprecated Use {@link updateVector} instead. This method will be removed on May 20th, 2025.
@@ -271,10 +262,7 @@ declare class PgVector extends MastraVector {
271
262
  * @returns A promise that resolves when the update is complete.
272
263
  * @throws Will throw an error if no updates are provided or if the update operation fails.
273
264
  */
274
- updateVector(indexName: string, id: string, update: {
275
- vector?: number[];
276
- metadata?: Record<string, any>;
277
- }): Promise<void>;
265
+ updateVector(...args: ParamsToArgs<UpdateVectorParams>): Promise<void>;
278
266
  /**
279
267
  * @deprecated Use {@link deleteVector} instead. This method will be removed on May 20th, 2025.
280
268
  *
@@ -292,7 +280,7 @@ declare class PgVector extends MastraVector {
292
280
  * @returns A promise that resolves when the deletion is complete.
293
281
  * @throws Will throw an error if the deletion operation fails.
294
282
  */
295
- deleteVector(indexName: string, id: string): Promise<void>;
283
+ deleteVector(...args: ParamsToArgs<DeleteVectorParams>): Promise<void>;
296
284
  }
297
285
  export { PgVector }
298
286
  export { PgVector as PgVector_alias_1 }
@@ -1,28 +1,26 @@
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
2
  import type { CreateIndexArgs } from '@mastra/core/vector';
5
3
  import type { CreateIndexParams } from '@mastra/core/vector';
6
- import type { ElementOperator } from '@mastra/core/vector/filter';
4
+ import type { DeleteIndexParams } from '@mastra/core/vector';
5
+ import type { DeleteVectorParams } from '@mastra/core/vector';
6
+ import type { DescribeIndexParams } from '@mastra/core/vector';
7
7
  import type { EvalRow } from '@mastra/core/storage';
8
8
  import type { IndexStats } from '@mastra/core/vector';
9
9
  import type { ISSLConfig } from 'pg-promise/typescript/pg-subset';
10
- import type { LogicalOperator } from '@mastra/core/vector/filter';
11
10
  import { MastraStorage } from '@mastra/core/storage';
12
11
  import { MastraVector } from '@mastra/core/vector';
13
12
  import type { MessageType } from '@mastra/core/memory';
14
- import type { NumericOperator } from '@mastra/core/vector/filter';
15
13
  import type { OperatorSupport } from '@mastra/core/vector/filter';
16
14
  import type { ParamsToArgs } from '@mastra/core/vector';
17
15
  import pg from 'pg';
18
16
  import type { QueryResult } from '@mastra/core/vector';
19
17
  import type { QueryVectorArgs } from '@mastra/core/vector';
20
18
  import type { QueryVectorParams } from '@mastra/core/vector';
21
- import type { RegexOperator } from '@mastra/core/vector/filter';
22
19
  import type { StorageColumn } from '@mastra/core/storage';
23
20
  import type { StorageGetMessagesArg } from '@mastra/core/storage';
24
21
  import type { StorageThreadType } from '@mastra/core/memory';
25
22
  import type { TABLE_NAMES } from '@mastra/core/storage';
23
+ import type { UpdateVectorParams } from '@mastra/core/vector';
26
24
  import type { UpsertVectorParams } from '@mastra/core/vector';
27
25
  import type { VectorFilter } from '@mastra/core/vector/filter';
28
26
  import type { WorkflowRun } from '@mastra/core/storage';
@@ -62,7 +60,7 @@ export declare const baseTestConfigs: {
62
60
  }[];
63
61
  };
64
62
 
65
- export declare function buildFilterQuery(filter: VectorFilter, minScore: number): FilterResult;
63
+ export declare function buildFilterQuery(filter: VectorFilter, minScore: number, topK: number): FilterResult;
66
64
 
67
65
  export declare const calculateRecall: (actual: number[], expected: number[], k: number) => number;
68
66
 
@@ -70,15 +68,7 @@ export declare const calculateTimeout: (dimension: number, size: number, k: numb
70
68
 
71
69
  export declare function cosineSimilarity(a: number[], b: number[]): number;
72
70
 
73
- export declare const FILTER_OPERATORS: Record<string, OperatorFn>;
74
-
75
- declare type FilterOperator = {
76
- sql: string;
77
- needsValue: boolean;
78
- transformValue?: () => any;
79
- };
80
-
81
- export declare interface FilterResult {
71
+ declare interface FilterResult {
82
72
  sql: string;
83
73
  values: any[];
84
74
  }
@@ -116,8 +106,6 @@ export declare function getSearchEf(k: number, m: number): {
116
106
 
117
107
  export declare const groupBy: <T, K extends keyof T>(array: T[], key: K | ((item: T) => string), reducer?: (group: T[]) => any) => Record<string, any>;
118
108
 
119
- export declare const handleKey: (key: string) => string;
120
-
121
109
  declare interface HNSWConfig {
122
110
  m?: number;
123
111
  efConstruction?: number;
@@ -137,10 +125,6 @@ declare interface IVFConfig {
137
125
 
138
126
  export declare function measureLatency<T>(fn: () => Promise<T>): Promise<[number, T]>;
139
127
 
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
128
  declare type PgCreateIndexArgs = [...CreateIndexArgs, IndexConfig?, boolean?];
145
129
 
146
130
  declare interface PgCreateIndexParams extends CreateIndexParams {
@@ -224,7 +208,7 @@ declare class PgVector extends MastraVector {
224
208
  private getMutexByName;
225
209
  private getTableName;
226
210
  transformFilter(filter?: VectorFilter): VectorFilter;
227
- getIndexInfo(indexName: string): Promise<PGIndexStats>;
211
+ getIndexInfo(...args: ParamsToArgs<DescribeIndexParams>): Promise<PGIndexStats>;
228
212
  query(...args: ParamsToArgs<PgQueryVectorParams> | PgQueryVectorArgs): Promise<QueryResult[]>;
229
213
  upsert(...args: ParamsToArgs<UpsertVectorParams>): Promise<string[]>;
230
214
  private hasher;
@@ -241,9 +225,16 @@ declare class PgVector extends MastraVector {
241
225
  private setupIndex;
242
226
  private installVectorExtension;
243
227
  listIndexes(): Promise<string[]>;
244
- describeIndex(indexName: string): Promise<PGIndexStats>;
245
- deleteIndex(indexName: string): Promise<void>;
246
- truncateIndex(indexName: string): Promise<void>;
228
+ /**
229
+ * Retrieves statistics about a vector index.
230
+ *
231
+ * @param params - The parameters for describing an index
232
+ * @param params.indexName - The name of the index to describe
233
+ * @returns A promise that resolves to the index statistics including dimension, count and metric
234
+ */
235
+ describeIndex(...args: ParamsToArgs<DescribeIndexParams>): Promise<PGIndexStats>;
236
+ deleteIndex(...args: ParamsToArgs<DeleteIndexParams>): Promise<void>;
237
+ truncateIndex(...args: ParamsToArgs<DeleteIndexParams>): Promise<void>;
247
238
  disconnect(): Promise<void>;
248
239
  /**
249
240
  * @deprecated Use {@link updateVector} instead. This method will be removed on May 20th, 2025.
@@ -271,10 +262,7 @@ declare class PgVector extends MastraVector {
271
262
  * @returns A promise that resolves when the update is complete.
272
263
  * @throws Will throw an error if no updates are provided or if the update operation fails.
273
264
  */
274
- updateVector(indexName: string, id: string, update: {
275
- vector?: number[];
276
- metadata?: Record<string, any>;
277
- }): Promise<void>;
265
+ updateVector(...args: ParamsToArgs<UpdateVectorParams>): Promise<void>;
278
266
  /**
279
267
  * @deprecated Use {@link deleteVector} instead. This method will be removed on May 20th, 2025.
280
268
  *
@@ -292,7 +280,7 @@ declare class PgVector extends MastraVector {
292
280
  * @returns A promise that resolves when the deletion is complete.
293
281
  * @throws Will throw an error if the deletion operation fails.
294
282
  */
295
- deleteVector(indexName: string, id: string): Promise<void>;
283
+ deleteVector(...args: ParamsToArgs<DeleteVectorParams>): Promise<void>;
296
284
  }
297
285
  export { PgVector }
298
286
  export { PgVector as PgVector_alias_1 }