@mastra/pg 0.11.1-alpha.0 → 0.11.1-alpha.2

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.11.1-alpha.0 build /home/runner/work/mastra/mastra/stores/pg
2
+ > @mastra/pg@0.11.1-alpha.2 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.5.0
8
8
  TSC Build start
9
- TSC ⚡️ Build success in 11031ms
9
+ TSC ⚡️ Build success in 10545ms
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 11090ms
16
+ DTS ⚡️ Build success in 12254ms
17
17
  CLI Cleaning output folder
18
18
  ESM Build start
19
19
  CJS Build start
20
- ESM dist/index.js 71.25 KB
21
- ESM ⚡️ Build success in 1507ms
22
- CJS dist/index.cjs 71.84 KB
23
- CJS ⚡️ Build success in 1506ms
20
+ CJS dist/index.cjs 87.61 KB
21
+ CJS ⚡️ Build success in 1984ms
22
+ ESM dist/index.js 86.23 KB
23
+ ESM ⚡️ Build success in 1985ms
package/CHANGELOG.md CHANGED
@@ -1,5 +1,33 @@
1
1
  # @mastra/pg
2
2
 
3
+ ## 0.11.1-alpha.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 15e9d26: Added per-resource working memory for LibSQL, Upstash, and PG
8
+ - 0fb9d64: [MASTRA-4018] Update saveMessages in storage adapters to upsert messages
9
+ - 144eb0b: [MASTRA-3669] Metadata Filter Types
10
+ - f0150c4: Fix LibSQLStore and PgStore getMessagesPaginated implementation
11
+ - Updated dependencies [15e9d26]
12
+ - Updated dependencies [07d6d88]
13
+ - Updated dependencies [5d74aab]
14
+ - Updated dependencies [144eb0b]
15
+ - @mastra/core@0.10.7-alpha.2
16
+
17
+ ## 0.11.1-alpha.1
18
+
19
+ ### Patch Changes
20
+
21
+ - 2097952: [MASTRA-4021] Fix PG getMessages and update messageLimit for all storage adapters
22
+ - 0e17048: Throw mastra errors in storage packages
23
+ - Updated dependencies [d1baedb]
24
+ - Updated dependencies [4d21bf2]
25
+ - Updated dependencies [2097952]
26
+ - Updated dependencies [4fb0cc2]
27
+ - Updated dependencies [d2a7a31]
28
+ - Updated dependencies [0e17048]
29
+ - @mastra/core@0.10.7-alpha.1
30
+
3
31
  ## 0.11.1-alpha.0
4
32
 
5
33
  ### Patch Changes
@@ -1,4 +1,5 @@
1
1
  import { BaseFilterTranslator } from '@mastra/core/vector/filter';
2
+ import type { BlacklistedRootOperators } from '@mastra/core/vector/filter';
2
3
  import type { CreateIndexParams } from '@mastra/core/vector';
3
4
  import type { DeleteIndexParams } from '@mastra/core/vector';
4
5
  import type { DeleteVectorParams } from '@mastra/core/vector';
@@ -6,12 +7,14 @@ import type { DescribeIndexParams } from '@mastra/core/vector';
6
7
  import type { EvalRow } from '@mastra/core/storage';
7
8
  import type { IndexStats } from '@mastra/core/vector';
8
9
  import type { ISSLConfig } from 'pg-promise/typescript/pg-subset';
10
+ import type { LogicalOperatorValueMap } from '@mastra/core/vector/filter';
9
11
  import type { MastraMessageContentV2 } from '@mastra/core/agent';
10
12
  import type { MastraMessageV1 } from '@mastra/core/memory';
11
13
  import type { MastraMessageV2 } from '@mastra/core/agent';
12
14
  import { MastraStorage } from '@mastra/core/storage';
13
15
  import { MastraVector } from '@mastra/core/vector';
14
16
  import type { OperatorSupport } from '@mastra/core/vector/filter';
17
+ import type { OperatorValueMap } from '@mastra/core/vector/filter';
15
18
  import type { PaginationArgs } from '@mastra/core/storage';
