@mastra/convex 0.0.0-fix-zod4-schema-validation-20251212180638 → 0.0.0-fix-11329-windows-path-20251222155941

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.
Files changed (42) hide show
  1. package/CHANGELOG.md +175 -5
  2. package/README.md +1 -1
  3. package/dist/{chunk-QKN2PWR2.cjs → chunk-BKVR7SL7.cjs} +2 -89
  4. package/dist/chunk-BKVR7SL7.cjs.map +1 -0
  5. package/dist/{chunk-NZCHEPNU.js → chunk-KSAPIIEJ.js} +5 -65
  6. package/dist/chunk-KSAPIIEJ.js.map +1 -0
  7. package/dist/chunk-PKUUSREO.js +76 -0
  8. package/dist/chunk-PKUUSREO.js.map +1 -0
  9. package/dist/chunk-ZBUP3DS6.cjs +93 -0
  10. package/dist/chunk-ZBUP3DS6.cjs.map +1 -0
  11. package/dist/index.cjs +177 -168
  12. package/dist/index.cjs.map +1 -1
  13. package/dist/index.js +161 -152
  14. package/dist/index.js.map +1 -1
  15. package/dist/schema.cjs +72 -0
  16. package/dist/schema.cjs.map +1 -0
  17. package/dist/schema.d.ts +151 -0
  18. package/dist/schema.d.ts.map +1 -0
  19. package/dist/schema.js +3 -0
  20. package/dist/schema.js.map +1 -0
  21. package/dist/server/index.cjs +19 -18
  22. package/dist/server/index.d.ts +1 -1
  23. package/dist/server/index.d.ts.map +1 -1
  24. package/dist/server/index.js +2 -1
  25. package/dist/storage/db/index.d.ts +57 -0
  26. package/dist/storage/db/index.d.ts.map +1 -0
  27. package/dist/storage/domains/{memory.d.ts → memory/index.d.ts} +6 -4
  28. package/dist/storage/domains/memory/index.d.ts.map +1 -0
  29. package/dist/storage/domains/{scores.d.ts → scores/index.d.ts} +6 -4
  30. package/dist/storage/domains/scores/index.d.ts.map +1 -0
  31. package/dist/storage/domains/{workflows.d.ts → workflows/index.d.ts} +6 -4
  32. package/dist/storage/domains/workflows/index.d.ts.map +1 -0
  33. package/dist/storage/index.d.ts +30 -31
  34. package/dist/storage/index.d.ts.map +1 -1
  35. package/package.json +15 -6
  36. package/dist/chunk-NZCHEPNU.js.map +0 -1
  37. package/dist/chunk-QKN2PWR2.cjs.map +0 -1
  38. package/dist/storage/domains/memory.d.ts.map +0 -1
  39. package/dist/storage/domains/scores.d.ts.map +0 -1
  40. package/dist/storage/domains/workflows.d.ts.map +0 -1
  41. package/dist/storage/operations.d.ts +0 -40
  42. package/dist/storage/operations.d.ts.map +0 -1
package/dist/index.js CHANGED
@@ -1,8 +1,10 @@
1
- export { TABLE_MESSAGES, TABLE_RESOURCES, TABLE_SCORERS, TABLE_THREADS, TABLE_WORKFLOW_SNAPSHOT, mastraDocumentsTable, mastraMessagesTable, mastraResourcesTable, mastraScoresTable, mastraStorage, mastraThreadsTable, mastraVectorIndexesTable, mastraVectorsTable, mastraWorkflowSnapshotsTable } from './chunk-NZCHEPNU.js';
2
- import { MastraStorage, StoreOperations, TABLE_WORKFLOW_SNAPSHOT, MemoryStorage, TABLE_THREADS, createStorageErrorId, TABLE_MESSAGES, normalizePerPage, calculatePagination, safelyParseJSON, TABLE_RESOURCES, WorkflowsStorage, ScoresStorage, TABLE_SCORERS } from '@mastra/core/storage';
1
+ export { mastraStorage } from './chunk-KSAPIIEJ.js';
2
+ export { TABLE_MESSAGES, TABLE_RESOURCES, TABLE_SCORERS, TABLE_THREADS, TABLE_WORKFLOW_SNAPSHOT, mastraDocumentsTable, mastraMessagesTable, mastraResourcesTable, mastraScoresTable, mastraThreadsTable, mastraVectorIndexesTable, mastraVectorsTable, mastraWorkflowSnapshotsTable } from './chunk-PKUUSREO.js';
3
+ import { MastraStorage, MemoryStorage, TABLE_THREADS, TABLE_MESSAGES, TABLE_RESOURCES, createStorageErrorId, normalizePerPage, calculatePagination, safelyParseJSON, WorkflowsStorage, TABLE_WORKFLOW_SNAPSHOT, ScoresStorage, TABLE_SCORERS } from '@mastra/core/storage';
3
4
  import { MessageList } from '@mastra/core/agent';
