@mastra/convex 1.8.0-alpha.0 → 1.8.1-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/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 +29 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +29 -1
- package/dist/index.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/package.json +10 -10
- 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",
|