16
19
  import type { PaginationInfo } from '@mastra/core/storage';
17
20
  import pg from 'pg';
@@ -19,10 +22,12 @@ import type { QueryResult } from '@mastra/core/vector';
19
22
  import type { QueryVectorParams } from '@mastra/core/vector';
20
23
  import type { StorageColumn } from '@mastra/core/storage';
21
24
  import type { StorageGetMessagesArg } from '@mastra/core/storage';
25
+ import type { StorageResourceType } from '@mastra/core/storage';
22
26
  import type { StorageThreadType } from '@mastra/core/memory';
23
27
  import type { TABLE_NAMES } from '@mastra/core/storage';
24
28
  import type { UpdateVectorParams } from '@mastra/core/vector';
25
29
  import type { UpsertVectorParams } from '@mastra/core/vector';
30
+ import type { VectorFieldValue } from '@mastra/core/vector/filter';
26
31
  import type { VectorFilter } from '@mastra/core/vector/filter';
27
32
  import type { WorkflowRun } from '@mastra/core/storage';
28
33
  import type { WorkflowRuns } from '@mastra/core/storage';
@@ -61,7 +66,7 @@ export declare const baseTestConfigs: {
61
66
  }[];
62
67
  };
63
68
 
64
- export declare function buildFilterQuery(filter: VectorFilter, minScore: number, topK: number): FilterResult;
69
+ export declare function buildFilterQuery(filter: PGVectorFilter, minScore: number, topK: number): FilterResult;
65
70
 
66
71
  export declare const calculateRecall: (actual: number[], expected: number[], k: number) => number;
67
72
 
