@mastra/mongodb 1.0.0-beta.3 → 1.0.0-beta.5

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/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import { MastraError, ErrorCategory, ErrorDomain } from '@mastra/core/error';
2
+ import { createVectorErrorId, MastraStorage, createStorageErrorId, StoreOperations, TABLE_SCHEMAS, safelyParseJSON, MemoryStorage, TABLE_MESSAGES, normalizePerPage, calculatePagination, TABLE_THREADS, TABLE_RESOURCES, ScoresStorage, TABLE_SCORERS, WorkflowsStorage, TABLE_WORKFLOW_SNAPSHOT, ObservabilityStorage, TABLE_SPANS, transformScoreRow as transformScoreRow$1 } from '@mastra/core/storage';
2
3
  import { MastraVector } from '@mastra/core/vector';
3
4
  import { MongoClient } from 'mongodb';
4
5
  import { v4 } from 'uuid';
5
6
  import { BaseFilterTranslator } from '@mastra/core/vector/filter';
6
- import { MastraStorage, StoreOperations, TABLE_SCHEMAS, safelyParseJSON, MemoryStorage, TABLE_MESSAGES, normalizePerPage, calculatePagination, TABLE_THREADS, TABLE_RESOURCES, ScoresStorage, TABLE_SCORERS, WorkflowsStorage, TABLE_WORKFLOW_SNAPSHOT, ObservabilityStorage, TABLE_SPANS, transformScoreRow as transformScoreRow$1 } from '@mastra/core/storage';
7
7
  import { MessageList } from '@mastra/core/agent';
8
8
  import { saveScorePayloadSchema } from '@mastra/core/evals';
9
9
 
@@ -11,7 +11,7 @@ import { saveScorePayloadSchema } from '@mastra/core/evals';
11
11
 
12
12
  // package.json
