@mastra/convex 1.8.0 → 1.9.0-alpha.1
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/dist/cache/index.d.ts +7 -0
- package/dist/cache/index.d.ts.map +1 -1
- package/dist/cache/types.d.ts +7 -0
- package/dist/cache/types.d.ts.map +1 -1
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +143 -2
- package/dist/index.cjs +35 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +35 -1
- package/dist/index.js.map +1 -1
- package/dist/schema.cjs +2 -0
- package/dist/schema.cjs.map +1 -1
- package/dist/schema.d.ts +5 -1
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +2 -0
- package/dist/schema.js.map +1 -1
- package/dist/server/cache.d.ts.map +1 -1
- package/dist/server/index.cjs +1 -1
- package/dist/server/index.js +1 -1
- package/dist/{server-BwpzJLxa.cjs → server-B6-3iw37.cjs} +62 -2
- package/dist/server-B6-3iw37.cjs.map +1 -0
- package/dist/{server-BRy-fyDz.js → server-BD08ym0I.js} +62 -2
- package/dist/server-BD08ym0I.js.map +1 -0
- package/dist/storage/domains/memory/index.d.ts +1 -1
- package/dist/storage/domains/schedules/index.d.ts.map +1 -1
- package/package.json +9 -9
- package/dist/server-BRy-fyDz.js.map +0 -1
- package/dist/server-BwpzJLxa.cjs.map +0 -1
- /package/dist/_types/{@internal_core → @internal_core@0.1.4}/dist/memory/index.d.ts +0 -0
- /package/dist/_types/{@internal_core → @internal_core@0.1.4}/package.json +0 -0
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as mastraCache, i as mastraStorage, n as mastraNativeVectorMutation, r as mastraNativeVectorQuery, t as mastraNativeVectorAction } from "./server-
|
|
1
|
+
import { a as mastraCache, i as mastraStorage, n as mastraNativeVectorMutation, r as mastraNativeVectorQuery, t as mastraNativeVectorAction } from "./server-BD08ym0I.js";
|
|
2
2
|
import { TABLE_BACKGROUND_TASKS, TABLE_CHANNEL_CONFIG, TABLE_CHANNEL_INSTALLATIONS, TABLE_MESSAGES, TABLE_OBSERVATIONAL_MEMORY, TABLE_RESOURCES, TABLE_SCHEDULES, TABLE_SCHEDULE_TRIGGERS, TABLE_SCORERS, TABLE_THREADS, TABLE_WORKFLOW_SNAPSHOT, defineMastraNativeVectorTable, mastraBackgroundTasksTable, mastraCacheListItemsTable, mastraCacheTable, mastraChannelConfigTable, mastraChannelInstallationsTable, mastraDocumentsTable, mastraMessagesTable, mastraObservationalMemoryTable, mastraResourcesTable, mastraScheduleTriggersTable, mastraSchedulesTable, mastraScoresTable, mastraThreadsTable, mastraVectorIndexesTable, mastraVectorsTable, mastraWorkflowSnapshotsTable } from "./schema.js";
|
|
3
3
|
import { MastraServerCache } from "@mastra/core/cache";
|
|
4
4
|
import { BackgroundTasksStorage, ChannelsStorage, MastraCompositeStore, MemoryStorage, RUN_FENCE_CONFLICT_ERROR_ID, RunFenceConflictError, SchedulesStorage, ScoresStorage, TABLE_BACKGROUND_TASKS as TABLE_BACKGROUND_TASKS$1, TABLE_CHANNEL_CONFIG as TABLE_CHANNEL_CONFIG$1, TABLE_CHANNEL_INSTALLATIONS as TABLE_CHANNEL_INSTALLATIONS$1, TABLE_MEMORY_RUN_FENCES, TABLE_MESSAGES as TABLE_MESSAGES$1, TABLE_RESOURCES as TABLE_RESOURCES$1, TABLE_SCHEDULES as TABLE_SCHEDULES$1, TABLE_SCHEDULE_TRIGGERS as TABLE_SCHEDULE_TRIGGERS$1, TABLE_SCORERS as TABLE_SCORERS$1, TABLE_THREADS as TABLE_THREADS$1, TABLE_WORKFLOW_RUN_OWNERS, TABLE_WORKFLOW_SNAPSHOT as TABLE_WORKFLOW_SNAPSHOT$1, WorkflowsStorage, calculatePagination, createStorageErrorId, createVectorErrorId, executeRetentionPrune, filterByDateRange, normalizePerPage, normalizeScheduleTarget, resolveRetentionTargets, resolveRunFence, retentionCutoffMs, safelyParseJSON, storageMessageMatchesMetadataFilter, validateStorageMetadataFilter } from "@mastra/core/storage";
|
|
@@ -93,6 +93,8 @@ var ConvexServerCache = class extends MastraServerCache {
|
|
|
93
93
|
client;
|
|
94
94
|
keyPrefix;
|
|
95
95
|
ttlMs;
|
|
96
|
+
/** Set once the deployed Convex handler is known to lack `listPushIndexed`. */
|
|
97
|
+
indexedPushUnsupported = false;
|
|
96
98
|
constructor(config) {
|
|
97
99
|
super({ name: "ConvexServerCache" });
|
|
98
100
|
this.client = isClientConfig$1(config) ? config.client : new ConvexCacheClient(config);
|
|
@@ -143,6 +145,32 @@ var ConvexServerCache = class extends MastraServerCache {
|
|
|
143
145
|
expiresAt: this.getExpiresAt()
|
|
144
146
|
}));
|
|
145
147
|
}
|
|
148
|
+
/**
|
|
149
|
+
* Allocates the index and appends the entry in one Convex mutation, so a
|
|
150
|
+
* failed request can never consume an index without appending its entry.
|
|
151
|
+
*/
|
|
152
|
+
async listPushIndexed(listKey, counterKey, value, ttlMs) {
|
|
153
|
+
if (this.indexedPushUnsupported) return super.listPushIndexed(listKey, counterKey, value, ttlMs);
|
|
154
|
+
const expiresAt = this.ttlMs > 0 ? Date.now() + Math.max(this.ttlMs, ttlMs ?? 0) : null;
|
|
155
|
+
const { index: _ignored, ...body } = value;
|
|
156
|
+
try {
|
|
157
|
+
return await this.callUntilSettled(() => ({
|
|
158
|
+
op: "listPushIndexed",
|
|
159
|
+
key: this.getKey(listKey),
|
|
160
|
+
counterKey: this.getKey(counterKey),
|
|
161
|
+
keyPrefix: this.keyPrefix,
|
|
162
|
+
value: body,
|
|
163
|
+
expiresAt
|
|
164
|
+
}));
|
|
165
|
+
} catch (error) {
|
|
166
|
+
if (error instanceof Error && error.message === "Unsupported operation listPushIndexed") {
|
|
167
|
+
this.indexedPushUnsupported = true;
|
|
168
|
+
this.logger.warn("[ConvexServerCache] The deployed Convex cache handler does not support listPushIndexed; falling back to increment + listPush, which is not atomic and ignores the requested retention, so cached replay expires after the default cache TTL. Redeploy your Convex functions, then restart this process.");
|
|
169
|
+
return super.listPushIndexed(listKey, counterKey, value, ttlMs);
|
|
170
|
+
}
|
|
171
|
+
throw error;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
146
174
|
async listFromTo(key, from, to = -1) {
|
|
147
175
|
return this.callUntilSettled(() => ({
|
|
148
176
|
op: "listFromTo",
|
|
@@ -2024,6 +2052,8 @@ function scheduleToRecord(schedule) {
|
|
|
2024
2052
|
metadata: schedule.metadata == null ? null : serializeJson(schedule.metadata),
|
|
2025
2053
|
owner_type: schedule.ownerType ?? null,
|
|
2026
2054
|
owner_id: schedule.ownerId ?? null,
|
|
2055
|
+
run_at: schedule.runAt ?? null,
|
|
2056
|
+
end_at: schedule.endAt ?? null,
|
|
2027
2057
|
workflow_id: schedule.target.type === "workflow" ? schedule.target.workflowId : null
|
|
2028
2058
|
};
|
|
2029
2059
|
}
|
|
@@ -2046,6 +2076,8 @@ function recordToSchedule(record) {
|
|
|
2046
2076
|
if (metadata != null) schedule.metadata = metadata;
|
|
2047
2077
|
if (record.owner_type != null) schedule.ownerType = String(record.owner_type);
|
|
2048
2078
|
if (record.owner_id != null) schedule.ownerId = String(record.owner_id);
|
|
2079
|
+
if (record.run_at != null) schedule.runAt = Number(record.run_at);
|
|
2080
|
+
if (record.end_at != null) schedule.endAt = Number(record.end_at);
|
|
2049
2081
|
return schedule;
|
|
2050
2082
|
}
|
|
2051
2083
|
function triggerToRecord(trigger) {
|
|
@@ -2171,6 +2203,8 @@ var SchedulesConvex = class extends SchedulesStorage {
|
|
|
2171
2203
|
if ("metadata" in patch) updates.metadata = patch.metadata == null ? null : serializeJson(patch.metadata);
|
|
2172
2204
|
if ("ownerType" in patch) updates.owner_type = patch.ownerType ?? null;
|
|
2173
2205
|
if ("ownerId" in patch) updates.owner_id = patch.ownerId ?? null;
|
|
2206
|
+
if ("runAt" in patch) updates.run_at = patch.runAt ?? null;
|
|
2207
|
+
if ("endAt" in patch) updates.end_at = patch.endAt ?? null;
|
|
2174
2208
|
if (Object.keys(updates).length === 0) {
|
|
2175
2209
|
const existing = await this.getSchedule(id);
|
|
2176
2210
|
if (!existing) throw new Error(`Schedule ${id} not found`);
|