@@ -126,6 +131,8 @@ declare interface IVFConfig {
126
131
 
127
132
  export declare function measureLatency<T>(fn: () => Promise<T>): Promise<[number, T]>;
128
133
 
134
+ declare type PGBlacklisted = BlacklistedRootOperators | '$contains' | '$size';
135
+
129
136
  declare interface PgCreateIndexParams extends CreateIndexParams {
130
137
  indexConfig?: IndexConfig;
131
138
  buildIndex?: boolean;
@@ -147,13 +154,15 @@ declare interface PgDefineIndexParams {
147
154
  * - Can take either a single condition or an array of conditions
148
155
  *
149
156
  */
150
- export declare class PGFilterTranslator extends BaseFilterTranslator {
157
+ export declare class PGFilterTranslator extends BaseFilterTranslator<PGVectorFilter> {
151
158
  protected getSupportedOperators(): OperatorSupport;
152
- translate(filter?: VectorFilter): VectorFilter;
159
+ translate(filter?: PGVectorFilter): PGVectorFilter;
153
160
  private translateNode;
154
161
  private translateRegexPattern;
155
162
  }
156
163
 
164
+ declare type PGFilterValue = VectorFieldValue | RegExp;
165
+
157
166
  declare interface PGIndexStats extends IndexStats {
158
167
  type: IndexType;
159
168
  config: {
@@ -166,7 +175,17 @@ declare interface PGIndexStats extends IndexStats {
166
175
  export { PGIndexStats }
167
176
  export { PGIndexStats as PGIndexStats_alias_1 }
168
177
 
169
- declare interface PgQueryVectorParams extends QueryVectorParams {
178
+ declare type PGOperatorValueMap = Omit<OperatorValueMap, '$in' | '$all' | '$nin' | '$eq' | '$ne'> & {
179
+ $size: number;
180
+ $contains: VectorFieldValue | Record<string, unknown>;
181
+ $all: VectorFieldValue;
182
+ $in: VectorFieldValue;
183
+ $nin: VectorFieldValue;
184
+ $eq: VectorFieldValue;
185
+ $ne: VectorFieldValue;
186
+ };
187
+
188
+ declare interface PgQueryVectorParams extends QueryVectorParams<PGVectorFilter> {
170
189
  minScore?: number;
171
190
  /**
172
191
  * HNSW search parameter. Controls the size of the dynamic candidate
@@ -180,7 +199,7 @@ declare interface PgQueryVectorParams extends QueryVectorParams {
180
199
  probes?: number;
181
200
  }
182
201
 
183
- declare class PgVector extends MastraVector {
202
+ declare class PgVector extends MastraVector<PGVectorFilter> {
184
203
  private pool;
185
204
  private describeIndexCache;
186
205
  private createdIndexes;
@@ -198,7 +217,7 @@ declare class PgVector extends MastraVector {
198
217
  private getMutexByName;
199
218
  private getTableName;
200
219
  private getSchemaName;
201
- transformFilter(filter?: VectorFilter): VectorFilter;
220
+ transformFilter(filter?: PGVectorFilter): PGVectorFilter;
202
221
  getIndexInfo({ indexName }: DescribeIndexParams): Promise<PGIndexStats>;
203
222
  query({ indexName, queryVector, topK, filter, includeVector, minScore, ef, probes, }: PgQueryVectorParams): Promise<QueryResult[]>;
204
223
  upsert({ indexName, vectors, metadata, ids }: UpsertVectorParams): Promise<string[]>;
@@ -252,6 +271,8 @@ declare const PGVECTOR_PROMPT = "When querying PG Vector, you can ONLY use the o
252
271
  export { PGVECTOR_PROMPT }
253
272
  export { PGVECTOR_PROMPT as PGVECTOR_PROMPT_alias_1 }
254
273
 
274
+ export declare type PGVectorFilter = VectorFilter<keyof PGOperatorValueMap, PGOperatorValueMap, LogicalOperatorValueMap, PGBlacklisted, PGFilterValue>;
275
+
255
276
  declare type PostgresConfig = {
256
277
  schemaName?: string;
257
278
  } & ({
@@ -276,6 +297,7 @@ declare class PostgresStore extends MastraStorage {
276
297
  constructor(config: PostgresConfig);
277
298
  get supports(): {
278
299
  selectByIncludeResourceScope: boolean;
300
+ resourceWorkingMemory: boolean;
279
301
  };
280
302
  private getTableName;
281
303
  private getSchemaName;
@@ -360,6 +382,7 @@ declare class PostgresStore extends MastraStorage {
360
382
  deleteThread({ threadId }: {
361
383
  threadId: string;
362
384
  }): Promise<void>;
385
+ private _getIncludedMessages;
363
386
  /**
364
387
  * @deprecated use getMessagesPaginated instead
365
388
  */
@@ -421,6 +444,17 @@ declare class PostgresStore extends MastraStorage {
421
444
  };
422
445
  })[];
423
446
  }): Promise<MastraMessageV2[]>;
447
+ getResourceById({ resourceId }: {
448
+ resourceId: string;
449
+ }): Promise<StorageResourceType | null>;
450
+ saveResource({ resource }: {
451
+ resource: StorageResourceType;
452
+ }): Promise<StorageResourceType>;
453
+ updateResource({ resourceId, workingMemory, metadata, }: {
454
+ resourceId: string;
455
+ workingMemory?: string;
456
+ metadata?: Record<string, unknown>;
457
+ }): Promise<StorageResourceType>;
424
458
  }
425
459
  export { PostgresStore }
426
460
  export { PostgresStore as PostgresStore_alias_1 }
@@ -1,4 +1,5 @@
1
1
  import { BaseFilterTranslator } from '@mastra/core/vector/filter';
2
+ import type { BlacklistedRootOperators } from '@mastra/core/vector/filter';
2
3
  import type { CreateIndexParams } from '@mastra/core/vector';
3
4
  import type { DeleteIndexParams } from '@mastra/core/vector';
4
5
  import type { DeleteVectorParams } from '@mastra/core/vector';
@@ -6,12 +7,14 @@ import type { DescribeIndexParams } from '@mastra/core/vector';
6
7
  import type { EvalRow } from '@mastra/core/storage';
7
8
  import type { IndexStats } from '@mastra/core/vector';
8
9
  import type { ISSLConfig } from 'pg-promise/typescript/pg-subset';
10
+ import type { LogicalOperatorValueMap } from '@mastra/core/vector/filter';
9
11
  import type { MastraMessageContentV2 } from '@mastra/core/agent';
10
12
  import type { MastraMessageV1 } from '@mastra/core/memory';
11
13
  import type { MastraMessageV2 } from '@mastra/core/agent';
12
14
  import { MastraStorage } from '@mastra/core/storage';
13
15
  import { MastraVector } from '@mastra/core/vector';
14
16
  import type { OperatorSupport } from '@mastra/core/vector/filter';
17
+ import type { OperatorValueMap } from '@mastra/core/vector/filter';
15
18
  import type { PaginationArgs } from '@mastra/core/storage';
16
19
  import type { PaginationInfo } from '@mastra/core/storage';
17
20
  import pg from 'pg';
@@ -19,10 +22,12 @@ import type { QueryResult } from '@mastra/core/vector';
19
22
  import type { QueryVectorParams } from '@mastra/core/vector';
20
23
  import type { StorageColumn } from '@mastra/core/storage';
21
24
  import type { StorageGetMessagesArg } from '@mastra/core/storage';
25
+ import type { StorageResourceType } from '@mastra/core/storage';
22
26
  import type { StorageThreadType } from '@mastra/core/memory';
23
27
  import type { TABLE_NAMES } from '@mastra/core/storage';
24
28
  import type { UpdateVectorParams } from '@mastra/core/vector';
25
29
  import type { UpsertVectorParams } from '@mastra/core/vector';
30
+ import type { VectorFieldValue } from '@mastra/core/vector/filter';
26
31
  import type { VectorFilter } from '@mastra/core/vector/filter';
27
32
  import type { WorkflowRun } from '@mastra/core/storage';
28
33
  import type { WorkflowRuns } from '@mastra/core/storage';
@@ -61,7 +66,7 @@ export declare const baseTestConfigs: {
61
66
  }[];
62
67
  };
63
68
 
64
- export declare function buildFilterQuery(filter: VectorFilter, minScore: number, topK: number): FilterResult;
69
+ export declare function buildFilterQuery(filter: PGVectorFilter, minScore: number, topK: number): FilterResult;
65
70
 
66
71
  export declare const calculateRecall: (actual: number[], expected: number[], k: number) => number;
67
72
 
@@ -126,6 +131,8 @@ declare interface IVFConfig {
126
131
 
127
132
  export declare function measureLatency<T>(fn: () => Promise<T>): Promise<[number, T]>;
128
133
 
134
+ declare type PGBlacklisted = BlacklistedRootOperators | '$contains' | '$size';
135
+
129
136
  declare interface PgCreateIndexParams extends CreateIndexParams {
130
137
  indexConfig?: IndexConfig;
131
138
  buildIndex?: boolean;
@@ -147,13 +154,15 @@ declare interface PgDefineIndexParams {
147
154
  * - Can take either a single condition or an array of conditions
148
155
  *
149
156
  */
150
- export declare class PGFilterTranslator extends BaseFilterTranslator {
157
+ export declare class PGFilterTranslator extends BaseFilterTranslator<PGVectorFilter> {
151
158
  protected getSupportedOperators(): OperatorSupport;
152
- translate(filter?: VectorFilter): VectorFilter;
159
+ translate(filter?: PGVectorFilter): PGVectorFilter;
153
160
  private translateNode;
154
161
  private translateRegexPattern;
155
162
  }
156
163
 
164
+ declare type PGFilterValue = VectorFieldValue | RegExp;
165
+
157
166
  declare interface PGIndexStats extends IndexStats {
158
167
  type: IndexType;
159
168
  config: {
@@ -166,7 +175,17 @@ declare interface PGIndexStats extends IndexStats {
166
175
  export { PGIndexStats }
167
176
  export { PGIndexStats as PGIndexStats_alias_1 }
168
177
 
169
- declare interface PgQueryVectorParams extends QueryVectorParams {
178
+ declare type PGOperatorValueMap = Omit<OperatorValueMap, '$in' | '$all' | '$nin' | '$eq' | '$ne'> & {
179
+ $size: number;
180
+ $contains: VectorFieldValue | Record<string, unknown>;
181
+ $all: VectorFieldValue;
182
+ $in: VectorFieldValue;
183
+ $nin: VectorFieldValue;
184
+ $eq: VectorFieldValue;
185
+ $ne: VectorFieldValue;
186
+ };
187
+
188
+ declare interface PgQueryVectorParams extends QueryVectorParams<PGVectorFilter> {
170
189
  minScore?: number;
171
190
  /**
172
191
  * HNSW search parameter. Controls the size of the dynamic candidate
@@ -180,7 +199,7 @@ declare interface PgQueryVectorParams extends QueryVectorParams {
180
199
  probes?: number;
181
200
  }
182
201
 
183
- declare class PgVector extends MastraVector {
202
+ declare class PgVector extends MastraVector<PGVectorFilter> {
184
203
  private pool;
185
204
  private describeIndexCache;
186
205
  private createdIndexes;
@@ -198,7 +217,7 @@ declare class PgVector extends MastraVector {
198
217
  private getMutexByName;
199
218
  private getTableName;
200
219
  private getSchemaName;
201
- transformFilter(filter?: VectorFilter): VectorFilter;
220
+ transformFilter(filter?: PGVectorFilter): PGVectorFilter;
202
221
  getIndexInfo({ indexName }: DescribeIndexParams): Promise<PGIndexStats>;
203
222
  query({ indexName, queryVector, topK, filter, includeVector, minScore, ef, probes, }: PgQueryVectorParams): Promise<QueryResult[]>;
204
223
  upsert({ indexName, vectors, metadata, ids }: UpsertVectorParams): Promise<string[]>;
@@ -252,6 +271,8 @@ declare const PGVECTOR_PROMPT = "When querying PG Vector, you can ONLY use the o
252
271
  export { PGVECTOR_PROMPT }
253
272
  export { PGVECTOR_PROMPT as PGVECTOR_PROMPT_alias_1 }
254
273
 
274
+ export declare type PGVectorFilter = VectorFilter<keyof PGOperatorValueMap, PGOperatorValueMap, LogicalOperatorValueMap, PGBlacklisted, PGFilterValue>;
275
+
255
276
  declare type PostgresConfig = {
256
277
  schemaName?: string;
257
278
  } & ({
@@ -276,6 +297,7 @@ declare class PostgresStore extends MastraStorage {
276
297
  constructor(config: PostgresConfig);
277
298
  get supports(): {
278
299
  selectByIncludeResourceScope: boolean;
300
+ resourceWorkingMemory: boolean;
279
301
  };
280
302
  private getTableName;
281
303
  private getSchemaName;
@@ -360,6 +382,7 @@ declare class PostgresStore extends MastraStorage {
360
382
  deleteThread({ threadId }: {
361
383
  threadId: string;
362
384
  }): Promise<void>;
385
+ private _getIncludedMessages;
363
386
  /**
364
387
  * @deprecated use getMessagesPaginated instead
365
388
  */
@@ -421,6 +444,17 @@ declare class PostgresStore extends MastraStorage {
421
444
  };
422
445
  })[];
423
446
  }): Promise<MastraMessageV2[]>;
447
+ getResourceById({ resourceId }: {
448
+ resourceId: string;
449
+ }): Promise<StorageResourceType | null>;
450
+ saveResource({ resource }: {
451
+ resource: StorageResourceType;
452
+ }): Promise<StorageResourceType>;
453
+ updateResource({ resourceId, workingMemory, metadata, }: {
454
+ resourceId: string;
455
+ workingMemory?: string;
456
+ metadata?: Record<string, unknown>;
457
+ }): Promise<StorageResourceType>;
424
458
  }
425
459
  export { PostgresStore }
426
460
  export { PostgresStore as PostgresStore_alias_1 }