13
13
  var package_default = {
14
- version: "1.0.0-beta.3"};
14
+ version: "1.0.0-beta.5"};
15
15
  var MongoDBFilterTranslator = class extends BaseFilterTranslator {
16
16
  getSupportedOperators() {
17
17
  return {
@@ -134,7 +134,7 @@ var MongoDBVector = class extends MastraVector {
134
134
  } catch (error) {
135
135
  throw new MastraError(
136
136
  {
137
- id: "STORAGE_MONGODB_VECTOR_CONNECT_FAILED",
137
+ id: createVectorErrorId("MONGODB", "CONNECT", "FAILED"),
138
138
  domain: ErrorDomain.STORAGE,
139
139
  category: ErrorCategory.THIRD_PARTY
140
140
  },
@@ -148,7 +148,7 @@ var MongoDBVector = class extends MastraVector {
148
148
  } catch (error) {
149
149
  throw new MastraError(
150
150
  {
151
- id: "STORAGE_MONGODB_VECTOR_DISCONNECT_FAILED",
151
+ id: createVectorErrorId("MONGODB", "DISCONNECT", "FAILED"),
152
152
  domain: ErrorDomain.STORAGE,
153
153
  category: ErrorCategory.THIRD_PARTY
154
154
  },
@@ -169,7 +169,7 @@ var MongoDBVector = class extends MastraVector {
169
169
  } catch (error) {
170
170
  throw new MastraError(
171
171
  {
172
- id: "STORAGE_MONGODB_VECTOR_CREATE_INDEX_INVALID_ARGS",
172
+ id: createVectorErrorId("MONGODB", "CREATE_INDEX", "INVALID_ARGS"),
173
173
  domain: ErrorDomain.STORAGE,
174
174
  category: ErrorCategory.USER,
175
175
  details: {
@@ -222,7 +222,7 @@ var MongoDBVector = class extends MastraVector {
222
222
  if (error.codeName !== "IndexAlreadyExists") {
223
223
  throw new MastraError(
224
224
  {
225
- id: "STORAGE_MONGODB_VECTOR_CREATE_INDEX_FAILED",
225
+ id: createVectorErrorId("MONGODB", "CREATE_INDEX", "FAILED"),
226
226
  domain: ErrorDomain.STORAGE,
227
227
  category: ErrorCategory.THIRD_PARTY
228
228
  },
@@ -235,7 +235,7 @@ var MongoDBVector = class extends MastraVector {
235
235
  } catch (error) {
236
236
  throw new MastraError(
237
237
  {
238
- id: "STORAGE_MONGODB_VECTOR_CREATE_INDEX_FAILED_STORE_METADATA",
238
+ id: createVectorErrorId("MONGODB", "CREATE_INDEX", "STORE_METADATA_FAILED"),
239
239
  domain: ErrorDomain.STORAGE,
240
240
  category: ErrorCategory.THIRD_PARTY,
241
241
  details: {
@@ -312,7 +312,7 @@ var MongoDBVector = class extends MastraVector {
312
312
  } catch (error) {
313
313
  throw new MastraError(
314
314
  {
315
- id: "STORAGE_MONGODB_VECTOR_UPSERT_FAILED",
315
+ id: createVectorErrorId("MONGODB", "UPSERT", "FAILED"),
316
316
  domain: ErrorDomain.STORAGE,
317
317
  category: ErrorCategory.THIRD_PARTY,
318
318
  details: {
@@ -393,7 +393,7 @@ var MongoDBVector = class extends MastraVector {
393
393
  } catch (error) {
394
394
  throw new MastraError(
395
395
  {
396
- id: "STORAGE_MONGODB_VECTOR_QUERY_FAILED",
396
+ id: createVectorErrorId("MONGODB", "QUERY", "FAILED"),
397
397
  domain: ErrorDomain.STORAGE,
398
398
  category: ErrorCategory.THIRD_PARTY,
399
399
  details: {
@@ -411,7 +411,7 @@ var MongoDBVector = class extends MastraVector {
411
411
  } catch (error) {
412
412
  throw new MastraError(
413
413
  {
414
- id: "STORAGE_MONGODB_VECTOR_LIST_INDEXES_FAILED",
414
+ id: createVectorErrorId("MONGODB", "LIST_INDEXES", "FAILED"),
415
415
  domain: ErrorDomain.STORAGE,
416
416
  category: ErrorCategory.THIRD_PARTY
417
417
  },
@@ -440,7 +440,7 @@ var MongoDBVector = class extends MastraVector {
440
440
  } catch (error) {
441
441
  throw new MastraError(
442
442
  {
443
- id: "STORAGE_MONGODB_VECTOR_DESCRIBE_INDEX_FAILED",
443
+ id: createVectorErrorId("MONGODB", "DESCRIBE_INDEX", "FAILED"),
444
444
  domain: ErrorDomain.STORAGE,
445
445
  category: ErrorCategory.THIRD_PARTY,
446
446
  details: {
@@ -463,7 +463,7 @@ var MongoDBVector = class extends MastraVector {
463
463
  } catch (error) {
464
464
  throw new MastraError(
465
465
  {
466
- id: "STORAGE_MONGODB_VECTOR_DELETE_INDEX_FAILED",
466
+ id: createVectorErrorId("MONGODB", "DELETE_INDEX", "FAILED"),
467
467
  domain: ErrorDomain.STORAGE,
468
468
  category: ErrorCategory.THIRD_PARTY,
469
469
  details: {
@@ -488,7 +488,7 @@ var MongoDBVector = class extends MastraVector {
488
488
  const { indexName, update } = params;
489
489
  if ("id" in params && params.id && "filter" in params && params.filter) {
490
490
  throw new MastraError({
491
- id: "STORAGE_MONGODB_VECTOR_UPDATE_MUTUALLY_EXCLUSIVE_PARAMS",
491
+ id: createVectorErrorId("MONGODB", "UPDATE_VECTOR", "MUTUALLY_EXCLUSIVE"),
492
492
  domain: ErrorDomain.STORAGE,
493
493
  category: ErrorCategory.USER,
494
494
  details: { indexName },
@@ -497,7 +497,7 @@ var MongoDBVector = class extends MastraVector {
497
497
  }
498
498
  if (!("id" in params || "filter" in params) || !params.id && !params.filter) {
499
499
  throw new MastraError({
500
- id: "STORAGE_MONGODB_VECTOR_UPDATE_MISSING_PARAMS",
500
+ id: createVectorErrorId("MONGODB", "UPDATE_VECTOR", "NO_TARGET"),
501
501
  domain: ErrorDomain.STORAGE,
502
502
  category: ErrorCategory.USER,
503
503
  text: "Either id or filter must be provided",
@@ -531,7 +531,7 @@ var MongoDBVector = class extends MastraVector {
531
531
  const filter = params.filter;
532
532
  if (!filter || Object.keys(filter).length === 0) {
533
533
  throw new MastraError({
534
- id: "STORAGE_MONGODB_VECTOR_UPDATE_EMPTY_FILTER",
534
+ id: createVectorErrorId("MONGODB", "UPDATE_VECTOR", "EMPTY_FILTER"),
535
535
  domain: ErrorDomain.STORAGE,
536
536
  category: ErrorCategory.USER,
537
537
  details: { indexName },
@@ -542,7 +542,7 @@ var MongoDBVector = class extends MastraVector {
542
542
  const transformedFilter = this.transformMetadataFilter(mongoFilter);
543
543
  if (!transformedFilter || Object.keys(transformedFilter).length === 0) {
544
544
  throw new MastraError({
545
- id: "STORAGE_MONGODB_VECTOR_UPDATE_INVALID_FILTER",
545
+ id: createVectorErrorId("MONGODB", "UPDATE_VECTOR", "INVALID_FILTER"),
546
546
  domain: ErrorDomain.STORAGE,
547
547
  category: ErrorCategory.USER,
548
548
  details: { indexName },
@@ -564,7 +564,7 @@ var MongoDBVector = class extends MastraVector {
564
564
  }
565
565
  throw new MastraError(
566
566
  {
567
- id: "STORAGE_MONGODB_VECTOR_UPDATE_VECTOR_FAILED",
567
+ id: createVectorErrorId("MONGODB", "UPDATE_VECTOR", "FAILED"),
568
568
  domain: ErrorDomain.STORAGE,
569
569
  category: ErrorCategory.THIRD_PARTY,
570
570
  details: errorDetails
@@ -587,7 +587,7 @@ var MongoDBVector = class extends MastraVector {
587
587
  } catch (error) {
588
588
  throw new MastraError(
589
589
  {
590
- id: "STORAGE_MONGODB_VECTOR_DELETE_VECTOR_FAILED",
590
+ id: createVectorErrorId("MONGODB", "DELETE_VECTOR", "FAILED"),
591
591
  domain: ErrorDomain.STORAGE,
592
592
  category: ErrorCategory.THIRD_PARTY,
593
593
  details: {
@@ -602,7 +602,7 @@ var MongoDBVector = class extends MastraVector {
602
602
  async deleteVectors({ indexName, filter, ids }) {
603
603
  if (!filter && !ids) {
604
604
  throw new MastraError({
605
- id: "STORAGE_MONGODB_VECTOR_DELETE_MISSING_PARAMS",
605
+ id: createVectorErrorId("MONGODB", "DELETE_VECTORS", "NO_TARGET"),
606
606
  domain: ErrorDomain.STORAGE,
607
607
  category: ErrorCategory.USER,
608
608
  details: { indexName },
@@ -611,7 +611,7 @@ var MongoDBVector = class extends MastraVector {
611
611
  }
612
612
  if (filter && ids) {
613
613
  throw new MastraError({
614
- id: "STORAGE_MONGODB_VECTOR_DELETE_CONFLICTING_PARAMS",
614
+ id: createVectorErrorId("MONGODB", "DELETE_VECTORS", "MUTUALLY_EXCLUSIVE"),
615
615
  domain: ErrorDomain.STORAGE,
616
616
  category: ErrorCategory.USER,
617
617
  details: { indexName },
@@ -623,7 +623,7 @@ var MongoDBVector = class extends MastraVector {
623
623
  if (ids) {
624
624
  if (ids.length === 0) {
625
625
  throw new MastraError({
626
- id: "STORAGE_MONGODB_VECTOR_DELETE_EMPTY_IDS",
626
+ id: createVectorErrorId("MONGODB", "DELETE_VECTORS", "EMPTY_IDS"),
627
627
  domain: ErrorDomain.STORAGE,
628
628
  category: ErrorCategory.USER,
629
629
  details: { indexName },
@@ -634,7 +634,7 @@ var MongoDBVector = class extends MastraVector {
634
634
  } else {
635
635
  if (!filter || Object.keys(filter).length === 0) {
636
636
  throw new MastraError({
637
- id: "STORAGE_MONGODB_VECTOR_DELETE_EMPTY_FILTER",
637
+ id: createVectorErrorId("MONGODB", "DELETE_VECTORS", "EMPTY_FILTER"),
638
638
  domain: ErrorDomain.STORAGE,
639
639
  category: ErrorCategory.USER,
640
640
  details: { indexName },
@@ -645,7 +645,7 @@ var MongoDBVector = class extends MastraVector {
645
645
  const transformedFilter = this.transformMetadataFilter(mongoFilter);
646
646
  if (!transformedFilter || Object.keys(transformedFilter).length === 0) {
647
647
  throw new MastraError({
648
- id: "STORAGE_MONGODB_VECTOR_DELETE_INVALID_FILTER",
648
+ id: createVectorErrorId("MONGODB", "DELETE_VECTORS", "INVALID_FILTER"),
649
649
  domain: ErrorDomain.STORAGE,
650
650
  category: ErrorCategory.USER,
651
651
  details: { indexName },
@@ -663,7 +663,7 @@ var MongoDBVector = class extends MastraVector {
663
663
  }
664
664
  throw new MastraError(
665
665
  {
666
- id: "STORAGE_MONGODB_VECTOR_DELETE_VECTORS_FAILED",
666
+ id: createVectorErrorId("MONGODB", "DELETE_VECTORS", "FAILED"),
667
667
  domain: ErrorDomain.STORAGE,
668
668
  category: ErrorCategory.THIRD_PARTY,
669
669
  details: {
@@ -905,7 +905,7 @@ var MemoryStorageMongoDB = class extends MemoryStorage {
905
905
  } catch (error) {
906
906
  throw new MastraError(
907
907
  {
908
- id: "MONGODB_STORE_LIST_MESSAGES_BY_ID_FAILED",
908
+ id: createStorageErrorId("MONGODB", "LIST_MESSAGES_BY_ID", "FAILED"),
909
909
  domain: ErrorDomain.STORAGE,
910
910
  category: ErrorCategory.THIRD_PARTY,
911
911
  details: { messageIds: JSON.stringify(messageIds) }
@@ -920,7 +920,7 @@ var MemoryStorageMongoDB = class extends MemoryStorage {
920
920
  if (threadIds.length === 0 || threadIds.some((id) => !id.trim())) {
921
921
  throw new MastraError(
922
922
  {
923
- id: "STORAGE_MONGODB_LIST_MESSAGES_INVALID_THREAD_ID",
923
+ id: createStorageErrorId("MONGODB", "LIST_MESSAGES", "INVALID_THREAD_ID"),
924
924
  domain: ErrorDomain.STORAGE,
925
925
  category: ErrorCategory.THIRD_PARTY,
926
926
  details: { threadId: Array.isArray(threadId) ? threadId.join(",") : threadId }
@@ -931,7 +931,7 @@ var MemoryStorageMongoDB = class extends MemoryStorage {
931
931
  if (page < 0) {
932
932
  throw new MastraError(
933
933
  {
934
- id: "STORAGE_MONGODB_LIST_MESSAGES_INVALID_PAGE",
934
+ id: createStorageErrorId("MONGODB", "LIST_MESSAGES", "INVALID_PAGE"),
935
935
  domain: ErrorDomain.STORAGE,
936
936
  category: ErrorCategory.USER,
937
937
  details: { page }
@@ -1014,7 +1014,7 @@ var MemoryStorageMongoDB = class extends MemoryStorage {
1014
1014
  } catch (error) {
1015
1015
  const mastraError = new MastraError(
1016
1016
  {
1017
- id: "MONGODB_STORE_LIST_MESSAGES_FAILED",
1017
+ id: createStorageErrorId("MONGODB", "LIST_MESSAGES", "FAILED"),
1018
1018
  domain: ErrorDomain.STORAGE,
1019
1019
  category: ErrorCategory.THIRD_PARTY,
1020
1020
  details: {
@@ -1083,7 +1083,7 @@ var MemoryStorageMongoDB = class extends MemoryStorage {
1083
1083
  } catch (error) {
1084
1084
  throw new MastraError(
1085
1085
  {
1086
- id: "MONGODB_STORE_SAVE_MESSAGES_FAILED",
1086
+ id: createStorageErrorId("MONGODB", "SAVE_MESSAGES", "FAILED"),
1087
1087
  domain: ErrorDomain.STORAGE,
1088
1088
  category: ErrorCategory.THIRD_PARTY
1089
1089
  },
@@ -1181,7 +1181,7 @@ var MemoryStorageMongoDB = class extends MemoryStorage {
1181
1181
  } catch (error) {
1182
1182
  throw new MastraError(
1183
1183
  {
1184
- id: "STORAGE_MONGODB_STORE_GET_RESOURCE_BY_ID_FAILED",
1184
+ id: createStorageErrorId("MONGODB", "GET_RESOURCE_BY_ID", "FAILED"),
1185
1185
  domain: ErrorDomain.STORAGE,
1186
1186
  category: ErrorCategory.THIRD_PARTY,
1187
1187
  details: { resourceId }
@@ -1207,7 +1207,7 @@ var MemoryStorageMongoDB = class extends MemoryStorage {
1207
1207
  } catch (error) {
1208
1208
  throw new MastraError(
1209
1209
  {
1210
- id: "STORAGE_MONGODB_STORE_SAVE_RESOURCE_FAILED",
1210
+ id: createStorageErrorId("MONGODB", "SAVE_RESOURCE", "FAILED"),
1211
1211
  domain: ErrorDomain.STORAGE,
1212
1212
  category: ErrorCategory.THIRD_PARTY,
1213
1213
  details: { resourceId: resource.id }
@@ -1252,7 +1252,7 @@ var MemoryStorageMongoDB = class extends MemoryStorage {
1252
1252
  } catch (error) {
1253
1253
  throw new MastraError(
1254
1254
  {
1255
- id: "STORAGE_MONGODB_STORE_UPDATE_RESOURCE_FAILED",
1255
+ id: createStorageErrorId("MONGODB", "UPDATE_RESOURCE", "FAILED"),
1256
1256
  domain: ErrorDomain.STORAGE,
1257
1257
  category: ErrorCategory.THIRD_PARTY,
1258
1258
  details: { resourceId }
@@ -1275,7 +1275,7 @@ var MemoryStorageMongoDB = class extends MemoryStorage {
1275
1275
  } catch (error) {
1276
1276
  throw new MastraError(
1277
1277
  {
1278
- id: "STORAGE_MONGODB_STORE_GET_THREAD_BY_ID_FAILED",
1278
+ id: createStorageErrorId("MONGODB", "GET_THREAD_BY_ID", "FAILED"),
1279
1279
  domain: ErrorDomain.STORAGE,
1280
1280
  category: ErrorCategory.THIRD_PARTY,
1281
1281
  details: { threadId }
@@ -1290,7 +1290,7 @@ var MemoryStorageMongoDB = class extends MemoryStorage {
1290
1290
  if (page < 0) {
1291
1291
  throw new MastraError(
1292
1292
  {
1293
- id: "STORAGE_MONGODB_LIST_THREADS_BY_RESOURCE_ID_INVALID_PAGE",
1293
+ id: createStorageErrorId("MONGODB", "LIST_THREADS_BY_RESOURCE_ID", "INVALID_PAGE"),
1294
1294
  domain: ErrorDomain.STORAGE,
1295
1295
  category: ErrorCategory.USER,
1296
1296
  details: { page }
@@ -1336,7 +1336,7 @@ var MemoryStorageMongoDB = class extends MemoryStorage {
1336
1336
  } catch (error) {
1337
1337
  throw new MastraError(
1338
1338
  {
1339
- id: "MONGODB_STORE_LIST_THREADS_BY_RESOURCE_ID_FAILED",
1339
+ id: createStorageErrorId("MONGODB", "LIST_THREADS_BY_RESOURCE_ID", "FAILED"),
1340
1340
  domain: ErrorDomain.STORAGE,
1341
1341
  category: ErrorCategory.THIRD_PARTY,
1342
1342
  details: { resourceId: args.resourceId }
@@ -1362,7 +1362,7 @@ var MemoryStorageMongoDB = class extends MemoryStorage {
1362
1362
  } catch (error) {
1363
1363
  throw new MastraError(
1364
1364
  {
1365
- id: "STORAGE_MONGODB_STORE_SAVE_THREAD_FAILED",
1365
+ id: createStorageErrorId("MONGODB", "SAVE_THREAD", "FAILED"),
1366
1366
  domain: ErrorDomain.STORAGE,
1367
1367
  category: ErrorCategory.THIRD_PARTY,
1368
1368
  details: { threadId: thread.id }
@@ -1379,7 +1379,7 @@ var MemoryStorageMongoDB = class extends MemoryStorage {
1379
1379
  const thread = await this.getThreadById({ threadId: id });
1380
1380
  if (!thread) {
1381
1381
  throw new MastraError({
1382
- id: "STORAGE_MONGODB_STORE_UPDATE_THREAD_NOT_FOUND",
1382
+ id: createStorageErrorId("MONGODB", "UPDATE_THREAD", "NOT_FOUND"),
1383
1383
  domain: ErrorDomain.STORAGE,
1384
1384
  category: ErrorCategory.THIRD_PARTY,
1385
1385
  details: { threadId: id, status: 404 },
@@ -1408,7 +1408,7 @@ var MemoryStorageMongoDB = class extends MemoryStorage {
1408
1408
  } catch (error) {
1409
1409
  throw new MastraError(
1410
1410
  {
1411
- id: "STORAGE_MONGODB_STORE_UPDATE_THREAD_FAILED",
1411
+ id: createStorageErrorId("MONGODB", "UPDATE_THREAD", "FAILED"),
1412
1412
  domain: ErrorDomain.STORAGE,
1413
1413
  category: ErrorCategory.THIRD_PARTY,
1414
1414
  details: { threadId: id }
@@ -1427,7 +1427,7 @@ var MemoryStorageMongoDB = class extends MemoryStorage {
1427
1427
  } catch (error) {
1428
1428
  throw new MastraError(
1429
1429
  {
1430
- id: "STORAGE_MONGODB_STORE_DELETE_THREAD_FAILED",
1430
+ id: createStorageErrorId("MONGODB", "DELETE_THREAD", "FAILED"),
1431
1431
  domain: ErrorDomain.STORAGE,
1432
1432
  category: ErrorCategory.THIRD_PARTY,
1433
1433
  details: { threadId }
@@ -1464,7 +1464,7 @@ var ObservabilityMongoDB = class extends ObservabilityStorage {
1464
1464
  } catch (error) {
1465
1465
  throw new MastraError(
1466
1466
  {
1467
- id: "MONGODB_STORE_CREATE_SPAN_FAILED",
1467
+ id: createStorageErrorId("MONGODB", "CREATE_SPAN", "FAILED"),
1468
1468
  domain: ErrorDomain.STORAGE,
1469
1469
  category: ErrorCategory.USER,
1470
1470
  details: {
@@ -1492,7 +1492,7 @@ var ObservabilityMongoDB = class extends ObservabilityStorage {
1492
1492
  } catch (error) {
1493
1493
  throw new MastraError(
1494
1494
  {
1495
- id: "MONGODB_STORE_GET_TRACE_FAILED",
1495
+ id: createStorageErrorId("MONGODB", "GET_TRACE", "FAILED"),
1496
1496
  domain: ErrorDomain.STORAGE,
1497
1497
  category: ErrorCategory.USER,
1498
1498
  details: {
@@ -1528,7 +1528,7 @@ var ObservabilityMongoDB = class extends ObservabilityStorage {
1528
1528
  } catch (error) {
1529
1529
  throw new MastraError(
1530
1530
  {
1531
- id: "MONGODB_STORE_UPDATE_SPAN_FAILED",
1531
+ id: createStorageErrorId("MONGODB", "UPDATE_SPAN", "FAILED"),
1532
1532
  domain: ErrorDomain.STORAGE,
1533
1533
  category: ErrorCategory.USER,
1534
1534
  details: {
@@ -1574,7 +1574,7 @@ var ObservabilityMongoDB = class extends ObservabilityStorage {
1574
1574
  name = `agent run: '${entityId}'`;
1575
1575
  } else {
1576
1576
  const error = new MastraError({
1577
- id: "MONGODB_STORE_GET_TRACES_PAGINATED_FAILED",
1577
+ id: createStorageErrorId("MONGODB", "GET_TRACES_PAGINATED", "INVALID_ENTITY_TYPE"),
1578
1578
  domain: ErrorDomain.STORAGE,
1579
1579
  category: ErrorCategory.USER,
1580
1580
  details: {
@@ -1611,7 +1611,7 @@ var ObservabilityMongoDB = class extends ObservabilityStorage {
1611
1611
  } catch (error) {
1612
1612
  throw new MastraError(
1613
1613
  {
1614
- id: "MONGODB_STORE_GET_TRACES_PAGINATED_FAILED",
1614
+ id: createStorageErrorId("MONGODB", "GET_TRACES_PAGINATED", "FAILED"),
1615
1615
  domain: ErrorDomain.STORAGE,
1616
1616
  category: ErrorCategory.USER
1617
1617
  },
@@ -1639,7 +1639,7 @@ var ObservabilityMongoDB = class extends ObservabilityStorage {
1639
1639
  } catch (error) {
1640
1640
  throw new MastraError(
1641
1641
  {
1642
- id: "MONGODB_STORE_BATCH_CREATE_SPANS_FAILED",
1642
+ id: createStorageErrorId("MONGODB", "BATCH_CREATE_SPANS", "FAILED"),
1643
1643
  domain: ErrorDomain.STORAGE,
1644
1644
  category: ErrorCategory.USER
1645
1645
  },
@@ -1672,7 +1672,7 @@ var ObservabilityMongoDB = class extends ObservabilityStorage {
1672
1672
  } catch (error) {
1673
1673
  throw new MastraError(
1674
1674
  {
1675
- id: "MONGODB_STORE_BATCH_UPDATE_SPANS_FAILED",
1675
+ id: createStorageErrorId("MONGODB", "BATCH_UPDATE_SPANS", "FAILED"),
1676
1676
  domain: ErrorDomain.STORAGE,
1677
1677
  category: ErrorCategory.USER
1678
1678
  },
@@ -1689,7 +1689,7 @@ var ObservabilityMongoDB = class extends ObservabilityStorage {
1689
1689
  } catch (error) {
1690
1690
  throw new MastraError(
1691
1691
  {
1692
- id: "MONGODB_STORE_BATCH_DELETE_TRACES_FAILED",
1692
+ id: createStorageErrorId("MONGODB", "BATCH_DELETE_TRACES", "FAILED"),
1693
1693
  domain: ErrorDomain.STORAGE,
1694
1694
  category: ErrorCategory.USER
1695
1695
  },
@@ -1740,7 +1740,7 @@ var StoreOperationsMongoDB = class extends StoreOperations {
1740
1740
  } catch (error) {
1741
1741
  const mastraError = new MastraError(
1742
1742
  {
1743
- id: "STORAGE_MONGODB_STORE_CLEAR_TABLE_FAILED",
1743
+ id: createStorageErrorId("MONGODB", "CLEAR_TABLE", "FAILED"),
1744
1744
  domain: ErrorDomain.STORAGE,
1745
1745
  category: ErrorCategory.THIRD_PARTY,
1746
1746
  details: { tableName }
@@ -1762,7 +1762,7 @@ var StoreOperationsMongoDB = class extends StoreOperations {
1762
1762
  }
1763
1763
  throw new MastraError(
1764
1764
  {
1765
- id: "MONGODB_STORE_DROP_TABLE_FAILED",
1765
+ id: createStorageErrorId("MONGODB", "DROP_TABLE", "FAILED"),
1766
1766
  domain: ErrorDomain.STORAGE,
1767
1767
  category: ErrorCategory.THIRD_PARTY,
1768
1768
  details: { tableName }
@@ -1793,7 +1793,7 @@ var StoreOperationsMongoDB = class extends StoreOperations {
1793
1793
  } catch (error) {
1794
1794
  const mastraError = new MastraError(
1795
1795
  {
1796
- id: "STORAGE_MONGODB_STORE_INSERT_FAILED",
1796
+ id: createStorageErrorId("MONGODB", "INSERT", "FAILED"),
1797
1797
  domain: ErrorDomain.STORAGE,
1798
1798
  category: ErrorCategory.THIRD_PARTY,
1799
1799
  details: { tableName }
@@ -1816,7 +1816,7 @@ var StoreOperationsMongoDB = class extends StoreOperations {
1816
1816
  } catch (error) {
1817
1817
  throw new MastraError(
1818
1818
  {
1819
- id: "STORAGE_MONGODB_STORE_BATCH_INSERT_FAILED",
1819
+ id: createStorageErrorId("MONGODB", "BATCH_INSERT", "FAILED"),
1820
1820
  domain: ErrorDomain.STORAGE,
1821
1821
  category: ErrorCategory.THIRD_PARTY,
1822
1822
  details: { tableName }
@@ -1833,7 +1833,7 @@ var StoreOperationsMongoDB = class extends StoreOperations {
1833
1833
  } catch (error) {
1834
1834
  throw new MastraError(
1835
1835
  {
1836
- id: "STORAGE_MONGODB_STORE_LOAD_FAILED",
1836
+ id: createStorageErrorId("MONGODB", "LOAD", "FAILED"),
1837
1837
  domain: ErrorDomain.STORAGE,
1838
1838
  category: ErrorCategory.THIRD_PARTY,
1839
1839
  details: { tableName }
@@ -1855,7 +1855,7 @@ var StoreOperationsMongoDB = class extends StoreOperations {
1855
1855
  } catch (error) {
1856
1856
  throw new MastraError(
1857
1857
  {
1858
- id: "STORAGE_MONGODB_STORE_UPDATE_FAILED",
1858
+ id: createStorageErrorId("MONGODB", "UPDATE", "FAILED"),
1859
1859
  domain: ErrorDomain.STORAGE,
1860
1860
  category: ErrorCategory.THIRD_PARTY,
1861
1861
  details: { tableName }
@@ -1887,7 +1887,7 @@ var StoreOperationsMongoDB = class extends StoreOperations {
1887
1887
  } catch (error) {
1888
1888
  throw new MastraError(
1889
1889
  {
1890
- id: "STORAGE_MONGODB_STORE_BATCH_UPDATE_FAILED",
1890
+ id: createStorageErrorId("MONGODB", "BATCH_UPDATE", "FAILED"),
1891
1891
  domain: ErrorDomain.STORAGE,
1892
1892
  category: ErrorCategory.THIRD_PARTY,
1893
1893
  details: { tableName }
@@ -1919,7 +1919,7 @@ var ScoresStorageMongoDB = class extends ScoresStorage {
1919
1919
  } catch (error) {
1920
1920
  throw new MastraError(
1921
1921
  {
1922
- id: "STORAGE_MONGODB_STORE_GET_SCORE_BY_ID_FAILED",
1922
+ id: createStorageErrorId("MONGODB", "GET_SCORE_BY_ID", "FAILED"),
1923
1923
  domain: ErrorDomain.STORAGE,
1924
1924
  category: ErrorCategory.THIRD_PARTY,
1925
1925
  details: { id }
@@ -1935,16 +1935,23 @@ var ScoresStorageMongoDB = class extends ScoresStorage {
1935
1935
  } catch (error) {
1936
1936
  throw new MastraError(
1937
1937
  {
1938
- id: "STORAGE_MONGODB_STORE_SAVE_SCORE_VALIDATION_FAILED",
1938
+ id: createStorageErrorId("MONGODB", "SAVE_SCORE", "VALIDATION_FAILED"),
1939
1939
  domain: ErrorDomain.STORAGE,
1940
- category: ErrorCategory.THIRD_PARTY
1940
+ category: ErrorCategory.USER,
1941
+ details: {
1942
+ scorer: score.scorer?.id ?? "unknown",
1943
+ entityId: score.entityId ?? "unknown",
1944
+ entityType: score.entityType ?? "unknown",
1945
+ traceId: score.traceId ?? "",
1946
+ spanId: score.spanId ?? ""
1947
+ }
1941
1948
  },
1942
1949
  error
1943
1950
  );
1944
1951
  }
1945
1952
  try {
1946
1953
  const now = /* @__PURE__ */ new Date();
1947
- const scoreId = `score-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
1954
+ const scoreId = crypto.randomUUID();
1948
1955
  const scorer = typeof validatedScore.scorer === "string" ? safelyParseJSON(validatedScore.scorer) : validatedScore.scorer;
1949
1956
  const preprocessStepResult = typeof validatedScore.preprocessStepResult === "string" ? safelyParseJSON(validatedScore.preprocessStepResult) : validatedScore.preprocessStepResult;
1950
1957
  const analyzeStepResult = typeof validatedScore.analyzeStepResult === "string" ? safelyParseJSON(validatedScore.analyzeStepResult) : validatedScore.analyzeStepResult;
@@ -1956,6 +1963,7 @@ var ScoresStorageMongoDB = class extends ScoresStorage {
1956
1963
  const updatedAt = now;
1957
1964
  const dataToSave = {
1958
1965
  ...validatedScore,
1966
+ id: scoreId,
1959
1967
  scorer,
1960
1968
  preprocessStepResult,
1961
1969
  analyzeStepResult,
@@ -1968,17 +1976,11 @@ var ScoresStorageMongoDB = class extends ScoresStorage {
1968
1976
  };
1969
1977
  const collection = await this.operations.getCollection(TABLE_SCORERS);
1970
1978
  await collection.insertOne(dataToSave);
1971
- const savedScore = {
1972
- ...score,
1973
- id: scoreId,
1974
- createdAt: now,
1975
- updatedAt: now
1976
- };
1977
- return { score: savedScore };
1979
+ return { score: dataToSave };
1978
1980
  } catch (error) {
1979
1981
  throw new MastraError(
1980
1982
  {
1981
- id: "STORAGE_MONGODB_STORE_SAVE_SCORE_FAILED",
1983
+ id: createStorageErrorId("MONGODB", "SAVE_SCORE", "FAILED"),
1982
1984
  domain: ErrorDomain.STORAGE,
1983
1985
  category: ErrorCategory.THIRD_PARTY,
1984
1986
  details: { scorerId: score.scorerId, runId: score.runId }
@@ -2040,7 +2042,7 @@ var ScoresStorageMongoDB = class extends ScoresStorage {
2040
2042
  } catch (error) {
2041
2043
  throw new MastraError(
2042
2044
  {
2043
- id: "STORAGE_MONGODB_STORE_GET_SCORES_BY_SCORER_ID_FAILED",
2045
+ id: createStorageErrorId("MONGODB", "LIST_SCORES_BY_SCORER_ID", "FAILED"),
2044
2046
  domain: ErrorDomain.STORAGE,
2045
2047
  category: ErrorCategory.THIRD_PARTY,
2046
2048
  details: { scorerId, page: pagination.page, perPage: pagination.perPage }
@@ -2089,7 +2091,7 @@ var ScoresStorageMongoDB = class extends ScoresStorage {
2089
2091
  } catch (error) {
2090
2092
  throw new MastraError(
2091
2093
  {
2092
- id: "STORAGE_MONGODB_STORE_GET_SCORES_BY_RUN_ID_FAILED",
2094
+ id: createStorageErrorId("MONGODB", "LIST_SCORES_BY_RUN_ID", "FAILED"),
2093
2095
  domain: ErrorDomain.STORAGE,
2094
2096
  category: ErrorCategory.THIRD_PARTY,
2095
2097
  details: { runId, page: pagination.page, perPage: pagination.perPage }
@@ -2139,7 +2141,7 @@ var ScoresStorageMongoDB = class extends ScoresStorage {
2139
2141
  } catch (error) {
2140
2142
  throw new MastraError(
2141
2143
  {
2142
- id: "STORAGE_MONGODB_STORE_GET_SCORES_BY_ENTITY_ID_FAILED",
2144
+ id: createStorageErrorId("MONGODB", "LIST_SCORES_BY_ENTITY_ID", "FAILED"),
2143
2145
  domain: ErrorDomain.STORAGE,
2144
2146
  category: ErrorCategory.THIRD_PARTY,
2145
2147
  details: { entityId, entityType, page: pagination.page, perPage: pagination.perPage }
@@ -2190,7 +2192,7 @@ var ScoresStorageMongoDB = class extends ScoresStorage {
2190
2192
  } catch (error) {
2191
2193
  throw new MastraError(
2192
2194
  {
2193
- id: "STORAGE_MONGODB_STORE_GET_SCORES_BY_SPAN_FAILED",
2195
+ id: createStorageErrorId("MONGODB", "LIST_SCORES_BY_SPAN", "FAILED"),
2194
2196
  domain: ErrorDomain.STORAGE,
2195
2197
  category: ErrorCategory.THIRD_PARTY,
2196
2198
  details: { traceId, spanId, page: pagination.page, perPage: pagination.perPage }
@@ -2247,7 +2249,7 @@ var WorkflowsStorageMongoDB = class extends WorkflowsStorage {
2247
2249
  } catch (error) {
2248
2250
  throw new MastraError(
2249
2251
  {
2250
- id: "STORAGE_MONGODB_STORE_PERSIST_WORKFLOW_SNAPSHOT_FAILED",
2252
+ id: createStorageErrorId("MONGODB", "PERSIST_WORKFLOW_SNAPSHOT", "FAILED"),
2251
2253
  domain: ErrorDomain.STORAGE,
2252
2254
  category: ErrorCategory.THIRD_PARTY,
2253
2255
  details: { workflowName, runId }
@@ -2275,7 +2277,7 @@ var WorkflowsStorageMongoDB = class extends WorkflowsStorage {
2275
2277
  } catch (error) {
2276
2278
  throw new MastraError(
2277
2279
  {
2278
- id: "STORAGE_MONGODB_STORE_LOAD_WORKFLOW_SNAPSHOT_FAILED",
2280
+ id: createStorageErrorId("MONGODB", "LOAD_WORKFLOW_SNAPSHOT", "FAILED"),
2279
2281
  domain: ErrorDomain.STORAGE,
2280
2282
  category: ErrorCategory.THIRD_PARTY,
2281
2283
  details: { workflowName, runId }
@@ -2314,7 +2316,7 @@ var WorkflowsStorageMongoDB = class extends WorkflowsStorage {
2314
2316
  if (options.page < 0) {
2315
2317
  throw new MastraError(
2316
2318
  {
2317
- id: "STORAGE_MONGODB_INVALID_PAGE",
2319
+ id: createStorageErrorId("MONGODB", "LIST_WORKFLOW_RUNS", "INVALID_PAGE"),
2318
2320
  domain: ErrorDomain.STORAGE,
2319
2321
  category: ErrorCategory.USER,
2320
2322
  details: { page: options.page }
@@ -2340,7 +2342,7 @@ var WorkflowsStorageMongoDB = class extends WorkflowsStorage {
2340
2342
  } catch (error) {
2341
2343
  throw new MastraError(
2342
2344
  {
2343
- id: "STORAGE_MONGODB_STORE_LIST_WORKFLOW_RUNS_FAILED",
2345
+ id: createStorageErrorId("MONGODB", "LIST_WORKFLOW_RUNS", "FAILED"),
2344
2346
  domain: ErrorDomain.STORAGE,
2345
2347
  category: ErrorCategory.THIRD_PARTY,
2346
2348
  details: { workflowName: options.workflowName || "unknown" }
@@ -2367,7 +2369,7 @@ var WorkflowsStorageMongoDB = class extends WorkflowsStorage {
2367
2369
  } catch (error) {
2368
2370
  throw new MastraError(
2369
2371
  {
2370
- id: "STORAGE_MONGODB_STORE_GET_WORKFLOW_RUN_BY_ID_FAILED",
2372
+ id: createStorageErrorId("MONGODB", "GET_WORKFLOW_RUN_BY_ID", "FAILED"),
2371
2373
  domain: ErrorDomain.STORAGE,
2372
2374
  category: ErrorCategory.THIRD_PARTY,
2373
2375
  details: { runId: args.runId }
@@ -2405,7 +2407,7 @@ var loadConnector = (config) => {
2405
2407
  } catch (error) {
2406
2408
  throw new MastraError(
2407
2409
  {
2408
- id: "STORAGE_MONGODB_STORE_CONSTRUCTOR_FAILED",
2410
+ id: createStorageErrorId("MONGODB", "CONSTRUCTOR", "FAILED"),
2409
2411
  domain: ErrorDomain.STORAGE,
2410
2412
  category: ErrorCategory.USER,
2411
2413
  details: { connectionHandler: true }
@@ -2423,7 +2425,7 @@ var loadConnector = (config) => {
2423
2425
  } catch (error) {
2424
2426
  throw new MastraError(
2425
2427
  {
2426
- id: "STORAGE_MONGODB_STORE_CONSTRUCTOR_FAILED",
2428
+ id: createStorageErrorId("MONGODB", "CONSTRUCTOR", "FAILED"),
2427
2429
  domain: ErrorDomain.STORAGE,
2428
2430
  category: ErrorCategory.USER,
2429
2431
  details: { url: config?.url, dbName: config?.dbName }
@@ -2446,7 +2448,7 @@ var MongoDBStore = class extends MastraStorage {
2446
2448
  };
2447
2449
  }
2448
2450
  constructor(config) {
2449
- super({ id: config.id, name: "MongoDBStore" });
2451
+ super({ id: config.id, name: "MongoDBStore", disableInit: config.disableInit });
2450
2452
  this.stores = {};
2451
2453
  this.#connector = loadConnector(config);
2452
2454
  const operations = new StoreOperationsMongoDB({
@@ -2566,7 +2568,7 @@ var MongoDBStore = class extends MastraStorage {
2566
2568
  } catch (error) {
2567
2569
  throw new MastraError(
2568
2570
  {
2569
- id: "STORAGE_MONGODB_STORE_CLOSE_FAILED",
2571
+ id: createStorageErrorId("MONGODB", "CLOSE", "FAILED"),
2570
2572
  domain: ErrorDomain.STORAGE,
2571
2573
  category: ErrorCategory.USER
2572
2574
  },
@@ -2638,7 +2640,7 @@ var MongoDBStore = class extends MastraStorage {
2638
2640
  async createSpan(span) {
2639
2641
  if (!this.stores.observability) {
2640
2642
  throw new MastraError({
2641
- id: "MONGODB_STORE_OBSERVABILITY_NOT_INITIALIZED",
2643
+ id: createStorageErrorId("MONGODB", "OBSERVABILITY", "NOT_INITIALIZED"),
2642
2644
  domain: ErrorDomain.STORAGE,
2643
2645
  category: ErrorCategory.SYSTEM,
2644
2646
  text: "Observability storage is not initialized"
@@ -2653,7 +2655,7 @@ var MongoDBStore = class extends MastraStorage {
2653
2655
  }) {
2654
2656
  if (!this.stores.observability) {
2655
2657
  throw new MastraError({
2656
- id: "MONGODB_STORE_OBSERVABILITY_NOT_INITIALIZED",
2658
+ id: createStorageErrorId("MONGODB", "OBSERVABILITY", "NOT_INITIALIZED"),
2657
2659
  domain: ErrorDomain.STORAGE,
2658
2660
  category: ErrorCategory.SYSTEM,
2659
2661
  text: "Observability storage is not initialized"
@@ -2664,7 +2666,7 @@ var MongoDBStore = class extends MastraStorage {
2664
2666
  async getTrace(traceId) {
2665
2667
  if (!this.stores.observability) {
2666
2668
  throw new MastraError({
2667
- id: "MONGODB_STORE_OBSERVABILITY_NOT_INITIALIZED",
2669
+ id: createStorageErrorId("MONGODB", "OBSERVABILITY", "NOT_INITIALIZED"),
2668
2670
  domain: ErrorDomain.STORAGE,
2669
2671
  category: ErrorCategory.SYSTEM,
2670
2672
  text: "Observability storage is not initialized"
@@ -2675,7 +2677,7 @@ var MongoDBStore = class extends MastraStorage {
2675
2677
  async getTracesPaginated(args) {
2676
2678
  if (!this.stores.observability) {
2677
2679
  throw new MastraError({
2678
- id: "MONGODB_STORE_OBSERVABILITY_NOT_INITIALIZED",
2680
+ id: createStorageErrorId("MONGODB", "OBSERVABILITY", "NOT_INITIALIZED"),
2679
2681
  domain: ErrorDomain.STORAGE,
2680
2682
  category: ErrorCategory.SYSTEM,
2681
2683
  text: "Observability storage is not initialized"
@@ -2686,7 +2688,7 @@ var MongoDBStore = class extends MastraStorage {
2686
2688
  async batchCreateSpans(args) {
2687
2689
  if (!this.stores.observability) {
2688
2690
  throw new MastraError({
2689
- id: "MONGODB_STORE_OBSERVABILITY_NOT_INITIALIZED",
2691
+ id: createStorageErrorId("MONGODB", "OBSERVABILITY", "NOT_INITIALIZED"),
2690
2692
  domain: ErrorDomain.STORAGE,
2691
2693
  category: ErrorCategory.SYSTEM,
2692
2694
  text: "Observability storage is not initialized"
@@ -2697,7 +2699,7 @@ var MongoDBStore = class extends MastraStorage {
2697
2699
  async batchUpdateSpans(args) {
2698
2700
  if (!this.stores.observability) {
2699
2701
  throw new MastraError({
2700
- id: "MONGODB_STORE_OBSERVABILITY_NOT_INITIALIZED",
2702
+ id: createStorageErrorId("MONGODB", "OBSERVABILITY", "NOT_INITIALIZED"),
2701
2703
  domain: ErrorDomain.STORAGE,
2702
2704
  category: ErrorCategory.SYSTEM,
2703
2705
  text: "Observability storage is not initialized"
@@ -2708,7 +2710,7 @@ var MongoDBStore = class extends MastraStorage {
2708
2710
  async batchDeleteTraces(args) {
2709
2711
  if (!this.stores.observability) {
2710
2712
  throw new MastraError({
2711
- id: "MONGODB_STORE_OBSERVABILITY_NOT_INITIALIZED",
2713
+ id: createStorageErrorId("MONGODB", "OBSERVABILITY", "NOT_INITIALIZED"),
2712
2714
  domain: ErrorDomain.STORAGE,
2713
2715
  category: ErrorCategory.SYSTEM,
2714
2716
  text: "Observability storage is not initialized"