@mastra/pg 0.1.6 → 0.1.8-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.1.6-alpha.4 build /home/runner/work/mastra/mastra/stores/pg
2
+ > @mastra/pg@0.1.8-alpha.0 build /home/runner/work/mastra/mastra/stores/pg
3
3
  > tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake
4
4
 
5
5
  CLI Building entry: src/index.ts
6
6
  CLI Using tsconfig: tsconfig.json
7
7
  CLI tsup v8.3.6
8
8
  TSC Build start
9
- TSC ⚡️ Build success in 7672ms
9
+ TSC ⚡️ Build success in 8825ms
10
10
  DTS Build start
11
11
  CLI Target: es2022
12
12
  Analysis will use the bundled TypeScript version 5.7.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.7.3
15
15
  Writing package typings: /home/runner/work/mastra/mastra/stores/pg/dist/_tsup-dts-rollup.d.cts
16
- DTS ⚡️ Build success in 10963ms
16
+ DTS ⚡️ Build success in 9901ms
17
17
  CLI Cleaning output folder
18
18
  ESM Build start
19
19
  CJS Build start
20
- ESM dist/index.js 33.20 KB
21
- ESM ⚡️ Build success in 1374ms
22
- CJS dist/index.cjs 33.60 KB
23
- CJS ⚡️ Build success in 1374ms
20
+ ESM dist/index.js 33.26 KB
21
+ ESM ⚡️ Build success in 1052ms
22
+ CJS dist/index.cjs 33.66 KB
23
+ CJS ⚡️ Build success in 1054ms
package/CHANGELOG.md CHANGED
@@ -1,5 +1,31 @@
1
1
  # @mastra/pg
2
2
 
3
+ ## 0.1.8-alpha.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [59df7b6]
8
+ - Updated dependencies [29f3a82]
9
+ - Updated dependencies [59df7b6]
10
+ - Updated dependencies [c139344]
11
+ - @mastra/core@0.5.0-alpha.0
12
+
13
+ ## 0.1.7
14
+
15
+ ### Patch Changes
16
+
17
+ - 1da20e7: Update typechecks for positional args
18
+ - Updated dependencies [1da20e7]
19
+ - @mastra/core@0.4.4
20
+
21
+ ## 0.1.7-alpha.0
22
+
23
+ ### Patch Changes
24
+
25
+ - 1da20e7: Update typechecks for positional args
26
+ - Updated dependencies [1da20e7]
27
+ - @mastra/core@0.4.4-alpha.0
28
+
3
29
  ## 0.1.6
4
30
 
5
31
  ### Patch Changes
@@ -1,6 +1,7 @@
1
1
  import type { ArrayOperator } from '@mastra/core/vector/filter';
2
2
  import { BaseFilterTranslator } from '@mastra/core/vector/filter';
3
3
  import type { BasicOperator } from '@mastra/core/vector/filter';
4
+ import type { CreateIndexArgs } from '@mastra/core/vector';
4
5
  import type { CreateIndexParams } from '@mastra/core/vector';
5
6
  import type { ElementOperator } from '@mastra/core/vector/filter';
6
7
  import type { EvalRow } from '@mastra/core/storage';
@@ -13,6 +14,7 @@ import type { NumericOperator } from '@mastra/core/vector/filter';
13
14
  import type { OperatorSupport } from '@mastra/core/vector/filter';
14
15
  import type { ParamsToArgs } from '@mastra/core/vector';
15
16
  import type { QueryResult } from '@mastra/core/vector';
17
+ import type { QueryVectorArgs } from '@mastra/core/vector';
16
18
  import type { QueryVectorParams } from '@mastra/core/vector';
17
19
  import type { RegexOperator } from '@mastra/core/vector/filter';
18
20
  import type { StorageColumn } from '@mastra/core/storage';
@@ -135,11 +137,15 @@ declare type OperatorFn = (key: string, paramIndex: number, value?: any) => Filt
135
137
 
