@mastra/convex 1.7.6-alpha.0 → 1.8.0-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/README.md +1 -1
- package/dist/docs/SKILL.md +2 -5
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/integrations-databases-convex.md +1 -1
- package/dist/docs/references/{reference-vectors-convex.md → integrations-vectors-convex.md} +13 -1
- package/dist/index.cjs +12 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +12 -3
- package/dist/index.js.map +1 -1
- package/dist/schema.cjs +3 -1
- 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 +3 -1
- package/dist/schema.js.map +1 -1
- package/dist/storage/domains/background-tasks/index.d.ts +1 -0
- package/dist/storage/domains/background-tasks/index.d.ts.map +1 -1
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -27,7 +27,7 @@ await vectorStore.createIndex({ indexName: 'documents', dimension: 1536 });
|
|
|
27
27
|
## Documentation
|
|
28
28
|
|
|
29
29
|
- [Convex integration guide](https://mastra.ai/integrations/databases/convex)
|
|
30
|
-
- [Convex vector reference](https://mastra.ai/
|
|
30
|
+
- [Convex vector reference](https://mastra.ai/integrations/vectors/convex)
|
|
31
31
|
|
|
32
32
|
## Changelog
|
|
33
33
|
|
package/dist/docs/SKILL.md
CHANGED
|
@@ -3,7 +3,7 @@ name: mastra-convex
|
|
|
3
3
|
description: Documentation for @mastra/convex. Use when working with @mastra/convex APIs, configuration, or implementation.
|
|
4
4
|
metadata:
|
|
5
5
|
package: "@mastra/convex"
|
|
6
|
-
version: "1.
|
|
6
|
+
version: "1.8.0-alpha.0"
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
## When to use
|
|
@@ -17,10 +17,7 @@ Read the individual reference documents for detailed explanations and code examp
|
|
|
17
17
|
### Integrations
|
|
18
18
|
|
|
19
19
|
- [Convex](references/integrations-databases-convex.md) - Store Mastra application data in Convex by defining schemas, deploying storage handlers, configuring the client, and enabling real-time serverless persistence.
|
|
20
|
-
|
|
21
|
-
### Reference
|
|
22
|
-
|
|
23
|
-
- [Reference: Convex vector store](references/reference-vectors-convex.md) - The ConvexVector class provides vector storage and similarity search using Convex. It stores embeddings inside Convex and performs cosine similarity search in the Mastra adapter.
|
|
20
|
+
- [Convex](references/integrations-vectors-convex.md) - Store embeddings in Convex and query them from Mastra with cosine similarity and metadata filtering, for development-scale search.
|
|
24
21
|
|
|
25
22
|
|
|
26
23
|
Read [assets/SOURCE_MAP.json](assets/SOURCE_MAP.json) for source code references.
|
|
@@ -230,5 +230,5 @@ Set these environment variables for your deployment:
|
|
|
230
230
|
|
|
231
231
|
## Related
|
|
232
232
|
|
|
233
|
-
- [Convex Vector Store](https://mastra.ai/
|
|
233
|
+
- [Convex Vector Store](https://mastra.ai/integrations/vectors/convex)
|
|
234
234
|
- [Convex Documentation](https://docs.convex.dev/)
|
|
@@ -42,6 +42,8 @@ Before using `ConvexVector`, you need to set up the Convex schema and storage ha
|
|
|
42
42
|
|
|
43
43
|
## Constructor options
|
|
44
44
|
|
|
45
|
+
**id** (`string`): Unique identifier for this vector store instance
|
|
46
|
+
|
|
45
47
|
**deploymentUrl** (`string`): Convex deployment URL (e.g., https\://your-project.convex.cloud)
|
|
46
48
|
|
|
47
49
|
**adminAuthToken** (`string`): Convex admin authentication token
|
|
@@ -271,6 +273,16 @@ Deletes the index and all its vectors.
|
|
|
271
273
|
await vectorStore.deleteIndex({ indexName: 'my_vectors' })
|
|
272
274
|
```
|
|
273
275
|
|
|
276
|
+
### `truncateIndex()`
|
|
277
|
+
|
|
278
|
+
Deletes every vector in an index while keeping the index itself. Rows are removed in batches so each mutation stays within Convex's per-mutation time limit. This method is available on `ConvexVector`; `ConvexNativeVector` uses Convex's own table operations instead.
|
|
279
|
+
|
|
280
|
+
**indexName** (`string`): Name of the index to clear
|
|
281
|
+
|
|
282
|
+
```typescript
|
|
283
|
+
await vectorStore.truncateIndex({ indexName: 'my_vectors' })
|
|
284
|
+
```
|
|
285
|
+
|
|
274
286
|
### `updateVector()`
|
|
275
287
|
|
|
276
288
|
Update a single vector by ID or by metadata filter. Either `id` or `filter` must be provided, but not both.
|
|
@@ -346,7 +358,7 @@ Query results are returned in this format:
|
|
|
346
358
|
interface QueryResult {
|
|
347
359
|
id: string
|
|
348
360
|
score: number
|
|
349
|
-
metadata
|
|
361
|
+
metadata?: Record<string, any>
|
|
350
362
|
vector?: number[] // Only included if includeVector is true
|
|
351
363
|
}
|
|
352
364
|
```
|
package/dist/index.cjs
CHANGED
|
@@ -766,7 +766,9 @@ function toStored(task) {
|
|
|
766
766
|
suspendedAt: task.suspendedAt?.toISOString() ?? null,
|
|
767
767
|
completedAt: task.completedAt?.toISOString() ?? null,
|
|
768
768
|
ownerId: task.ownerId ?? null,
|
|
769
|
-
leaseExpiresAt: task.leaseExpiresAt?.toISOString() ?? null
|
|
769
|
+
leaseExpiresAt: task.leaseExpiresAt?.toISOString() ?? null,
|
|
770
|
+
expiresAt: task.expiresAt?.toISOString() ?? null,
|
|
771
|
+
metadata: serializeJson$1(task.metadata)
|
|
770
772
|
};
|
|
771
773
|
}
|
|
772
774
|
function toStoredPatch(update) {
|
|
@@ -783,6 +785,8 @@ function toStoredPatch(update) {
|
|
|
783
785
|
if ("completedAt" in update) patch.completedAt = update.completedAt?.toISOString() ?? null;
|
|
784
786
|
if ("ownerId" in update) patch.ownerId = update.ownerId ?? null;
|
|
785
787
|
if ("leaseExpiresAt" in update) patch.leaseExpiresAt = update.leaseExpiresAt?.toISOString() ?? null;
|
|
788
|
+
if ("expiresAt" in update) patch.expiresAt = update.expiresAt?.toISOString() ?? null;
|
|
789
|
+
if ("metadata" in update) patch.metadata = serializeJson$1(update.metadata);
|
|
786
790
|
return patch;
|
|
787
791
|
}
|
|
788
792
|
function legacyOrCurrent(stored, currentKey, legacyKey) {
|
|
@@ -819,13 +823,16 @@ function fromStored(stored) {
|
|
|
819
823
|
suspendedAt: record.suspendedAt ? new Date(record.suspendedAt) : void 0,
|
|
820
824
|
completedAt: record.completedAt ? new Date(record.completedAt) : void 0,
|
|
821
825
|
ownerId: record.ownerId ?? void 0,
|
|
822
|
-
leaseExpiresAt: record.leaseExpiresAt ? new Date(record.leaseExpiresAt) : void 0
|
|
826
|
+
leaseExpiresAt: record.leaseExpiresAt ? new Date(record.leaseExpiresAt) : void 0,
|
|
827
|
+
expiresAt: record.expiresAt ? new Date(record.expiresAt) : void 0,
|
|
828
|
+
metadata: parseJson(record.metadata)
|
|
823
829
|
};
|
|
824
830
|
}
|
|
825
831
|
function hasDeleteFilter(filter) {
|
|
826
|
-
return Boolean((Array.isArray(filter.status) ? filter.status.length > 0 : filter.status) || filter.agentId || filter.threadId || filter.resourceId || filter.toolName || filter.toolCallId || filter.runId || filter.fromDate || filter.toDate);
|
|
832
|
+
return Boolean((Array.isArray(filter.status) ? filter.status.length > 0 : filter.status) || filter.agentId || filter.threadId || filter.resourceId || filter.toolName || filter.toolCallId || filter.runId || filter.hasExpiresAt !== void 0 || filter.fromDate || filter.toDate);
|
|
827
833
|
}
|
|
828
834
|
var BackgroundTasksConvex = class extends _mastra_core_storage.BackgroundTasksStorage {
|
|
835
|
+
supportsTaskExpiry = true;
|
|
829
836
|
#db;
|
|
830
837
|
constructor(config) {
|
|
831
838
|
super();
|
|
@@ -848,6 +855,7 @@ var BackgroundTasksConvex = class extends _mastra_core_storage.BackgroundTasksSt
|
|
|
848
855
|
if (options?.expectedStatus) expected.status = options.expectedStatus;
|
|
849
856
|
if (options?.expectedOwnerId !== void 0) expected.ownerId = options.expectedOwnerId;
|
|
850
857
|
if (options?.expectedLeaseExpiresAt !== void 0) expected.leaseExpiresAt = options.expectedLeaseExpiresAt?.toISOString() ?? null;
|
|
858
|
+
if (options?.expectedSuspendedAt !== void 0) expected.suspendedAt = options.expectedSuspendedAt?.toISOString() ?? null;
|
|
851
859
|
return this.#db.patch({
|
|
852
860
|
tableName: _mastra_core_storage.TABLE_BACKGROUND_TASKS,
|
|
853
861
|
id: taskId,
|
|
@@ -907,6 +915,7 @@ var BackgroundTasksConvex = class extends _mastra_core_storage.BackgroundTasksSt
|
|
|
907
915
|
if (filter.toolName) tasks = tasks.filter((t) => t.toolName === filter.toolName);
|
|
908
916
|
if (filter.toolCallId) tasks = tasks.filter((t) => t.toolCallId === filter.toolCallId);
|
|
909
917
|
if (filter.runId) tasks = tasks.filter((t) => t.runId === filter.runId);
|
|
918
|
+
if (filter.hasExpiresAt !== void 0) tasks = tasks.filter((t) => t.expiresAt != null === filter.hasExpiresAt);
|
|
910
919
|
const dateCol = filter.dateFilterBy ?? "createdAt";
|
|
911
920
|
if (filter.fromDate) tasks = tasks.filter((t) => {
|
|
912
921
|
const val = t[dateCol];
|