@mastra/pg 0.12.2 → 0.12.3-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.
- package/.turbo/turbo-build.log +7 -7
- package/CHANGELOG.md +18 -0
- package/dist/index.cjs +2 -2
- package/dist/index.js +2 -2
- package/package.json +6 -6
- package/src/storage/index.test.ts +8 -13
- package/src/storage/index.ts +2 -2
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
|
|
2
|
-
> @mastra/pg@0.12.
|
|
2
|
+
> @mastra/pg@0.12.3-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
|
[34mCLI[39m Building entry: src/index.ts
|
|
6
6
|
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
7
7
|
[34mCLI[39m tsup v8.5.0
|
|
8
8
|
[34mTSC[39m Build start
|
|
9
|
-
[32mTSC[39m ⚡️ Build success in
|
|
9
|
+
[32mTSC[39m ⚡️ Build success in 11580ms
|
|
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 11970ms
|
|
17
17
|
[34mCLI[39m Cleaning output folder
|
|
18
18
|
[34mESM[39m Build start
|
|
19
19
|
[34mCJS[39m Build start
|
|
20
|
-
[
|
|
21
|
-
[
|
|
22
|
-
[
|
|
23
|
-
[
|
|
20
|
+
[32mESM[39m [1mdist/index.js [22m[32m86.90 KB[39m
|
|
21
|
+
[32mESM[39m ⚡️ Build success in 1842ms
|
|
22
|
+
[32mCJS[39m [1mdist/index.cjs [22m[32m88.28 KB[39m
|
|
23
|
+
[32mCJS[39m ⚡️ Build success in 1845ms
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @mastra/pg
|
|
2
2
|
|
|
3
|
+
## 0.12.3-alpha.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- ca52f88: dependencies updates:
|
|
8
|
+
- Updated dependency [`pg-promise@^11.15.0` ↗︎](https://www.npmjs.com/package/pg-promise/v/11.15.0) (from `^11.14.0`, in `dependencies`)
|
|
9
|
+
- 00c57ff: fix: pg storage should select resourceId when getMessages
|
|
10
|
+
- Updated dependencies [db5cc15]
|
|
11
|
+
- Updated dependencies [5237998]
|
|
12
|
+
- Updated dependencies [37c1acd]
|
|
13
|
+
- Updated dependencies [1aa60b1]
|
|
14
|
+
- Updated dependencies [89ec9d4]
|
|
15
|
+
- Updated dependencies [626b0f4]
|
|
16
|
+
- Updated dependencies [c22a91f]
|
|
17
|
+
- Updated dependencies [f7403ab]
|
|
18
|
+
- Updated dependencies [6c89d7f]
|
|
19
|
+
- @mastra/core@0.10.15-alpha.0
|
|
20
|
+
|
|
3
21
|
## 0.12.2
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/dist/index.cjs
CHANGED
|
@@ -1850,7 +1850,7 @@ var PostgresStore = class extends storage.MastraStorage {
|
|
|
1850
1850
|
}
|
|
1851
1851
|
async getMessages(args) {
|
|
1852
1852
|
const { threadId, format, selectBy } = args;
|
|
1853
|
-
const selectStatement = `SELECT id, content, role, type, "createdAt", thread_id AS "threadId"`;
|
|
1853
|
+
const selectStatement = `SELECT id, content, role, type, "createdAt", thread_id AS "threadId", "resourceId"`;
|
|
1854
1854
|
const orderByStatement = `ORDER BY "createdAt" DESC`;
|
|
1855
1855
|
const limit = this.resolveMessageLimit({ last: selectBy?.last, defaultLimit: 40 });
|
|
1856
1856
|
try {
|
|
@@ -1910,7 +1910,7 @@ var PostgresStore = class extends storage.MastraStorage {
|
|
|
1910
1910
|
const { page = 0, perPage: perPageInput, dateRange } = selectBy?.pagination || {};
|
|
1911
1911
|
const fromDate = dateRange?.start;
|
|
1912
1912
|
const toDate = dateRange?.end;
|
|
1913
|
-
const selectStatement = `SELECT id, content, role, type, "createdAt", thread_id AS "threadId"`;
|
|
1913
|
+
const selectStatement = `SELECT id, content, role, type, "createdAt", thread_id AS "threadId", "resourceId"`;
|
|
1914
1914
|
const orderByStatement = `ORDER BY "createdAt" DESC`;
|
|
1915
1915
|
const messages = [];
|
|
1916
1916
|
if (selectBy?.include?.length) {
|
package/dist/index.js
CHANGED
|
@@ -1842,7 +1842,7 @@ var PostgresStore = class extends MastraStorage {
|
|
|
1842
1842
|
}
|
|
1843
1843
|
async getMessages(args) {
|
|
1844
1844
|
const { threadId, format, selectBy } = args;
|
|
1845
|
-
const selectStatement = `SELECT id, content, role, type, "createdAt", thread_id AS "threadId"`;
|
|
1845
|
+
const selectStatement = `SELECT id, content, role, type, "createdAt", thread_id AS "threadId", "resourceId"`;
|
|
1846
1846
|
const orderByStatement = `ORDER BY "createdAt" DESC`;
|
|
1847
1847
|
const limit = this.resolveMessageLimit({ last: selectBy?.last, defaultLimit: 40 });
|
|
1848
1848
|
try {
|
|
@@ -1902,7 +1902,7 @@ var PostgresStore = class extends MastraStorage {
|
|
|
1902
1902
|
const { page = 0, perPage: perPageInput, dateRange } = selectBy?.pagination || {};
|
|
1903
1903
|
const fromDate = dateRange?.start;
|
|
1904
1904
|
const toDate = dateRange?.end;
|
|
1905
|
-
const selectStatement = `SELECT id, content, role, type, "createdAt", thread_id AS "threadId"`;
|
|
1905
|
+
const selectStatement = `SELECT id, content, role, type, "createdAt", thread_id AS "threadId", "resourceId"`;
|
|
1906
1906
|
const orderByStatement = `ORDER BY "createdAt" DESC`;
|
|
1907
1907
|
const messages = [];
|
|
1908
1908
|
if (selectBy?.include?.length) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/pg",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.3-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",
|
|
@@ -22,20 +22,20 @@
|
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"async-mutex": "^0.5.0",
|
|
24
24
|
"pg": "^8.16.3",
|
|
25
|
-
"pg-promise": "^11.
|
|
25
|
+
"pg-promise": "^11.15.0",
|
|
26
26
|
"xxhash-wasm": "^1.1.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@microsoft/api-extractor": "^7.52.8",
|
|
30
30
|
"@types/node": "^20.19.0",
|
|
31
31
|
"@types/pg": "^8.15.4",
|
|
32
|
-
"eslint": "^9.
|
|
32
|
+
"eslint": "^9.30.1",
|
|
33
33
|
"tsup": "^8.5.0",
|
|
34
34
|
"typescript": "^5.8.3",
|
|
35
35
|
"vitest": "^3.2.4",
|
|
36
|
-
"@internal/
|
|
37
|
-
"@internal/
|
|
38
|
-
"@mastra/core": "0.10.
|
|
36
|
+
"@internal/storage-test-utils": "0.0.15",
|
|
37
|
+
"@internal/lint": "0.0.19",
|
|
38
|
+
"@mastra/core": "0.10.15-alpha.0"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"@mastra/core": ">=0.10.7-0 <0.11.0-0"
|
|
@@ -258,7 +258,10 @@ describe('PostgresStore', () => {
|
|
|
258
258
|
const thread = createSampleThread();
|
|
259
259
|
await store.saveThread({ thread });
|
|
260
260
|
|
|
261
|
-
const messages = [
|
|
261
|
+
const messages = [
|
|
262
|
+
createSampleMessageV1({ threadId: thread.id, resourceId: thread.resourceId }),
|
|
263
|
+
createSampleMessageV1({ threadId: thread.id, resourceId: thread.resourceId }),
|
|
264
|
+
];
|
|
262
265
|
|
|
263
266
|
// Save messages
|
|
264
267
|
const savedMessages = await store.saveMessages({ messages });
|
|
@@ -267,11 +270,7 @@ describe('PostgresStore', () => {
|
|
|
267
270
|
// Retrieve messages
|
|
268
271
|
const retrievedMessages = await store.getMessages({ threadId: thread.id, format: 'v1' });
|
|
269
272
|
expect(retrievedMessages).toHaveLength(2);
|
|
270
|
-
|
|
271
|
-
const { resourceId, ...rest } = m;
|
|
272
|
-
return rest;
|
|
273
|
-
});
|
|
274
|
-
expect(retrievedMessages).toEqual(expect.arrayContaining(checkMessages));
|
|
273
|
+
expect(retrievedMessages).toEqual(expect.arrayContaining(messages));
|
|
275
274
|
});
|
|
276
275
|
|
|
277
276
|
it('should handle empty message array', async () => {
|
|
@@ -1821,8 +1820,8 @@ describe('PostgresStore', () => {
|
|
|
1821
1820
|
await store.saveThread({ thread });
|
|
1822
1821
|
|
|
1823
1822
|
const messages = [
|
|
1824
|
-
createSampleMessageV1({ threadId: thread.id }),
|
|
1825
|
-
createSampleMessageV1({ threadId: thread.id }),
|
|
1823
|
+
createSampleMessageV1({ threadId: thread.id, resourceId: thread.resourceId }),
|
|
1824
|
+
createSampleMessageV1({ threadId: thread.id, resourceId: thread.resourceId }),
|
|
1826
1825
|
];
|
|
1827
1826
|
|
|
1828
1827
|
// Save messages
|
|
@@ -1832,11 +1831,7 @@ describe('PostgresStore', () => {
|
|
|
1832
1831
|
// Retrieve messages
|
|
1833
1832
|
const retrievedMessages = await store.getMessagesPaginated({ threadId: thread.id, format: 'v1' });
|
|
1834
1833
|
expect(retrievedMessages.messages).toHaveLength(2);
|
|
1835
|
-
|
|
1836
|
-
const { resourceId, ...rest } = m;
|
|
1837
|
-
return rest;
|
|
1838
|
-
});
|
|
1839
|
-
expect(retrievedMessages.messages).toEqual(expect.arrayContaining(checkMessages));
|
|
1834
|
+
expect(retrievedMessages.messages).toEqual(expect.arrayContaining(messages));
|
|
1840
1835
|
});
|
|
1841
1836
|
|
|
1842
1837
|
it('should maintain message order', async () => {
|
package/src/storage/index.ts
CHANGED
|
@@ -938,7 +938,7 @@ export class PostgresStore extends MastraStorage {
|
|
|
938
938
|
): Promise<MastraMessageV1[] | MastraMessageV2[]> {
|
|
939
939
|
const { threadId, format, selectBy } = args;
|
|
940
940
|
|
|
941
|
-
const selectStatement = `SELECT id, content, role, type, "createdAt", thread_id AS "threadId"`;
|
|
941
|
+
const selectStatement = `SELECT id, content, role, type, "createdAt", thread_id AS "threadId", "resourceId"`;
|
|
942
942
|
const orderByStatement = `ORDER BY "createdAt" DESC`;
|
|
943
943
|
const limit = this.resolveMessageLimit({ last: selectBy?.last, defaultLimit: 40 });
|
|
944
944
|
|
|
@@ -1015,7 +1015,7 @@ export class PostgresStore extends MastraStorage {
|
|
|
1015
1015
|
const fromDate = dateRange?.start;
|
|
1016
1016
|
const toDate = dateRange?.end;
|
|
1017
1017
|
|
|
1018
|
-
const selectStatement = `SELECT id, content, role, type, "createdAt", thread_id AS "threadId"`;
|
|
1018
|
+
const selectStatement = `SELECT id, content, role, type, "createdAt", thread_id AS "threadId", "resourceId"`;
|
|
1019
1019
|
const orderByStatement = `ORDER BY "createdAt" DESC`;
|
|
1020
1020
|
|
|
1021
1021
|
const messages: MastraMessageV2[] = [];
|