@mastra/pg 1.8.1 → 1.8.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.
- package/CHANGELOG.md +22 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/docs-memory-semantic-recall.md +1 -1
- package/dist/docs/references/docs-memory-storage.md +4 -4
- package/dist/docs/references/docs-memory-working-memory.md +1 -1
- package/dist/index.cjs +11 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +11 -13
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/memory/index.d.ts.map +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -7819,7 +7819,7 @@ var MemoryPG = class _MemoryPG extends MemoryStorage {
|
|
|
7819
7819
|
try {
|
|
7820
7820
|
const tableName = getTableName3({ indexName: TABLE_MESSAGES, schemaName: getSchemaName3(this.#schema) });
|
|
7821
7821
|
await this.#db.client.tx(async (t) => {
|
|
7822
|
-
const
|
|
7822
|
+
for (const message of messages) {
|
|
7823
7823
|
if (!message.threadId) {
|
|
7824
7824
|
throw new Error(
|
|
7825
7825
|
`Expected to find a threadId for message, but couldn't find one. An unexpected error has occurred.`
|
|
@@ -7830,7 +7830,7 @@ var MemoryPG = class _MemoryPG extends MemoryStorage {
|
|
|
7830
7830
|
`Expected to find a resourceId for message, but couldn't find one. An unexpected error has occurred.`
|
|
7831
7831
|
);
|
|
7832
7832
|
}
|
|
7833
|
-
|
|
7833
|
+
await t.none(
|
|
7834
7834
|
`INSERT INTO ${tableName} (id, thread_id, content, "createdAt", "createdAtZ", role, type, "resourceId")
|
|
7835
7835
|
VALUES ($1, $2, $3, $4, $5, $6, $7, $8)
|
|
7836
7836
|
ON CONFLICT (id) DO UPDATE SET
|
|
@@ -7850,19 +7850,17 @@ var MemoryPG = class _MemoryPG extends MemoryStorage {
|
|
|
7850
7850
|
message.resourceId
|
|
7851
7851
|
]
|
|
7852
7852
|
);
|
|
7853
|
-
}
|
|
7853
|
+
}
|
|
7854
7854
|
const threadTableName = getTableName3({ indexName: TABLE_THREADS, schemaName: getSchemaName3(this.#schema) });
|
|
7855
7855
|
const nowStr = (/* @__PURE__ */ new Date()).toISOString();
|
|
7856
|
-
|
|
7856
|
+
await t.none(
|
|
7857
7857
|
`UPDATE ${threadTableName}
|
|
7858
|
-
|
|
7859
|
-
|
|
7860
|
-
|
|
7861
|
-
|
|
7862
|
-
`,
|
|
7858
|
+
SET
|
|
7859
|
+
"updatedAt" = $1,
|
|
7860
|
+
"updatedAtZ" = $2
|
|
7861
|
+
WHERE id = $3`,
|
|
7863
7862
|
[nowStr, nowStr, threadId]
|
|
7864
7863
|
);
|
|
7865
|
-
await Promise.all([...messageInserts, threadUpdate]);
|
|
7866
7864
|
});
|
|
7867
7865
|
const messagesWithParsedContent = messages.map((message) => {
|
|
7868
7866
|
if (typeof message.content === "string") {
|
|
@@ -7999,10 +7997,10 @@ var MemoryPG = class _MemoryPG extends MemoryStorage {
|
|
|
7999
7997
|
const threadIds = messages?.map((msg) => msg.thread_id).filter(Boolean) || [];
|
|
8000
7998
|
await t.none(`DELETE FROM ${messageTableName} WHERE id IN (${placeholders})`, messageIds);
|
|
8001
7999
|
if (threadIds.length > 0) {
|
|
8002
|
-
|
|
8003
|
-
|
|
8000
|
+
await t.none(
|
|
8001
|
+
`UPDATE ${threadTableName} SET "updatedAt" = NOW(), "updatedAtZ" = NOW() WHERE id IN (${inPlaceholders(threadIds.length)})`,
|
|
8002
|
+
threadIds
|
|
8004
8003
|
);
|
|
8005
|
-
await Promise.all(updatePromises);
|
|
8006
8004
|
}
|
|
8007
8005
|
});
|
|
8008
8006
|
} catch (error) {
|