@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.
@@ -18,6 +18,8 @@ export declare class ConvexServerCache extends MastraServerCache {
18
18
  private readonly client;
19
19
  private readonly keyPrefix;
20
20
  private readonly ttlMs;
21
+ /** Set once the deployed Convex handler is known to lack `listPushIndexed`. */
22
+ private indexedPushUnsupported;
21
23
  constructor(config: ConvexServerCacheConfig);
22
24
  private getKey;
23
25
  private getExpiresAt;
@@ -26,6 +28,11 @@ export declare class ConvexServerCache extends MastraServerCache {
26
28
  set(key: string, value: unknown, ttlMs?: number): Promise<void>;
27
29
  listLength(key: string): Promise<number>;
28
30
  listPush(key: string, value: unknown): Promise<void>;
31
+ /**
32
+ * Allocates the index and appends the entry in one Convex mutation, so a
33
+ * failed request can never consume an index without appending its entry.
34
+ */
35
+ listPushIndexed(listKey: string, counterKey: string, value: Record<string, unknown>, ttlMs?: number): Promise<number>;
29
36
  listFromTo(key: string, from: number, to?: number): Promise<unknown[]>;
30
37
  delete(key: string): Promise<void>;
31
38
  clear(): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cache/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAEvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAExD,MAAM,MAAM,uBAAuB,GAAG;IACpC;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,GAAG,CAAC;IAAE,MAAM,EAAE,iBAAiB,CAAA;CAAE,GAAG,uBAAuB,CAAC,CAAC;AAU9D,qBAAa,iBAAkB,SAAQ,iBAAiB;IACtD,OAAO,CAAC,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EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAKvC;IAEK,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAK3B;IAEK,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAO5C;CACF;AAED,OAAO,EAAE,iBAAiB,EAAE,KAAK,uBAAuB,EAAE,CAAC"}
@@ -16,6 +16,13 @@ export type CacheRequest = {
16
16
  keyPrefix: string;
17
17
  value: unknown;
18
18
  expiresAt: number | null;
19
+ } | {
20
+ op: 'listPushIndexed';
21
+ key: string;
22
+ counterKey: string;
23
+ keyPrefix: string;
24
+ value: Record<string, unknown>;
25
+ expiresAt: number | null;
19
26
  } | {
20
27
  op: 'listFromTo';
21
28
  key: string;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/cache/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GACpB;IACE,EAAE,EAAE,KAAK,CAAC;IACV,GAAG,EAAE,MAAM,CAAC;CACb,GACD;IACE,EAAE,EAAE,KAAK,CAAC;IACV,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,OAAO,CAAC;IACf,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B,GACD;IACE,EAAE,EAAE,YAAY,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;CACb,GACD;IACE,EAAE,EAAE,UAAU,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,OAAO,CAAC;IACf,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B,GACD;IACE,EAAE,EAAE,YAAY,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;CACZ,GACD;IACE,EAAE,EAAE,QAAQ,CAAC;IACb,GAA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SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B,GACD;IACE,EAAE,EAAE,YAAY,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;CACZ,GACD;IACE,EAAE,EAAE,QAAQ,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;CACb,GACD;IACE,EAAE,EAAE,OAAO,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;CACnB,GACD;IACE,EAAE,EAAE,WAAW,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B,CAAC;AAEN,MAAM,MAAM,aAAa,GACrB;IACE,EAAE,EAAE,IAAI,CAAC;IACT,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,GACD;IACE,EAAE,EAAE,KAAK,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC,CAAC"}
@@ -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.8.0"
6
+ version: "1.9.0-alpha.1"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,6 +1,147 @@
1
1
  {
2
- "version": "1.8.0",
2
+ "version": "1.9.0-alpha.1",
3
3
  "package": "@mastra/convex",
4
- "exports": {},
4
+ "exports": {
5
+ "ConvexCacheClient": {
6
+ "types": "dist/cache/client.d.ts",
7
+ "implementation": "dist/index.js",
8
+ "line": 17
9
+ },
10
+ "ConvexNativeVector": {
11
+ "types": "dist/vector/native.d.ts",
12
+ "implementation": "dist/index.js",
13
+ "line": 2861
14
+ },
15
+ "ConvexServerCache": {
16
+ "types": "dist/cache/index.d.ts",
17
+ "implementation": "dist/index.js",
18
+ "line": 92
19
+ },
20
+ "ConvexStore": {
21
+ "types": "dist/storage/index.d.ts",
22
+ "implementation": "dist/index.js",
23
+ "line": 2558
24
+ },
25
+ "ConvexVector": {
26
+ "types": "dist/vector/index.d.ts",
27
+ "implementation": "dist/index.js",
28
+ "line": 2582
29
+ },
30
+ "TABLE_OBSERVATIONAL_MEMORY": {
31
+ "types": "dist/schema.d.ts",
32
+ "implementation": "dist/schema.js",
33
+ "line": 332
34
+ },
35
+ "defineMastraNativeVectorTable": {
36
+ "types": "dist/schema.d.ts",
37
+ "implementation": "dist/schema.js",
38
+ "line": 282
39
+ },
40
+ "mastraBackgroundTasksTable": {
41
+ "types": "dist/schema.d.ts",
42
+ "implementation": "dist/schema.js",
43
+ "line": 174
44
+ },
45
+ "mastraCache": {
46
+ "types": "dist/server/cache.d.ts",
47
+ "implementation": "dist/server-BD08ym0I.js",
48
+ "line": 297
49
+ },
50
+ "mastraCacheListItemsTable": {
51
+ "types": "dist/schema.d.ts",
52
+ "implementation": "dist/schema.js",
53
+ "line": 315
54
+ },
55
+ "mastraCacheTable": {
56
+ "types": "dist/schema.d.ts",
57
+ "implementation": "dist/schema.js",
58
+ "line": 303
59
+ },
60
+ "mastraChannelConfigTable": {
61
+ "types": "dist/schema.d.ts",
62
+ "implementation": "dist/schema.js",
63
+ "line": 159
64
+ },
65
+ "mastraChannelInstallationsTable": {
66
+ "types": "dist/schema.d.ts",
67
+ "implementation": "dist/schema.js",
68
+ "line": 141
69
+ },
70
+ "mastraDocumentsTable": {
71
+ "types": "dist/schema.d.ts",
72
+ "implementation": "dist/schema.js",
73
+ "line": 324
74
+ },
75
+ "mastraMessagesTable": {
76
+ "types": "dist/schema.d.ts",
77
+ "implementation": "dist/schema.js",
78
+ "line": 63
79
+ },
80
+ "mastraNativeVectorAction": {
81
+ "types": "dist/server/native-vector.d.ts",
82
+ "implementation": "dist/server-BD08ym0I.js",
83
+ "line": 2244
84
+ },
85
+ "mastraNativeVectorMutation": {
86
+ "types": "dist/server/native-vector.d.ts",
87
+ "implementation": "dist/server-BD08ym0I.js",
88
+ "line": 2300
89
+ },
90
+ "mastraNativeVectorQuery": {
91
+ "types": "dist/server/native-vector.d.ts",
92
+ "implementation": "dist/server-BD08ym0I.js",
93
+ "line": 2266
94
+ },
95
+ "mastraObservationalMemoryTable": {
96
+ "types": "dist/schema.d.ts",
97
+ "implementation": "dist/schema.js",
98
+ "line": 218
99
+ },
100
+ "mastraResourcesTable": {
101
+ "types": "dist/schema.d.ts",
102
+ "implementation": "dist/schema.js",
103
+ "line": 68
104
+ },
105
+ "mastraScheduleTriggersTable": {
106
+ "types": "dist/schema.d.ts",
107
+ "implementation": "dist/schema.js",
108
+ "line": 123
109
+ },
110
+ "mastraSchedulesTable": {
111
+ "types": "dist/schema.d.ts",
112
+ "implementation": "dist/schema.js",
113
+ "line": 102
114
+ },
115
+ "mastraScoresTable": {
116
+ "types": "dist/schema.d.ts",
117
+ "implementation": "dist/schema.js",
118
+ "line": 94
119
+ },
120
+ "mastraStorage": {
121
+ "types": "dist/server/storage.d.ts",
122
+ "implementation": "dist/server-BD08ym0I.js",
123
+ "line": 1523
124
+ },
125
+ "mastraThreadsTable": {
126
+ "types": "dist/schema.d.ts",
127
+ "implementation": "dist/schema.js",
128
+ "line": 58
129
+ },
130
+ "mastraVectorIndexesTable": {
131
+ "types": "dist/schema.d.ts",
132
+ "implementation": "dist/schema.js",
133
+ "line": 258
134
+ },
135
+ "mastraVectorsTable": {
136
+ "types": "dist/schema.d.ts",
137
+ "implementation": "dist/schema.js",
138
+ "line": 269
139
+ },
140
+ "mastraWorkflowSnapshotsTable": {
141
+ "types": "dist/schema.d.ts",
142
+ "implementation": "dist/schema.js",
143
+ "line": 81
144
+ }
145
+ },
5
146
  "modules": {}
6
147
  }
package/dist/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_server = require("./server-BwpzJLxa.cjs");
2
+ const require_server = require("./server-B6-3iw37.cjs");
3
3
  const require_schema = require("./schema.cjs");
4
4
  let _mastra_core_cache = require("@mastra/core/cache");
5
5
  let _mastra_core_storage = require("@mastra/core/storage");
@@ -95,6 +95,8 @@ var ConvexServerCache = class extends _mastra_core_cache.MastraServerCache {
95
95
  client;
96
96
  keyPrefix;
97
97
  ttlMs;
98
+ /** Set once the deployed Convex handler is known to lack `listPushIndexed`. */
99
+ indexedPushUnsupported = false;
98
100
  constructor(config) {
99
101
  super({ name: "ConvexServerCache" });
100
102
  this.client = isClientConfig$1(config) ? config.client : new ConvexCacheClient(config);
@@ -145,6 +147,32 @@ var ConvexServerCache = class extends _mastra_core_cache.MastraServerCache {
145
147
  expiresAt: this.getExpiresAt()
146
148
  }));
147
149
  }
150
+ /**
151
+ * Allocates the index and appends the entry in one Convex mutation, so a
152
+ * failed request can never consume an index without appending its entry.
153
+ */
154
+ async listPushIndexed(listKey, counterKey, value, ttlMs) {
155
+ if (this.indexedPushUnsupported) return super.listPushIndexed(listKey, counterKey, value, ttlMs);
156
+ const expiresAt = this.ttlMs > 0 ? Date.now() + Math.max(this.ttlMs, ttlMs ?? 0) : null;
157
+ const { index: _ignored, ...body } = value;
158
+ try {
159
+ return await this.callUntilSettled(() => ({
160
+ op: "listPushIndexed",
161
+ key: this.getKey(listKey),
162
+ counterKey: this.getKey(counterKey),
163
+ keyPrefix: this.keyPrefix,
164
+ value: body,
165
+ expiresAt
166
+ }));
167
+ } catch (error) {
168
+ if (error instanceof Error && error.message === "Unsupported operation listPushIndexed") {
169
+ this.indexedPushUnsupported = true;
170
+ 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.");
171
+ return super.listPushIndexed(listKey, counterKey, value, ttlMs);
172
+ }
173
+ throw error;
174
+ }
175
+ }
148
176
  async listFromTo(key, from, to = -1) {
149
177
  return this.callUntilSettled(() => ({
150
178
  op: "listFromTo",
@@ -2026,6 +2054,8 @@ function scheduleToRecord(schedule) {
2026
2054
  metadata: schedule.metadata == null ? null : serializeJson(schedule.metadata),
2027
2055
  owner_type: schedule.ownerType ?? null,
2028
2056
  owner_id: schedule.ownerId ?? null,
2057
+ run_at: schedule.runAt ?? null,
2058
+ end_at: schedule.endAt ?? null,
2029
2059
  workflow_id: schedule.target.type === "workflow" ? schedule.target.workflowId : null
2030
2060
  };
2031
2061
  }
@@ -2048,6 +2078,8 @@ function recordToSchedule(record) {
2048
2078
  if (metadata != null) schedule.metadata = metadata;
2049
2079
  if (record.owner_type != null) schedule.ownerType = String(record.owner_type);
2050
2080
  if (record.owner_id != null) schedule.ownerId = String(record.owner_id);
2081
+ if (record.run_at != null) schedule.runAt = Number(record.run_at);
2082
+ if (record.end_at != null) schedule.endAt = Number(record.end_at);
2051
2083
  return schedule;
2052
2084
  }
2053
2085
  function triggerToRecord(trigger) {
@@ -2173,6 +2205,8 @@ var SchedulesConvex = class extends _mastra_core_storage.SchedulesStorage {
2173
2205
  if ("metadata" in patch) updates.metadata = patch.metadata == null ? null : serializeJson(patch.metadata);
2174
2206
  if ("ownerType" in patch) updates.owner_type = patch.ownerType ?? null;
2175
2207
  if ("ownerId" in patch) updates.owner_id = patch.ownerId ?? null;
2208
+ if ("runAt" in patch) updates.run_at = patch.runAt ?? null;
2209
+ if ("endAt" in patch) updates.end_at = patch.endAt ?? null;
2176
2210
  if (Object.keys(updates).length === 0) {
2177
2211
  const existing = await this.getSchedule(id);
2178
2212
  if (!existing) throw new Error(`Schedule ${id} not found`);