136
138
  export declare type OperatorType = BasicOperator | NumericOperator | ArrayOperator | ElementOperator | LogicalOperator | '$contains' | Exclude<RegexOperator, '$options'>;
137
139
 
140
+ declare type PgCreateIndexArgs = [...CreateIndexArgs, IndexConfig?, boolean?];
141
+
138
142
  declare interface PgCreateIndexParams extends CreateIndexParams {
139
143
  indexConfig?: IndexConfig;
140
144
  buildIndex?: boolean;
141
145
  }
142
146
 
147
+ declare type PgDefineIndexArgs = [string, 'cosine' | 'euclidean' | 'dotproduct', IndexConfig];
148
+
143
149
  declare interface PgDefineIndexParams {
144
150
  indexName: string;
145
151
  metric: 'cosine' | 'euclidean' | 'dotproduct';
@@ -175,6 +181,8 @@ declare interface PGIndexStats extends IndexStats {
175
181
  export { PGIndexStats }
176
182
  export { PGIndexStats as PGIndexStats_alias_1 }
177
183
 
184
+ declare type PgQueryVectorArgs = [...QueryVectorArgs, number?, number?, number?];
185
+
178
186
  declare interface PgQueryVectorParams extends QueryVectorParams {
179
187
  minScore?: number;
180
188
  /**
@@ -195,14 +203,14 @@ declare class PgVector extends MastraVector {
195
203
  constructor(connectionString: string);
196
204
  transformFilter(filter?: VectorFilter): VectorFilter;
197
205
  getIndexInfo(indexName: string): Promise<PGIndexStats>;
198
- query(...args: ParamsToArgs<PgQueryVectorParams>): Promise<QueryResult[]>;
206
+ query(...args: ParamsToArgs<PgQueryVectorParams> | PgQueryVectorArgs): Promise<QueryResult[]>;
199
207
  upsert(...args: ParamsToArgs<UpsertVectorParams>): Promise<string[]>;
200
- createIndex(...args: ParamsToArgs<PgCreateIndexParams>): Promise<void>;
208
+ createIndex(...args: ParamsToArgs<PgCreateIndexParams> | PgCreateIndexArgs): Promise<void>;
201
209
  /**
202
210
  * @deprecated This function is deprecated. Use buildIndex instead
203
211
  */
204
212
  defineIndex(indexName: string, metric: "cosine" | "euclidean" | "dotproduct" | undefined, indexConfig: IndexConfig): Promise<void>;
205
- buildIndex(...args: ParamsToArgs<PgDefineIndexParams>): Promise<void>;
213
+ buildIndex(...args: ParamsToArgs<PgDefineIndexParams> | PgDefineIndexArgs): Promise<void>;
206
214
  listIndexes(): Promise<string[]>;
207
215
  describeIndex(indexName: string): Promise<PGIndexStats>;
208
216
  deleteIndex(indexName: string): Promise<void>;
@@ -1,6 +1,7 @@
1
1
  import type { ArrayOperator } from '@mastra/core/vector/filter';
2
2
  import { BaseFilterTranslator } from '@mastra/core/vector/filter';
3
3
  import type { BasicOperator } from '@mastra/core/vector/filter';
4
+ import type { CreateIndexArgs } from '@mastra/core/vector';
4
5
  import type { CreateIndexParams } from '@mastra/core/vector';
5
6
  import type { ElementOperator } from '@mastra/core/vector/filter';
6
7
  import type { EvalRow } from '@mastra/core/storage';
@@ -13,6 +14,7 @@ import type { NumericOperator } from '@mastra/core/vector/filter';
13
14
  import type { OperatorSupport } from '@mastra/core/vector/filter';
14
15
  import type { ParamsToArgs } from '@mastra/core/vector';
15
16
  import type { QueryResult } from '@mastra/core/vector';
17
+ import type { QueryVectorArgs } from '@mastra/core/vector';
16
18
  import type { QueryVectorParams } from '@mastra/core/vector';
17
19
  import type { RegexOperator } from '@mastra/core/vector/filter';
18
20
  import type { StorageColumn } from '@mastra/core/storage';
@@ -135,11 +137,15 @@ declare type OperatorFn = (key: string, paramIndex: number, value?: any) => Filt
135
137
 
136
138
  export declare type OperatorType = BasicOperator | NumericOperator | ArrayOperator | ElementOperator | LogicalOperator | '$contains' | Exclude<RegexOperator, '$options'>;
137
139
 
140
+ declare type PgCreateIndexArgs = [...CreateIndexArgs, IndexConfig?, boolean?];
141
+
138
142
  declare interface PgCreateIndexParams extends CreateIndexParams {
139
143
  indexConfig?: IndexConfig;
140
144
  buildIndex?: boolean;
141
145
  }
142
146
 
147
+ declare type PgDefineIndexArgs = [string, 'cosine' | 'euclidean' | 'dotproduct', IndexConfig];
148
+
143
149
  declare interface PgDefineIndexParams {
144
150
  indexName: string;
145
151
  metric: 'cosine' | 'euclidean' | 'dotproduct';
@@ -175,6 +181,8 @@ declare interface PGIndexStats extends IndexStats {
175
181
  export { PGIndexStats }
176
182
  export { PGIndexStats as PGIndexStats_alias_1 }
177
183
 
184
+ declare type PgQueryVectorArgs = [...QueryVectorArgs, number?, number?, number?];
185
+
178
186
  declare interface PgQueryVectorParams extends QueryVectorParams {
179
187
  minScore?: number;
180
188
  /**
@@ -195,14 +203,14 @@ declare class PgVector extends MastraVector {
195
203
  constructor(connectionString: string);
196
204
  transformFilter(filter?: VectorFilter): VectorFilter;
197
205
  getIndexInfo(indexName: string): Promise<PGIndexStats>;
198
- query(...args: ParamsToArgs<PgQueryVectorParams>): Promise<QueryResult[]>;
206
+ query(...args: ParamsToArgs<PgQueryVectorParams> | PgQueryVectorArgs): Promise<QueryResult[]>;
199
207
  upsert(...args: ParamsToArgs<UpsertVectorParams>): Promise<string[]>;
200
- createIndex(...args: ParamsToArgs<PgCreateIndexParams>): Promise<void>;
208
+ createIndex(...args: ParamsToArgs<PgCreateIndexParams> | PgCreateIndexArgs): Promise<void>;
201
209
  /**
202
210
  * @deprecated This function is deprecated. Use buildIndex instead
203
211
  */
204
212
  defineIndex(indexName: string, metric: "cosine" | "euclidean" | "dotproduct" | undefined, indexConfig: IndexConfig): Promise<void>;
205
- buildIndex(...args: ParamsToArgs<PgDefineIndexParams>): Promise<void>;
213
+ buildIndex(...args: ParamsToArgs<PgDefineIndexParams> | PgDefineIndexArgs): Promise<void>;
206
214
  listIndexes(): Promise<string[]>;
207
215
  describeIndex(indexName: string): Promise<PGIndexStats>;
208
216
  deleteIndex(indexName: string): Promise<void>;
package/dist/index.cjs CHANGED
@@ -324,7 +324,11 @@ var PgVector = class extends vector.MastraVector {
324
324
  return this.indexCache.get(indexName);
325
325
  }
326
326
  async query(...args) {
327
- const params = this.normalizeArgs("query", args, ["minScore", "ef", "probes"]);
327
+ const params = this.normalizeArgs("query", args, [
328
+ "minScore",
329
+ "ef",
330
+ "probes"
331
+ ]);
328
332
  const { indexName, queryVector, topK = 10, filter, includeVector = false, minScore = 0, ef, probes } = params;
329
333
  const client = await this.pool.connect();
330
334
  try {
@@ -395,7 +399,10 @@ var PgVector = class extends vector.MastraVector {
395
399
  }
396
400
  }
397
401
  async createIndex(...args) {
398
- const params = this.normalizeArgs("createIndex", args, ["indexConfig", "buildIndex"]);
402
+ const params = this.normalizeArgs("createIndex", args, [
403
+ "indexConfig",
404
+ "buildIndex"
405
+ ]);
399
406
  const { indexName, dimension, metric = "cosine", indexConfig = {}, buildIndex = true } = params;
400
407
  const client = await this.pool.connect();
401
408
  try {
@@ -439,7 +446,10 @@ var PgVector = class extends vector.MastraVector {
439
446
  return this.buildIndex({ indexName, metric, indexConfig });
440
447
  }
441
448
  async buildIndex(...args) {
442
- const params = this.normalizeArgs("buildIndex", args, ["metric", "indexConfig"]);
449
+ const params = this.normalizeArgs("buildIndex", args, [
450
+ "metric",
451
+ "indexConfig"
452
+ ]);
443
453
  const { indexName, metric = "cosine", indexConfig } = params;
444
454
  const client = await this.pool.connect();
445
455
  try {
package/dist/index.js CHANGED
@@ -317,7 +317,11 @@ var PgVector = class extends MastraVector {
317
317
  return this.indexCache.get(indexName);
318
318
  }
319
319
  async query(...args) {
320
- const params = this.normalizeArgs("query", args, ["minScore", "ef", "probes"]);
320
+ const params = this.normalizeArgs("query", args, [
321
+ "minScore",
322
+ "ef",
323
+ "probes"
324
+ ]);
321
325
  const { indexName, queryVector, topK = 10, filter, includeVector = false, minScore = 0, ef, probes } = params;
322
326
  const client = await this.pool.connect();
323
327
  try {
@@ -388,7 +392,10 @@ var PgVector = class extends MastraVector {
388
392
  }
389
393
  }
390
394
  async createIndex(...args) {
391
- const params = this.normalizeArgs("createIndex", args, ["indexConfig", "buildIndex"]);
395
+ const params = this.normalizeArgs("createIndex", args, [
396
+ "indexConfig",
397
+ "buildIndex"
398
+ ]);
392
399
  const { indexName, dimension, metric = "cosine", indexConfig = {}, buildIndex = true } = params;
393
400
  const client = await this.pool.connect();
394
401
  try {
@@ -432,7 +439,10 @@ var PgVector = class extends MastraVector {
432
439
  return this.buildIndex({ indexName, metric, indexConfig });
433
440
  }
434
441
  async buildIndex(...args) {
435
- const params = this.normalizeArgs("buildIndex", args, ["metric", "indexConfig"]);
442
+ const params = this.normalizeArgs("buildIndex", args, [
443
+ "metric",
444
+ "indexConfig"
445
+ ]);
436
446
  const { indexName, metric = "cosine", indexConfig } = params;
437
447
  const client = await this.pool.connect();
438
448
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/pg",
3
- "version": "0.1.6",
3
+ "version": "0.1.8-alpha.0",
4
4
  "description": "Postgres provider for Mastra - includes both vector and db storage capabilities",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -21,7 +21,7 @@
21
21
  "dependencies": {
22
22
  "pg": "^8.13.1",
23
23
  "pg-promise": "^11.5.4",
24
- "@mastra/core": "^0.4.3"
24
+ "@mastra/core": "^0.5.0-alpha.0"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@microsoft/api-extractor": "^7.49.2",
@@ -6,6 +6,8 @@ import type {
6
6
  CreateIndexParams,
7
7
  UpsertVectorParams,
8
8
  ParamsToArgs,
9
+ QueryVectorArgs,
10
+ CreateIndexArgs,
9
11
  } from '@mastra/core/vector';
10
12
  import type { VectorFilter } from '@mastra/core/vector/filter';
11
13
  import pg from 'pg';
@@ -38,17 +40,23 @@ interface PgQueryVectorParams extends QueryVectorParams {
38
40
  probes?: number;
39
41
  }
40
42
 
43
+ type PgQueryVectorArgs = [...QueryVectorArgs, number?, number?, number?];
44
+
41
45
  interface PgCreateIndexParams extends CreateIndexParams {
42
46
  indexConfig?: IndexConfig;
43
47
  buildIndex?: boolean;
44
48
  }
45
49
 
50
+ type PgCreateIndexArgs = [...CreateIndexArgs, IndexConfig?, boolean?];
51
+
46
52
  interface PgDefineIndexParams {
47
53
  indexName: string;
48
54
  metric: 'cosine' | 'euclidean' | 'dotproduct';
49
55
  indexConfig: IndexConfig;
50
56
  }
51
57
 
58
+ type PgDefineIndexArgs = [string, 'cosine' | 'euclidean' | 'dotproduct', IndexConfig];
59
+
52
60
  export class PgVector extends MastraVector {
53
61
  private pool: pg.Pool;
54
62
  private indexCache: Map<string, PGIndexStats> = new Map();
@@ -86,8 +94,12 @@ export class PgVector extends MastraVector {
86
94
  return this.indexCache.get(indexName)!;
87
95
  }
88
96
 
89
- async query(...args: ParamsToArgs<PgQueryVectorParams>): Promise<QueryResult[]> {
90
- const params = this.normalizeArgs<PgQueryVectorParams>('query', args, ['minScore', 'ef', 'probes']);
97
+ async query(...args: ParamsToArgs<PgQueryVectorParams> | PgQueryVectorArgs): Promise<QueryResult[]> {
98
+ const params = this.normalizeArgs<PgQueryVectorParams, PgQueryVectorArgs>('query', args, [
99
+ 'minScore',
100
+ 'ef',
101
+ 'probes',
102
+ ]);
91
103
  const { indexName, queryVector, topK = 10, filter, includeVector = false, minScore = 0, ef, probes } = params;
92
104
 
93
105
  const client = await this.pool.connect();
@@ -174,8 +186,11 @@ export class PgVector extends MastraVector {
174
186
  }
175
187
  }
176
188
 
177
- async createIndex(...args: ParamsToArgs<PgCreateIndexParams>): Promise<void> {
178
- const params = this.normalizeArgs<PgCreateIndexParams>('createIndex', args, ['indexConfig', 'buildIndex']);
189
+ async createIndex(...args: ParamsToArgs<PgCreateIndexParams> | PgCreateIndexArgs): Promise<void> {
190
+ const params = this.normalizeArgs<PgCreateIndexParams, PgCreateIndexArgs>('createIndex', args, [
191
+ 'indexConfig',
192
+ 'buildIndex',
193
+ ]);
179
194
 
180
195
  const { indexName, dimension, metric = 'cosine', indexConfig = {}, buildIndex = true } = params;
181
196
 
@@ -235,8 +250,11 @@ export class PgVector extends MastraVector {
235
250
  return this.buildIndex({ indexName, metric, indexConfig });
236
251
  }
237
252
 
238
- async buildIndex(...args: ParamsToArgs<PgDefineIndexParams>): Promise<void> {
239
- const params = this.normalizeArgs<PgDefineIndexParams>('buildIndex', args, ['metric', 'indexConfig']);
253
+ async buildIndex(...args: ParamsToArgs<PgDefineIndexParams> | PgDefineIndexArgs): Promise<void> {
254
+ const params = this.normalizeArgs<PgDefineIndexParams, PgDefineIndexArgs>('buildIndex', args, [
255
+ 'metric',
256
+ 'indexConfig',
257
+ ]);
240
258
 
241
259
  const { indexName, metric = 'cosine', indexConfig } = params;
242
260