@mastra/convex 1.9.0 → 1.9.1-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.
@@ -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.9.0"
6
+ version: "1.9.1-alpha.1"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.9.0",
2
+ "version": "1.9.1-alpha.1",
3
3
  "package": "@mastra/convex",
4
4
  "exports": {
5
5
  "ConvexCacheClient": {
@@ -10,7 +10,7 @@
10
10
  "ConvexNativeVector": {
11
11
  "types": "dist/vector/native.d.ts",
12
12
  "implementation": "dist/index.js",
13
- "line": 2861
13
+ "line": 2875
14
14
  },
15
15
  "ConvexServerCache": {
16
16
  "types": "dist/cache/index.d.ts",
@@ -20,12 +20,12 @@
20
20
  "ConvexStore": {
21
21
  "types": "dist/storage/index.d.ts",
22
22
  "implementation": "dist/index.js",
23
- "line": 2558
23
+ "line": 2581
24
24
  },
25
25
  "ConvexVector": {
26
26
  "types": "dist/vector/index.d.ts",
27
27
  "implementation": "dist/index.js",
28
- "line": 2582
28
+ "line": 2605
29
29
  },
30
30
  "TABLE_OBSERVATIONAL_MEMORY": {
31
31
  "types": "dist/schema.d.ts",
package/dist/index.cjs CHANGED
@@ -2339,6 +2339,25 @@ var ScoresConvex = class extends _mastra_core_storage.ScoresStorage {
2339
2339
  }
2340
2340
  };
2341
2341
  // src/storage/domains/workflows/index.ts
2342
+ /**
2343
+ * A stored snapshot reduced to what `listWorkflowRuns({ summary: true })` returns: `status` and
2344
+ * `timestamp` when set, and `parentWorkflow` only when both of its IDs are non-empty strings.
2345
+ * A missing snapshot reduces to `{}`. Reads the stored value in place, without a full copy.
2346
+ */
2347
+ function summarySnapshot(stored) {
2348
+ const parsed = typeof stored === "string" ? JSON.parse(stored) : stored;
2349
+ const { status, timestamp, parentWorkflow } = parsed !== null && typeof parsed === "object" ? parsed : {};
2350
+ const summary = {};
2351
+ if (status !== void 0 && status !== null) summary.status = status;
2352
+ if (timestamp !== void 0 && timestamp !== null) summary.timestamp = timestamp;
2353
+ const workflowId = parentWorkflow?.workflowId;
2354
+ const runId = parentWorkflow?.runId;
2355
+ if (typeof workflowId === "string" && workflowId !== "" && typeof runId === "string" && runId !== "") summary.parentWorkflow = {
2356
+ workflowId,
2357
+ runId
2358
+ };
2359
+ return summary;
2360
+ }
2342
2361
  var WorkflowsConvex = class WorkflowsConvex extends _mastra_core_storage.WorkflowsStorage {
2343
2362
  /**
2344
2363
  * Tables `prune()` can clean up. Run ownership records anchor on `updatedAt` (epoch ms), which every
@@ -2443,8 +2462,12 @@ var WorkflowsConvex = class WorkflowsConvex extends _mastra_core_storage.Workflo
2443
2462
  if (!row) return null;
2444
2463
  return typeof row.snapshot === "string" ? JSON.parse(row.snapshot) : JSON.parse(JSON.stringify(row.snapshot));
2445
2464
  }
2465
+ /**
2466
+ * Lists runs newest first. With `summary`, each snapshot keeps only its status, timestamp and
2467
+ * parent run; the full rows are still read from Convex.
2468
+ */
2446
2469
  async listWorkflowRuns(args = {}) {
2447
- const { workflowName, fromDate, toDate, perPage, page, resourceId, status } = args;
2470
+ const { workflowName, fromDate, toDate, perPage, page, resourceId, status, summary } = args;
2448
2471
  const filters = [];
2449
2472
  if (workflowName) filters.push({
2450
2473
  field: "workflow_name",
@@ -2471,7 +2494,7 @@ var WorkflowsConvex = class WorkflowsConvex extends _mastra_core_storage.Workflo
2471
2494
  runs: rows.map((run) => ({
2472
2495
  workflowName: run.workflow_name,
2473
2496
  runId: run.run_id,
2474
- snapshot: this.ensureSnapshot(run),
2497
+ snapshot: summary ? summarySnapshot(run.snapshot) : this.ensureSnapshot(run),
2475
2498
  createdAt: new Date(run.createdAt),
2476
2499
  updatedAt: new Date(run.updatedAt),
2477
2500
  resourceId: run.resourceId
@@ -2768,38 +2791,29 @@ var ConvexVector = class extends _mastra_core_vector.MastraVector {
2768
2791
  if (!value.some((cond) => this.matchesFilterConditions(recordMetadata, cond))) return false;
2769
2792
  continue;
2770
2793
  }
2771
- if (typeof value === "object" && value !== null && "$in" in value) {
2772
- if (!Array.isArray(value.$in) || !value.$in.includes(recordMetadata[key])) return false;
2773
- continue;
2774
- }
2775
- if (typeof value === "object" && value !== null && "$nin" in value) {
2776
- if (Array.isArray(value.$nin) && value.$nin.includes(recordMetadata[key])) return false;
2777
- continue;
2778
- }
2779
- if (typeof value === "object" && value !== null && "$gt" in value) {
2780
- if (!(recordMetadata[key] > value.$gt)) return false;
2781
- continue;
2782
- }
2783
- if (typeof value === "object" && value !== null && "$gte" in value) {
2784
- if (!(recordMetadata[key] >= value.$gte)) return false;
2785
- continue;
2786
- }
2787
- if (typeof value === "object" && value !== null && "$lt" in value) {
2788
- if (!(recordMetadata[key] < value.$lt)) return false;
2789
- continue;
2790
- }
2791
- if (typeof value === "object" && value !== null && "$lte" in value) {
2792
- if (!(recordMetadata[key] <= value.$lte)) return false;
2793
- continue;
2794
- }
2795
- if (typeof value === "object" && value !== null && "$ne" in value) {
2796
- if (recordMetadata[key] === value.$ne) return false;
2794
+ if (typeof value === "object" && value !== null && !Array.isArray(value) && Object.keys(value).some((k) => k.startsWith("$"))) {
2795
+ if (!this.matchesFieldOperators(recordMetadata[key], value)) return false;
2797
2796
  continue;
2798
2797
  }
2799
2798
  if (recordMetadata[key] !== value) return false;
2800
2799
  }
2801
2800
  return true;
2802
2801
  }
2802
+ matchesFieldOperators(fieldValue, operators) {
2803
+ return Object.entries(operators).every(([operator, operand]) => {
2804
+ switch (operator) {
2805
+ case "$eq": return fieldValue === operand;
2806
+ case "$ne": return fieldValue !== operand;
2807
+ case "$in": return Array.isArray(operand) && operand.includes(fieldValue);
2808
+ case "$nin": return !(Array.isArray(operand) && operand.includes(fieldValue));
2809
+ case "$gt": return fieldValue > operand;
2810
+ case "$gte": return fieldValue >= operand;
2811
+ case "$lt": return fieldValue < operand;
2812
+ case "$lte": return fieldValue <= operand;
2813
+ default: return false;
2814
+ }
2815
+ });
2816
+ }
2803
2817
  async callStorage(request) {
2804
2818
  return this.client.callStorage(request);
2805
2819
  }