4
5
  import { MastraError, ErrorCategory, ErrorDomain } from '@mastra/core/error';
5
6
  import crypto from 'crypto';
7
+ import { MastraBase } from '@mastra/core/base';
6
8
  import { MastraVector } from '@mastra/core/vector';
7
9
 
8
10
  // src/storage/client.ts
@@ -68,13 +70,114 @@ var ConvexAdminClient = class {
68
70
  return result;
69
71
  }
70
72
  };
73
+ function resolveConvexConfig(config) {
74
+ if ("client" in config) {
75
+ return config.client;
76
+ }
77
+ return new ConvexAdminClient(config);
78
+ }
79
+ var ConvexDB = class extends MastraBase {
80
+ constructor(client) {
81
+ super({ name: "convex-db" });
82
+ this.client = client;
83
+ }
84
+ async hasColumn(_table, _column) {
85
+ return true;
86
+ }
87
+ async clearTable({ tableName }) {
88
+ let hasMore = true;
89
+ while (hasMore) {
90
+ const response = await this.client.callStorageRaw({
91
+ op: "clearTable",
92
+ tableName
93
+ });
94
+ hasMore = response.hasMore ?? false;
95
+ }
96
+ }
97
+ async dropTable({ tableName }) {
98
+ let hasMore = true;
99
+ while (hasMore) {
100
+ const response = await this.client.callStorageRaw({
101
+ op: "dropTable",
102
+ tableName
103
+ });
104
+ hasMore = response.hasMore ?? false;
105
+ }
106
+ }
107
+ async insert({ tableName, record }) {
108
+ await this.client.callStorage({
109
+ op: "insert",
110
+ tableName,
111
+ record: this.normalizeRecord(tableName, record)
112
+ });
113
+ }
114
+ async batchInsert({ tableName, records }) {
115
+ if (records.length === 0) return;
116
+ await this.client.callStorage({
117
+ op: "batchInsert",
118
+ tableName,
119
+ records: records.map((record) => this.normalizeRecord(tableName, record))
120
+ });
121
+ }
122
+ async load({ tableName, keys }) {
123
+ const result = await this.client.callStorage({
124
+ op: "load",
125
+ tableName,
126
+ keys
127
+ });
128
+ return result;
129
+ }
130
+ async queryTable(tableName, filters) {
131
+ return this.client.callStorage({
132
+ op: "queryTable",
133
+ tableName,
134
+ filters
135
+ });
136
+ }
137
+ async deleteMany(tableName, ids) {
138
+ if (ids.length === 0) return;
139
+ await this.client.callStorage({
140
+ op: "deleteMany",
141
+ tableName,
142
+ ids
143
+ });
144
+ }
145
+ normalizeRecord(tableName, record) {
146
+ const normalized = { ...record };
147
+ if (tableName === TABLE_WORKFLOW_SNAPSHOT && !normalized.id) {
148
+ const runId = normalized.run_id || normalized.runId;
149
+ const workflowName = normalized.workflow_name || normalized.workflowName;
150
+ normalized.id = workflowName ? `${workflowName}-${runId}` : runId;
151
+ }
152
+ if (!normalized.id) {
153
+ normalized.id = crypto.randomUUID();
154
+ }
155
+ for (const [key, value] of Object.entries(normalized)) {
156
+ if (value instanceof Date) {
157
+ normalized[key] = value.toISOString();
158
+ }
159
+ }
160
+ return normalized;
161
+ }
162
+ };
163
+
164
+ // src/storage/domains/memory/index.ts
71
165
  var MemoryConvex = class extends MemoryStorage {
72
- constructor(operations) {
166
+ #db;
167
+ constructor(config) {
73
168
  super();
74
- this.operations = operations;
169
+ const client = resolveConvexConfig(config);
170
+ this.#db = new ConvexDB(client);
171
+ }
172
+ async init() {
173
+ }
174
+ async dangerouslyClearAll() {
175
+ await this.#db.clearTable({ tableName: TABLE_THREADS });
176
+ await this.#db.clearTable({ tableName: TABLE_MESSAGES });
177
+ await this.#db.clearTable({ tableName: TABLE_RESOURCES });
75
178
  }
76
179
  async getThreadById({ threadId }) {
77
- const row = await this.operations.load({
180
+ const row = await this.#db.load({
78
181
  tableName: TABLE_THREADS,
79
182
  keys: { id: threadId }
80
183
  });
@@ -87,7 +190,7 @@ var MemoryConvex = class extends MemoryStorage {
87
190
  };
88
191
  }
89
192
  async saveThread({ thread }) {
90
- await this.operations.insert({
193
+ await this.#db.insert({
91
194
  tableName: TABLE_THREADS,
92
195
  record: {
93
196
  ...thread,
@@ -123,21 +226,21 @@ var MemoryConvex = class extends MemoryStorage {
123
226
  return updated;
124
227
  }
125
228
  async deleteThread({ threadId }) {
126
- const messages = await this.operations.queryTable(TABLE_MESSAGES, [
229
+ const messages = await this.#db.queryTable(TABLE_MESSAGES, [
127
230
  { field: "thread_id", value: threadId }
128
231
  ]);
129
- await this.operations.deleteMany(
232
+ await this.#db.deleteMany(
130
233
  TABLE_MESSAGES,
131
234
  messages.map((msg) => msg.id)
132
235
  );
133
- await this.operations.deleteMany(TABLE_THREADS, [threadId]);
236
+ await this.#db.deleteMany(TABLE_THREADS, [threadId]);
134
237
  }
135
238
  async listThreadsByResourceId(args) {
136
239
  const { resourceId, page = 0, perPage: perPageInput, orderBy } = args;
137
240
  const perPage = normalizePerPage(perPageInput, 100);
138
241
  const { field, direction } = this.parseOrderBy(orderBy);
139
242
  const { offset, perPage: perPageForResponse } = calculatePagination(page, perPageInput, perPage);
140
- const rows = await this.operations.queryTable(TABLE_THREADS, [{ field: "resourceId", value: resourceId }]);
243
+ const rows = await this.#db.queryTable(TABLE_THREADS, [{ field: "resourceId", value: resourceId }]);
141
244
  const threads = rows.map((row) => ({
142
245
  ...row,
143
246
  metadata: typeof row.metadata === "string" ? JSON.parse(row.metadata) : row.metadata,
@@ -180,9 +283,7 @@ var MemoryConvex = class extends MemoryStorage {
180
283
  const { field, direction } = this.parseOrderBy(orderBy, "ASC");
181
284
  let rows = [];
182
285
  for (const tid of threadIds) {
183
- const threadRows = await this.operations.queryTable(TABLE_MESSAGES, [
184
- { field: "thread_id", value: tid }
185
- ]);
286
+ const threadRows = await this.#db.queryTable(TABLE_MESSAGES, [{ field: "thread_id", value: tid }]);
186
287
  rows.push(...threadRows);
187
288
  }
188
289
  if (resourceId) {
@@ -226,14 +327,14 @@ var MemoryConvex = class extends MemoryStorage {
226
327
  }
227
328
  }
228
329
  if (!target) {
229
- const messageRows = await this.operations.queryTable(TABLE_MESSAGES, [
330
+ const messageRows = await this.#db.queryTable(TABLE_MESSAGES, [
230
331
  { field: "id", value: includeItem.id }
231
332
  ]);
232
333
  if (messageRows.length > 0) {
233
334
  target = messageRows[0];
234
335
  targetThreadId = target.thread_id;
235
336
  if (targetThreadId && !threadMessagesCache.has(targetThreadId)) {
236
- const otherThreadRows = await this.operations.queryTable(TABLE_MESSAGES, [
337
+ const otherThreadRows = await this.#db.queryTable(TABLE_MESSAGES, [
237
338
  { field: "thread_id", value: targetThreadId }
238
339
  ]);
239
340
  threadMessagesCache.set(targetThreadId, otherThreadRows);
@@ -276,7 +377,7 @@ var MemoryConvex = class extends MemoryStorage {
276
377
  if (messageIds.length === 0) {
277
378
  return { messages: [] };
278
379
  }
279
- const rows = await this.operations.queryTable(TABLE_MESSAGES, void 0);
380
+ const rows = await this.#db.queryTable(TABLE_MESSAGES, void 0);
280
381
  const filtered = rows.filter((row) => messageIds.includes(row.id)).map((row) => this.parseStoredMessage(row));
281
382
  const list = new MessageList().add(filtered, "memory");
282
383
  return { messages: list.get.all.db() };
@@ -301,7 +402,7 @@ var MemoryConvex = class extends MemoryStorage {
301
402
  resourceId: message.resourceId
302
403
  };
303
404
  });
304
- await this.operations.batchInsert({
405
+ await this.#db.batchInsert({
305
406
  tableName: TABLE_MESSAGES,
306
407
  records: normalized
307
408
  });
@@ -310,7 +411,7 @@ var MemoryConvex = class extends MemoryStorage {
310
411
  for (const threadId of threadIds) {
311
412
  const thread = await this.getThreadById({ threadId });
312
413
  if (thread) {
313
- await this.operations.insert({
414
+ await this.#db.insert({
314
415
  tableName: TABLE_THREADS,
315
416
  record: {
316
417
  ...thread,
@@ -329,7 +430,7 @@ var MemoryConvex = class extends MemoryStorage {
329
430
  messages
330
431
  }) {
331
432
  if (messages.length === 0) return [];
332
- const existing = await this.operations.queryTable(TABLE_MESSAGES, void 0);
433
+ const existing = await this.#db.queryTable(TABLE_MESSAGES, void 0);
333
434
  const updated = [];
334
435
  const affectedThreadIds = /* @__PURE__ */ new Set();
335
436
  for (const update of messages) {
@@ -358,7 +459,7 @@ var MemoryConvex = class extends MemoryStorage {
358
459
  };
359
460
  current.content = JSON.stringify(mergedContent);
360
461
  }
361
- await this.operations.insert({
462
+ await this.#db.insert({
362
463
  tableName: TABLE_MESSAGES,
363
464
  record: current
364
465
  });
@@ -368,7 +469,7 @@ var MemoryConvex = class extends MemoryStorage {
368
469
  for (const threadId of affectedThreadIds) {
369
470
  const thread = await this.getThreadById({ threadId });
370
471
  if (thread) {
371
- await this.operations.insert({
472
+ await this.#db.insert({
372
473
  tableName: TABLE_THREADS,
373
474
  record: {
374
475
  ...thread,
@@ -383,7 +484,7 @@ var MemoryConvex = class extends MemoryStorage {
383
484
  return updated;
384
485
  }
385
486
  async deleteMessages(messageIds) {
386
- await this.operations.deleteMany(TABLE_MESSAGES, messageIds);
487
+ await this.#db.deleteMany(TABLE_MESSAGES, messageIds);
387
488
  }
388
489
  async saveResource({ resource }) {
389
490
  const record = {
@@ -394,14 +495,14 @@ var MemoryConvex = class extends MemoryStorage {
394
495
  if (resource.metadata !== void 0) {
395
496
  record.metadata = resource.metadata;
396
497
  }
397
- await this.operations.insert({
498
+ await this.#db.insert({
398
499
  tableName: TABLE_RESOURCES,
399
500
  record
400
501
  });
401
502
  return resource;
402
503
  }
403
504
  async getResourceById({ resourceId }) {
404
- const record = await this.operations.load({
505
+ const record = await this.#db.load({
405
506
  tableName: TABLE_RESOURCES,
406
507
  keys: { id: resourceId }
407
508
  });
@@ -487,12 +588,19 @@ var MemoryConvex = class extends MemoryStorage {
487
588
  }
488
589
  };
489
590
  var ScoresConvex = class extends ScoresStorage {
490
- constructor(operations) {
591
+ #db;
592
+ constructor(config) {
491
593
  super();
492
- this.operations = operations;
594
+ const client = resolveConvexConfig(config);
595
+ this.#db = new ConvexDB(client);
596
+ }
597
+ async init() {
598
+ }
599
+ async dangerouslyClearAll() {
600
+ await this.#db.clearTable({ tableName: TABLE_SCORERS });
493
601
  }
494
602
  async getScoreById({ id }) {
495
- const row = await this.operations.load({
603
+ const row = await this.#db.load({
496
604
  tableName: TABLE_SCORERS,
497
605
  keys: { id }
498
606
  });
@@ -506,7 +614,7 @@ var ScoresConvex = class extends ScoresStorage {
506
614
  createdAt: now.toISOString(),
507
615
  updatedAt: now.toISOString()
508
616
  };
509
- await this.operations.insert({
617
+ await this.#db.insert({
510
618
  tableName: TABLE_SCORERS,
511
619
  record
512
620
  });
@@ -557,7 +665,7 @@ var ScoresConvex = class extends ScoresStorage {
557
665
  new Error("page must be >= 0")
558
666
  );
559
667
  }
560
- const rows = await this.operations.queryTable(TABLE_SCORERS, void 0);
668
+ const rows = await this.#db.queryTable(TABLE_SCORERS, void 0);
561
669
  const filtered = rows.filter((row) => filters.scorerId ? row.scorerId === filters.scorerId : true).filter((row) => filters.entityId ? row.entityId === filters.entityId : true).filter((row) => filters.entityType ? row.entityType === filters.entityType : true).filter((row) => filters.runId ? row.runId === filters.runId : true).filter((row) => filters.source ? row.source === filters.source : true).sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime());
562
670
  const { perPage, page } = pagination;
563
671
  const perPageValue = perPage === false ? filtered.length : perPage;
@@ -583,9 +691,16 @@ var ScoresConvex = class extends ScoresStorage {
583
691
  }
584
692
  };
585
693
  var WorkflowsConvex = class extends WorkflowsStorage {
586
- constructor(operations) {
694
+ #db;
695
+ constructor(config) {
587
696
  super();
588
- this.operations = operations;
697
+ const client = resolveConvexConfig(config);
698
+ this.#db = new ConvexDB(client);
699
+ }
700
+ async init() {
701
+ }
702
+ async dangerouslyClearAll() {
703
+ await this.#db.clearTable({ tableName: TABLE_WORKFLOW_SNAPSHOT });
589
704
  }
590
705
  async updateWorkflowResults({
591
706
  workflowName,
@@ -632,11 +747,11 @@ var WorkflowsConvex = class extends WorkflowsStorage {
632
747
  snapshot
633
748
  }) {
634
749
  const now = /* @__PURE__ */ new Date();
635
- const existing = await this.operations.load({
750
+ const existing = await this.#db.load({
636
751
  tableName: TABLE_WORKFLOW_SNAPSHOT,
637
752
  keys: { workflow_name: workflowName, run_id: runId }
638
753
  });
639
- await this.operations.insert({
754
+ await this.#db.insert({
640
755
  tableName: TABLE_WORKFLOW_SNAPSHOT,
641
756
  record: {
642
757
  workflow_name: workflowName,
@@ -652,7 +767,7 @@ var WorkflowsConvex = class extends WorkflowsStorage {
652
767
  workflowName,
653
768
  runId
654
769
  }) {
655
- const row = await this.operations.load({
770
+ const row = await this.#db.load({
656
771
  tableName: TABLE_WORKFLOW_SNAPSHOT,
657
772
  keys: { workflow_name: workflowName, run_id: runId }
658
773
  });
@@ -661,7 +776,7 @@ var WorkflowsConvex = class extends WorkflowsStorage {
661
776
  }
662
777
  async listWorkflowRuns(args = {}) {
663
778
  const { workflowName, fromDate, toDate, perPage, page, resourceId, status } = args;
664
- let rows = await this.operations.queryTable(TABLE_WORKFLOW_SNAPSHOT, void 0);
779
+ let rows = await this.#db.queryTable(TABLE_WORKFLOW_SNAPSHOT, void 0);
665
780
  if (workflowName) rows = rows.filter((run) => run.workflow_name === workflowName);
666
781
  if (resourceId) rows = rows.filter((run) => run.resourceId === resourceId);
667
782
  if (fromDate) rows = rows.filter((run) => new Date(run.createdAt).getTime() >= fromDate.getTime());
@@ -693,7 +808,7 @@ var WorkflowsConvex = class extends WorkflowsStorage {
693
808
  runId,
694
809
  workflowName
695
810
  }) {
696
- const runs = await this.operations.queryTable(TABLE_WORKFLOW_SNAPSHOT, void 0);
811
+ const runs = await this.#db.queryTable(TABLE_WORKFLOW_SNAPSHOT, void 0);
697
812
  const match = runs.find((run) => run.run_id === runId && (!workflowName || run.workflow_name === workflowName));
698
813
  if (!match) return null;
699
814
  return {
@@ -706,10 +821,10 @@ var WorkflowsConvex = class extends WorkflowsStorage {
706
821
  };
707
822
  }
708
823
  async deleteWorkflowRunById({ runId, workflowName }) {
709
- await this.operations.deleteMany(TABLE_WORKFLOW_SNAPSHOT, [`${workflowName}-${runId}`]);
824
+ await this.#db.deleteMany(TABLE_WORKFLOW_SNAPSHOT, [`${workflowName}-${runId}`]);
710
825
  }
711
826
  async getRun(workflowName, runId) {
712
- const runs = await this.operations.queryTable(TABLE_WORKFLOW_SNAPSHOT, [
827
+ const runs = await this.#db.queryTable(TABLE_WORKFLOW_SNAPSHOT, [
713
828
  { field: "workflow_name", value: workflowName }
714
829
  ]);
715
830
  return runs.find((run) => run.run_id === runId) ?? null;
@@ -736,110 +851,23 @@ var WorkflowsConvex = class extends WorkflowsStorage {
736
851
  return JSON.parse(JSON.stringify(run.snapshot));
737
852
  }
738
853
  };
739
- var StoreOperationsConvex = class extends StoreOperations {
740
- constructor(client) {
741
- super();
742
- this.client = client;
743
- }
744
- async hasColumn(_table, _column) {
745
- return true;
746
- }
747
- async createTable(_args) {
748
- }
749
- async clearTable({ tableName }) {
750
- let hasMore = true;
751
- while (hasMore) {
752
- const response = await this.client.callStorageRaw({
753
- op: "clearTable",
754
- tableName
755
- });
756
- hasMore = response.hasMore ?? false;
757
- }
758
- }
759
- async dropTable({ tableName }) {
760
- let hasMore = true;
761
- while (hasMore) {
762
- const response = await this.client.callStorageRaw({
763
- op: "dropTable",
764
- tableName
765
- });
766
- hasMore = response.hasMore ?? false;
767
- }
768
- }
769
- async alterTable(_args) {
770
- }
771
- async insert({ tableName, record }) {
772
- await this.client.callStorage({
773
- op: "insert",
774
- tableName,
775
- record: this.normalizeRecord(tableName, record)
776
- });
777
- }
778
- async batchInsert({ tableName, records }) {
779
- if (records.length === 0) return;
780
- await this.client.callStorage({
781
- op: "batchInsert",
782
- tableName,
783
- records: records.map((record) => this.normalizeRecord(tableName, record))
784
- });
785
- }
786
- async load({ tableName, keys }) {
787
- const result = await this.client.callStorage({
788
- op: "load",
789
- tableName,
790
- keys
791
- });
792
- return result;
793
- }
794
- async queryTable(tableName, filters) {
795
- return this.client.callStorage({
796
- op: "queryTable",
797
- tableName,
798
- filters
799
- });
800
- }
801
- async deleteMany(tableName, ids) {
802
- if (ids.length === 0) return;
803
- await this.client.callStorage({
804
- op: "deleteMany",
805
- tableName,
806
- ids
807
- });
808
- }
809
- normalizeRecord(tableName, record) {
810
- const normalized = { ...record };
811
- if (tableName === TABLE_WORKFLOW_SNAPSHOT && !normalized.id) {
812
- const runId = normalized.run_id || normalized.runId;
813
- const workflowName = normalized.workflow_name || normalized.workflowName;
814
- normalized.id = workflowName ? `${workflowName}-${runId}` : runId;
815
- }
816
- if (!normalized.id) {
817
- normalized.id = crypto.randomUUID();
818
- }
819
- for (const [key, value] of Object.entries(normalized)) {
820
- if (value instanceof Date) {
821
- normalized[key] = value.toISOString();
822
- }
823
- }
824
- return normalized;
825
- }
826
- };
827
854
 
828
855
  // src/storage/index.ts
856
+ var isClientConfig = (config) => {
857
+ return "client" in config;
858
+ };
829
859
  var ConvexStore = class extends MastraStorage {
830
- operations;
831
860
  memory;
832
861
  workflows;
833
862
  scores;
834
863
  constructor(config) {
835
864
  super({ id: config.id, name: config.name ?? "ConvexStore", disableInit: config.disableInit });
836
- const client = new ConvexAdminClient(config);
837
- this.operations = new StoreOperationsConvex(client);
838
- this.memory = new MemoryConvex(this.operations);
839
- this.workflows = new WorkflowsConvex(this.operations);
840
- this.scores = new ScoresConvex(this.operations);
865
+ const client = isClientConfig(config) ? config.client : new ConvexAdminClient(config);
866
+ const domainConfig = { client };
867
+ this.memory = new MemoryConvex(domainConfig);
868
+ this.workflows = new WorkflowsConvex(domainConfig);
869
+ this.scores = new ScoresConvex(domainConfig);
841
870
  this.stores = {
842
- operations: this.operations,
843
871
  memory: this.memory,
844
872
  workflows: this.workflows,
845
873
  scores: this.scores
@@ -856,25 +884,6 @@ var ConvexStore = class extends MastraStorage {
856
884
  listScoresBySpan: false
857
885
  };
858
886
  }
859
- async createTable(_args) {
860
- }
861
- async clearTable({ tableName }) {
862
- await this.operations.clearTable({ tableName });
863
- }
864
- async dropTable({ tableName }) {
865
- await this.operations.dropTable({ tableName });
866
- }
867
- async alterTable(_args) {
868
- }
869
- async insert({ tableName, record }) {
870
- await this.operations.insert({ tableName, record });
871
- }
872
- async batchInsert({ tableName, records }) {
873
- await this.operations.batchInsert({ tableName, records });
874
- }
875
- async load({ tableName, keys }) {
876
- return this.operations.load({ tableName, keys });
877
- }
878
887
  async getThreadById({ threadId }) {
879
888
  return this.memory.getThreadById({ threadId });
880
889
  }