@mastra/pg 0.2.6 → 0.2.7-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.2.6-alpha.4 build /home/runner/work/mastra/mastra/stores/pg
2
+ > @mastra/pg@0.2.7-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.4.0
8
8
  TSC Build start
9
- TSC ⚡️ Build success in 10437ms
9
+ TSC ⚡️ Build success in 10747ms
10
10
  DTS Build start
11
11
  CLI Target: es2022
12
12
  Analysis will use the bundled TypeScript version 5.8.2
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.2
15
15
  Writing package typings: /home/runner/work/mastra/mastra/stores/pg/dist/_tsup-dts-rollup.d.cts
16
- DTS ⚡️ Build success in 10976ms
16
+ DTS ⚡️ Build success in 11651ms
17
17
  CLI Cleaning output folder
18
18
  ESM Build start
19
19
  CJS Build start
20
- CJS dist/index.cjs 36.85 KB
21
- CJS ⚡️ Build success in 1339ms
22
- ESM dist/index.js 36.43 KB
23
- ESM ⚡️ Build success in 1339ms
20
+ CJS dist/index.cjs 37.38 KB
21
+ CJS ⚡️ Build success in 1188ms
22
+ ESM dist/index.js 36.97 KB
23
+ ESM ⚡️ Build success in 1188ms
package/CHANGELOG.md CHANGED
@@ -1,5 +1,40 @@
1
1
  # @mastra/pg
2
2
 
3
+ ## 0.2.7-alpha.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [56c31b7]
8
+ - Updated dependencies [dbbbf80]
9
+ - Updated dependencies [99d43b9]
10
+ - @mastra/core@0.8.0-alpha.2
11
+
12
+ ## 0.2.7-alpha.1
13
+
14
+ ### Patch Changes
15
+
16
+ - 7071597: Update pinecone to include namespace and hybrid search
17
+ - Updated dependencies [619c39d]
18
+ - Updated dependencies [fe56be0]
19
+ - Updated dependencies [a0967a0]
20
+ - Updated dependencies [fca3b21]
21
+ - Updated dependencies [0118361]
22
+ - Updated dependencies [619c39d]
23
+ - @mastra/core@0.8.0-alpha.1
24
+
25
+ ## 0.2.7-alpha.0
26
+
27
+ ### Patch Changes
28
+
29
+ - cafae83: Changed error messages for vector mismatch with index
30
+ - Updated dependencies [107bcfe]
31
+ - Updated dependencies [5b4e19f]
32
+ - Updated dependencies [7599d77]
33
+ - Updated dependencies [cafae83]
34
+ - Updated dependencies [8076ecf]
35
+ - Updated dependencies [304397c]
36
+ - @mastra/core@0.7.1-alpha.0
37
+
3
38
  ## 0.2.6
4
39
 
5
40
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -394,6 +394,15 @@ var PgVector = class extends vector.MastraVector {
394
394
  return vectorIds;
395
395
  } catch (error) {
396
396
  await client.query("ROLLBACK");
397
+ if (error instanceof Error && error.message?.includes("expected") && error.message?.includes("dimensions")) {
398
+ const match = error.message.match(/expected (\d+) dimensions, not (\d+)/);
399
+ if (match) {
400
+ const [, expected, actual] = match;
401
+ throw new Error(
402
+ `Vector dimension mismatch: Index "${params.indexName}" expects ${expected} dimensions but got ${actual} dimensions. Either use a matching embedding model or delete and recreate the index with the new dimension.`
403
+ );
404
+ }
405
+ }
397
406
  throw error;
398
407
  } finally {
399
408
  client.release();
package/dist/index.js CHANGED
@@ -387,6 +387,15 @@ var PgVector = class extends MastraVector {
387
387
  return vectorIds;
388
388
  } catch (error) {
389
389
  await client.query("ROLLBACK");
390
+ if (error instanceof Error && error.message?.includes("expected") && error.message?.includes("dimensions")) {
391
+ const match = error.message.match(/expected (\d+) dimensions, not (\d+)/);
392
+ if (match) {
393
+ const [, expected, actual] = match;
394
+ throw new Error(
395
+ `Vector dimension mismatch: Index "${params.indexName}" expects ${expected} dimensions but got ${actual} dimensions. Either use a matching embedding model or delete and recreate the index with the new dimension.`
396
+ );
397
+ }
398
+ }
390
399
  throw error;
391
400
  } finally {
392
401
  client.release();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/pg",
3
- "version": "0.2.6",
3
+ "version": "0.2.7-alpha.2",
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.3",
23
23
  "pg-promise": "^11.11.0",
24
- "@mastra/core": "^0.7.0"
24
+ "@mastra/core": "^0.8.0-alpha.2"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@microsoft/api-extractor": "^7.52.1",
@@ -229,7 +229,10 @@ describe('PgVector', () => {
229
229
 
230
230
  it('should throw error if vector dimensions dont match', async () => {
231
231
  const vectors = [[1, 2, 3, 4]]; // 4D vector for 3D index
232
- await expect(vectorDB.upsert({ indexName: testIndexName, vectors })).rejects.toThrow();
232
+ await expect(vectorDB.upsert({ indexName: testIndexName, vectors })).rejects.toThrow(
233
+ `Vector dimension mismatch: Index "${testIndexName}" expects 3 dimensions but got 4 dimensions. ` +
234
+ `Either use a matching embedding model or delete and recreate the index with the new dimension.`,
235
+ );
233
236
  });
234
237
  });
235
238
 
@@ -307,7 +310,7 @@ describe('PgVector', () => {
307
310
  expect(ids).toHaveLength(3);
308
311
 
309
312
  const idToBeUpdated = ids[0];
310
- const newVector = [1, 2, 3];
313
+ const newVector = [4, 4, 4];
311
314
 
312
315
  const update = {
313
316
  vector: newVector,
@@ -181,6 +181,16 @@ export class PgVector extends MastraVector {
181
181
  return vectorIds;
182
182
  } catch (error) {
183
183
  await client.query('ROLLBACK');
184
+ if (error instanceof Error && error.message?.includes('expected') && error.message?.includes('dimensions')) {
185
+ const match = error.message.match(/expected (\d+) dimensions, not (\d+)/);
186
+ if (match) {
187
+ const [, expected, actual] = match;
188
+ throw new Error(
189
+ `Vector dimension mismatch: Index "${params.indexName}" expects ${expected} dimensions but got ${actual} dimensions. ` +
190
+ `Either use a matching embedding model or delete and recreate the index with the new dimension.`,
191
+ );
192
+ }
193
+ }
184
194
  throw error;
185
195
  } finally {
186
196
  client.release();