@mastra/convex 1.2.1-alpha.1 → 1.2.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.
- package/CHANGELOG.md +9 -0
- package/dist/{chunk-ZFDTGYKC.cjs → chunk-6P3LEDHY.cjs} +52 -2
- package/dist/chunk-6P3LEDHY.cjs.map +1 -0
- package/dist/{chunk-LXPDHMDN.js → chunk-77UWNT5X.js} +52 -2
- package/dist/chunk-77UWNT5X.js.map +1 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +6 -6
- package/dist/index.cjs +30 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +25 -5
- package/dist/index.js.map +1 -1
- package/dist/server/index.cjs +6 -6
- package/dist/server/index.js +1 -1
- package/dist/server/storage.d.ts.map +1 -1
- package/dist/storage/db/index.d.ts +1 -0
- package/dist/storage/db/index.d.ts.map +1 -1
- package/dist/storage/domains/memory/index.d.ts.map +1 -1
- package/dist/storage/types.d.ts +4 -0
- package/dist/storage/types.d.ts.map +1 -1
- package/package.json +3 -3
- package/dist/chunk-LXPDHMDN.js.map +0 -1
- package/dist/chunk-ZFDTGYKC.cjs.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { mastraCache, mastraNativeVectorAction, mastraNativeVectorMutation, mastraNativeVectorQuery, mastraStorage } from './chunk-
|
|
1
|
+
export { mastraCache, mastraNativeVectorAction, mastraNativeVectorMutation, mastraNativeVectorQuery, mastraStorage } from './chunk-77UWNT5X.js';
|
|
2
2
|
export { TABLE_BACKGROUND_TASKS, TABLE_CHANNEL_CONFIG, TABLE_CHANNEL_INSTALLATIONS, TABLE_MESSAGES, TABLE_RESOURCES, TABLE_SCHEDULES, TABLE_SCHEDULE_TRIGGERS, TABLE_SCORERS, TABLE_THREADS, TABLE_WORKFLOW_SNAPSHOT, defineMastraNativeVectorTable, mastraBackgroundTasksTable, mastraCacheListItemsTable, mastraCacheTable, mastraChannelConfigTable, mastraChannelInstallationsTable, mastraDocumentsTable, mastraMessagesTable, mastraResourcesTable, mastraScheduleTriggersTable, mastraSchedulesTable, mastraScoresTable, mastraThreadsTable, mastraVectorIndexesTable, mastraVectorsTable, mastraWorkflowSnapshotsTable } from './chunk-MC75WADX.js';
|
|
3
3
|
import { MastraServerCache } from '@mastra/core/cache';
|
|
4
4
|
import { MastraCompositeStore, createVectorErrorId, MemoryStorage, TABLE_THREADS, TABLE_MESSAGES, TABLE_RESOURCES, createStorageErrorId, normalizePerPage, calculatePagination, filterByDateRange, safelyParseJSON, WorkflowsStorage, TABLE_WORKFLOW_SNAPSHOT, ScoresStorage, TABLE_SCORERS, ChannelsStorage, TABLE_CHANNEL_INSTALLATIONS, TABLE_CHANNEL_CONFIG, SchedulesStorage, TABLE_SCHEDULE_TRIGGERS, TABLE_SCHEDULES, BackgroundTasksStorage, TABLE_BACKGROUND_TASKS } from '@mastra/core/storage';
|
|
@@ -275,6 +275,7 @@ var ConvexAdminClient = class {
|
|
|
275
275
|
return result;
|
|
276
276
|
}
|
|
277
277
|
};
|
|
278
|
+
var LOAD_MANY_REQUEST_BATCH_SIZE = 10;
|
|
278
279
|
function resolveConvexConfig(config) {
|
|
279
280
|
if ("client" in config) {
|
|
280
281
|
return config.client;
|
|
@@ -390,6 +391,21 @@ var ConvexDB = class extends MastraBase {
|
|
|
390
391
|
});
|
|
391
392
|
return result;
|
|
392
393
|
}
|
|
394
|
+
async loadMany(tableName, ids) {
|
|
395
|
+
const uniqueIds = [...new Set(ids)];
|
|
396
|
+
if (uniqueIds.length === 0) return [];
|
|
397
|
+
const rows = [];
|
|
398
|
+
for (let index = 0; index < uniqueIds.length; index += LOAD_MANY_REQUEST_BATCH_SIZE) {
|
|
399
|
+
rows.push(
|
|
400
|
+
...await this.client.callStorage({
|
|
401
|
+
op: "loadMany",
|
|
402
|
+
tableName,
|
|
403
|
+
ids: uniqueIds.slice(index, index + LOAD_MANY_REQUEST_BATCH_SIZE)
|
|
404
|
+
})
|
|
405
|
+
);
|
|
406
|
+
}
|
|
407
|
+
return rows;
|
|
408
|
+
}
|
|
393
409
|
async queryTable(tableName, filters, indexHint, limit) {
|
|
394
410
|
return this.client.callStorage({
|
|
395
411
|
op: "queryTable",
|
|
@@ -1095,8 +1111,8 @@ var MemoryConvex = class extends MemoryStorage {
|
|
|
1095
1111
|
if (messageIds.length === 0) {
|
|
1096
1112
|
return { messages: [] };
|
|
1097
1113
|
}
|
|
1098
|
-
const rows = await this.#db.
|
|
1099
|
-
const filtered = rows.
|
|
1114
|
+
const rows = await this.#db.loadMany(TABLE_MESSAGES, messageIds);
|
|
1115
|
+
const filtered = rows.map((row) => this.parseStoredMessage(row));
|
|
1100
1116
|
const list = new MessageList().add(filtered, "memory");
|
|
1101
1117
|
return { messages: list.get.all.db() };
|
|
1102
1118
|
}
|
|
@@ -1140,11 +1156,15 @@ var MemoryConvex = class extends MemoryStorage {
|
|
|
1140
1156
|
messages
|
|
1141
1157
|
}) {
|
|
1142
1158
|
if (messages.length === 0) return [];
|
|
1143
|
-
const
|
|
1159
|
+
const existingRows = await this.#db.loadMany(
|
|
1160
|
+
TABLE_MESSAGES,
|
|
1161
|
+
messages.map((message) => message.id)
|
|
1162
|
+
);
|
|
1163
|
+
const existing = new Map(existingRows.map((row) => [row.id, row]));
|
|
1144
1164
|
const updated = [];
|
|
1145
1165
|
const affectedThreadIds = /* @__PURE__ */ new Set();
|
|
1146
1166
|
for (const update of messages) {
|
|
1147
|
-
const current = existing.
|
|
1167
|
+
const current = existing.get(update.id);
|
|
1148
1168
|
if (!current) continue;
|
|
1149
1169
|
affectedThreadIds.add(current.thread_id);
|
|
1150
1170
|
if (update.threadId) {
|